blob: e0b562e58251c5e188e51253cb4e299cbb4fa74c [file] [log] [blame]
Sergey Matveeva52e5c62013-06-26 15:37:14 +00001//===-- 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
19namespace __sanitizer {
20
21enum SuppressionType {
22 SuppressionNone,
23 SuppressionRace,
24 SuppressionMutex,
25 SuppressionThread,
26 SuppressionSignal,
Sergey Matveevb33cfeb2013-06-28 14:38:31 +000027 SuppressionLeak,
Sergey Matveeva52e5c62013-06-26 15:37:14 +000028 SuppressionTypeCount
29};
30
31struct Suppression {
32 SuppressionType type;
33 char *templ;
34 unsigned hit_count;
Sergey Matveevb33cfeb2013-06-28 14:38:31 +000035 uptr weight;
Sergey Matveeva52e5c62013-06-26 15:37:14 +000036};
37
38class SuppressionContext {
39 public:
40 SuppressionContext() : suppressions_(1), can_parse_(true) {}
41 void Parse(const char *str);
42 bool Match(const char* str, SuppressionType type, Suppression **s);
43 uptr SuppressionCount();
44 void GetMatched(InternalMmapVector<Suppression *> *matched);
45
46 private:
47 InternalMmapVector<Suppression> suppressions_;
48 bool can_parse_;
49
50 friend class SuppressionContextTest;
51};
52
53const char *SuppressionTypeString(SuppressionType t);
54
55// Exposed for testing.
56bool TemplateMatch(char *templ, const char *str);
57
58} // namespace __sanitizer
59
60#endif // SANITIZER_SUPPRESSIONS_H