[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

llvm-svn: 156966
This commit is contained in:
Argyrios Kyrtzidis 2012-05-16 23:49:15 +00:00
parent 06fd3c61be
commit fbb2bb5a3d
2 changed files with 11 additions and 0 deletions

View File

@ -1050,6 +1050,7 @@ Parser::DeclGroupPtrTy Parser::ParseSimpleDeclaration(StmtVector &Stmts,
// C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };" // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
// declaration-specifiers init-declarator-list[opt] ';' // declaration-specifiers init-declarator-list[opt] ';'
if (Tok.is(tok::semi)) { if (Tok.is(tok::semi)) {
DeclEnd = Tok.getLocation();
if (RequireSemi) ConsumeToken(); if (RequireSemi) ConsumeToken();
Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none, Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none,
DS); DS);

View File

@ -38,6 +38,13 @@ void test() {
} catch (X e) { } catch (X e) {
X x; 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 // 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 // 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@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] // 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])