Sergey Matveev | a52e5c6 | 2013-06-26 15:37:14 +0000 | [diff] [blame] | 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, |
Sergey Matveev | b33cfeb | 2013-06-28 14:38:31 +0000 | [diff] [blame] | 27 | SuppressionLeak, |
Sergey Matveev | a52e5c6 | 2013-06-26 15:37:14 +0000 | [diff] [blame] | 28 | SuppressionTypeCount |
| 29 | }; |
| 30 | |
| 31 | struct Suppression { |
| 32 | SuppressionType type; |
| 33 | char *templ; |
| 34 | unsigned hit_count; |
Sergey Matveev | b33cfeb | 2013-06-28 14:38:31 +0000 | [diff] [blame] | 35 | uptr weight; |
Sergey Matveev | a52e5c6 | 2013-06-26 15:37:14 +0000 | [diff] [blame] | 36 | }; |
| 37 | |
| 38 | class 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 | |
| 53 | const char *SuppressionTypeString(SuppressionType t); |
| 54 | |
| 55 | // Exposed for testing. |
| 56 | bool TemplateMatch(char *templ, const char *str); |
| 57 | |
| 58 | } // namespace __sanitizer |
| 59 | |
| 60 | #endif // SANITIZER_SUPPRESSIONS_H |