]> granicus.if.org Git - clang/commitdiff
Move the type specifier location for elaborated-type-specifiers from
authorDouglas Gregor <dgregor@apple.com>
Mon, 25 Jan 2010 16:33:23 +0000 (16:33 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 25 Jan 2010 16:33:23 +0000 (16:33 +0000)
the tag kind (union, struct, class, enum) over to the name of the tag,
if there is a name, since most clients want to point at the name.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94424 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseDecl.cpp
lib/Parse/ParseDeclCXX.cpp
test/Index/c-index-api-loadTU-test.m
test/Index/load-exprs.c

index b5ba8acafc8d4529499452e545c7a98ba400d77b..8cf7a63397ffc9fbbe978f706bfc0f54d7bf9bdb 100644 (file)
@@ -1878,10 +1878,12 @@ void Parser::ParseEnumSpecifier(SourceLocation StartLoc, DeclSpec &DS,
   if (Tok.is(tok::l_brace))
     ParseEnumBody(StartLoc, TagDecl);
 
-  // TODO: semantic analysis on the declspec for enums.
+  // FIXME: The DeclSpec should keep the locations of both the keyword and the
+  // name (if there is one).
+  SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
   const char *PrevSpec = 0;
   unsigned DiagID;
-  if (DS.SetTypeSpecType(DeclSpec::TST_enum, StartLoc, PrevSpec, DiagID,
+  if (DS.SetTypeSpecType(DeclSpec::TST_enum, TSTLoc, PrevSpec, DiagID,
                          TagDecl.getAs<void>(), Owned))
     Diag(StartLoc, DiagID) << PrevSpec;
 }
index efaf8ee3270ed44476090e930a535f049306fa77..04845d3b41186752d7eba61037654374052d8ce1 100644 (file)
@@ -917,7 +917,11 @@ void Parser::ParseClassSpecifier(tok::TokenKind TagTokKind,
   const char *PrevSpec = 0;
   unsigned DiagID;
 
-  if (DS.SetTypeSpecType(TagType, StartLoc, PrevSpec, DiagID,
+  // FIXME: The DeclSpec should keep the locations of both the keyword and the
+  // name (if there is one).
+  SourceLocation TSTLoc = NameLoc.isValid()? NameLoc : StartLoc;
+  
+  if (DS.SetTypeSpecType(TagType, TSTLoc, PrevSpec, DiagID,
                          Result, Owned))
     Diag(StartLoc, DiagID) << PrevSpec;
 }
index cf0dbff457a15667a0cb56e6ec64202d4137d197..891e18b67d5613a9ef5590135e6534e1c3739b78 100644 (file)
@@ -65,7 +65,7 @@ int main (int argc, const char * argv[]) {
 // CHECK: <invalid loc>:87:81: FieldDecl=overflow_arg_area:87:81 (Definition)
 // CHECK: <invalid loc>:87:107: FieldDecl=reg_save_area:87:107 (Definition)
 // CHECK: <invalid loc>:87:123: TypedefDecl=__va_list_tag:87:123 (Definition)
-// CHECK: <invalid loc>:87:9: TypeRef=struct __va_list_tag:87:16
+// CHECK: <invalid loc>:87:16: TypeRef=struct __va_list_tag:87:16
 // CHECK: <invalid loc>:87:159: TypedefDecl=__builtin_va_list:87:159 (Definition)
 // CHECK: <invalid loc>:87:145: TypeRef=__va_list_tag:87:123
 // CHECK: <invalid loc>:87:177: UnexposedExpr=
index a360efd755a4e85b0889b5e2f8fec9d1cabc567d..ea4d0ea52943e08ac4ae6fb4e2ea0bb16f8fb14d 100644 (file)
@@ -10,4 +10,5 @@ void f(void *ptr) {
 
 // CHECK: load-exprs.c:4:15: TypeRef=T:1:13 [Extent=4:15:4:15]
 // CHECK: load-exprs.c:5:16: TypeRef=T:1:13 [Extent=5:16:5:16]
-// FIXME: the source location for "struct X" points at "struct", not "X"
+// CHECK: load-exprs.c:6:10: TypeRef=struct X:2:8 [Extent=6:10:6:10]
+// CHECK: load-exprs.c:6:24: TypeRef=struct X:2:8 [Extent=6:24:6:24]