[cfe-commits] r145536 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp test/PCH/pending-ids.m
Argyrios Kyrtzidis
akyrtzi at gmail.com
Wed Nov 30 15:18:27 PST 2011
Author: akirtzidis
Date: Wed Nov 30 17:18:26 2011
New Revision: 145536
URL: http://llvm.org/viewvc/llvm-project?rev=145536&view=rev
Log:
[PCH] In ASTReader::FinishedDeserializing, after we do PassInterestingDeclsToConsumer
we may end up having added more pending stuff to do, so go in a loop until everything
is cleared out.
This fixes the error in rdar://10278815 which has a certain David Lynch-esque quality..
error: unknown type name 'BOOL'; did you mean 'BOOL'?
Added:
cfe/trunk/test/PCH/pending-ids.m
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=145536&r1=145535&r2=145536&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Nov 30 17:18:26 2011
@@ -738,6 +738,7 @@
getModulePreprocessedEntity(unsigned GlobalIndex);
void PassInterestingDeclsToConsumer();
+ void PassInterestingDeclToConsumer(Decl *D);
/// \brief Produce an error diagnostic and return true.
///
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=145536&r1=145535&r2=145536&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Nov 30 17:18:26 2011
@@ -4531,13 +4531,17 @@
Decl *D = InterestingDecls.front();
InterestingDecls.pop_front();
- if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
- PassObjCImplDeclToConsumer(ImplD, Consumer);
- else
- Consumer->HandleInterestingDecl(DeclGroupRef(D));
+ PassInterestingDeclToConsumer(D);
}
}
+void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
+ if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
+ PassObjCImplDeclToConsumer(ImplD, Consumer);
+ else
+ Consumer->HandleInterestingDecl(DeclGroupRef(D));
+}
+
void ASTReader::StartTranslationUnit(ASTConsumer *Consumer) {
this->Consumer = Consumer;
@@ -5693,33 +5697,43 @@
assert(NumCurrentElementsDeserializing &&
"FinishedDeserializing not paired with StartedDeserializing");
if (NumCurrentElementsDeserializing == 1) {
- // If any identifiers with corresponding top-level declarations have
- // been loaded, load those declarations now.
- while (!PendingIdentifierInfos.empty()) {
- SetGloballyVisibleDecls(PendingIdentifierInfos.front().II,
- PendingIdentifierInfos.front().DeclIDs, true);
- PendingIdentifierInfos.pop_front();
- }
-
- // Ready to load previous declarations of Decls that were delayed.
- while (!PendingPreviousDecls.empty()) {
- loadAndAttachPreviousDecl(PendingPreviousDecls.front().first,
- PendingPreviousDecls.front().second);
- PendingPreviousDecls.pop_front();
- }
+ do {
+ // If any identifiers with corresponding top-level declarations have
+ // been loaded, load those declarations now.
+ while (!PendingIdentifierInfos.empty()) {
+ SetGloballyVisibleDecls(PendingIdentifierInfos.front().II,
+ PendingIdentifierInfos.front().DeclIDs, true);
+ PendingIdentifierInfos.pop_front();
+ }
+
+ // Ready to load previous declarations of Decls that were delayed.
+ while (!PendingPreviousDecls.empty()) {
+ loadAndAttachPreviousDecl(PendingPreviousDecls.front().first,
+ PendingPreviousDecls.front().second);
+ PendingPreviousDecls.pop_front();
+ }
+
+ for (std::vector<std::pair<ObjCInterfaceDecl *,
+ serialization::DeclID> >::iterator
+ I = PendingChainedObjCCategories.begin(),
+ E = PendingChainedObjCCategories.end(); I != E; ++I) {
+ loadObjCChainedCategories(I->second, I->first);
+ }
+ PendingChainedObjCCategories.clear();
+
+ // We are not in recursive loading, so it's safe to pass the "interesting"
+ // decls to the consumer.
+ if (Consumer && !InterestingDecls.empty()) {
+ Decl *D = InterestingDecls.front();
+ InterestingDecls.pop_front();
- for (std::vector<std::pair<ObjCInterfaceDecl *,
- serialization::DeclID> >::iterator
- I = PendingChainedObjCCategories.begin(),
- E = PendingChainedObjCCategories.end(); I != E; ++I) {
- loadObjCChainedCategories(I->second, I->first);
- }
- PendingChainedObjCCategories.clear();
+ PassInterestingDeclToConsumer(D);
+ }
- // We are not in recursive loading, so it's safe to pass the "interesting"
- // decls to the consumer.
- if (Consumer)
- PassInterestingDeclsToConsumer();
+ } while ((Consumer && !InterestingDecls.empty()) ||
+ !PendingIdentifierInfos.empty() ||
+ !PendingPreviousDecls.empty() ||
+ !PendingChainedObjCCategories.empty());
assert(PendingForwardRefs.size() == 0 &&
"Some forward refs did not get linked to the definition!");
Added: cfe/trunk/test/PCH/pending-ids.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pending-ids.m?rev=145536&view=auto
==============================================================================
--- cfe/trunk/test/PCH/pending-ids.m (added)
+++ cfe/trunk/test/PCH/pending-ids.m Wed Nov 30 17:18:26 2011
@@ -0,0 +1,33 @@
+// Test for rdar://10278815
+
+// Without PCH
+// RUN: %clang_cc1 -fsyntax-only -verify -include %s %s
+
+// With PCH
+// RUN: %clang_cc1 %s -emit-pch -o %t
+// RUN: %clang_cc1 -emit-llvm-only -verify %s -include-pch %t -g
+
+#ifndef HEADER
+#define HEADER
+//===----------------------------------------------------------------------===//
+// Header
+
+typedef char BOOL;
+
+ at interface NSString
++ (BOOL)meth;
+ at end
+
+static NSString * const cake = @"cake";
+
+//===----------------------------------------------------------------------===//
+#else
+//===----------------------------------------------------------------------===//
+
+ at interface Foo {
+ BOOL ivar;
+}
+ at end
+
+//===----------------------------------------------------------------------===//
+#endif
More information about the cfe-commits
mailing list