15 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTER_H
16 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTER_H
24 #include "llvm/ADT/DenseSet.h"
25 #include "llvm/ADT/FoldingSet.h"
26 #include "llvm/ADT/ImmutableSet.h"
27 #include "llvm/ADT/SmallSet.h"
28 #include "llvm/ADT/ilist.h"
29 #include "llvm/ADT/ilist_node.h"
34 class DiagnosticsEngine;
45 class BugReporterContext;
55 class BugReport :
public llvm::ilist_node<BugReport> {
58 virtual void anchor();
138 Symbols &getInterestingSymbols();
139 Regions &getInterestingRegions();
141 void lazyInitializeInterestingSets();
142 void pushInterestingSymbolsAndRegions();
143 void popInterestingSymbolsAndRegions();
287 assert((R.
isValid() ||
Ranges.empty()) &&
"Invalid range can only be used "
288 "to specify that the report does not have a range.");
293 virtual llvm::iterator_range<ranges_iterator>
getRanges();
302 void addVisitor(std::unique_ptr<BugReporterVisitor> visitor);
311 virtual void Profile(llvm::FoldingSetNodeID& hash)
const;
318 template<>
struct ilist_traits<clang::ento::BugReport>
326 return createSentinel();
329 return createSentinel();
332 mutable ilist_half_node<clang::ento::BugReport> Sentinel;
345 llvm::ilist<BugReport> Reports;
348 void AddReport(std::unique_ptr<BugReport> R) {
349 Reports.push_back(R.release());
357 assert(!Reports.empty());
358 Reports.front().Profile(ID);
394 BugTypesTy::Factory F;
405 void FlushReport(
BugReport *exampleReport,
410 llvm::FoldingSet<BugReportEquivClass> EQClasses;
412 std::vector<BugReportEquivClass *> EQClassesVector;
467 void emitReport(std::unique_ptr<BugReport> R);
470 StringRef BugName, StringRef BugCategory,
475 StringRef BugName, StringRef BugCategory,
480 llvm::StringMap<BugType *> StrBugTypes;
527 virtual void anchor();
VisitorList::iterator visitor_iterator
BugReporter(BugReporterData &d)
unsigned getConfigurationChangeToken() const
const Decl * getDeclWithIssue() const
const SourceRange * ranges_iterator
MemRegion - The root abstract class for all memory regions.
ASTContext & getASTContext()
bool isInteresting(SymbolRef sym)
llvm::DenseSet< SymbolRef > Symbols
const ExplodedNode * getErrorNode() const
virtual PathDiagnosticLocation getLocation(const SourceManager &SM) const
Return the "definitive" location of the reported bug.
BugReport(BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errornode)
ArrayRef< PathDiagnosticConsumer * > getPathDiagnosticConsumers()
void disablePathPruning()
Disable all path pruning when generating a PathDiagnostic.
SmallVector< SourceRange, 4 > Ranges
virtual AnalyzerOptions & getAnalyzerOptions()=0
bool shouldPrunePath() const
Symbolic value. These values used to capture symbolic execution of the program.
const Decl * getUniqueingDecl() const
Get the declaration containing the uniqueing location.
clang::ento::BugReport * createSentinel() const
void addRange(SourceRange R)
Add a range to a bug report.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
BugReport(BugType &bt, StringRef desc, const ExplodedNode *errornode, PathDiagnosticLocation LocationToUnique, const Decl *DeclToUnique)
Create a BugReport with a custom uniqueing location.
const BugType & getBugType() const
std::string ShortDescription
virtual DiagnosticsEngine & getDiagnostic()=0
llvm::SmallSet< InvalidationRecord, 4 > Invalidations
SValBuilder & getSValBuilder()
const Stmt * getStmt() const
SmallVector< Regions *, 2 > interestingRegions
virtual llvm::iterator_range< ranges_iterator > getRanges()
Get the SourceRanges associated with the report.
llvm::FoldingSet< BugReporterVisitor > CallbacksSet
Used for ensuring the visitors are only added once.
llvm::SmallSet< const LocationContext *, 2 > InterestingLocationContexts
BugReporter(BugReporterData &d, Kind k)
ASTContext & getContext()
const_iterator end() const
Concrete class used by the front-end to report problems and issues.
ExplodedGraph & getGraph()
llvm::FoldingSet< BugReportEquivClass >::iterator EQClasses_iterator
Iterator over the set of BugReports tracked by the BugReporter.
GRBugReporter(BugReporterData &d, ExprEngine &eng)
StringRef getDescription() const
StringRef getShortDescription(bool UseFallback=true) const
BugReporterContext(GRBugReporter &br)
virtual BugReport::NodeResolver & getNodeResolver()=0
void addVisitor(std::unique_ptr< BugReporterVisitor > visitor)
Add custom or predefined bug report visitors to this report.
const_iterator begin() const
const Decl * UniqueingDecl
BugReportEquivClass(std::unique_ptr< BugReport > R)
ID
Defines the set of possible language-specific address spaces.
virtual const ExtraTextList & getExtraText()
visitor_iterator visitor_end()
void Profile(llvm::FoldingSetNodeID &ID) const
~GRBugReporter() override
visitor_iterator visitor_begin()
Iterators through the custom diagnostic visitors.
BugReport(BugType &bt, StringRef desc, PathDiagnosticLocation l)
virtual SourceManager & getSourceManager()=0
void Register(BugType *BT)
unsigned ConfigurationChangeToken
void FlushReports()
Generate and flush diagnostics for all bug reports.
SValBuilder & getSValBuilder()
virtual bool generatePathDiagnostic(PathDiagnostic &pathDiagnostic, PathDiagnosticConsumer &PC, ArrayRef< BugReport * > &bugReports)
void markInteresting(SymbolRef sym)
AnalyzerOptions & getAnalyzerOptions()
clang::ento::BugReport * provideInitialHead() const
virtual ArrayRef< PathDiagnosticConsumer * > getPathDiagnosticConsumers()=0
llvm::ilist< BugReport >::iterator iterator
PathDiagnosticLocation UniqueingLocation
static bool classof(const BugReporter *R)
classof - Used by isa<>, cast<>, and dyn_cast<>.
llvm::DenseSet< const MemRegion * > Regions
EQClasses_iterator EQClasses_begin()
void EmitBasicReport(const Decl *DeclWithIssue, const CheckerBase *Checker, StringRef BugName, StringRef BugCategory, StringRef BugStr, PathDiagnosticLocation Loc, ArrayRef< SourceRange > Ranges=None)
const ExplodedNode * ErrorNode
ExplodedGraph & getGraph()
void emitReport(std::unique_ptr< BugReport > R)
Add the given report to the set of reports tracked by BugReporter.
BugTypesTy::iterator iterator
Iterator over the set of BugTypes tracked by the BugReporter.
bool generatePathDiagnostic(PathDiagnostic &PD, PathDiagnosticConsumer &PC, ArrayRef< BugReport * > &bugReports) override
PathDiagnosticLocation Location
const Decl * DeclWithIssue
std::pair< const void *, const void * > InvalidationRecord
SmallVector< Symbols *, 2 > interestingSymbols
virtual void Profile(llvm::FoldingSetNodeID &hash) const
virtual ~BugReporterData()
GRBugReporter & getBugReporter()
PathDiagnosticLocation getUniqueingLocation() const
Get the location on which the report should be uniqued.
llvm::ilist< BugReport >::const_iterator const_iterator
virtual ~BugReporterContext()
DiagnosticsEngine & getDiagnostic()
ProgramStateManager & getStateManager()
EQClasses_iterator EQClasses_end()
bool RemoveUnneededCalls(PathPieces &pieces, BugReport *R)
SourceManager & getSourceManager()
ProgramStateManager & getStateManager()
BugReport(BugType &bt, StringRef desc, const ExplodedNode *errornode)
Defines the clang::SourceLocation class and associated facilities.
void addExtraText(StringRef S)
This allows for addition of meta data to the diagnostic.
void removeInvalidation(const void *Tag, const void *Data)
void markInvalid(const void *Tag, const void *Data)
clang::ento::BugReport * ensureHead(clang::ento::BugReport *) const
virtual const ExplodedNode * getOriginalNode(const ExplodedNode *N)=0
void destroySentinel(clang::ento::BugReport *) const
SmallVector< StringRef, 2 > ExtraTextList
A trivial tuple used to represent a source range.
SmallVector< std::unique_ptr< BugReporterVisitor >, 8 > VisitorList
This class handles loading and caching of source files into memory.
virtual ASTContext & getASTContext()=0
SourceManager & getSourceManager()
void setDeclWithIssue(const Decl *declWithIssue)