[cfe-commits] r164351 - in /cfe/trunk: lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderDecl.cpp test/Index/rdar12316296-codecompletion.m

Argyrios Kyrtzidis akyrtzi at gmail.com
Thu Sep 20 18:30:00 PDT 2012


Author: akirtzidis
Date: Thu Sep 20 20:30:00 2012
New Revision: 164351

URL: http://llvm.org/viewvc/llvm-project?rev=164351&view=rev
Log:
[PCH] After deserializing a DeclContext, if it has external lexical decls but not
external visible decls, call DeclContext::setMustBuildLookupTable so that the
"lazy decls" bit of the LookupPtr is set.

Previously, in non-C++, if there were no new declarations causing the "lazy decls" bit
to be set, then DeclContext::lookups_begin() would fail to return the decls from the PCH.

Fixes rdar://12316296.

Added:
    cfe/trunk/test/Index/rdar12316296-codecompletion.m
Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=164351&r1=164350&r2=164351&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Sep 20 20:30:00 2012
@@ -1661,6 +1661,10 @@
         return Failure;
       }
 
+      DeclContext *DC = Context.getTranslationUnitDecl();
+      if (!DC->hasExternalVisibleStorage() && DC->hasExternalLexicalStorage())
+        DC->setMustBuildLookupTable();
+
       return Success;
     }
 

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=164351&r1=164350&r2=164351&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Thu Sep 20 20:30:00 2012
@@ -2127,6 +2127,9 @@
       }
       PendingVisibleUpdates.erase(I);
     }
+
+    if (!DC->hasExternalVisibleStorage() && DC->hasExternalLexicalStorage())
+      DC->setMustBuildLookupTable();
   }
   assert(Idx == Record.size());
 

Added: cfe/trunk/test/Index/rdar12316296-codecompletion.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/rdar12316296-codecompletion.m?rev=164351&view=auto
==============================================================================
--- cfe/trunk/test/Index/rdar12316296-codecompletion.m (added)
+++ cfe/trunk/test/Index/rdar12316296-codecompletion.m Thu Sep 20 20:30:00 2012
@@ -0,0 +1,23 @@
+// RUN: c-index-test -write-pch %t.h.pch %s
+// RUN: c-index-test -code-completion-at=%s:19:1 %s -include %t.h | FileCheck %s
+
+// <rdar://12316296> clang Code Completion returns nothing but preprocessor macros
+
+#ifndef HEADER
+#define HEADER
+
+ at interface I
+ at end
+
+// CHECK: FunctionDecl:{ResultType void}{TypedText foo}
+void foo();
+
+#else
+
+ at implementation I
+-(void)meth {
+
+}
+ at end
+
+#endif





More information about the cfe-commits mailing list