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

#include "clang/Analysis/PathDiagnostic.h"

Public Member Functions

 PathDiagnosticLocation ()=default
 Create an invalid location.
 
 PathDiagnosticLocation (const Stmt *s, const SourceManager &sm, LocationOrAnalysisDeclContext lac)
 Create a location corresponding to the given statement.
 
 PathDiagnosticLocation (const Decl *d, const SourceManager &sm)
 Create a location corresponding to the given declaration.
 
 PathDiagnosticLocation (SourceLocation loc, const SourceManager &sm)
 Create a location at an explicit offset in the source.
 
bool operator== (const PathDiagnosticLocation &X) const
 
bool operator!= (const PathDiagnosticLocation &X) const
 
bool isValid () const
 
FullSourceLoc asLocation () const
 
PathDiagnosticRange asRange () const
 
const StmtasStmt () const
 
const StmtgetStmtOrNull () const
 
const DeclasDecl () const
 
bool hasRange () const
 
bool hasValidLocation () const
 
void invalidate ()
 
void flatten ()
 
const SourceManagergetManager () const
 
void Profile (llvm::FoldingSetNodeID &ID) const
 
void dump () const
 

Static Public Member Functions

static PathDiagnosticLocation create (const Decl *D, const SourceManager &SM)
 Create a location corresponding to the given declaration.
 
static PathDiagnosticLocation createBegin (const Decl *D, const SourceManager &SM)
 Create a location for the beginning of the declaration.
 
static PathDiagnosticLocation createBegin (const Decl *D, const SourceManager &SM, const LocationOrAnalysisDeclContext LAC)
 Create a location for the beginning of the declaration.
 
static PathDiagnosticLocation createBegin (const Stmt *S, const SourceManager &SM, const LocationOrAnalysisDeclContext LAC)
 Create a location for the beginning of the statement.
 
static PathDiagnosticLocation createEnd (const Stmt *S, const SourceManager &SM, const LocationOrAnalysisDeclContext LAC)
 Create a location for the end of the statement.
 
static PathDiagnosticLocation createOperatorLoc (const BinaryOperator *BO, const SourceManager &SM)
 Create the location for the operator of the binary expression.
 
static PathDiagnosticLocation createConditionalColonLoc (const ConditionalOperator *CO, const SourceManager &SM)
 
static PathDiagnosticLocation createMemberLoc (const MemberExpr *ME, const SourceManager &SM)
 For member expressions, return the location of the '.
 
static PathDiagnosticLocation createBeginBrace (const CompoundStmt *CS, const SourceManager &SM)
 Create a location for the beginning of the compound statement.
 
static PathDiagnosticLocation createEndBrace (const CompoundStmt *CS, const SourceManager &SM)
 Create a location for the end of the compound statement.
 
static PathDiagnosticLocation createDeclBegin (const LocationContext *LC, const SourceManager &SM)
 Create a location for the beginning of the enclosing declaration body.
 
static PathDiagnosticLocation createDeclEnd (const LocationContext *LC, const SourceManager &SM)
 Constructs a location for the end of the enclosing declaration body.
 
static PathDiagnosticLocation create (const ProgramPoint &P, const SourceManager &SMng)
 Create a location corresponding to the given valid ProgramPoint.
 
static PathDiagnosticLocation createSingleLocation (const PathDiagnosticLocation &PDL)
 Convert the given location into a single kind location.
 
static SourceLocation getValidSourceLocation (const Stmt *S, LocationOrAnalysisDeclContext LAC, bool UseEndOfStatement=false)
 Construct a source location that corresponds to either the beginning or the end of the given statement, or a nearby valid source location if the statement does not have a valid source location of its own.
 

Detailed Description

Definition at line 195 of file PathDiagnostic.h.

Constructor & Destructor Documentation

◆ PathDiagnosticLocation() [1/4]

clang::ento::PathDiagnosticLocation::PathDiagnosticLocation ( )
default

Create an invalid location.

Referenced by create(), and invalidate().

◆ PathDiagnosticLocation() [2/4]

clang::ento::PathDiagnosticLocation::PathDiagnosticLocation ( const Stmt s,
const SourceManager sm,
LocationOrAnalysisDeclContext  lac 
)
inline

Create a location corresponding to the given statement.

Definition at line 220 of file PathDiagnostic.h.

References clang::ento::DefinedSVal::isValid(), and SM.

◆ PathDiagnosticLocation() [3/4]

clang::ento::PathDiagnosticLocation::PathDiagnosticLocation ( const Decl d,
const SourceManager sm 
)
inline

