clang 22.0.0git
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 isValid(), clang::nullptr, and s.

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

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

Member Function Documentation

◆ asDecl()

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

Definition at line 354 of file PathDiagnostic.h.

References isValid().

◆ asLocation()

◆ asRange()

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

Definition at line 343 of file PathDiagnostic.h.

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

◆ create() [2/2]

◆ createBegin() [1/3]

◆ createBegin() [2/3]

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

◆ 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 580 of file PathDiagnostic.cpp.

References getValidSourceLocation().

◆ 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 626 of file PathDiagnostic.cpp.

References clang::CompoundStmt::getLBracLoc().

◆ createConditionalColonLoc()

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

◆ 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 640 of file PathDiagnostic.cpp.

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

◆ 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 653 of file PathDiagnostic.cpp.

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

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 589 of file PathDiagnostic.cpp.

References createEndBrace(), and getValidSourceLocation().

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 633 of file PathDiagnostic.cpp.

References clang::CompoundStmt::getRBracLoc().

Referenced by createEnd().

◆ 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 612 of file PathDiagnostic.cpp.

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

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 599 of file PathDiagnostic.cpp.

References clang::BinaryOperator::getOperatorLoc().

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 733 of file PathDiagnostic.cpp.

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

Referenced by CompactMacroExpandedPieces().

◆ dump()

LLVM_DUMP_METHOD void PathDiagnosticLocation::dump ( ) const

Definition at line 1200 of file PathDiagnostic.cpp.

References asLocation(), clang::isa(), and isValid().

◆ flatten()

void PathDiagnosticLocation::flatten ( )

Definition at line 826 of file PathDiagnostic.cpp.

◆ getManager()

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

Definition at line 366 of file PathDiagnostic.h.

References isValid().

Referenced by 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 471 of file PathDiagnostic.cpp.

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

Referenced by createBegin(), createEnd(), and clang::ento::PathSensitiveBugReport::getLocation().

◆ hasRange()

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

Definition at line 356 of file PathDiagnostic.h.

◆ hasValidLocation()

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

Definition at line 358 of file PathDiagnostic.h.

References asLocation(), and clang::SourceLocation::isValid().

◆ invalidate()

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

Definition at line 360 of file PathDiagnostic.h.

References PathDiagnosticLocation().

◆ isValid()

◆ 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

Definition at line 1082 of file PathDiagnostic.cpp.

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


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