class PathDiagnosticLocation {
private:
enum Kind { RangeK, SingleLocK, StmtK, DeclK } K;
- SourceRange R;
const Stmt *S;
const Decl *D;
const SourceManager *SM;
PathDiagnosticLocation(SourceLocation L, const SourceManager &sm,
Kind kind)
- : K(kind), R(L, L), S(0), D(0), SM(&sm),
- Loc(genLocation()), Range(genRange()) {
- }
+ : K(kind), S(0), D(0), SM(&sm),
+ Loc(genLocation(L)), Range(genRange(L)) {}
FullSourceLoc
- genLocation(LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
+ genLocation(SourceLocation L = SourceLocation(),
+ LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
+
PathDiagnosticRange
- genRange(LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
+ genRange(SourceLocation L = SourceLocation(),
+ LocationOrAnalysisContext LAC = (AnalysisContext*)0) const;
public:
/// Create an invalid location.
const SourceManager &sm,
LocationOrAnalysisContext lac)
: K(StmtK), S(s), D(0), SM(&sm),
- Loc(genLocation(lac)), Range(genRange(lac)) {}
+ Loc(genLocation(SourceLocation(), lac)),
+ Range(genRange(SourceLocation(), lac)) {}
/// Create a location corresponding to the given declaration.
const PathDiagnosticLocation &PDL);
bool operator==(const PathDiagnosticLocation &X) const {
- return K == X.K && R == X.R && S == X.S && D == X.D;
+ return K == X.K && Loc == X.Loc && Range == X.Range;
}
bool operator!=(const PathDiagnosticLocation &X) const {
}
FullSourceLoc
- PathDiagnosticLocation::genLocation(LocationOrAnalysisContext LAC) const {
+ PathDiagnosticLocation::genLocation(SourceLocation L, LocationOrAnalysisContext LAC) const {
assert(isValid());
// Note that we want a 'switch' here so that the compiler can warn us in
// case we add more cases.
return FullSourceLoc(D->getLocation(), const_cast<SourceManager&>(*SM));
}
- return FullSourceLoc(R.getBegin(), const_cast<SourceManager&>(*SM));
+ return FullSourceLoc(L, const_cast<SourceManager&>(*SM));
}
PathDiagnosticRange
- PathDiagnosticLocation::genRange(LocationOrAnalysisContext LAC) const {
+ PathDiagnosticLocation::genRange(SourceLocation L, LocationOrAnalysisContext LAC) const {
assert(isValid());
// Note that we want a 'switch' here so that the compiler can warn us in
// case we add more cases.
switch (K) {
case SingleLocK:
- return PathDiagnosticRange(R, true);
+ return PathDiagnosticRange(SourceRange(L,L), true);
case RangeK:
break;
case StmtK: {
}
}
- return R;
+ return SourceRange(L,L);
}
void PathDiagnosticLocation::flatten() {
if (K == StmtK) {
- R = asRange();
K = RangeK;
S = 0;
D = 0;
}
else if (K == DeclK) {
- SourceLocation L = D->getLocation();
- R = SourceRange(L, L);
K = SingleLocK;
S = 0;
D = 0;