clang 20.0.0git
|
This class provides an interface through which checkers can create individual bug reports. More...
#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
Public Types | |
enum class | Kind { Basic , PathSensitive } |
Public Member Functions | |
virtual | ~BugReport ()=default |
Kind | getKind () const |
const BugType & | getBugType () const |
StringRef | getDescription () const |
A verbose warning message that is appropriate for displaying next to the source code that introduces the problem. | |
StringRef | getShortDescription (bool UseFallback=true) const |
A short general warning message that is appropriate for displaying in the list of all reported bugs. | |
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. | |
virtual PathDiagnosticLocation | getUniqueingLocation () const =0 |
Get the location on which the report should be uniqued. | |
virtual const Decl * | getUniqueingDecl () const =0 |
Get the declaration that corresponds to (usually contains) the uniqueing location. | |
void | addNote (StringRef Msg, const PathDiagnosticLocation &Pos, ArrayRef< SourceRange > Ranges={}) |
Add new item to the list of additional notes that need to be attached to this report. | |
ArrayRef< std::shared_ptr< PathDiagnosticNotePiece > > | getNotes () |
void | addRange (SourceRange R) |
Add a range to a bug report. | |
virtual ArrayRef< SourceRange > | getRanges () const |
Get the SourceRanges associated with the report. | |
void | addFixItHint (const FixItHint &F) |
Add a fix-it hint to the bug report. | |
llvm::ArrayRef< FixItHint > | getFixits () const |
virtual void | Profile (llvm::FoldingSetNodeID &hash) const =0 |
Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug. | |
Protected Member Functions | |
BugReport (Kind kind, const BugType &bt, StringRef desc) | |
BugReport (Kind K, const BugType &BT, StringRef ShortDescription, StringRef Description) | |
Protected Attributes | |
Kind | K |
const BugType & | BT |
std::string | ShortDescription |
std::string | Description |
SmallVector< SourceRange, 4 > | Ranges |
SmallVector< std::shared_ptr< PathDiagnosticNotePiece >, 4 > | Notes |
SmallVector< FixItHint, 4 > | Fixits |
Friends | |
class | BugReportEquivClass |
class | BugReporter |
This class provides an interface through which checkers can create individual bug reports.
Definition at line 119 of file BugReporter.h.
|
strong |
Enumerator | |
---|---|
Basic | |
PathSensitive |
Definition at line 121 of file BugReporter.h.
Definition at line 136 of file BugReporter.h.
|
inlineprotected |
Definition at line 139 of file BugReporter.h.
|
virtualdefault |
|
inline |
Add a fix-it hint to the bug report.
Fix-it hints are the suggested edits to the code that would resolve the problem explained by the bug report. Fix-it hints should be as conservative as possible because it is not uncommon for the user to blindly apply all fixits to their project. Note that it is very hard to produce a good fix-it hint for most path-sensitive warnings.
Definition at line 240 of file BugReporter.h.
References Fixits.
Referenced by clang::ento::BugReporter::EmitBasicReport().
|
inline |
Add new item to the list of additional notes that need to be attached to this report.
If the report is path-sensitive, these notes will not be displayed as part of the execution path explanation, but will be displayed separately. Use bug visitors if you need to add an extra path note.
Definition at line 201 of file BugReporter.h.
|
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 222 of file BugReporter.h.
References clang::SourceRange::isValid(), and Ranges.
Referenced by clang::ento::BugReporter::EmitBasicReport().
|
inline |
Definition at line 149 of file BugReporter.h.
References BT.
Referenced by generateDiagnosticForBasicReport(), generateEmptyDiagnosticForReport(), and clang::ento::retaincountchecker::RefCountReportVisitor::VisitNode().
|
pure virtual |
The smallest declaration that contains the bug location.
This is purely cosmetic; the declaration can be displayed to the user but it does not affect whether the report is emitted.
Implemented in clang::ento::BasicBugReport, and clang::ento::PathSensitiveBugReport.
Referenced by clang::ento::BugSuppression::isSuppressed().
|
inline |
A verbose warning message that is appropriate for displaying next to the source code that introduces the problem.
The description should be at least a full sentence starting with a capital letter. The period at the end of the warning is traditionally omitted. If the description consists of multiple sentences, periods between the sentences are encouraged, but the period at the end of the description is still omitted.
Definition at line 157 of file BugReporter.h.
References Description.
Referenced by generateDiagnosticForBasicReport(), generateEmptyDiagnosticForReport(), and clang::ento::BugReporterVisitor::getDefaultEndPath().
|
inline |
Definition at line 244 of file BugReporter.h.
References Fixits.
|
inline |
Definition at line 147 of file BugReporter.h.
References K.
Referenced by clang::ento::BasicBugReport::classof(), clang::ento::PathSensitiveBugReport::classof(), clang::ento::BasicBugReport::Profile(), and clang::ento::PathSensitiveBugReport::Profile().
|
pure virtual |
The primary location of the bug report that points at the undesirable behavior in the code.
UIs should attach the warning description to this location. The warning description should describe the bad behavior at this location.
Implemented in clang::ento::BasicBugReport, clang::ento::PathSensitiveBugReport, and clang::ento::retaincountchecker::RefLeakReport.
Referenced by clang::ento::BugSuppression::isSuppressed().
|
inline |
Definition at line 211 of file BugReporter.h.
References Notes.
|
inlinevirtual |
Get the SourceRanges associated with the report.
Reimplemented in clang::ento::PathSensitiveBugReport, and clang::ento::retaincountchecker::RefCountReport.
Definition at line 229 of file BugReporter.h.
References Ranges.
A short general warning message that is appropriate for displaying in the list of all reported bugs.
It should describe what kind of bug is found but does not need to try to go into details of that specific bug. Grammatical conventions of getDescription() apply here as well.
Definition at line 163 of file BugReporter.h.
References Description, and ShortDescription.
Referenced by generateDiagnosticForBasicReport(), generateEmptyDiagnosticForReport(), clang::ento::BasicBugReport::Profile(), and clang::ento::PathSensitiveBugReport::Profile().
|
pure virtual |
Get the declaration that corresponds to (usually contains) the uniqueing location.
This is not actively used for uniqueing, i.e. otherwise identical reports that have different uniqueing decls will be considered equivalent.
Implemented in clang::ento::BasicBugReport, and clang::ento::PathSensitiveBugReport.
|
pure virtual |
Get the location on which the report should be uniqued.
Two warnings are considered to be equivalent whenever they have the same bug types, descriptions, and uniqueing locations. Out of a class of equivalent warnings only one gets displayed to the user. For most warnings the uniqueing location coincides with their location, but sometimes it makes sense to use different locations. For example, a leak checker can place the warning at the location where the last reference to the leaking resource is dropped but at the same time unique the warning by where that resource is acquired (allocated).
Implemented in clang::ento::BasicBugReport, and clang::ento::PathSensitiveBugReport.
Referenced by clang::ento::BugSuppression::isSuppressed().
|
pure virtual |
Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug.
Implemented in clang::ento::BasicBugReport, and clang::ento::PathSensitiveBugReport.
|
friend |
Definition at line 124 of file BugReporter.h.
|
friend |
Definition at line 125 of file BugReporter.h.
|
protected |
Definition at line 128 of file BugReporter.h.
Referenced by getBugType(), clang::ento::BasicBugReport::Profile(), and clang::ento::PathSensitiveBugReport::Profile().
|
protected |
Definition at line 130 of file BugReporter.h.
Referenced by getDescription(), and getShortDescription().
|
protected |
Definition at line 134 of file BugReporter.h.
Referenced by addFixItHint(), and getFixits().
|
protected |
Definition at line 127 of file BugReporter.h.
Referenced by getKind().
|
protected |
Definition at line 133 of file BugReporter.h.
Referenced by getNotes().
|
protected |
Definition at line 132 of file BugReporter.h.
Referenced by addRange(), getRanges(), clang::ento::PathSensitiveBugReport::getRanges(), clang::ento::BasicBugReport::Profile(), and clang::ento::PathSensitiveBugReport::Profile().
|
protected |
Definition at line 129 of file BugReporter.h.
Referenced by getShortDescription().