const SourceManager &SM);
/// Create a location corresponding to the given valid ExplodedNode.
- PathDiagnosticLocation(const ProgramPoint& P, const SourceManager &SMng);
+ static PathDiagnosticLocation create(const ProgramPoint& P,
+ const SourceManager &SMng);
/// Create a location corresponding to the next valid ExplodedNode as end
/// of path location.
static PathDiagnosticLocation createEndOfPath(const ExplodedNode* N,
const SourceManager &SM);
+ /// Convert the given location into a single kind location.
+ static PathDiagnosticLocation createSingleLocation(
+ const PathDiagnosticLocation &PDL);
+
bool operator==(const PathDiagnosticLocation &X) const {
return K == X.K && R == X.R && S == X.S && D == X.D && LC == X.LC;
}
*this = PathDiagnosticLocation();
}
- /// Specify that the object represents a single location.
- void setSingleLocKind() {
- if (K == SingleLocK)
- return;
-
- SourceLocation L = asLocation();
- K = SingleLocK;
- R = SourceRange(L, L);
- }
-
void flatten();
const SourceManager& getManager() const { assert(isValid()); return *SM; }
// Construct a new PathDiagnosticPiece.
ProgramPoint P = N->getLocation();
- PathDiagnosticLocation L = PathDiagnosticLocation(P,BRC.getSourceManager());
+ PathDiagnosticLocation L =
+ PathDiagnosticLocation::create(P, BRC.getSourceManager());
if (!L.isValid())
return NULL;
return new PathDiagnosticEventPiece(L, os.str());
// Construct a new PathDiagnosticPiece.
ProgramPoint P = N->getLocation();
- PathDiagnosticLocation L = PathDiagnosticLocation(P,BRC.getSourceManager());
+ PathDiagnosticLocation L =
+ PathDiagnosticLocation::create(P, BRC.getSourceManager());
if (!L.isValid())
return NULL;
return new PathDiagnosticEventPiece(L, os.str());
return PathDiagnosticLocation(getValidSourceLocation(S, LC), SM, SingleLocK);
}
+
PathDiagnosticLocation
PathDiagnosticLocation::createOperatorLoc(const BinaryOperator *BO,
const SourceManager &SM) {
PathDiagnosticLocation
PathDiagnosticLocation::createDeclEnd(const LocationContext *LC,
- const SourceManager &SM) {
+ const SourceManager &SM) {
SourceLocation L = LC->getDecl()->getBodyRBrace();
return PathDiagnosticLocation(L, SM, SingleLocK);
}
-PathDiagnosticLocation::PathDiagnosticLocation(const ProgramPoint& P,
- const SourceManager &SMng)
- : K(StmtK), S(0), D(0), SM(&SMng), LC(P.getLocationContext()) {
+PathDiagnosticLocation
+ PathDiagnosticLocation::create(const ProgramPoint& P,
+ const SourceManager &SMng) {
+ const Stmt* S = 0;
if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
const CFGBlock *BSrc = BE->getSrc();
S = BSrc->getTerminatorCondition();
S = PS->getStmt();
}
+ return PathDiagnosticLocation(S, SMng, P.getLocationContext());
+
if (!S)
- invalidate();
+ return PathDiagnosticLocation();
}
PathDiagnosticLocation
while (NI) {
ProgramPoint P = NI->getLocation();
const LocationContext *LC = P.getLocationContext();
- if (const StmtPoint *PS = dyn_cast<StmtPoint>(&P)) {
+ if (const StmtPoint *PS = dyn_cast<StmtPoint>(&P))
return PathDiagnosticLocation(PS->getStmt(), SM, LC);
- }
else if (const BlockEdge *BE = dyn_cast<BlockEdge>(&P)) {
const Stmt *Term = BE->getSrc()->getTerminator();
assert(Term);
return createDeclEnd(N->getLocationContext(), SM);
}
+PathDiagnosticLocation PathDiagnosticLocation::createSingleLocation(
+ const PathDiagnosticLocation &PDL) {
+ FullSourceLoc L = PDL.asLocation();
+ return PathDiagnosticLocation(L, L.getManager(), SingleLocK);
+}
+
FullSourceLoc PathDiagnosticLocation::asLocation() const {
assert(isValid());
// Note that we want a 'switch' here so that the compiler can warn us in