From: Ted Kremenek Date: Wed, 22 Apr 2009 18:03:00 +0000 (+0000) Subject: PathDiagnosticLocation: ranges for terminators now only include the first X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8f33290741c2c6190576523e06a0d3bb698554b1;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69812 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/PathDiagnostic.cpp b/lib/Analysis/PathDiagnostic.cpp index 1d00727d0a..fa075a3959 100644 --- a/lib/Analysis/PathDiagnostic.cpp +++ b/lib/Analysis/PathDiagnostic.cpp @@ -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(D)) return MD->getSourceRange();