20inline bool hasSuppression(
const Decl *
D) {
23 if (
const auto *Suppression =
D->
getAttr<SuppressAttr>())
24 return !Suppression->isGSL() &&
25 (Suppression->diagnosticIdentifiers().empty());
31 return llvm::any_of(S->getAttrs(), [](
const Attr *A) {
32 const auto *Suppression = dyn_cast<SuppressAttr>(A);
33 return Suppression && !Suppression->isGSL() &&
34 (Suppression->diagnosticIdentifiers().empty());
62 return !
SM.isBeforeInTranslationUnit(RHS, LHS);
82 CacheInitializer(ToInit).TraverseDecl(
const_cast<Decl *
>(
D));
90 return VisitAttributedNode(
D);
97 return VisitAttributedNode(AS);
101 template <
class NodeType>
bool VisitAttributedNode(NodeType *
Node) {
102 if (hasSuppression(
Node)) {
118 CacheInitializer(Ranges &R) : Result(R) {}
139 const Decl *DeclWithIssue,
144 if (!DeclWithIssue) {
159 if (
Parent ==
nullptr || isa<TranslationUnitDecl>(
Parent))
176 auto InsertionResult = CachedSuppressionLocations.insert(
178 Ranges &SuppressionRanges = InsertionResult.first->second;
179 if (InsertionResult.second) {
181 CacheInitializer::initialize(DeclWithIssue, SuppressionRanges);
187 return llvm::any_of(SuppressionRanges,
189 return fullyContains(Suppression, BugRange,
SM);
static CharSourceRange getRange(const CharSourceRange &EditRange, const SourceManager &SM, const LangOptions &LangOpts, bool IncludeMacroExpansion)
TranslationUnitDecl * getTranslationUnitDecl() const
Attr - This represents one attribute.
Represents an attribute applied to a statement.
Decl - This represents one declaration (or definition), e.g.
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC).
SourceRange getSourceRange() const
For nodes which represent textual entities in the source code, return their SourceRange.
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
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.
bool isSuppressed(const BugReport &)
Return true if the given bug report was explicitly suppressed by the user.
PathDiagnosticRange asRange() const
const SourceManager & getManager() const
The JSON file list parser is used to communicate input to InstallAPI.
void initialize(TemplateInstantiationCallbackPtrs &Callbacks, const Sema &TheSema)
@ Result
The result type of a method or function.