1 //===- BugSuppression.h - Suppression interface -----------------*- 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 // This file defines BugSuppression, a simple interface class encapsulating 10 // all user provided in-code suppressions. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPRESSION_H 15 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPRESSION_H 16 17 #include "clang/Basic/SourceLocation.h" 18 #include "llvm/ADT/DenseMap.h" 19 #include "llvm/ADT/SmallVector.h" 20 21 namespace clang { 22 class Decl; 23 24 namespace ento { 25 class BugReport; 26 class PathDiagnosticLocation; 27 28 class BugSuppression { 29 public: 30 using DiagnosticIdentifierList = llvm::ArrayRef<llvm::StringRef>; 31 32 /// Return true if the given bug report was explicitly suppressed by the user. 33 bool isSuppressed(const BugReport &); 34 35 /// Return true if the bug reported at the given location was explicitly 36 /// suppressed by the user. 37 bool isSuppressed(const PathDiagnosticLocation &Location, 38 const Decl *DeclWithIssue, 39 DiagnosticIdentifierList DiagnosticIdentification); 40 41 private: 42 // Overly pessimistic number, to be honest. 43 static constexpr unsigned EXPECTED_NUMBER_OF_SUPPRESSIONS = 8; 44 using CachedRanges = 45 llvm::SmallVector<SourceRange, EXPECTED_NUMBER_OF_SUPPRESSIONS>; 46 47 llvm::DenseMap<const Decl *, CachedRanges> CachedSuppressionLocations; 48 }; 49 50 } // end namespace ento 51 } // end namespace clang 52 53 #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPRESSION_H 54