]> granicus.if.org Git - clang/commitdiff
[libclang/AST] When declaring a local class, don't neglect to set the end location
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 16 May 2012 23:49:15 +0000 (23:49 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 16 May 2012 23:49:15 +0000 (23:49 +0000)
of the DeclStmt node, otherwise libclang will not work for anything inside that
class.

rdar://10837710

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

lib/Parse/ParseDecl.cpp
test/Index/get-cursor.cpp

index ba40c9b26264d0e895b1d7b3c09b952b909d9c54..d1350104bc3781d21071ba16b70fd24490b2fdb1 100644 (file)
@@ -1050,6 +1050,7 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(StmtVector &Stmts,
   // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
   // declaration-specifiers init-declarator-list[opt] ';'
   if (Tok.is(tok::semi)) {
+    DeclEnd = Tok.getLocation();
     if (RequireSemi) ConsumeToken();
     Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none,
                                                        DS);
index e1e6835becad59ca42a705f94009d36715ef6c4d..8b70216dd16513a509992f822ee4b8172cb8bb56 100644 (file)
@@ -38,6 +38,13 @@ void test() {
   } catch (X e) {
     X x;
   }
+
+  struct LocalS {
+    void meth() {
+      int x;
+      ++x;
+    }
+  };
 }
 
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
@@ -93,3 +100,6 @@ void test() {
 // RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s
 // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15]
 // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8]
+
+// RUN: c-index-test -cursor-at=%s:45:9 %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s
+// CHECK-LOCALCLASS: 45:9 DeclRefExpr=x:44:11 Extent=[45:9 - 45:10] Spelling=x ([45:9 - 45:10])