summaryrefslogtreecommitdiff
path: root/lib/sanitizer_common/sanitizer_suppressions.h
diff options
context:
space:
mode:
authorSergey Matveev <earthdok@google.com>2013-06-26 15:37:14 +0000
committerSergey Matveev <earthdok@google.com>2013-06-26 15:37:14 +0000
commita52e5c6f371bcc66e89792db1219a557664aab8d (patch)
treeef740503c2d0b73765b1104f11e86a8c29a1cdd9 /lib/sanitizer_common/sanitizer_suppressions.h
parentb5cf98f76fd62236f2945bff17b3cdb4e8a5c2f4 (diff)
downloadcompiler-rt-a52e5c6f371bcc66e89792db1219a557664aab8d.tar.gz
[tsan] Move some suppressions-related code to common.
Factor out code to be reused in LSan. Also switch from linked list to vector. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@184957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_suppressions.h')
-rw-r--r--lib/sanitizer_common/sanitizer_suppressions.h58
1 files changed, 58 insertions, 0 deletions
diff --git a/lib/sanitizer_common/sanitizer_suppressions.h b/lib/sanitizer_common/sanitizer_suppressions.h
new file mode 100644
index 000000000..d78da0c49
--- /dev/null
+++ b/lib/sanitizer_common/sanitizer_suppressions.h
@@ -0,0 +1,58 @@
+//===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Suppression parsing/matching code shared between TSan and LSan.
+//
+//===----------------------------------------------------------------------===//
+#ifndef SANITIZER_SUPPRESSIONS_H
+#define SANITIZER_SUPPRESSIONS_H
+
+#include "sanitizer_common.h"
+#include "sanitizer_internal_defs.h"
+
+namespace __sanitizer {
+
+enum SuppressionType {
+ SuppressionNone,
+ SuppressionRace,
+ SuppressionMutex,
+ SuppressionThread,
+ SuppressionSignal,
+ SuppressionTypeCount
+};
+
+struct Suppression {
+ SuppressionType type;
+ char *templ;
+ unsigned hit_count;
+};
+
+class SuppressionContext {
+ public:
+ SuppressionContext() : suppressions_(1), can_parse_(true) {}
+ void Parse(const char *str);
+ bool Match(const char* str, SuppressionType type, Suppression **s);
+ uptr SuppressionCount();
+ void GetMatched(InternalMmapVector<Suppression *> *matched);
+
+ private:
+ InternalMmapVector<Suppression> suppressions_;
+ bool can_parse_;
+
+ friend class SuppressionContextTest;
+};
+
+const char *SuppressionTypeString(SuppressionType t);
+
+// Exposed for testing.
+bool TemplateMatch(char *templ, const char *str);
+
+} // namespace __sanitizer
+
+#endif // SANITIZER_SUPPRESSIONS_H