r178706 - Pare back r164351 somewhat. The problem that change was addressing was that we
Richard Smith
richard-llvm at metafoo.co.uk
Wed Apr 3 15:49:41 PDT 2013
Author: rsmith
Date: Wed Apr 3 17:49:41 2013
New Revision: 178706
URL: http://llvm.org/viewvc/llvm-project?rev=178706&view=rev
Log:
Pare back r164351 somewhat. The problem that change was addressing was that we
don't serialize a lookup map for the translation unit outside C++ mode, so we
can't tell when lookup within the TU needs to look within modules. Only apply
the fix outside C++ mode, and only to the translation unit.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=178706&r1=178705&r2=178706&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Wed Apr 3 17:49:41 2013
@@ -1479,7 +1479,11 @@ public:
inline ddiag_iterator ddiag_end() const;
// Low-level accessors
-
+
+ bool mustBuildLookupTable() {
+ return LookupPtr.getInt();
+ }
+
/// \brief Mark the lookup table as needing to be built. This should be
/// used only if setHasExternalLexicalStorage() has been called on any
/// decl context for which this is the primary context.
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=178706&r1=178705&r2=178706&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Apr 3 17:49:41 2013
@@ -1995,8 +1995,14 @@ bool ASTReader::ReadASTBlock(ModuleFile
Error("error at end of module block in AST file");
return true;
case llvm::BitstreamEntry::EndBlock: {
+ // Outside of C++, we do not store a lookup map for the translation unit.
+ // Instead, mark it as needing a lookup map to be built if this module
+ // contains any declarations lexically within it (which it always does!).
+ // This usually has no cost, since we very rarely need the lookup map for
+ // the translation unit outside C++.
DeclContext *DC = Context.getTranslationUnitDecl();
- if (!DC->hasExternalVisibleStorage() && DC->hasExternalLexicalStorage())
+ if (DC->hasExternalLexicalStorage() &&
+ !getContext().getLangOpts().CPlusPlus)
DC->setMustBuildLookupTable();
return false;
Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=178706&r1=178705&r2=178706&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Apr 3 17:49:41 2013
@@ -2196,10 +2196,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID I
}
PendingVisibleUpdates.erase(I);
}
-
- if (!LookupDC->hasExternalVisibleStorage() &&
- DC->hasExternalLexicalStorage())
- LookupDC->setMustBuildLookupTable();
}
assert(Idx == Record.size());
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=178706&r1=178705&r2=178706&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Apr 3 17:49:41 2013
@@ -3324,8 +3324,6 @@ uint64_t ASTWriter::WriteDeclContextVisi
// If not in C++, we perform name lookup for the translation unit via the
// IdentifierInfo chains, don't bother to build a visible-declarations table.
- // FIXME: In C++ we need the visible declarations in order to "see" the
- // friend declarations, is there a way to do this without writing the table ?
if (DC->isTranslationUnit() && !Context.getLangOpts().CPlusPlus)
return 0;
More information about the cfe-commits
mailing list