summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2016-07-15 21:33:46 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2016-07-15 21:33:46 +0000
commit13fb860c7847d371a6b18dc38e805366bc582e24 (patch)
treeb3aa960dc285985f11222a29a64a3b8a50e98150 /clang/lib
parentc7536a5d60aa1568b0014dc9da3214d62b26e808 (diff)
downloadbcm5719-llvm-13fb860c7847d371a6b18dc38e805366bc582e24.tar.gz
bcm5719-llvm-13fb860c7847d371a6b18dc38e805366bc582e24.zip
Revert r275481, r275490. This broke modules bootstrap.
llvm-svn: 275624
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Serialization/ASTReader.cpp90
-rw-r--r--clang/lib/Serialization/ASTReaderDecl.cpp17
-rw-r--r--clang/lib/Serialization/ASTWriterDecl.cpp2
3 files changed, 9 insertions, 100 deletions
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index d4bcdac5989..b35bd7bd329 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2691,8 +2691,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
case EAGERLY_DESERIALIZED_DECLS:
// FIXME: Skip reading this record if our ASTConsumer doesn't care
// about "interesting" decls (for instance, if we're building a module).
- // FIXME: Store this somewhere per-module and defer until
- // markModuleReferenced is called.
for (unsigned I = 0, N = Record.size(); I != N; ++I)
EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
break;
@@ -3363,9 +3361,6 @@ void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner) {
void ASTReader::makeModuleVisible(Module *Mod,
Module::NameVisibilityKind NameVisibility,
SourceLocation ImportLoc) {
- // If we import anything from the module in any way, then it is used.
- markModuleUsed(Mod);
-
llvm::SmallPtrSet<Module *, 4> Visited;
SmallVector<Module *, 4> Stack;
Stack.push_back(Mod);
@@ -6732,95 +6727,10 @@ void ASTReader::PassInterestingDeclsToConsumer() {
Decl *D = InterestingDecls.front();
InterestingDecls.pop_front();
- // If we have found an interesting ImportDecl, then its imported module
- // is considered used.
- if (auto *ID = dyn_cast<ImportDecl>(D))
- markModuleUsed(ID->getImportedModule());
-
PassInterestingDeclToConsumer(D);
}
}
-void ASTReader::markModuleUsed(Module *M) {
- M = M->getTopLevelModule();
- // Mark that interesting decls in this module should now be passed to the
- // consumer, and pass any pending decls.
- auto MInterestingDecls =
- UnimportedModuleInterestingDecls.insert(std::make_pair(M, nullptr)).first;
- if (auto *Decls = MInterestingDecls->second) {
- MInterestingDecls->second = nullptr;
- for (auto *D : *Decls) {
- Module *Owner = D->getImportedOwningModule();
- if (Owner)
- Owner = Owner->getTopLevelModule();
- if (Owner != M) {
- // Mark that this decl has been handed to the consumer in its original
- // module, and stop if it's already been removed from there.
- auto OwnerIt = UnimportedModuleInterestingDecls.find(Owner);
- if (OwnerIt == UnimportedModuleInterestingDecls.end() ||
- !OwnerIt->second)
- continue;
- auto NewEnd =
- std::remove(OwnerIt->second->begin(), OwnerIt->second->end(), D);
- if (NewEnd == OwnerIt->second->end())
- continue;
- OwnerIt->second->erase(NewEnd, OwnerIt->second->end());
- }
- InterestingDecls.push_back(D);
- }
- }
-}
-
-void ASTReader::addInterestingDecl(Decl *D,
- llvm::Optional<Module *> OwnerOverride) {
- Module *Owner = D->getImportedOwningModule();
- if (Owner)
- Owner = Owner->getTopLevelModule();
- Module *ExportedBy = OwnerOverride ? *OwnerOverride : Owner;
- if (ExportedBy)
- ExportedBy = ExportedBy->getTopLevelModule();
-
- auto It = ExportedBy ? UnimportedModuleInterestingDecls.find(ExportedBy)
- : UnimportedModuleInterestingDecls.end();
- if (It == UnimportedModuleInterestingDecls.end())
- It = UnimportedModuleInterestingDecls.insert(
- std::make_pair(ExportedBy, new (Context) ModuleInterestingDecls))
- .first;
- ModuleInterestingDecls *Interesting = It->second;
-
- // If this declaration's module has been imported, hand it to the consumer.
- if (!ExportedBy || !Interesting) {
- if (Owner != ExportedBy) {
- // Mark that this decl has been handed to the consumer in its original
- // module, and stop if it's already been removed from there.
- auto OwnerIt = UnimportedModuleInterestingDecls.find(Owner);
- if (OwnerIt == UnimportedModuleInterestingDecls.end() || !OwnerIt->second)
- return;
- auto NewEnd =
- std::remove(OwnerIt->second->begin(), OwnerIt->second->end(), D);
- if (NewEnd == OwnerIt->second->end())
- return;
- OwnerIt->second->erase(NewEnd, OwnerIt->second->end());
- }
- InterestingDecls.push_back(D);
- return;
- }
- assert(Owner && "re-export of unowned decl");
-
- // If this is a re-export of another module's decl, check whether the decl
- // has already been handed to the consumer.
- if (Owner != ExportedBy) {
- auto OwnerIt = UnimportedModuleInterestingDecls.find(Owner);
- if (OwnerIt != UnimportedModuleInterestingDecls.end() &&
- (!OwnerIt->second ||
- std::find(OwnerIt->second->begin(), OwnerIt->second->end(), D) ==
- OwnerIt->second->end()))
- return;
- }
-
- Interesting->push_back(D);
-}
-
void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
PassObjCImplDeclToConsumer(ImplD, Consumer);
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index d9ed39a501b..4fd7aeb83ac 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3462,13 +3462,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
}
assert(Idx == Record.size());
- // If we have deserialized a declaration that has a definition the
- // AST consumer might need to know about, queue it.
- // We don't pass it to the consumer immediately because we may be in recursive
- // loading, and some declarations may still be initializing.
- if (isConsumerInterestedIn(D, Reader.hasPendingBody()))
- addInterestingDecl(D);
-
// Load any relevant update records.
PendingUpdateRecords.push_back(std::make_pair(ID, D));
@@ -3477,6 +3470,13 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
if (Class->isThisDeclarationADefinition())
loadObjCCategories(ID, Class);
+ // If we have deserialized a declaration that has a definition the
+ // AST consumer might need to know about, queue it.
+ // We don't pass it to the consumer immediately because we may be in recursive
+ // loading, and some declarations may still be initializing.
+ if (isConsumerInterestedIn(D, Reader.hasPendingBody()))
+ InterestingDecls.push_back(D);
+
return D;
}
@@ -3511,7 +3511,7 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
// we need to hand it off to the consumer.
if (!WasInteresting &&
isConsumerInterestedIn(D, Reader.hasPendingBody())) {
- addInterestingDecl(D);
+ InterestingDecls.push_back(D);
WasInteresting = true;
}
}
@@ -3945,7 +3945,6 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
// The declaration is now visible.
Exported->Hidden = false;
}
- Reader.addInterestingDecl(Exported, Owner);
break;
}
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp b/clang/lib/Serialization/ASTWriterDecl.cpp
index 8a54d9e1633..23d18540e82 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2126,7 +2126,7 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context,
// ImportDecl is used by codegen to determine the set of imported modules to
// search for inputs for automatic linking; include it if it has a semantic
// effect.
- if (isa<ImportDecl>(D))
+ if (isa<ImportDecl>(D) && !WritingModule)
return true;
return Context.DeclMustBeEmitted(D);
OpenPOWER on IntegriCloud