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