Home | History | Annotate | Download | only in sanitizer_common
      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,
     27   SuppressionLeak,
     28   SuppressionTypeCount
     29 };
     30 
     31 struct Suppression {
     32   SuppressionType type;
     33   char *templ;
     34   unsigned hit_count;
     35   uptr weight;
     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
     61