Fixed in r150555. On Tue, Feb 14, 2012 at 5:57 PM, Douglas Gregor <[email protected]> wrote:
> Sorry, I won't be back at a computer for a few more hours. Can you either > apply the obvious fix or revert? > > Sent from my iPhone > > On Feb 14, 2012, at 5:57 PM, Chad Rosier <[email protected]> wrote: > > Hi Doug, > This commit is causing failures on our internal buildbots with the > following error: > > llvm[4]: Compiling IndexingContext.cpp for Release+Asserts build > (PIC)/Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin10-gcc42-RA/llvm/tools/clang/tools/libclang/IndexBody.cpp:109:18: > error: no member named 'indexFunctionLocalSymbols' in > 'clang::cxindex::IndexingContext'; did you mean > 'shouldIndexFunctionLocalSymbols'? > if (IndexCtx.indexFunctionLocalSymbols()) > ^~~~~~~~~~~~~~~~~~~~~~~~~ > shouldIndexFunctionLocalSymbols > /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin10-gcc42-RA/llvm/tools/clang/tools/libclang/IndexingContext.h:329:8: > note: 'shouldIndexFunctionLocalSymbols' declared here > bool shouldIndexFunctionLocalSymbols() const { > ^ > 1 error generated. > make[4]: *** > [/Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.clang-x86_64-darwin10-gcc42-RA/clang-build/tools/clang/tools/libclang/Release+Asserts/IndexBody.o] > Error 1 > > See also: > > http://smooshlab.apple.com:8013/builders/clang-x86_64-darwin10-gcc42-RA/builds/11827 > > Chad > > On Feb 14, 2012, at 4:54 PM, Douglas Gregor wrote: > > Author: dgregor > Date: Tue Feb 14 18:54:55 2012 > New Revision: 150549 > > URL: http://llvm.org/viewvc/llvm-project?rev=150549&view=rev > Log: > Implement indexing support for lambdas in libclang (both kinds), as > well as improving the RecursiveASTVisitor's walk of lambda > expressions. > > Added: > cfe/trunk/test/Index/cxx11-lambdas.cpp > Modified: > cfe/trunk/include/clang-c/Index.h > cfe/trunk/include/clang/AST/RecursiveASTVisitor.h > cfe/trunk/tools/libclang/CIndex.cpp > cfe/trunk/tools/libclang/CXCursor.cpp > cfe/trunk/tools/libclang/CXCursor.h > cfe/trunk/tools/libclang/CXType.cpp > cfe/trunk/tools/libclang/CursorVisitor.h > cfe/trunk/tools/libclang/IndexBody.cpp > cfe/trunk/tools/libclang/IndexingContext.cpp > > Modified: cfe/trunk/include/clang-c/Index.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=150549&r1=150548&r2=150549&view=diff > > ============================================================================== > --- cfe/trunk/include/clang-c/Index.h (original) > +++ cfe/trunk/include/clang-c/Index.h Tue Feb 14 18:54:55 2012 > @@ -1500,7 +1500,13 @@ > */ > CXCursor_OverloadedDeclRef = 49, > > - CXCursor_LastRef = CXCursor_OverloadedDeclRef, > + /** > + * \brief A reference to a variable that occurs in some non-expression > + * context, e.g., a C++ lambda capture list. > + */ > + CXCursor_VariableRef = 50, > + > + CXCursor_LastRef = CXCursor_VariableRef, > > /* Error conditions */ > CXCursor_FirstInvalid = 70, > @@ -1746,7 +1752,21 @@ > */ > CXCursor_SizeOfPackExpr = 143, > > - CXCursor_LastExpr = CXCursor_SizeOfPackExpr, > + /* \brief Represents a C++ lambda expression that produces a local > function > + * object. > + * > + * \code > + * void abssort(float *x, unsigned N) { > + * std::sort(x, x + N, > + * [](float a, float b) { > + * return std::abs(a) < std::abs(b); > + * }); > + * } > + * \endcode > + */ > + CXCursor_LambdaExpr = 144, > + > + CXCursor_LastExpr = CXCursor_LambdaExpr, > > /* Statements */ > CXCursor_FirstStmt = 200, > > Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=150549&r1=150548&r2=150549&view=diff > > ============================================================================== > --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original) > +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Tue Feb 14 18:54:55 > 2012 > @@ -228,6 +228,11 @@ > /// \returns false if the visitation was terminated early, true > otherwise. > bool TraverseConstructorInitializer(CXXCtorInitializer *Init); > > + /// \brief Recursively visit a lambda capture. > + /// > + /// \returns false if the visitation was terminated early, true > otherwise. > + bool TraverseLambdaCapture(LambdaExpr::Capture C); > + > // ---- Methods on Stmts ---- > > // Declare Traverse*() for all concrete Stmt classes. > @@ -675,6 +680,10 @@ > return true; > } > > +template<typename Derived> > +bool > RecursiveASTVisitor<Derived>::TraverseLambdaCapture(LambdaExpr::Capture C){ > + return true; > +} > > // ----------------- Type traversal ----------------- > > @@ -1953,9 +1962,36 @@ > TRY_TO(TraverseTypeLoc(S->getTypeSourceInfo()->getTypeLoc())); > }) > > -DEF_TRAVERSE_STMT(LambdaExpr, { > - TRY_TO(TraverseStmt(S->getBody())); > - }) > +// Walk only the visible parts of lambda expressions. > +template<typename Derived> > +bool RecursiveASTVisitor<Derived>::TraverseLambdaExpr(LambdaExpr *S) { > + for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), > + CEnd = S->explicit_capture_end(); > + C != CEnd; ++C) { > + TRY_TO(TraverseLambdaCapture(*C)); > + } > + > + if (S->hasExplicitParameters() || S->hasExplicitResultType()) { > + TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc(); > + if (S->hasExplicitParameters() && S->hasExplicitResultType()) { > + // Visit the whole type. > + TRY_TO(TraverseTypeLoc(TL)); > + } else if (isa<FunctionProtoTypeLoc>(TL)) { > + FunctionProtoTypeLoc Proto = cast<FunctionProtoTypeLoc>(TL); > + if (S->hasExplicitParameters()) { > + // Visit parameters. > + for (unsigned I = 0, N = Proto.getNumArgs(); I != N; ++I) { > + TRY_TO(TraverseDecl(Proto.getArg(I))); > + } > + } else { > + TRY_TO(TraverseTypeLoc(Proto.getResultLoc())); > + } > + } > + } > + > + TRY_TO(TraverseStmt(S->getBody())); > + return true; > +} > > DEF_TRAVERSE_STMT(CXXUnresolvedConstructExpr, { > // This is called for code like 'T()', where T is a template argument. > > Added: cfe/trunk/test/Index/cxx11-lambdas.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/cxx11-lambdas.cpp?rev=150549&view=auto > > ============================================================================== > --- cfe/trunk/test/Index/cxx11-lambdas.cpp (added) > +++ cfe/trunk/test/Index/cxx11-lambdas.cpp Tue Feb 14 18:54:55 2012 > @@ -0,0 +1,33 @@ > +// Test is line- and column-sensitive; see below. > + > +typedef int Integer; > +struct X { > + void f() { > + int localA, localB; > + auto lambda = [&localA, localB] (Integer x) -> Integer { > + return localA + localB + x; > + }; > + } > +}; > + > +// RUN: c-index-test -test-load-source all -std=c++11 %s | FileCheck > -check-prefix=CHECK-LOAD %s > +// CHECK-LOAD: cxx11-lambdas.cpp:7:19: LambdaExpr= Extent=[7:19 - 9:6] > +// CHECK-LOAD: cxx11-lambdas.cpp:7:21: VariableRef=localA:6:9 > Extent=[7:21 - 7:27] > +// CHECK-LOAD: cxx11-lambdas.cpp:7:29: VariableRef=localB:6:17 > Extent=[7:29 - 7:35] > +// CHECK-LOAD: cxx11-lambdas.cpp:7:52: TypeRef=Integer:3:13 Extent=[7:52 > - 7:59] > +// CHECK-LOAD: cxx11-lambdas.cpp:7:46: ParmDecl=x:7:46 (Definition) > Extent=[7:38 - 7:47] > +// CHECK-LOAD: cxx11-lambdas.cpp:7:38: TypeRef=Integer:3:13 Extent=[7:38 > - 7:45] > +// CHECK-LOAD: cxx11-lambdas.cpp:7:60: CompoundStmt= Extent=[7:60 - 9:6] > +// CHECK-LOAD: cxx11-lambdas.cpp:8:7: ReturnStmt= Extent=[8:7 - 8:33] > +// CHECK-LOAD: cxx11-lambdas.cpp:8:14: DeclRefExpr=localA:6:9 > Extent=[8:14 - 8:20] > +// CHECK-LOAD: cxx11-lambdas.cpp:8:23: DeclRefExpr=localB:6:17 > Extent=[8:23 - 8:29] > +// CHECK-LOAD: cxx11-lambdas.cpp:8:32: DeclRefExpr=x:7:46 Extent=[8:32 - > 8:33] > + > +// RUN: env CINDEXTEST_INDEXLOCALSYMBOLS=1 c-index-test -index-file > -std=c++11 %s | FileCheck -check-prefix=CHECK-INDEX %s > +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | > USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: > VariableRef=localA:6:9 | loc: 7:21 > +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | > USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: > VariableRef=localB:6:17 | loc: 7:29 > +// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | > USR: c:cxx11-lambdas.cpp@51@T@Integer | lang: C | cursor: > TypeRef=Integer:3:13 | loc: 7:52 > +// CHECK-INDEX: [indexEntityReference]: kind: typedef | name: Integer | > USR: c:cxx11-lambdas.cpp@51@T@Integer | lang: C | cursor: > TypeRef=Integer:3:13 | loc: 7:38 > +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localA | > USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localA | lang: C | cursor: > DeclRefExpr=localA:6:9 | loc: 8:14 > +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: localB | > USR: c:cxx11-lambdas.cpp@100@S@X@F@f#@localB | lang: C | cursor: > DeclRefExpr=localB:6:17 | loc: 8:23 > +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: x | USR: > c:cxx11-lambdas.cpp@157@S@X@F@f#@Ca@F@operator()#I#1@x | lang: C | > cursor: DeclRefExpr=x:7:46 | loc: 8:32 > > Modified: cfe/trunk/tools/libclang/CIndex.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=150549&r1=150548&r2=150549&view=diff > > ============================================================================== > --- cfe/trunk/tools/libclang/CIndex.cpp (original) > +++ cfe/trunk/tools/libclang/CIndex.cpp Tue Feb 14 18:54:55 2012 > @@ -1615,6 +1615,7 @@ > DEF_JOB(ExplicitTemplateArgsVisit, ASTTemplateArgumentListInfo, > ExplicitTemplateArgsVisitKind) > DEF_JOB(SizeOfPackExprParts, SizeOfPackExpr, SizeOfPackExprPartsKind) > +DEF_JOB(LambdaExprParts, LambdaExpr, LambdaExprPartsKind) > #undef DEF_JOB > > class DeclVisit : public VisitorJob { > @@ -1761,6 +1762,7 @@ > void VisitSizeOfPackExpr(SizeOfPackExpr *E); > void VisitPseudoObjectExpr(PseudoObjectExpr *E); > void VisitOpaqueValueExpr(OpaqueValueExpr *E); > + void VisitLambdaExpr(LambdaExpr *E); > > private: > void AddDeclarationNameInfo(Stmt *S); > @@ -2081,6 +2083,10 @@ > if (Expr *SourceExpr = E->getSourceExpr()) > return Visit(SourceExpr); > } > +void EnqueueVisitor::VisitLambdaExpr(LambdaExpr *E) { > + AddStmt(E->getBody()); > + WL.push_back(LambdaExprParts(E, Parent)); > +} > void EnqueueVisitor::VisitPseudoObjectExpr(PseudoObjectExpr *E) { > // Treat the expression like its syn > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits > >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
