[cfe-commits] r156966 - in /cfe/trunk: lib/Parse/ParseDecl.cpp test/Index/get-cursor.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed May 16 16:49:16 PDT 2012


Author: akirtzidis
Date: Wed May 16 18:49:15 2012
New Revision: 156966

URL: http://llvm.org/viewvc/llvm-project?rev=156966&view=rev
Log:
[libclang/AST] When declaring a local class, don't neglect to set the end location
of the DeclStmt node, otherwise libclang will not work for anything inside that
class.

rdar://10837710

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/test/Index/get-cursor.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=156966&r1=156965&r2=156966&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Wed May 16 18:49:15 2012
@@ -1050,6 +1050,7 @@
   // 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);

Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=156966&r1=156965&r2=156966&view=diff
==============================================================================
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Wed May 16 18:49:15 2012
@@ -38,6 +38,13 @@
   } 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 @@
 // 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 at 472@F at test#@e Extent=[38:12 - 38:15]
 // CHECK-USR: get-cursor.cpp c:get-cursor.cpp at 483@F at 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])





More information about the cfe-commits mailing list