]> granicus.if.org Git - clang/commitdiff
Added LabelLoc to GotoStmt to record the source location of the label token
authorTed Kremenek <kremenek@apple.com>
Thu, 6 Sep 2007 17:11:52 +0000 (17:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 6 Sep 2007 17:11:52 +0000 (17:11 +0000)
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

Sema/SemaStmt.cpp
include/clang/AST/Stmt.h

index 2924370df3a62e0e4ce6822a49010401c8017fe8..9cca2c24f02cbe77e35c55501944bb3aaeda8549 100644 (file)
@@ -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 
index b0dca78648f98e9e25547399202082008af282b0..b2703f4647294a774933ada74baae92bd25f634e 100644 (file)
@@ -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;