Create a location corresponding to the given declaration.

Definition at line 231 of file PathDiagnostic.h.

References clang::ento::DefinedSVal::isValid(), and SM.

◆ PathDiagnosticLocation() [4/4]

clang::ento::PathDiagnosticLocation::PathDiagnosticLocation ( SourceLocation  loc,
const SourceManager sm 
)
inline

Create a location at an explicit offset in the source.

This should only be used if there are no more appropriate constructors.

Definition at line 241 of file PathDiagnostic.h.

References clang::ento::DefinedSVal::isValid(), and SM.

Member Function Documentation

◆ asDecl()

const Decl * clang::ento::PathDiagnosticLocation::asDecl ( ) const
inline

Definition at line 354 of file PathDiagnostic.h.

References isValid().

◆ asLocation()

FullSourceLoc clang::ento::PathDiagnosticLocation::asLocation ( ) const
inline

◆ asRange()

PathDiagnosticRange clang::ento::PathDiagnosticLocation::asRange ( ) const
inline

◆ asStmt()

const Stmt * clang::ento::PathDiagnosticLocation::asStmt ( ) const
inline

Definition at line 347 of file PathDiagnostic.h.

References isValid().

Referenced by addContextEdges(), addEdgeToPath(), and getStmtOrNull().

◆ create() [1/2]

static PathDiagnosticLocation clang::ento::PathDiagnosticLocation::create ( const Decl D,
const SourceManager SM 
)
inlinestatic

◆ create() [2/2]

PathDiagnosticLocation PathDiagnosticLocation::create ( const ProgramPoint P,
const SourceManager SMng 
)
static

◆ createBegin() [1/3]

PathDiagnosticLocation PathDiagnosticLocation::createBegin ( const Decl D,
const SourceManager SM 
)
static

◆ createBegin() [2/3]

static PathDiagnosticLocation clang::ento::PathDiagnosticLocation::createBegin ( const Decl D,
const SourceManager SM,
const LocationOrAnalysisDeclContext  LAC 
)
inlinestatic

Create a location for the beginning of the declaration.

The third argument is ignored, useful for generic treatment of statements and declarations.

Definition at line 261 of file PathDiagnostic.h.

References createBegin(), and SM.

◆ createBegin() [3/3]

PathDiagnosticLocation PathDiagnosticLocation::createBegin ( const Stmt S,
const SourceManager SM,
const LocationOrAnalysisDeclContext  LAC 
)
static

Create a location for the beginning of the statement.

Definition at line 585 of file PathDiagnostic.cpp.

References SM.

◆ createBeginBrace()

PathDiagnosticLocation PathDiagnosticLocation::createBeginBrace ( const CompoundStmt CS,
const SourceManager SM 
)
static

Create a location for the beginning of the compound statement.

Assumes the statement has a valid location.

Definition at line 631 of file PathDiagnostic.cpp.

References clang::CompoundStmt::getLBracLoc(), and SM.

◆ createConditionalColonLoc()

PathDiagnosticLocation PathDiagnosticLocation::createConditionalColonLoc ( const ConditionalOperator CO,
const SourceManager SM 
)
static

Definition at line 610 of file PathDiagnostic.cpp.

References clang::AbstractConditionalOperator::getColonLoc(), and SM.

◆ createDeclBegin()

PathDiagnosticLocation PathDiagnosticLocation::createDeclBegin ( const LocationContext LC,
const SourceManager SM 
)
static

Create a location for the beginning of the enclosing declaration body.

Defaults to the beginning of the first statement in the declaration body.

Definition at line 645 of file PathDiagnostic.cpp.

References clang::Decl::getBody(), clang::LocationContext::getDecl(), and SM.

◆ createDeclEnd()

PathDiagnosticLocation PathDiagnosticLocation::createDeclEnd ( const LocationContext LC,
const SourceManager SM 
)
static

Constructs a location for the end of the enclosing declaration body.

Defaults to the end of brace.

Definition at line 658 of file PathDiagnostic.cpp.

References clang::Decl::getBodyRBrace(), clang::LocationContext::getDecl(), and SM.

Referenced by clang::ento::PathSensitiveBugReport::getLocation().

◆ createEnd()

PathDiagnosticLocation PathDiagnosticLocation::createEnd ( const Stmt S,
const SourceManager SM,
const LocationOrAnalysisDeclContext  LAC 
)
static

Create a location for the end of the statement.

If the statement is a CompoundStatement, the location will point to the closing brace instead of following it.

Definition at line 594 of file PathDiagnostic.cpp.

