sanitizer_suppressions.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //===-- sanitizer_suppressions.h --------------------------------*- C++ -*-===//
  2. //
  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
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // Suppression parsing/matching code.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. #ifndef SANITIZER_SUPPRESSIONS_H
  13. #define SANITIZER_SUPPRESSIONS_H
  14. #include "sanitizer_common.h"
  15. #include "sanitizer_atomic.h"
  16. #include "sanitizer_internal_defs.h"
  17. namespace __sanitizer {
  18. struct Suppression {
  19. Suppression() { internal_memset(this, 0, sizeof(*this)); }
  20. const char *type;
  21. char *templ;
  22. atomic_uint32_t hit_count;
  23. uptr weight;
  24. };
  25. class SuppressionContext {
  26. public:
  27. // Create new SuppressionContext capable of parsing given suppression types.
  28. SuppressionContext(const char *supprression_types[],
  29. int suppression_types_num);
  30. void ParseFromFile(const char *filename);
  31. void Parse(const char *str);
  32. bool Match(const char *str, const char *type, Suppression **s);
  33. uptr SuppressionCount() const;
  34. bool HasSuppressionType(const char *type) const;
  35. const Suppression *SuppressionAt(uptr i) const;
  36. void GetMatched(InternalMmapVector<Suppression *> *matched);
  37. private:
  38. static const int kMaxSuppressionTypes = 64;
  39. const char **const suppression_types_;
  40. const int suppression_types_num_;
  41. InternalMmapVector<Suppression> suppressions_;
  42. bool has_suppression_type_[kMaxSuppressionTypes];
  43. bool can_parse_;
  44. };
  45. } // namespace __sanitizer
  46. #endif // SANITIZER_SUPPRESSIONS_H