1//===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Suppression parsing/matching code.
11//
12//===----------------------------------------------------------------------===//
13#ifndef SANITIZER_SUPPRESSIONS_H
14#define SANITIZER_SUPPRESSIONS_H
15
16#include "sanitizer_common.h"
17#include "sanitizer_internal_defs.h"
18
19namespace __sanitizer {
20
21struct Suppression {
22  const char *type;
23  char *templ;
24  unsigned hit_count;
25  uptr weight;
26};
27
28class SuppressionContext {
29 public:
30  // Create new SuppressionContext capable of parsing given suppression types.
31  SuppressionContext(const char *supprression_types[],
32                     int suppression_types_num);
33
34  void ParseFromFile(const char *filename);
35  void Parse(const char *str);
36
37  bool Match(const char *str, const char *type, Suppression **s);
38  uptr SuppressionCount() const;
39  bool HasSuppressionType(const char *type) const;
40  const Suppression *SuppressionAt(uptr i) const;
41  void GetMatched(InternalMmapVector<Suppression *> *matched);
42
43 private:
44  static const int kMaxSuppressionTypes = 16;
45  const char **const suppression_types_;
46  const int suppression_types_num_;
47
48  InternalMmapVector<Suppression> suppressions_;
49  bool has_suppression_type_[kMaxSuppressionTypes];
50  bool can_parse_;
51};
52
53}  // namespace __sanitizer
54
55#endif  // SANITIZER_SUPPRESSIONS_H
56