[cfe-commits] r165137 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTReaderDecl.cpp
Douglas Gregor
dgregor at apple.com
Wed Oct 3 11:34:48 PDT 2012
Author: dgregor
Date: Wed Oct 3 13:34:48 2012
New Revision: 165137
URL: http://llvm.org/viewvc/llvm-project?rev=165137&view=rev
Log:
Revert most of the functionality in r165001. Instead, make sure that
the ASTReader doesn't attach a body to a function that is already
defined elsewhere.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=165137&r1=165136&r2=165137&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Oct 3 13:34:48 2012
@@ -687,12 +687,6 @@
/// Objective-C protocols.
std::deque<Decl *> InterestingDecls;
- /// \brief Redecls that have been added to the AST
- ///
- /// Redecls that are deserialized but not in RedeclsAddedToAST must
- /// not be passed to the ASTConsumers, even if they are InterestignDecls.
- llvm::SmallPtrSet<Decl *, 16> RedeclsAddedToAST;
-
/// \brief The set of redeclarable declarations that have been deserialized
/// since the last time the declaration chains were linked.
llvm::SmallPtrSet<Decl *, 16> RedeclsDeserialized;
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=165137&r1=165136&r2=165137&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Oct 3 13:34:48 2012
@@ -5614,10 +5614,7 @@
SourceLocation Loc
= SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]);
- // For modules, find out whether an instantiation already exists
- if (!getContext().getLangOpts().Modules
- || needPendingInstantiation(D))
- Pending.push_back(std::make_pair(D, Loc));
+ Pending.push_back(std::make_pair(D, Loc));
}
PendingInstantiations.clear();
}
@@ -6528,5 +6525,4 @@
J != F; ++J)
delete J->first;
}
- assert(RedeclsAddedToAST.empty() && "RedeclsAddedToAST not empty!");
}
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=165137&r1=165136&r2=165137&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Oct 3 13:34:48 2012
@@ -320,7 +320,10 @@
ID->TypeForDecl = Reader.GetType(TypeIDForTypeDecl).getTypePtrOrNull();
} else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
// FunctionDecl's body was written last after all other Stmts/Exprs.
- if (Record[Idx++])
+ // We only read it if FD doesn't already have a body (e.g., from another
+ // module).
+ if (Record[Idx++] &&
+ (!Reader.getContext().getLangOpts().Modules || !FD->hasBody()))
FD->setLazyBody(GetCurrentCursorOffset());
} else if (D->isTemplateParameter()) {
// If we have a fully initialized template parameter, we can now
@@ -1778,11 +1781,9 @@
DeclContext *DC = New->getLexicalDeclContext();
if (DC->isTranslationUnit() && Reader.SemaObj) {
- if (Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName()))
- Reader.RedeclsAddedToAST.insert(New);
+ Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, New->getDeclName());
} else if (DC->isNamespace()) {
DC->addDecl(New);
- Reader.RedeclsAddedToAST.insert(New);
}
}
@@ -2157,13 +2158,7 @@
// 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 (getContext().getLangOpts().Modules) {
- if (RedeclsAddedToAST.count(D)) {
- RedeclsAddedToAST.erase(D);
- if (isConsumerInterestedIn(D))
- InterestingDecls.push_back(D);
- }
- } else if (isConsumerInterestedIn(D))
+ if (isConsumerInterestedIn(D))
InterestingDecls.push_back(D);
return D;
More information about the cfe-commits
mailing list