• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   SuppressionTypeCount
31 };
32 
33 struct Suppression {
34   SuppressionType type;
35   char *templ;
36   unsigned hit_count;
37   uptr weight;
38 };
39 
40 class SuppressionContext {
41  public:
SuppressionContext()42   SuppressionContext() : suppressions_(1), can_parse_(true) {}
43   void Parse(const char *str);
44   bool Match(const char* str, SuppressionType type, Suppression **s);
45   uptr SuppressionCount() const;
46   const Suppression *SuppressionAt(uptr i) const;
47   void GetMatched(InternalMmapVector<Suppression *> *matched);
48 
49  private:
50   InternalMmapVector<Suppression> suppressions_;
51   bool can_parse_;
52 
53   friend class SuppressionContextTest;
54 };
55 
56 const char *SuppressionTypeString(SuppressionType t);
57 
58 bool TemplateMatch(char *templ, const char *str);
59 
60 }  // namespace __sanitizer
61 
62 #endif  // SANITIZER_SUPPRESSIONS_H
63