[cfe-commits] r126952 - in /cfe/trunk: include/clang/AST/Decl.h lib/AST/Decl.cpp lib/Sema/SemaLookup.cpp lib/Sema/SemaStmt.cpp lib/Serialization/ASTReaderDecl.cpp lib/Serialization/ASTWriterDecl.cpp

Abramo Bagnara abramo.bagnara at gmail.com
Thu Mar 3 10:24:14 PST 2011


Author: abramo
Date: Thu Mar  3 12:24:14 2011
New Revision: 126952

URL: http://llvm.org/viewvc/llvm-project?rev=126952&view=rev
Log:
Fixed source range for LabelDecl.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/lib/AST/Decl.cpp
    cfe/trunk/lib/Sema/SemaLookup.cpp
    cfe/trunk/lib/Sema/SemaStmt.cpp
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
    cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=126952&r1=126951&r2=126952&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Mar  3 12:24:14 2011
@@ -309,17 +309,22 @@
 /// location of the statement.  For GNU local labels (__label__), the decl
 /// location is where the __label__ is.
 class LabelDecl : public NamedDecl {
-  LabelStmt *TheStmt;
-  LabelDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *II, LabelStmt *S)
-    : NamedDecl(Label, DC, L, II), TheStmt(S) {}
+  llvm::PointerIntPair<LabelStmt *, 1, bool> StmtAndGnuLocal;
+  LabelDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *II,
+            LabelStmt *S, bool isGnuLocal)
+    : NamedDecl(Label, DC, L, II), StmtAndGnuLocal(S, isGnuLocal) {}
   
 public:
   static LabelDecl *Create(ASTContext &C, DeclContext *DC,
-                           SourceLocation L, IdentifierInfo *II);
+                           SourceLocation L, IdentifierInfo *II,
+                           bool isGnuLocal = false);
 
-  LabelStmt *getStmt() const { return TheStmt; }
-  void setStmt(LabelStmt *T) { TheStmt = T; }
+  LabelStmt *getStmt() const { return StmtAndGnuLocal.getPointer(); }
+  void setStmt(LabelStmt *T) { StmtAndGnuLocal.setPointer(T); }
   
+  bool isGnuLocal() const { return StmtAndGnuLocal.getInt(); }
+  void setGnuLocal(bool V = true) { StmtAndGnuLocal.setInt(V); }
+
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
   static bool classof(const LabelDecl *D) { return true; }

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=126952&r1=126951&r2=126952&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Mar  3 12:24:14 2011
@@ -2200,8 +2200,9 @@
 }
 
 LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC,
-                             SourceLocation L, IdentifierInfo *II) {
-  return new (C) LabelDecl(DC, L, II, 0);
+                             SourceLocation L, IdentifierInfo *II,
+                             bool isGnuLocal) {
+  return new (C) LabelDecl(DC, L, II, 0, isGnuLocal);
 }
 
 

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=126952&r1=126951&r2=126952&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Mar  3 12:24:14 2011
@@ -2784,7 +2784,7 @@
   
   if (Res == 0) {
     // If not forward referenced or defined already, create the backing decl.
-    Res = LabelDecl::Create(Context, CurContext, Loc, II);
+    Res = LabelDecl::Create(Context, CurContext, Loc, II, isLocalLabel);
     Scope *S = isLocalLabel ? CurScope : CurScope->getFnParent();
     assert(S && "Not in a function?");
     PushOnScopeChains(Res, S, true);

Modified: cfe/trunk/lib/Sema/SemaStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmt.cpp?rev=126952&r1=126951&r2=126952&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmt.cpp Thu Mar  3 12:24:14 2011
@@ -245,11 +245,10 @@
   }
 
   // Otherwise, things are good.  Fill in the declaration and return it.
-  TheDecl->setLocation(IdentLoc);
-  
   LabelStmt *LS = new (Context) LabelStmt(IdentLoc, TheDecl, SubStmt);
   TheDecl->setStmt(LS);
-  TheDecl->setLocation(IdentLoc);
+  if (!TheDecl->isGnuLocal())
+    TheDecl->setLocation(IdentLoc);
   return Owned(LS);
 }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=126952&r1=126951&r2=126952&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Mar  3 12:24:14 2011
@@ -726,6 +726,8 @@
 
 void ASTDeclReader::VisitLabelDecl(LabelDecl *D) {
   VisitNamedDecl(D);
+  bool IsGnuLocal = Record[Idx++];
+  D->setGnuLocal(IsGnuLocal);
 }
 
 

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=126952&r1=126951&r2=126952&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Thu Mar  3 12:24:14 2011
@@ -653,6 +653,7 @@
 
 void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) {
   VisitNamedDecl(D);
+  Record.push_back(D->isGnuLocal());
   Code = serialization::DECL_LABEL;
 }
 





More information about the cfe-commits mailing list