1 //===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Suppression parsing/matching code shared between TSan and LSan.
12 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_SUPPRESSIONS_H
14 #define SANITIZER_SUPPRESSIONS_H
16 #include "sanitizer_common.h"
17 #include "sanitizer_internal_defs.h"
19 namespace __sanitizer {
21 enum SuppressionType {
31 SuppressionInterceptorName,
32 SuppressionInterceptorViaFunction,
33 SuppressionInterceptorViaLibrary,
44 class SuppressionContext {
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);
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();
62 InternalMmapVector<Suppression> suppressions_;
63 bool has_suppresson_type_[SuppressionTypeCount];
66 friend class SuppressionContextTest;
69 const char *SuppressionTypeString(SuppressionType t);
71 bool TemplateMatch(char *templ, const char *str);
73 } // namespace __sanitizer
75 #endif // SANITIZER_SUPPRESSIONS_H