r221874 - [liblang] Handle CXXForRangeStmt during AST visitation.

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Nov 13 01:03:22 PST 2014


Author: akirtzidis
Date: Thu Nov 13 03:03:21 2014
New Revision: 221874

URL: http://llvm.org/viewvc/llvm-project?rev=221874&view=rev
Log:
[liblang] Handle CXXForRangeStmt during AST visitation.

Modified:
    cfe/trunk/test/Index/get-cursor.cpp
    cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/test/Index/get-cursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/get-cursor.cpp?rev=221874&r1=221873&r2=221874&view=diff
==============================================================================
--- cfe/trunk/test/Index/get-cursor.cpp (original)
+++ cfe/trunk/test/Index/get-cursor.cpp Thu Nov 13 03:03:21 2014
@@ -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])

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=221874&r1=221873&r2=221874&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Nov 13 03:03:21 2014
@@ -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(c
   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());





More information about the cfe-commits mailing list