]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/sanitizer_common/sanitizer_suppressions.h
Update compiler-rt to trunk r224034. This brings a number of new
[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 shared between TSan and LSan.
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
19 namespace __sanitizer {
20
21 enum SuppressionType {
22   SuppressionNone,
23   SuppressionRace,
24   SuppressionMutex,
25   SuppressionThread,
26   SuppressionSignal,
27   SuppressionLeak,
28   SuppressionLib,
29   SuppressionDeadlock,
30   SuppressionVptrCheck,
31   SuppressionInterceptorName,
32   SuppressionInterceptorViaFunction,
33   SuppressionInterceptorViaLibrary,
34   SuppressionTypeCount
35 };
36
37 struct Suppression {
38   SuppressionType type;
39   char *templ;
40   unsigned hit_count;
41   uptr weight;
42 };
43
44 class SuppressionContext {
45  public:
46   void Parse(const char *str);
47   bool Match(const char* str, SuppressionType type, Suppression **s);
48   uptr SuppressionCount() const;
49   bool HasSuppressionType(SuppressionType type) const;
50   const Suppression *SuppressionAt(uptr i) const;
51   void GetMatched(InternalMmapVector<Suppression *> *matched);
52
53   // Create a SuppressionContext singleton if it hasn't been created earlier.
54   // Not thread safe. Must be called early during initialization (but after
55   // runtime flags are parsed).
56   static void InitIfNecessary();
57   // Returns a SuppressionContext singleton.
58   static SuppressionContext *Get();
59
60  private:
61   SuppressionContext();
62   InternalMmapVector<Suppression> suppressions_;
63   bool has_suppresson_type_[SuppressionTypeCount];
64   bool can_parse_;
65
66   friend class SuppressionContextTest;
67 };
68
69 const char *SuppressionTypeString(SuppressionType t);
70
71 bool TemplateMatch(char *templ, const char *str);
72
73 }  // namespace __sanitizer
74
75 #endif  // SANITIZER_SUPPRESSIONS_H