From: Ted Kremenek Date: Thu, 6 Sep 2007 17:11:52 +0000 (+0000) Subject: Added LabelLoc to GotoStmt to record the source location of the label token X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=61f62165220e75694fe333179c78815e2e48d71f;p=clang Added LabelLoc to GotoStmt to record the source location of the label token in the actual GotoStmt. Fixed bug where GotoStmt::getSourceRange incorrectly used the target LabelStmt to compute its extent. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41745 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Sema/SemaStmt.cpp b/Sema/SemaStmt.cpp index 2924370df3..9cca2c24f0 100644 --- a/Sema/SemaStmt.cpp +++ b/Sema/SemaStmt.cpp @@ -510,7 +510,7 @@ Sema::ParseGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc, if (LabelDecl == 0) LabelDecl = new LabelStmt(LabelLoc, LabelII, 0); - return new GotoStmt(LabelDecl, GotoLoc); + return new GotoStmt(LabelDecl, GotoLoc, LabelLoc); } Action::StmtResult diff --git a/include/clang/AST/Stmt.h b/include/clang/AST/Stmt.h index b0dca78648..b2703f4647 100644 --- a/include/clang/AST/Stmt.h +++ b/include/clang/AST/Stmt.h @@ -524,14 +524,15 @@ public: class GotoStmt : public Stmt { LabelStmt *Label; SourceLocation GotoLoc; + SourceLocation LabelLoc; public: - GotoStmt(LabelStmt *label, SourceLocation GL) : Stmt(GotoStmtClass), - Label(label), GotoLoc(GL) {} + GotoStmt(LabelStmt *label, SourceLocation GL, SourceLocation LL) + : Stmt(GotoStmtClass), Label(label), GotoLoc(GL), LabelLoc(LL) {} LabelStmt *getLabel() const { return Label; } virtual SourceRange getSourceRange() const { - return SourceRange(GotoLoc, Label->getLocEnd()); + return SourceRange(GotoLoc, LabelLoc); } static bool classof(const Stmt *T) { return T->getStmtClass() == GotoStmtClass;