2014-01-30 Alangi Derick <alangiderick@gmail.com>
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_suppressions.h
blobb4c719cb1874deffe9c21530c046ee30a97fc32c
1 //===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // Suppression parsing/matching code shared between TSan and LSan.
9 //
10 //===----------------------------------------------------------------------===//
11 #ifndef SANITIZER_SUPPRESSIONS_H
12 #define SANITIZER_SUPPRESSIONS_H
14 #include "sanitizer_common.h"
15 #include "sanitizer_internal_defs.h"
17 namespace __sanitizer {
19 enum SuppressionType {
20 SuppressionNone,
21 SuppressionRace,
22 SuppressionMutex,
23 SuppressionThread,
24 SuppressionSignal,
25 SuppressionLeak,
26 SuppressionLib,
27 SuppressionTypeCount
30 struct Suppression {
31 SuppressionType type;
32 char *templ;
33 unsigned hit_count;
34 uptr weight;
37 class SuppressionContext {
38 public:
39 SuppressionContext() : suppressions_(1), can_parse_(true) {}
40 void Parse(const char *str);
41 bool Match(const char* str, SuppressionType type, Suppression **s);
42 uptr SuppressionCount() const;
43 const Suppression *SuppressionAt(uptr i) const;
44 void GetMatched(InternalMmapVector<Suppression *> *matched);
46 private:
47 InternalMmapVector<Suppression> suppressions_;
48 bool can_parse_;
50 friend class SuppressionContextTest;
53 const char *SuppressionTypeString(SuppressionType t);
55 bool TemplateMatch(char *templ, const char *str);
57 } // namespace __sanitizer
59 #endif // SANITIZER_SUPPRESSIONS_H