]> granicus.if.org Git - clang/commitdiff
[liblang] Handle CXXForRangeStmt during AST visitation.
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 13 Nov 2014 09:03:21 +0000 (09:03 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 13 Nov 2014 09:03:21 +0000 (09:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@221874 91177308-0d34-0410-b5e6-96231b3b80d8

test/Index/get-cursor.cpp
tools/libclang/CIndex.cpp

index 211ecb3497f1e35ab24bddb335f6c972d21238a8..bdee1653d06de3e942dc5223dff4247eba5ad80a 100644 (file)
@@ -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])
index 084e9d9cc4aa9514b911a4001df7d852dcfb6aa1..0e42a94b5439fbe19a12dc53b9d424fec758f106 100644 (file)
@@ -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());