clang  10.0.0svn
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]
Collaboration diagram for clang::ento::BasicBugReport:
Collaboration 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. More...
 
const DeclgetDeclWithIssue () const override
 The smallest declaration that contains the bug location. More...
 
PathDiagnosticLocation getUniqueingLocation () const override
 Get the location on which the report should be uniqued. More...
 
const DeclgetUniqueingDecl () const override
 Get the declaration that corresponds to (usually contains) the uniqueing location. More...
 
void setDeclWithIssue (const Decl *declWithIssue)
 Specifically set the Decl where an issue occurred. More...
 
void Profile (llvm::FoldingSetNodeID &hash) const override
 Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug. More...
 
- 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. More...
 
StringRef getShortDescription (bool UseFallback=true) const
 A short general warning message that is appropriate for displaying in the list of all reported bugs. More...
 
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. More...
 
ArrayRef< std::shared_ptr< PathDiagnosticNotePiece > > getNotes ()
 
void addRange (SourceRange R)
 Add a range to a bug report. More...
 
virtual ArrayRef< SourceRangegetRanges () const
 Get the SourceRanges associated with the report. More...
 
void addFixItHint (const FixItHint &F)
 Add a fix-it hint to the bug report. More...
 
llvm::ArrayRef< FixItHintgetFixits () const
 

Static Public Member Functions

static bool classof (const BugReport *R)
 

Additional Inherited Members

- Public Types inherited from clang::ento::BugReport
enum  Kind { Kind::Basic, Kind::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

Definition at line 259 of file BugReporter.h.

References clang::ento::BugReport::getKind().

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

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

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

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

◆ Profile()

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

Reports are uniqued to ensure that we do not emit multiple diagnostics for each bug.

Implements clang::ento::BugReport.

Definition at line 2137 of file BugReporter.cpp.

References getKind(), and clang::transformer::range().

◆ 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: