clang 19.0.0git
Public Member Functions | Static Public Member Functions | List of all members
clang::ento::BasicBugReport Class Reference

#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"

Inheritance diagram for clang::ento::BasicBugReport:
Inheritance graph
[legend]

Public Member Functions

 BasicBugReport (const BugType &bt, StringRef desc, PathDiagnosticLocation l)
 
PathDiagnosticLocation getLocation () const override
 The primary location of the bug report that points at the undesirable behavior in the code.
 
const DeclgetDeclWithIssue () const override
 The smallest declaration that contains the bug location.
 
PathDiagnosticLocation getUniqueingLocation () const override
 Get the location on which the report should be uniqued.
 
const DeclgetUniqueingDecl () const override
 Get the declaration that corresponds to (usually contains) the uniqueing location.
 
void setDeclWithIssue (const Decl *declWithIssue)
 Specifically set the Decl where an issue occurred.
 
void Profile (llvm::FoldingSetNodeID &hash) const override
 Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug.
 
- Public Member Functions inherited from clang::ento::BugReport
virtual ~BugReport ()=default
 
Kind getKind () const
 
const BugTypegetBugType () 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 DeclgetDeclWithIssue () 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 DeclgetUniqueingDecl () 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< SourceRangegetRanges () const
 Get the SourceRanges associated with the report.
 
void addFixItHint (const FixItHint &F)
 Add a fix-it hint to the bug report.
 
llvm::ArrayRef< FixItHintgetFixits () const
 
virtual void Profile (llvm::FoldingSetNodeID &hash) const =0
 Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug.
 

Static Public Member Functions

static bool classof (const BugReport *R)
 

Additional Inherited Members

- Public Types inherited from clang::ento::BugReport
enum class  Kind { Basic , PathSensitive }
 
- Protected Member Functions inherited from clang::ento::BugReport
 BugReport (Kind kind, const BugType &bt, StringRef desc)
 
 BugReport (Kind K, const BugType &BT, StringRef ShortDescription, StringRef Description)
 
- Protected Attributes inherited from clang::ento::BugReport
Kind K
 
const BugTypeBT
 
std::string ShortDescription
 
std::string Description
 
SmallVector< SourceRange, 4 > Ranges
 
SmallVector< std::shared_ptr< PathDiagnosticNotePiece >, 4 > Notes
 
SmallVector< FixItHint, 4 > Fixits
 

Detailed Description

Definition at line 251 of file BugReporter.h.

Constructor & Destructor Documentation

◆ BasicBugReport()

clang::ento::BasicBugReport::BasicBugReport ( const BugType bt,
StringRef  desc,
PathDiagnosticLocation  l 
)
inline

Definition at line 256 of file BugReporter.h.

Member Function Documentation

◆ classof()

static bool clang::ento::BasicBugReport::classof ( const BugReport R)
inlinestatic

◆ getDeclWithIssue()

const Decl * clang::ento::BasicBugReport::getDeclWithIssue ( ) const
inlineoverridevirtual

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.

Implements clang::ento::BugReport.

Definition at line 268 of file BugReporter.h.

Referenced by generateDiagnosticForBasicReport(), and getUniqueingDecl().

◆ getLocation()

PathDiagnosticLocation clang::ento::BasicBugReport::getLocation ( ) const
inlineoverridevirtual

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.

Implements clang::ento::BugReport.

Definition at line 263 of file BugReporter.h.

References clang::ento::PathDiagnosticLocation::isValid().

Referenced by getUniqueingLocation().

◆ getUniqueingDecl()

const Decl * clang::ento::BasicBugReport::getUniqueingDecl ( ) const
inlineoverridevirtual

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.

Implements clang::ento::BugReport.

Definition at line 276 of file BugReporter.h.

References getDeclWithIssue().

Referenced by generateDiagnosticForBasicReport().

◆ getUniqueingLocation()

PathDiagnosticLocation clang::ento::BasicBugReport::getUniqueingLocation ( ) const
inlineoverridevirtual

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).

Implements clang::ento::BugReport.

Definition at line 272 of file BugReporter.h.

References getLocation().

Referenced by generateDiagnosticForBasicReport().

◆ Profile()

void BasicBugReport::Profile ( llvm::FoldingSetNodeID &  hash) const
overridevirtual

◆ setDeclWithIssue()

void clang::ento::BasicBugReport::setDeclWithIssue ( const Decl declWithIssue)
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 282 of file BugReporter.h.


The documentation for this class was generated from the following files: