12#include "llvm/Support/FormatVariadic.h" 
   13#include "llvm/Support/TimeProfiler.h" 
   22inline bool hasSuppression(
const Decl *D) {
 
   25  if (
const auto *Suppression = D->
getAttr<SuppressAttr>())
 
   26    return !Suppression->isGSL() &&
 
   27           (Suppression->diagnosticIdentifiers().empty());
 
   34    const auto *Suppression = dyn_cast<SuppressAttr>(A);
 
   35    return Suppression && !Suppression->isGSL() &&
 
   36           (Suppression->diagnosticIdentifiers().empty());
 
   41  return Node->getSourceRange();
 
   64  return !
SM.isBeforeInTranslationUnit(RHS, LHS);
 
   83  static void initialize(
const Decl *D, Ranges &ToInit) {
 
   84    CacheInitializer(ToInit).TraverseDecl(
const_cast<Decl *
>(D));
 
   87  bool VisitDecl(Decl *D)
 override {
 
   92    return VisitAttributedNode(D);
 
   95  bool VisitAttributedStmt(AttributedStmt *AS)
 override {
 
   99    return VisitAttributedNode(AS);
 
  103  template <
class NodeType> 
bool VisitAttributedNode(NodeType *Node) {
 
  104    if (hasSuppression(Node)) {
 
  114  void addRange(SourceRange R) {
 
  120  CacheInitializer(Ranges &R) : Result(R) {}
 
  124std::string timeScopeName(
const Decl *DeclWithIssue) {
 
  125  if (!llvm::timeTraceProfilerEnabled())
 
  127  return llvm::formatv(
 
  128             "BugSuppression::isSuppressed init suppressions cache for {0}",
 
  133llvm::TimeTraceMetadata getDeclTimeTraceMetadata(
const Decl *DeclWithIssue) {
 
  134  assert(DeclWithIssue);
 
  135  assert(llvm::timeTraceProfilerEnabled());
 
  136  std::string Name = 
"<noname>";
 
  137  if (
const auto *ND = dyn_cast<NamedDecl>(DeclWithIssue)) {
 
  138    Name = ND->getNameAsString();
 
  143  return llvm::TimeTraceMetadata{std::move(Name), Fname.str(),
 
  144                                 static_cast<int>(
Line)};
 
  164                                  const Decl *DeclWithIssue,
 
  166  if (!Location.isValid())
 
  169  if (!DeclWithIssue) {
 
  187      DeclWithIssue = Parent;
 
  201  auto InsertionResult = CachedSuppressionLocations.insert(
 
  202      std::make_pair(DeclWithIssue, CachedRanges{}));
 
  203  Ranges &SuppressionRanges = InsertionResult.first->second;
 
  204  if (InsertionResult.second) {
 
  205    llvm::TimeTraceScope TimeScope(
 
  206        timeScopeName(DeclWithIssue),
 
  207        [DeclWithIssue]() { 
return getDeclTimeTraceMetadata(DeclWithIssue); });
 
  209    CacheInitializer::initialize(DeclWithIssue, SuppressionRanges);
 
  215  return llvm::any_of(SuppressionRanges,
 
  217                        return fullyContains(Suppression, BugRange, 
SM);
 
 
static CharSourceRange getRange(const CharSourceRange &EditRange, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeMacroExpansion)
SourceManager & getSourceManager()
Attr - This represents one attribute.
Represents an attribute applied to a statement.
ArrayRef< const Attr * > getAttrs() const
Decl - This represents one declaration (or definition), e.g.
ASTContext & getASTContext() const LLVM_READONLY
const char * getDeclKindName() const
SourceLocation getBeginLoc() const LLVM_READONLY
TranslationUnitDecl * getTranslationUnitDecl()
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
Encodes a location in the source.
This class handles loading and caching of source files into memory.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
This class provides an interface through which checkers can create individual bug reports.
virtual PathDiagnosticLocation getUniqueingLocation() const =0
Get the location on which the report should be uniqued.
virtual PathDiagnosticLocation getLocation() const =0
The primary location of the bug report that points at the undesirable behavior in the code.
virtual const Decl * getDeclWithIssue() const =0
The smallest declaration that contains the bug location.
llvm::ArrayRef< llvm::StringRef > DiagnosticIdentifierList
bool isSuppressed(const BugReport &)
Return true if the given bug report was explicitly suppressed by the user.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
DynamicRecursiveASTVisitorBase< false > DynamicRecursiveASTVisitor