sanitizer_suppressions.h revision a52e5c6f371bcc66e89792db1219a557664aab8d
19fc12334a7d14347cd6951d0653264b2597bd3a0Sam Judd//===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===// 2fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// 39fc12334a7d14347cd6951d0653264b2597bd3a0Sam Judd// The LLVM Compiler Infrastructure 4fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// 5fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// This file is distributed under the University of Illinois Open Source 6fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// License. See LICENSE.TXT for details. 7fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// 8fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd//===----------------------------------------------------------------------===// 9fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// 10fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// Suppression parsing/matching code shared between TSan and LSan. 11fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd// 12fcd787c911d5fbca2a34ff0963d4665543a03275Sam Judd//===----------------------------------------------------------------------===// 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, 27 SuppressionTypeCount 28}; 29 30struct Suppression { 31 SuppressionType type; 32 char *templ; 33 unsigned hit_count; 34}; 35 36class SuppressionContext { 37 public: 38 SuppressionContext() : suppressions_(1), can_parse_(true) {} 39 void Parse(const char *str); 40 bool Match(const char* str, SuppressionType type, Suppression **s); 41 uptr SuppressionCount(); 42 void GetMatched(InternalMmapVector<Suppression *> *matched); 43 44 private: 45 InternalMmapVector<Suppression> suppressions_; 46 bool can_parse_; 47 48 friend class SuppressionContextTest; 49}; 50 51const char *SuppressionTypeString(SuppressionType t); 52 53// Exposed for testing. 54bool TemplateMatch(char *templ, const char *str); 55 56} // namespace __sanitizer 57 58#endif // SANITIZER_SUPPRESSIONS_H 59