Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:37:07

0001 //===- BugSuppression.h - Suppression interface -----------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 //  This file defines BugSuppression, a simple interface class encapsulating
0010 //  all user provided in-code suppressions.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPRESSION_H
0015 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPRESSION_H
0016 
0017 #include "clang/Basic/SourceLocation.h"
0018 #include "llvm/ADT/DenseMap.h"
0019 #include "llvm/ADT/SmallVector.h"
0020 
0021 namespace clang {
0022 class ASTContext;
0023 class Decl;
0024 
0025 namespace ento {
0026 class BugReport;
0027 class PathDiagnosticLocation;
0028 
0029 class BugSuppression {
0030 public:
0031   explicit BugSuppression(const ASTContext &ACtx) : ACtx(ACtx) {}
0032 
0033   using DiagnosticIdentifierList = llvm::ArrayRef<llvm::StringRef>;
0034 
0035   /// Return true if the given bug report was explicitly suppressed by the user.
0036   bool isSuppressed(const BugReport &);
0037 
0038   /// Return true if the bug reported at the given location was explicitly
0039   /// suppressed by the user.
0040   bool isSuppressed(const PathDiagnosticLocation &Location,
0041                     const Decl *DeclWithIssue,
0042                     DiagnosticIdentifierList DiagnosticIdentification);
0043 
0044 private:
0045   // Overly pessimistic number, to be honest.
0046   static constexpr unsigned EXPECTED_NUMBER_OF_SUPPRESSIONS = 8;
0047   using CachedRanges =
0048       llvm::SmallVector<SourceRange, EXPECTED_NUMBER_OF_SUPPRESSIONS>;
0049 
0050   llvm::DenseMap<const Decl *, CachedRanges> CachedSuppressionLocations;
0051 
0052   const ASTContext &ACtx;
0053 };
0054 
0055 } // end namespace ento
0056 } // end namespace clang
0057 
0058 #endif // LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_SUPPRESSION_H