From: Argyrios Kyrtzidis Date: Thu, 13 Nov 2014 09:03:21 +0000 (+0000) Subject: [liblang] Handle CXXForRangeStmt during AST visitation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1dde64b6e34fcaed8e9fbf0925a6cc3ecba67c7e;p=clang [liblang] Handle CXXForRangeStmt during AST visitation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221874 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp index 211ecb3497..bdee1653d0 100644 --- a/test/Index/get-cursor.cpp +++ b/test/Index/get-cursor.cpp @@ -132,6 +132,15 @@ class A { explicit operator bool() const; }; +struct TestColl { + int* begin(); + int* end(); +}; + +void test(TestColl coll) { + for (auto lv : coll) {} +} + // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s // CHECK-COMPLETION-1: CXXConstructor=X:6:3 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )} @@ -243,3 +252,7 @@ class A { // CHECK-SPELLING: 129:6 CXXMethod=operator->:129:6 Extent=[129:3 - 129:18] Spelling=operator-> ([129:6 - 129:16]) // 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 +// 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]) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 084e9d9cc4..0e42a94b54 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -1834,6 +1834,7 @@ public: void VisitCXXUnresolvedConstructExpr(const CXXUnresolvedConstructExpr *E); void VisitCXXUuidofExpr(const CXXUuidofExpr *E); void VisitCXXCatchStmt(const CXXCatchStmt *S); + void VisitCXXForRangeStmt(const CXXForRangeStmt *S); void VisitDeclRefExpr(const DeclRefExpr *D); void VisitDeclStmt(const DeclStmt *S); void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E); @@ -2154,6 +2155,11 @@ void EnqueueVisitor::VisitCXXCatchStmt(const CXXCatchStmt *S) { AddDecl(S->getExceptionDecl()); } +void EnqueueVisitor::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { + AddDecl(S->getLoopVariable()); + AddStmt(S->getRangeInit()); +} + void EnqueueVisitor::VisitDeclRefExpr(const DeclRefExpr *DR) { if (DR->hasExplicitTemplateArgs()) { AddExplicitTemplateArgs(&DR->getExplicitTemplateArgs());