]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.h
Copy googletest 1.8.1 from ^/vendor/google/googletest/1.8.1 to .../contrib/googletest
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / sanitizer_common / sanitizer_suppressions.h
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_atomic.h"
18 #include "sanitizer_internal_defs.h"
19
20 namespace __sanitizer {
21
22 struct Suppression {
23   Suppression() { internal_memset(this, 0, sizeof(*this)); }
24   const char *type;
25   char *templ;
26   atomic_uint32_t hit_count;
27   uptr weight;
28 };
29
30 class SuppressionContext {
31  public:
32   // Create new SuppressionContext capable of parsing given suppression types.
33   SuppressionContext(const char *supprression_types[],
34                      int suppression_types_num);
35
36   void ParseFromFile(const char *filename);
37   void Parse(const char *str);
38
39   bool Match(const char *str, const char *type, Suppression **s);
40   uptr SuppressionCount() const;
41   bool HasSuppressionType(const char *type) const;
42   const Suppression *SuppressionAt(uptr i) const;
43   void GetMatched(InternalMmapVector<Suppression *> *matched);
44
45  private:
46   static const int kMaxSuppressionTypes = 32;
47   const char **const suppression_types_;
48   const int suppression_types_num_;
49
50   InternalMmapVector<Suppression> suppressions_;
51   bool has_suppression_type_[kMaxSuppressionTypes];
52   bool can_parse_;
53 };
54
55 }  // namespace __sanitizer
56
57 #endif  // SANITIZER_SUPPRESSIONS_H