clang
3.7.0
|
#include <BugReporter.h>
Classes | |
class | NodeResolver |
Public Types | |
typedef const SourceRange * | ranges_iterator |
typedef SmallVector < std::unique_ptr < BugReporterVisitor >, 8 > | VisitorList |
typedef VisitorList::iterator | visitor_iterator |
typedef SmallVector< StringRef, 2 > | ExtraTextList |
Public Member Functions | |
BugReport (BugType &bt, StringRef desc, const ExplodedNode *errornode) | |
BugReport (BugType &bt, StringRef shortDesc, StringRef desc, const ExplodedNode *errornode) | |
BugReport (BugType &bt, StringRef desc, PathDiagnosticLocation l) | |
BugReport (BugType &bt, StringRef desc, const ExplodedNode *errornode, PathDiagnosticLocation LocationToUnique, const Decl *DeclToUnique) | |
Create a BugReport with a custom uniqueing location. More... | |
virtual | ~BugReport () |
const BugType & | getBugType () const |
BugType & | getBugType () |
const ExplodedNode * | getErrorNode () const |
StringRef | getDescription () const |
StringRef | getShortDescription (bool UseFallback=true) const |
bool | shouldPrunePath () const |
void | disablePathPruning () |
Disable all path pruning when generating a PathDiagnostic. More... | |
void | markInteresting (SymbolRef sym) |
void | markInteresting (const MemRegion *R) |
void | markInteresting (SVal V) |
void | markInteresting (const LocationContext *LC) |
bool | isInteresting (SymbolRef sym) |
bool | isInteresting (const MemRegion *R) |
bool | isInteresting (SVal V) |
bool | isInteresting (const LocationContext *LC) |
unsigned | getConfigurationChangeToken () const |
bool | isValid () const |
void | markInvalid (const void *Tag, const void *Data) |
void | removeInvalidation (const void *Tag, const void *Data) |
const Decl * | getDeclWithIssue () const |
void | setDeclWithIssue (const Decl *declWithIssue) |
void | addExtraText (StringRef S) |
This allows for addition of meta data to the diagnostic. More... | |
virtual const ExtraTextList & | getExtraText () |
virtual PathDiagnosticLocation | getLocation (const SourceManager &SM) const |
Return the "definitive" location of the reported bug. More... | |
PathDiagnosticLocation | getUniqueingLocation () const |
Get the location on which the report should be uniqued. More... | |
const Decl * | getUniqueingDecl () const |
Get the declaration containing the uniqueing location. More... | |
const Stmt * | getStmt () const |
void | addRange (SourceRange R) |
Add a range to a bug report. More... | |
virtual llvm::iterator_range < ranges_iterator > | getRanges () |
Get the SourceRanges associated with the report. More... | |
void | addVisitor (std::unique_ptr< BugReporterVisitor > visitor) |
Add custom or predefined bug report visitors to this report. More... | |
visitor_iterator | visitor_begin () |
Iterators through the custom diagnostic visitors. More... | |
visitor_iterator | visitor_end () |
virtual void | Profile (llvm::FoldingSetNodeID &hash) const |
Protected Types | |
typedef llvm::DenseSet< SymbolRef > | Symbols |
typedef llvm::DenseSet< const MemRegion * > | Regions |
typedef std::pair< const void *, const void * > | InvalidationRecord |
Protected Attributes | |
BugType & | BT |
const Decl * | DeclWithIssue |
std::string | ShortDescription |
std::string | Description |
PathDiagnosticLocation | Location |
PathDiagnosticLocation | UniqueingLocation |
const Decl * | UniqueingDecl |
const ExplodedNode * | ErrorNode |
SmallVector< SourceRange, 4 > | Ranges |
ExtraTextList | ExtraText |
SmallVector< Symbols *, 2 > | interestingSymbols |
SmallVector< Regions *, 2 > | interestingRegions |
llvm::SmallSet< const LocationContext *, 2 > | InterestingLocationContexts |
VisitorList | Callbacks |
llvm::FoldingSet < BugReporterVisitor > | CallbacksSet |
Used for ensuring the visitors are only added once. More... | |
unsigned | ConfigurationChangeToken |
bool | DoNotPrunePath |
llvm::SmallSet < InvalidationRecord, 4 > | Invalidations |
Friends | |
class | BugReporter |
class | BugReportEquivClass |
This class provides an interface through which checkers can create individual bug reports.
Definition at line 55 of file BugReporter.h.
typedef SmallVector<StringRef, 2> clang::ento::BugReport::ExtraTextList |
Definition at line 68 of file BugReporter.h.
|
protected |
Used to track unique reasons why a bug report might be invalid.
Definition at line 127 of file BugReporter.h.
typedef const SourceRange* clang::ento::BugReport::ranges_iterator |
Definition at line 65 of file BugReporter.h.
|
protected |
Definition at line 87 of file BugReporter.h.
|
protected |
Definition at line 86 of file BugReporter.h.
typedef VisitorList::iterator clang::ento::BugReport::visitor_iterator |
Definition at line 67 of file BugReporter.h.
typedef SmallVector<std::unique_ptr<BugReporterVisitor>, 8> clang::ento::BugReport::VisitorList |
Definition at line 66 of file BugReporter.h.
|
inline |
Definition at line 146 of file BugReporter.h.
|
inline |
Definition at line 150 of file BugReporter.h.
|
inline |
Definition at line 156 of file BugReporter.h.
|
inline |
Create a BugReport with a custom uniqueing location.
The reports that have the same report location, description, bug type, and ranges are uniqued - only one of the equivalent reports will be presented to the user. This method allows to rest the location which should be used for uniquing reports. For example, memory leaks checker, could set this to the allocation site, rather then the location where the bug is reported.
Definition at line 167 of file BugReporter.h.
|
virtual |
Definition at line 2551 of file BugReporter.cpp.
References interestingSymbols.
|
inline |
This allows for addition of meta data to the diagnostic.
Currently, only the HTMLDiagnosticClient knows how to display it.
Definition at line 252 of file BugReporter.h.
References ExtraText.
|
inline |
Add a range to a bug report.
Ranges are used to highlight regions of interest in the source code. They should be at the same source code line as the BugReport location. By default, the source range of the statement corresponding to the error node will be used; add a single invalid range to specify absence of ranges.
Definition at line 286 of file BugReporter.h.
References clang::SourceRange::isValid(), and Ranges.
Referenced by getRanges().
void BugReport::addVisitor | ( | std::unique_ptr< BugReporterVisitor > | visitor | ) |
Add custom or predefined bug report visitors to this report.
The visitors should be used when the default trace is not sufficient. For example, they allow constructing a more elaborate trace.
Definition at line 2535 of file BugReporter.cpp.
References Callbacks, CallbacksSet, and ConfigurationChangeToken.
Referenced by clang::ento::FindLastStoreBRVisitor::registerStatementVarDecls(), clang::ento::bugreporter::trackNullOrUndefValue(), and clang::ento::FindLastStoreBRVisitor::VisitNode().
|
inline |
Disable all path pruning when generating a PathDiagnostic.
Definition at line 195 of file BugReporter.h.
References DoNotPrunePath.
|
inline |
Definition at line 177 of file BugReporter.h.
References BT.
|
inline |
Definition at line 178 of file BugReporter.h.
References BT.
|
inline |
Definition at line 207 of file BugReporter.h.
References ConfigurationChangeToken.
const Decl * BugReport::getDeclWithIssue | ( | ) | const |
Return the canonical declaration, be it a method or class, where this issue semantically occurred.
Definition at line 2557 of file BugReporter.cpp.
References DeclWithIssue, clang::LocationContext::getCurrentStackFrame(), clang::LocationContext::getDecl(), getErrorNode(), and clang::ento::ExplodedNode::getLocationContext().
|
inline |
Definition at line 182 of file BugReporter.h.
References Description.
Referenced by clang::ento::BugReporterVisitor::getDefaultEndPath().
|
inline |
Definition at line 180 of file BugReporter.h.
References ErrorNode.
Referenced by getDeclWithIssue(), clang::ento::FindLastStoreBRVisitor::registerStatementVarDecls(), and clang::ento::SuppressInlineDefensiveChecksVisitor::VisitNode().
|
inlinevirtual |
Definition at line 256 of file BugReporter.h.
References ExtraText.
|
virtual |
Return the "definitive" location of the reported bug.
While a bug can span an entire path, usually there is a specific location that can be used to identify where the key issue occurred. This location is used by clients rendering diagnostics.
Definition at line 2721 of file BugReporter.cpp.
References clang::ento::PathDiagnosticLocation::createEndOfPath(), ErrorNode, clang::ento::PathDiagnosticLocation::isValid(), and Location.
Referenced by clang::ento::PathDiagnosticEventPiece::dump(), clang::ento::PathDiagnosticCallPiece::dump(), and clang::ento::LikelyFalsePositiveSuppressionBRVisitor::getEndPath().
|
virtual |
Get the SourceRanges associated with the report.
Definition at line 2703 of file BugReporter.cpp.
References addRange(), getStmt(), and Ranges.
Referenced by clang::ento::BugReporterVisitor::getDefaultEndPath().
Definition at line 184 of file BugReporter.h.
References Description, and ShortDescription.
const Stmt * BugReport::getStmt | ( | ) | const |
Definition at line 2685 of file BugReporter.cpp.
References ErrorNode, clang::ProgramPoint::getAs(), clang::LocationContext::getCFG(), clang::CFG::getExit(), clang::ento::ExplodedNode::getLocation(), clang::ProgramPoint::getLocationContext(), GetPreviousStmt(), clang::ento::PathDiagnosticLocation::getStmt(), and S.
Referenced by getRanges().
|
inline |
Get the declaration containing the uniqueing location.
Definition at line 273 of file BugReporter.h.
References UniqueingDecl.
|
inline |
Get the location on which the report should be uniqued.
Definition at line 268 of file BugReporter.h.
References UniqueingLocation.
Referenced by Profile().
Definition at line 2632 of file BugReporter.cpp.
Referenced by isInteresting(), clang::ento::ConditionBRVisitor::patternMatch(), removeUnneededCalls(), reversePropagateIntererstingSymbols(), reversePropagateInterestingSymbols(), clang::ento::ConditionBRVisitor::VisitConditionVariable(), and clang::ento::ConditionBRVisitor::VisitTrueTest().
Definition at line 2640 of file BugReporter.cpp.
References clang::ento::MemRegion::getBaseRegion().
Definition at line 2628 of file BugReporter.cpp.
References clang::ento::SVal::getAsRegion(), clang::ento::SVal::getAsSymbol(), and isInteresting().
bool BugReport::isInteresting | ( | const LocationContext * | LC | ) |
Definition at line 2652 of file BugReporter.cpp.
References InterestingLocationContexts.
|
inline |
Returns whether or not this report should be considered valid.
Invalid reports are those that have been classified as likely false positives after the fact.
Definition at line 215 of file BugReporter.h.
References Invalidations.
Referenced by clang::ento::PathDiagnosticLocation::dump(), GenerateAlternateExtensivePathDiagnostic(), and GenerateVisitorsOnlyPathDiagnostic().
void BugReport::markInteresting | ( | SymbolRef | sym | ) |
Definition at line 2592 of file BugReporter.cpp.
References ConfigurationChangeToken.
Referenced by markInteresting(), reversePropagateIntererstingSymbols(), clang::ento::bugreporter::trackNullOrUndefValue(), and clang::ento::UndefOrNullArgVisitor::VisitNode().
void BugReport::markInteresting | ( | const MemRegion * | R | ) |
Definition at line 2604 of file BugReporter.cpp.
References ConfigurationChangeToken, and clang::ento::MemRegion::getBaseRegion().
void BugReport::markInteresting | ( | SVal | V | ) |
Definition at line 2617 of file BugReporter.cpp.
References clang::ento::SVal::getAsRegion(), clang::ento::SVal::getAsSymbol(), and markInteresting().
void BugReport::markInteresting | ( | const LocationContext * | LC | ) |
Definition at line 2622 of file BugReporter.cpp.
References InterestingLocationContexts.
|
inline |
Marks the current report as invalid, meaning that it is probably a false positive and should not be reported to the user.
The Tag
and Data
arguments are intended to be opaque identifiers for this particular invalidation, where Tag
represents the visitor responsible for invalidation, and Data
represents the reason this visitor decided to invalidate the bug report.
Definition at line 228 of file BugReporter.h.
References Invalidations.
Referenced by clang::ento::LikelyFalsePositiveSuppressionBRVisitor::getEndPath(), and clang::ento::SuppressInlineDefensiveChecksVisitor::VisitNode().
|
virtual |
Profile to identify equivalent bug reports for error report coalescing. Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug.
Definition at line 2569 of file BugReporter.cpp.
References BT, Description, ErrorNode, clang::SourceRange::getBegin(), GetCurrentOrPreviousStmt(), clang::SourceRange::getEnd(), clang::SourceLocation::getRawEncoding(), getUniqueingLocation(), clang::SourceRange::isValid(), clang::ento::PathDiagnosticLocation::isValid(), Location, clang::ento::PathDiagnosticLocation::Profile(), and Ranges.
|
inline |
Reverses the effects of a previous invalidation.
Definition at line 235 of file BugReporter.h.
References Invalidations.
|
inline |
Specifically set the Decl where an issue occurred. This isn't necessary for BugReports that cover a path as it will be automatically inferred.
Definition at line 245 of file BugReporter.h.
References DeclWithIssue.
|
inline |
Indicates whether or not any path pruning should take place when generating a PathDiagnostic from this BugReport.
Definition at line 192 of file BugReporter.h.
References DoNotPrunePath.
|
inline |
Iterators through the custom diagnostic visitors.
Definition at line 305 of file BugReporter.h.
References Callbacks.
|
inline |
Definition at line 306 of file BugReporter.h.
References Callbacks.
|
friend |
Definition at line 72 of file BugReporter.h.
Referenced by clang::ento::BugReporter::emitReport().
|
friend |
Definition at line 71 of file BugReporter.h.
|
protected |
Definition at line 74 of file BugReporter.h.
Referenced by clang::ento::BugReporter::EmitBasicReport(), clang::ento::BugReporter::emitReport(), FindReportInEquivalenceClass(), getBugType(), and Profile().
|
protected |
A set of custom visitors which generate "event" diagnostics at interesting points in the path.
Definition at line 109 of file BugReporter.h.
Referenced by addVisitor(), visitor_begin(), and visitor_end().
|
protected |
Used for ensuring the visitors are only added once.
Definition at line 112 of file BugReporter.h.
Referenced by addVisitor().
|
protected |
Used for clients to tell if the report's configuration has changed since the last time they checked.
Definition at line 116 of file BugReporter.h.
Referenced by addVisitor(), getConfigurationChangeToken(), and markInteresting().
|
protected |
Definition at line 75 of file BugReporter.h.
Referenced by getDeclWithIssue(), and setDeclWithIssue().
|
protected |
Definition at line 77 of file BugReporter.h.
Referenced by getDescription(), getShortDescription(), and Profile().
|
protected |
When set, this flag disables all callstack pruning from a diagnostic path. This is useful for some reports that want maximum fidelty when reporting an issue.
Definition at line 121 of file BugReporter.h.
Referenced by disablePathPruning(), and shouldPrunePath().
|
protected |
Definition at line 82 of file BugReporter.h.
Referenced by getErrorNode(), getLocation(), getStmt(), and Profile().
|
protected |
Definition at line 84 of file BugReporter.h.
Referenced by addExtraText(), and getExtraText().
|
protected |
A set of location contexts that correspoind to call sites which should be considered "interesting".
Definition at line 105 of file BugReporter.h.
Referenced by isInteresting(), and markInteresting().
|
protected |
A (stack of) set of regions that are registered with this report as being "interesting", and thus used to help decide which diagnostics to include when constructing the final path diagnostic. The stack is largely used by BugReporter when generating PathDiagnostics for multiple PathDiagnosticConsumers.
Definition at line 101 of file BugReporter.h.
|
protected |
A (stack of) a set of symbols that are registered with this report as being "interesting", and thus used to help decide which diagnostics to include when constructing the final path diagnostic. The stack is largely used by BugReporter when generating PathDiagnostics for multiple PathDiagnosticConsumers.
Definition at line 94 of file BugReporter.h.
Referenced by ~BugReport().
|
protected |
If non-empty, this bug report is likely a false positive and should not be shown to the user.
Definition at line 134 of file BugReporter.h.
Referenced by isValid(), markInvalid(), and removeInvalidation().
|
protected |
Definition at line 78 of file BugReporter.h.
Referenced by getLocation(), and Profile().
|
protected |
Definition at line 83 of file BugReporter.h.
Referenced by addRange(), clang::ento::BugReporter::EmitBasicReport(), getRanges(), and Profile().
|
protected |
Definition at line 76 of file BugReporter.h.
Referenced by getShortDescription().
|
protected |
Definition at line 80 of file BugReporter.h.
Referenced by getUniqueingDecl().
|
protected |
Definition at line 79 of file BugReporter.h.
Referenced by getUniqueingLocation().