Author: rsmith Date: Tue Jun 30 21:29:35 2015 New Revision: 241137 URL: http://llvm.org/viewvc/llvm-project?rev=241137&view=rev Log: [modules] Before checking whether the controlling macro of a header is defined, update the identifier in case we've imported a definition of the macro (and thus the contents of the header) from a module.
Also fold ExternalIdentifierLookup into ExternalPreprocessorSource; it no longer makes sense to keep these separate now that the only user of the former also needs the latter. Added: cfe/trunk/test/Modules/Inputs/submodule-visibility/c.h cfe/trunk/test/Modules/Inputs/submodule-visibility/other.h Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h cfe/trunk/include/clang/Lex/ExternalPreprocessorSource.h cfe/trunk/include/clang/Lex/HeaderSearch.h cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Basic/IdentifierTable.cpp cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/test/Modules/Inputs/submodule-visibility/a.h cfe/trunk/test/Modules/Inputs/submodule-visibility/b.h cfe/trunk/test/Modules/Inputs/submodule-visibility/module.modulemap Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/include/clang/Basic/IdentifierTable.h (original) +++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue Jun 30 21:29:35 2015 @@ -406,19 +406,6 @@ public: virtual IdentifierIterator *getIdentifiers(); }; -/// \brief An abstract class used to resolve numerical identifier -/// references (meaningful only to some external source) into -/// IdentifierInfo pointers. -class ExternalIdentifierLookup { -public: - virtual ~ExternalIdentifierLookup(); - - /// \brief Return the identifier associated with the given ID number. - /// - /// The ID 0 is associated with the NULL identifier. - virtual IdentifierInfo *GetIdentifier(unsigned ID) = 0; -}; - /// \brief Implements an efficient mapping from strings to IdentifierInfo nodes. /// /// This has no other purpose, but this is an extremely performance-critical Modified: cfe/trunk/include/clang/Lex/ExternalPreprocessorSource.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ExternalPreprocessorSource.h?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/ExternalPreprocessorSource.h (original) +++ cfe/trunk/include/clang/Lex/ExternalPreprocessorSource.h Tue Jun 30 21:29:35 2015 @@ -23,7 +23,7 @@ class Module; /// information. /// /// This abstract class allows an external sources (such as the \c ASTReader) -/// to provide additional macro definitions. +/// to provide additional preprocessing information. class ExternalPreprocessorSource { public: virtual ~ExternalPreprocessorSource(); @@ -34,6 +34,11 @@ public: /// \brief Update an out-of-date identifier. virtual void updateOutOfDateIdentifier(IdentifierInfo &II) = 0; + /// \brief Return the identifier associated with the given ID number. + /// + /// The ID 0 is associated with the NULL identifier. + virtual IdentifierInfo *GetIdentifier(unsigned ID) = 0; + /// \brief Map a module ID to a module. virtual Module *getModule(unsigned ModuleID) = 0; }; Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/include/clang/Lex/HeaderSearch.h (original) +++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jun 30 21:29:35 2015 @@ -27,7 +27,7 @@ namespace clang { class DiagnosticsEngine; -class ExternalIdentifierLookup; +class ExternalPreprocessorSource; class FileEntry; class FileManager; class HeaderSearchOptions; @@ -111,8 +111,9 @@ struct HeaderFileInfo { /// \brief Retrieve the controlling macro for this header file, if /// any. - const IdentifierInfo *getControllingMacro(ExternalIdentifierLookup *External); - + const IdentifierInfo * + getControllingMacro(ExternalPreprocessorSource *External); + /// \brief Determine whether this is a non-default header file info, e.g., /// it corresponds to an actual header we've included or tried to include. bool isNonDefault() const { @@ -242,8 +243,9 @@ class HeaderSearch { llvm::StringSet<llvm::BumpPtrAllocator> FrameworkNames; /// \brief Entity used to resolve the identifier IDs of controlling - /// macros into IdentifierInfo pointers, as needed. - ExternalIdentifierLookup *ExternalLookup; + /// macros into IdentifierInfo pointers, and keep the identifire up to date, + /// as needed. + ExternalPreprocessorSource *ExternalLookup; /// \brief Entity used to look up stored header file information. ExternalHeaderFileInfoSource *ExternalSource; @@ -345,11 +347,11 @@ public: FileInfo.clear(); } - void SetExternalLookup(ExternalIdentifierLookup *EIL) { - ExternalLookup = EIL; + void SetExternalLookup(ExternalPreprocessorSource *EPS) { + ExternalLookup = EPS; } - ExternalIdentifierLookup *getExternalLookup() const { + ExternalPreprocessorSource *getExternalLookup() const { return ExternalLookup; } Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Tue Jun 30 21:29:35 2015 @@ -304,7 +304,6 @@ class ASTReader public ExternalHeaderFileInfoSource, public ExternalSemaSource, public IdentifierInfoLookup, - public ExternalIdentifierLookup, public ExternalSLocEntrySource { public: Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original) +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue Jun 30 21:29:35 2015 @@ -71,8 +71,6 @@ IdentifierIterator *IdentifierInfoLookup return new EmptyLookupIterator(); } -ExternalIdentifierLookup::~ExternalIdentifierLookup() {} - IdentifierTable::IdentifierTable(const LangOptions &LangOpts, IdentifierInfoLookup* externalLookup) : HashTable(8192), // Start with space for 8K identifiers. Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original) +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Jun 30 21:29:35 2015 @@ -14,6 +14,7 @@ #include "clang/Lex/HeaderSearch.h" #include "clang/Basic/FileManager.h" #include "clang/Basic/IdentifierTable.h" +#include "clang/Lex/ExternalPreprocessorSource.h" #include "clang/Lex/HeaderMap.h" #include "clang/Lex/HeaderSearchOptions.h" #include "clang/Lex/LexDiagnostic.h" @@ -33,9 +34,13 @@ using namespace clang; const IdentifierInfo * -HeaderFileInfo::getControllingMacro(ExternalIdentifierLookup *External) { - if (ControllingMacro) +HeaderFileInfo::getControllingMacro(ExternalPreprocessorSource *External) { + if (ControllingMacro) { + if (ControllingMacro->isOutOfDate()) + External->updateOutOfDateIdentifier( + *const_cast<IdentifierInfo *>(ControllingMacro)); return ControllingMacro; + } if (!ControllingMacroID || !External) return nullptr; Modified: cfe/trunk/test/Modules/Inputs/submodule-visibility/a.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-visibility/a.h?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/submodule-visibility/a.h (original) +++ cfe/trunk/test/Modules/Inputs/submodule-visibility/a.h Tue Jun 30 21:29:35 2015 @@ -5,3 +5,5 @@ int n; #endif #define A + +#include "c.h" Modified: cfe/trunk/test/Modules/Inputs/submodule-visibility/b.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-visibility/b.h?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/submodule-visibility/b.h (original) +++ cfe/trunk/test/Modules/Inputs/submodule-visibility/b.h Tue Jun 30 21:29:35 2015 @@ -1,5 +1,8 @@ int m = n; +#include "other.h" +#include "c.h" + #if defined(A) && !defined(ALLOW_NAME_LEAKAGE) #error A is defined #endif Added: cfe/trunk/test/Modules/Inputs/submodule-visibility/c.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-visibility/c.h?rev=241137&view=auto ============================================================================== --- cfe/trunk/test/Modules/Inputs/submodule-visibility/c.h (added) +++ cfe/trunk/test/Modules/Inputs/submodule-visibility/c.h Tue Jun 30 21:29:35 2015 @@ -0,0 +1,6 @@ +#ifndef C_H_INCLUDED +#define C_H_INCLUDED + +struct C {}; + +#endif Modified: cfe/trunk/test/Modules/Inputs/submodule-visibility/module.modulemap URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-visibility/module.modulemap?rev=241137&r1=241136&r2=241137&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/submodule-visibility/module.modulemap (original) +++ cfe/trunk/test/Modules/Inputs/submodule-visibility/module.modulemap Tue Jun 30 21:29:35 2015 @@ -1,4 +1,5 @@ module x { module a { header "a.h" } module b { header "b.h" } } +module other { header "other.h" } module cycles { module cycle1 { header "cycle1.h" } Added: cfe/trunk/test/Modules/Inputs/submodule-visibility/other.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-visibility/other.h?rev=241137&view=auto ============================================================================== --- cfe/trunk/test/Modules/Inputs/submodule-visibility/other.h (added) +++ cfe/trunk/test/Modules/Inputs/submodule-visibility/other.h Tue Jun 30 21:29:35 2015 @@ -0,0 +1 @@ +#include "c.h" _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits