]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/sanitizer_common/sanitizer_suppressions.h
Libsanitizer merge from trunk r368656.
[thirdparty/gcc.git] / libsanitizer / sanitizer_common / sanitizer_suppressions.h
CommitLineData
ef1b3fda
KS
1//===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===//
2//
b667dd70
ML
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
ef1b3fda
KS
6//
7//===----------------------------------------------------------------------===//
8//
696d846a 9// Suppression parsing/matching code.
ef1b3fda
KS
10//
11//===----------------------------------------------------------------------===//
12#ifndef SANITIZER_SUPPRESSIONS_H
13#define SANITIZER_SUPPRESSIONS_H
14
15#include "sanitizer_common.h"
696d846a 16#include "sanitizer_atomic.h"
ef1b3fda
KS
17#include "sanitizer_internal_defs.h"
18
19namespace __sanitizer {
20
ef1b3fda 21struct Suppression {
10189819 22 Suppression() { internal_memset(this, 0, sizeof(*this)); }
696d846a 23 const char *type;
ef1b3fda 24 char *templ;
696d846a 25 atomic_uint32_t hit_count;
ef1b3fda
KS
26 uptr weight;
27};
28
29class SuppressionContext {
30 public:
696d846a
MO
31 // Create new SuppressionContext capable of parsing given suppression types.
32 SuppressionContext(const char *supprression_types[],
33 int suppression_types_num);
34
35 void ParseFromFile(const char *filename);
ef1b3fda 36 void Parse(const char *str);
696d846a
MO
37
38 bool Match(const char *str, const char *type, Suppression **s);
df77f0e4 39 uptr SuppressionCount() const;
696d846a 40 bool HasSuppressionType(const char *type) const;
df77f0e4 41 const Suppression *SuppressionAt(uptr i) const;
ef1b3fda
KS
42 void GetMatched(InternalMmapVector<Suppression *> *matched);
43
44 private:
10189819 45 static const int kMaxSuppressionTypes = 32;
696d846a
MO
46 const char **const suppression_types_;
47 const int suppression_types_num_;
48
ef1b3fda 49 InternalMmapVector<Suppression> suppressions_;
696d846a 50 bool has_suppression_type_[kMaxSuppressionTypes];
ef1b3fda 51 bool can_parse_;
ef1b3fda
KS
52};
53
ef1b3fda
KS
54} // namespace __sanitizer
55
56#endif // SANITIZER_SUPPRESSIONS_H