From da5bcf310ea7bff05a15b8650034774016bea7a3 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 13 Nov 2014 09:50:19 +0000 Subject: [PATCH] [libclang] Make sure to visit the body of a CXXForRangeStmt. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221881 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Index/get-cursor.cpp | 7 +++++-- tools/libclang/CIndex.cpp | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp index bdee1653d0..60aab5f7ed 100644 --- a/test/Index/get-cursor.cpp +++ b/test/Index/get-cursor.cpp @@ -138,7 +138,9 @@ struct TestColl { }; void test(TestColl coll) { - for (auto lv : coll) {} + for (auto lv : coll) { + (void)lv; + } } // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s @@ -253,6 +255,7 @@ void test(TestColl coll) { // CHECK-SPELLING: 130:6 CXXMethod=operator():130:6 (const) Extent=[130:3 - 130:37] Spelling=operator() ([130:6 - 130:16]) // CHECK-SPELLING: 132:12 CXXConversion=operator bool:132:12 (const) Extent=[132:3 - 132:33] Spelling=operator bool ([132:12 - 132:25]) -// RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s +// RUN: c-index-test -cursor-at=%s:141:13 -cursor-at=%s:141:18 -cursor-at=%s:142:11 -std=c++11 %s | FileCheck -check-prefix=CHECK-FORRANGE %s // CHECK-FORRANGE: 141:13 VarDecl=lv:141:13 (Definition) Extent=[141:8 - 141:17] Spelling=lv ([141:13 - 141:15]) // CHECK-FORRANGE: 141:18 DeclRefExpr=coll:140:20 Extent=[141:18 - 141:22] Spelling=coll ([141:18 - 141:22]) +// CHECK-FORRANGE: 142:11 DeclRefExpr=lv:141:13 Extent=[142:11 - 142:13] Spelling=lv ([142:11 - 142:13]) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 0e42a94b54..00ef8c0bf4 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2156,8 +2156,9 @@ void EnqueueVisitor::VisitCXXCatchStmt(const CXXCatchStmt *S) { } void EnqueueVisitor::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { - AddDecl(S->getLoopVariable()); + AddStmt(S->getBody()); AddStmt(S->getRangeInit()); + AddDecl(S->getLoopVariable()); } void EnqueueVisitor::VisitDeclRefExpr(const DeclRefExpr *DR) { -- 2.40.0