References SM.

Referenced by create(), clang::ento::PathSensitiveBugReport::getLocation(), and getLocationForCaller().

◆ createEndBrace()

PathDiagnosticLocation PathDiagnosticLocation::createEndBrace ( const CompoundStmt CS,
const SourceManager SM 
)
static

Create a location for the end of the compound statement.

Assumes the statement has a valid location.

Definition at line 638 of file PathDiagnostic.cpp.

References clang::CompoundStmt::getRBracLoc(), and SM.

◆ createMemberLoc()

PathDiagnosticLocation PathDiagnosticLocation::createMemberLoc ( const MemberExpr ME,
const SourceManager SM 
)
static

For member expressions, return the location of the '.

' or '->'. Assumes the statement has a valid location.

Definition at line 617 of file PathDiagnostic.cpp.

References clang::MemberExpr::getBeginLoc(), clang::MemberExpr::getMemberLoc(), clang::SourceLocation::isValid(), and SM.

Referenced by clang::ento::PathSensitiveBugReport::getLocation().

◆ createOperatorLoc()

PathDiagnosticLocation PathDiagnosticLocation::createOperatorLoc ( const BinaryOperator BO,
const SourceManager SM 
)
static

Create the location for the operator of the binary expression.

Assumes the statement has a valid location.

Definition at line 604 of file PathDiagnostic.cpp.

References clang::BinaryOperator::getOperatorLoc(), and SM.

Referenced by clang::ento::PathSensitiveBugReport::getLocation().

◆ createSingleLocation()

PathDiagnosticLocation PathDiagnosticLocation::createSingleLocation ( const PathDiagnosticLocation PDL)
static

Convert the given location into a single kind location.

Definition at line 738 of file PathDiagnostic.cpp.

References asLocation(), and clang::FullSourceLoc::getManager().

Referenced by CompactMacroExpandedPieces().

◆ dump()

LLVM_DUMP_METHOD void PathDiagnosticLocation::dump ( ) const

Definition at line 1205 of file PathDiagnostic.cpp.

◆ flatten()

void PathDiagnosticLocation::flatten ( )

◆ getManager()

const SourceManager & clang::ento::PathDiagnosticLocation::getManager ( ) const
inline

Definition at line 366 of file PathDiagnostic.h.

References isValid(), and SM.

Referenced by clang::ento::BugSuppression::isSuppressed(), and resetDiagnosticLocationToMainFile().

◆ getStmtOrNull()

const Stmt * clang::ento::PathDiagnosticLocation::getStmtOrNull ( ) const
inline

Definition at line 348 of file PathDiagnostic.h.

References asStmt(), and isValid().

Referenced by addContextEdges(), and simplifySimpleBranches().

◆ getValidSourceLocation()

SourceLocation PathDiagnosticLocation::getValidSourceLocation ( const Stmt S,
LocationOrAnalysisDeclContext  LAC,
bool  UseEndOfStatement = false 
)
static

Construct a source location that corresponds to either the beginning or the end of the given statement, or a nearby valid source location if the statement does not have a valid source location of its own.

Definition at line 476 of file PathDiagnostic.cpp.

References clang::Stmt::getBeginLoc(), clang::AnalysisDeclContext::getBody(), clang::AnalysisDeclContext::getDecl(), clang::Decl::getEndLoc(), clang::AnalysisDeclContext::getParentMap(), clang::SourceLocation::isValid(), and Parent.

Referenced by clang::ento::PathSensitiveBugReport::getLocation().

◆ hasRange()

bool clang::ento::PathDiagnosticLocation::hasRange ( ) const
inline

◆ hasValidLocation()

bool clang::ento::PathDiagnosticLocation::hasValidLocation ( ) const
inline

◆ invalidate()

void clang::ento::PathDiagnosticLocation::invalidate ( )
inline

Definition at line 360 of file PathDiagnostic.h.

References PathDiagnosticLocation().

◆ isValid()

bool clang::ento::PathDiagnosticLocation::isValid ( ) const
inline

◆ operator!=()

bool clang::ento::PathDiagnosticLocation::operator!= ( const PathDiagnosticLocation X) const
inline

Definition at line 331 of file PathDiagnostic.h.

References X.

◆ operator==()

bool clang::ento::PathDiagnosticLocation::operator== ( const PathDiagnosticLocation X) const
inline

Definition at line 327 of file PathDiagnostic.h.

References X.

◆ Profile()

void PathDiagnosticLocation::Profile ( llvm::FoldingSetNodeID &  ID) const

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