diff options
-rw-r--r-- | include/clang/AST/DeclBase.h | 6 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 8 | ||||
-rw-r--r-- | lib/Serialization/ASTReaderDecl.cpp | 4 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 2 |
4 files changed, 12 insertions, 8 deletions
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 852bb9ab04..4af49efb7d 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -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. diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 4c4277c30f..d9844152b7 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1995,8 +1995,14 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) { 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; diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index 3dcae6fe6a..0fbdd7e5da 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -2196,10 +2196,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) { } PendingVisibleUpdates.erase(I); } - - if (!LookupDC->hasExternalVisibleStorage() && - DC->hasExternalLexicalStorage()) - LookupDC->setMustBuildLookupTable(); } assert(Idx == Record.size()); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 6893b5003f..cf93d1cf01 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3324,8 +3324,6 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context, // 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; |