PathDiagnosticLocation: ranges for terminators now only include the first

character instead of the entire range for the IfStmt, ForStmt, etc. We may
gradually refine these ranges later, but basically terminator ranges just refer
to the first keyword.

llvm-svn: 69812
This commit is contained in:
Ted Kremenek 2009-04-22 18:03:00 +00:00
parent e4f25b706b
commit 22579c4c8f
1 changed files with 22 additions and 1 deletions

View File

@ -166,8 +166,29 @@ SourceRange PathDiagnosticLocation::asRange() const {
case SingleLocK:
case RangeK:
break;
case StmtK:
case StmtK: {
const Stmt *S = asStmt();
switch (S->getStmtClass()) {
default:
break;
// FIXME: Provide better range information for different
// terminators.
case Stmt::IfStmtClass:
case Stmt::WhileStmtClass:
case Stmt::DoStmtClass:
case Stmt::ForStmtClass:
case Stmt::ChooseExprClass:
case Stmt::IndirectGotoStmtClass:
case Stmt::SwitchStmtClass:
case Stmt::ConditionalOperatorClass:
case Stmt::ObjCForCollectionStmtClass: {
SourceLocation L = S->getLocStart();
return SourceRange(L, L);
}
}
return S->getSourceRange();
}
case DeclK:
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
return MD->getSourceRange();