<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 11, 2014, at 10:55 AM, Ben Langmuir <<a href="mailto:blangmuir@apple.com" class="">blangmuir@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Dec 10, 2014, at 5:42 PM, Richard Smith <<a href="mailto:richard@metafoo.co.uk" class="">richard@metafoo.co.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, Apr 14, 2014 at 11:00 AM, Ben Langmuir<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:blangmuir@apple.com" target="_blank" class="">blangmuir@apple.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Author: benlangmuir<br class="">Date: Mon Apr 14 13:00:01 2014<br class="">New Revision: 206201<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=206201&view=rev" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=206201&view=rev</a><br class="">Log:<br class="">Allow multiple modules with the same name to coexist in the module cache<br class=""><br class="">To differentiate between two modules with the same name, we will<br class="">consider the path the module map file that they are defined by* part of<br class="">the ‘key’ for looking up the precompiled module (pcm file).<br class="">Specifically, this patch renames the precompiled module (pcm) files from<br class=""> cache-path/<module hash>/Foo.pcm<br class="">to<br class=""> cache-path/<module hash>/Foo-<hash of module map path>.pcm<br class=""><br class="">In addition, I’ve taught the ASTReader to re-resolve the names of<br class="">imported modules during module loading so that if the header search<br class="">context changes between when a module was originally built and when it<br class="">is loaded we can rebuild it if necessary. For example, if module A<br class="">imports module B<br class=""><br class="">first time:<br class="">clang -I /path/to/A -I /path/to/B ...<br class=""><br class="">second time:<br class="">clang -I /path/to/A -I /different/path/to/B ...<br class=""><br class="">will now rebuild A as expected.<br class=""><br class="">* in the case of inferred modules, we use the module map file that<br class="">allowed the inference, not the __inferred_module.map file, since the<br class="">inferred file path is the same for every inferred module.<br class=""><br class="">Added:<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/a.h<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/a.h<br class=""> cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap<br class=""> cfe/trunk/test/Modules/modules-with-same-name.m<br class=""> cfe/trunk/test/Modules/resolution-change.m<br class="">Modified:<br class=""> cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td<br class=""> cfe/trunk/include/clang/Basic/Module.h<br class=""> cfe/trunk/include/clang/Frontend/FrontendActions.h<br class=""> cfe/trunk/include/clang/Lex/HeaderSearch.h<br class=""> cfe/trunk/include/clang/Lex/ModuleMap.h<br class=""> cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br class=""> cfe/trunk/include/clang/Serialization/ASTReader.h<br class=""> cfe/trunk/include/clang/Serialization/Module.h<br class=""> cfe/trunk/lib/Basic/Module.cpp<br class=""> cfe/trunk/lib/Frontend/CompilerInstance.cpp<br class=""> cfe/trunk/lib/Frontend/FrontendAction.cpp<br class=""> cfe/trunk/lib/Frontend/FrontendActions.cpp<br class=""> cfe/trunk/lib/Lex/HeaderSearch.cpp<br class=""> cfe/trunk/lib/Lex/ModuleMap.cpp<br class=""> cfe/trunk/lib/Serialization/ASTReader.cpp<br class=""> cfe/trunk/lib/Serialization/ASTWriter.cpp<br class=""> cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp<br class=""> cfe/trunk/lib/Serialization/ModuleManager.cpp<br class=""> cfe/trunk/test/Index/annotate-module.m<br class=""> cfe/trunk/test/Index/pch-depending-on-deleted-module.c<br class=""> cfe/trunk/test/Modules/dependency-gen-pch.m<br class=""> cfe/trunk/test/Modules/diamond-pch.c<br class=""> cfe/trunk/test/Modules/macro-undef-through-pch.m<br class=""> cfe/trunk/test/Modules/prune.m<br class=""> cfe/trunk/test/Modules/redecls/main.m<br class=""> cfe/trunk/test/Modules/system_version.m<br class=""> cfe/trunk/test/PCH/modified-module-dependency.m<br class=""><br class="">Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)<br class="">+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Mon Apr 14 13:00:01 2014<br class="">@@ -48,7 +48,12 @@ def err_pch_different_branch : Error<<br class=""> "PCH file built from a different branch (%0) than the compiler (%1)">;<br class=""> def err_pch_with_compiler_errors : Error<<br class=""> "PCH file contains compiler errors">;<br class="">-<br class="">+<br class="">+def err_imported_module_not_found : Error<<br class="">+ "module '%0' imported by AST file '%1' not found">, DefaultFatal;<br class="">+def err_imported_module_modmap_changed : Error<<br class="">+ "module '%0' imported by AST file '%1' found in a different module map file"<br class="">+ " (%2) than when the importing AST file was built (%3)">, DefaultFatal;<br class=""> def warn_module_conflict : Warning<<br class=""> "module '%0' conflicts with already-imported module '%1': %2">,<br class=""> InGroup<ModuleConflict>;<br class=""><br class="">Modified: cfe/trunk/include/clang/Basic/Module.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Basic/Module.h (original)<br class="">+++ cfe/trunk/include/clang/Basic/Module.h Mon Apr 14 13:00:01 2014<br class="">@@ -51,10 +51,21 @@ public:<br class=""><br class=""> /// \brief The location of the module definition.<br class=""> SourceLocation DefinitionLoc;<br class="">-<br class="">+<br class=""> /// \brief The parent of this module. This will be NULL for the top-level<br class=""> /// module.<br class=""> Module *Parent;<br class="">+<br class="">+ /// \brief The module map file that (along with the module name) uniquely<br class="">+ /// identifies this module.<br class="">+ ///<br class="">+ /// The particular module that \c Name refers to may depend on how the module<br class="">+ /// was found in header search. However, the combination of \c Name and<br class="">+ /// \c ModuleMap will be globally unique for top-level modules. In the case of<br class="">+ /// inferred modules, \c ModuleMap will contain the module map that allowed<br class="">+ /// the inference (e.g. contained 'Module *') rather than the virtual<br class="">+ /// inferred module map file.<br class="">+ const FileEntry *ModuleMap;<br class=""><br class=""> /// \brief The umbrella header or directory.<br class=""> llvm::PointerUnion<const DirectoryEntry *, const FileEntry *> Umbrella;<br class="">@@ -264,8 +275,10 @@ public:<br class=""> std::vector<Conflict> Conflicts;<br class=""><br class=""> /// \brief Construct a new module or submodule.<br class="">- Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,<br class="">- bool IsFramework, bool IsExplicit);<br class="">+ ///<br class="">+ /// For an explanation of \p ModuleMap, see Module::ModuleMap.<br class="">+ Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,<br class="">+ const FileEntry *ModuleMap, bool IsFramework, bool IsExplicit);<br class=""><br class=""> ~Module();<br class=""><br class=""><br class="">Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)<br class="">+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Mon Apr 14 13:00:01 2014<br class="">@@ -17,6 +17,7 @@<br class=""> namespace clang {<br class=""><br class=""> class Module;<br class="">+class FileEntry;<br class=""><br class=""> //===----------------------------------------------------------------------===//<br class=""> // Custom Consumer Actions<br class="">@@ -92,7 +93,8 @@ public:<br class=""> };<br class=""><br class=""> class GenerateModuleAction : public ASTFrontendAction {<br class="">- clang::Module *Module;<br class="">+ Module *Module;<br class="">+ const FileEntry *ModuleMapForUniquing;<br class=""> bool IsSystem;<br class=""><br class=""> protected:<br class="">@@ -106,8 +108,10 @@ protected:<br class=""> bool hasASTFileSupport() const override { return false; }<br class=""><br class=""> public:<br class="">- explicit GenerateModuleAction(bool IsSystem = false)<br class="">- : ASTFrontendAction(), IsSystem(IsSystem) { }<br class="">+ GenerateModuleAction(const FileEntry *ModuleMap = nullptr,<br class="">+ bool IsSystem = false)<br class="">+ : ASTFrontendAction(), ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem)<br class="">+ { }<br class=""><br class=""> bool BeginSourceFileAction(CompilerInstance &CI, StringRef Filename) override;<br class=""><br class="">@@ -115,11 +119,11 @@ public:<br class=""> /// create the PCHGenerator instance returned by CreateASTConsumer.<br class=""> ///<br class=""> /// \returns true if an error occurred, false otherwise.<br class="">- static bool ComputeASTConsumerArguments(CompilerInstance &CI,<br class="">- StringRef InFile,<br class="">- std::string &Sysroot,<br class="">- std::string &OutputFile,<br class="">- raw_ostream *&OS);<br class="">+ bool ComputeASTConsumerArguments(CompilerInstance &CI,<br class="">+ StringRef InFile,<br class="">+ std::string &Sysroot,<br class="">+ std::string &OutputFile,<br class="">+ raw_ostream *&OS);<br class=""> };<br class=""><br class=""> class SyntaxOnlyAction : public ASTFrontendAction {<br class=""><br class="">Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)<br class="">+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Mon Apr 14 13:00:01 2014<br class="">@@ -493,9 +493,12 @@ public:<br class=""> ///<br class=""> /// \param ModuleName The module whose module file name will be returned.<br class=""> ///<br class="">+ /// \param ModuleMapPath A path that when combined with \c ModuleName<br class="">+ /// uniquely identifies this module. See Module::ModuleMap.<br class="">+ ///<br class=""> /// \returns The name of the module file that corresponds to this module,<br class=""> /// or an empty string if this module does not correspond to any module file.<br class="">- std::string getModuleFileName(StringRef ModuleName);<br class="">+ std::string getModuleFileName(StringRef ModuleName, StringRef ModuleMapPath);<br class=""><br class=""> /// \brief Lookup a module Search for a module with the given name.<br class=""> ///<br class=""><br class="">Modified: cfe/trunk/include/clang/Lex/ModuleMap.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)<br class="">+++ cfe/trunk/include/clang/Lex/ModuleMap.h Mon Apr 14 13:00:01 2014<br class="">@@ -131,6 +131,10 @@ private:<br class=""> /// \brief Whether the modules we infer are [system] modules.<br class=""> unsigned InferSystemModules : 1;<br class=""><br class="">+ /// \brief If \c InferModules is non-zero, the module map file that allowed<br class="">+ /// inferred modules. Otherwise, nullptr.<br class="">+ const FileEntry *ModuleMapFile;<br class="">+<br class=""> /// \brief The names of modules that cannot be inferred within this<br class=""> /// directory.<br class=""> SmallVector<std::string, 2> ExcludedModules;<br class="">@@ -293,13 +297,17 @@ public:<br class=""> /// \param Parent The module that will act as the parent of this submodule,<br class=""> /// or NULL to indicate that this is a top-level module.<br class=""> ///<br class="">+ /// \param ModuleMap The module map that defines or allows the inference of<br class="">+ /// this module.<br class="">+ ///<br class=""> /// \param IsFramework Whether this is a framework module.<br class=""> ///<br class=""> /// \param IsExplicit Whether this is an explicit submodule.<br class=""> ///<br class=""> /// \returns The found or newly-created module, along with a boolean value<br class=""> /// that will be true if the module is newly-created.<br class="">- std::pair<Module *, bool> findOrCreateModule(StringRef Name, Module *Parent,<br class="">+ std::pair<Module *, bool> findOrCreateModule(StringRef Name, Module *Parent,<br class="">+ const FileEntry *ModuleMap,<br class=""> bool IsFramework,<br class=""> bool IsExplicit);<br class=""><br class=""><br class="">Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)<br class="">+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Mon Apr 14 13:00:01 2014<br class="">@@ -281,7 +281,14 @@ namespace clang {<br class=""> HEADER_SEARCH_OPTIONS = 11,<br class=""><br class=""> /// \brief Record code for the preprocessor options table.<br class="">- PREPROCESSOR_OPTIONS = 12<br class="">+ PREPROCESSOR_OPTIONS = 12,<br class="">+<br class="">+ /// \brief Record code for the module name.<br class="">+ MODULE_NAME = 13,<br class="">+<br class="">+ /// \brief Record code for the module map file that was used to build this<br class="">+ /// AST file.<br class="">+ MODULE_MAP_FILE = 14<br class=""> };<br class=""><br class=""> /// \brief Record types that occur within the input-files block<br class=""><br class="">Modified: cfe/trunk/include/clang/Serialization/ASTReader.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)<br class="">+++ cfe/trunk/include/clang/Serialization/ASTReader.h Mon Apr 14 13:00:01 2014<br class="">@@ -1079,6 +1079,7 @@ private:<br class=""> unsigned ClientLoadCapabilities);<br class=""> ASTReadResult ReadControlBlock(ModuleFile &F,<br class=""> SmallVectorImpl<ImportedModule> &Loaded,<br class="">+ const ModuleFile *ImportedBy,<br class=""> unsigned ClientLoadCapabilities);<br class=""> ASTReadResult ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities);<br class=""> bool ParseLineTable(ModuleFile &F, SmallVectorImpl<uint64_t> &Record);<br class=""><br class="">Modified: cfe/trunk/include/clang/Serialization/Module.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/Module.h?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/include/clang/Serialization/Module.h (original)<br class="">+++ cfe/trunk/include/clang/Serialization/Module.h Mon Apr 14 13:00:01 2014<br class="">@@ -116,6 +116,9 @@ public:<br class=""> /// \brief The file name of the module file.<br class=""> std::string FileName;<br class=""><br class="">+ /// \brief The name of the module.<br class="">+ std::string ModuleName;<br class="">+<br class=""> std::string getTimestampFilename() const {<br class=""> return FileName + ".timestamp";<br class=""> }<br class="">@@ -137,6 +140,8 @@ public:<br class=""> /// allow resolving headers even after headers+PCH was moved to a new path.<br class=""> std::string OriginalDir;<br class=""><br class="">+ std::string ModuleMapPath;<br class="">+<br class=""> /// \brief Whether this precompiled header is a relocatable PCH file.<br class=""> bool RelocatablePCH;<br class=""><br class=""><br class="">Modified: cfe/trunk/lib/Basic/Module.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Basic/Module.cpp (original)<br class="">+++ cfe/trunk/lib/Basic/Module.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -25,8 +25,8 @@<br class=""> using namespace clang;<br class=""><br class=""> Module::Module(StringRef Name, SourceLocation DefinitionLoc, Module *Parent,<br class="">- bool IsFramework, bool IsExplicit)<br class="">- : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent),<br class="">+ const FileEntry *File, bool IsFramework, bool IsExplicit)<br class="">+ : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), ModuleMap(File),<br class=""> Umbrella(), ASTFile(0), IsAvailable(true), IsFromModuleFile(false),<br class=""> IsFramework(IsFramework), IsExplicit(IsExplicit), IsSystem(false),<br class=""> IsExternC(false), InferSubmodules(false), InferExplicitSubmodules(false),<br class=""><br class="">Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br class="">+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -870,8 +870,9 @@ static void compileModuleImpl(CompilerIn<br class=""> SourceMgr.overrideFileContents(ModuleMapFile, ModuleMapBuffer);<br class=""> }<br class=""><br class="">- // Construct a module-generating action.<br class="">- GenerateModuleAction CreateModuleAction(Module->IsSystem);<br class="">+ // Construct a module-generating action. Passing through Module->ModuleMap is<br class="">+ // safe because the FileManager is shared between the compiler instances.<br class="">+ GenerateModuleAction CreateModuleAction(Module->ModuleMap, Module->IsSystem);<br class=""><br class=""> // Execute the action to actually build the module in-place. Use a separate<br class=""> // thread so that we get a stack large enough.<br class=""><br class="">Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)<br class="">+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -256,6 +256,10 @@ bool FrontendAction::BeginSourceFile(Com<br class=""> if (!BeginSourceFileAction(CI, InputFile))<br class=""> goto failure;<br class=""><br class="">+ // Initialize the main file entry.<br class="">+ if (!CI.InitializeSourceManager(CurrentInput))<br class="">+ goto failure;<br class="">+<br class=""> return true;<br class=""> }<br class=""><br class="">@@ -302,6 +306,11 @@ bool FrontendAction::BeginSourceFile(Com<br class=""> if (!BeginSourceFileAction(CI, InputFile))<br class=""> goto failure;<br class=""><br class="">+ // Initialize the main file entry. It is important that this occurs after<br class="">+ // BeginSourceFileAction, which may change CurrentInput during module builds.<br class="">+ if (!CI.InitializeSourceManager(CurrentInput))<br class="">+ goto failure;<br class="">+<br class=""> // Create the AST context and consumer unless this is a preprocessor only<br class=""> // action.<br class=""> if (!usesPreprocessorOnly()) {<br class="">@@ -389,13 +398,6 @@ bool FrontendAction::BeginSourceFile(Com<br class=""> bool FrontendAction::Execute() {<br class=""> CompilerInstance &CI = getCompilerInstance();<br class=""><br class="">- // Initialize the main file entry. This needs to be delayed until after PCH<br class="">- // has loaded.<br class="">- if (!isCurrentFileAST()) {<br class="">- if (!CI.InitializeSourceManager(getCurrentInput()))<br class="">- return false;<br class="">- }<br class="">-<br class=""> if (CI.hasFrontendTimer()) {<br class=""> llvm::TimeRegion Timer(CI.getFrontendTimer());<br class=""> ExecuteAction();<br class=""><br class="">Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)<br class="">+++ cfe/trunk/lib/Frontend/FrontendActions.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -299,6 +299,11 @@ bool GenerateModuleAction::BeginSourceFi<br class=""> return false;<br class=""> }<br class=""><br class="">+ if (!ModuleMapForUniquing)<br class="">+ ModuleMapForUniquing = ModuleMap;<br class="">+ Module->ModuleMap = ModuleMapForUniquing;<br class="">+ assert(Module->ModuleMap && "missing module map file");<br class="">+<br class=""> FileManager &FileMgr = CI.getFileManager();<br class=""><br class=""> // Collect the set of #includes we need to build the module.<br class="">@@ -337,10 +342,9 @@ bool GenerateModuleAction::ComputeASTCon<br class=""> // in the module cache.<br class=""> if (CI.getFrontendOpts().OutputFile.empty()) {<br class=""> HeaderSearch &HS = CI.getPreprocessor().getHeaderSearchInfo();<br class="">- SmallString<256> ModuleFileName(HS.getModuleCachePath());<br class="">- llvm::sys::path::append(ModuleFileName,<br class="">- CI.getLangOpts().CurrentModule + ".pcm");<br class="">- CI.getFrontendOpts().OutputFile = ModuleFileName.str();<br class="">+ CI.getFrontendOpts().OutputFile =<br class="">+ HS.getModuleFileName(CI.getLangOpts().CurrentModule,<br class="">+ ModuleMapForUniquing->getName());<br class=""> }<br class=""><br class=""> // We use createOutputFile here because this is exposed via libclang, and we<br class=""><br class="">Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)<br class="">+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -18,6 +18,8 @@<br class=""> #include "clang/Lex/HeaderSearchOptions.h"<br class=""> #include "clang/Lex/LexDiagnostic.h"<br class=""> #include "clang/Lex/Lexer.h"<br class="">+#include "llvm/ADT/APInt.h"<br class="">+#include "llvm/ADT/Hashing.h"<br class=""> #include "llvm/ADT/SmallString.h"<br class=""> #include "llvm/Support/Capacity.h"<br class=""> #include "llvm/Support/FileSystem.h"<br class="">@@ -112,24 +114,33 @@ const HeaderMap *HeaderSearch::CreateHea<br class=""> }<br class=""><br class=""> std::string HeaderSearch::getModuleFileName(Module *Module) {<br class="">- // If we don't have a module cache path, we can't do anything.<br class="">- if (ModuleCachePath.empty())<br class="">- return std::string();<br class="">-<br class="">-<br class="">- SmallString<256> Result(ModuleCachePath);<br class="">- llvm::sys::path::append(Result, Module->getTopLevelModule()->Name + ".pcm");<br class="">- return Result.str().str();<br class="">+ return getModuleFileName(Module->Name, Module->ModuleMap->getName());<br class=""> }<br class=""><br class="">-std::string HeaderSearch::getModuleFileName(StringRef ModuleName) {<br class="">+std::string HeaderSearch::getModuleFileName(StringRef ModuleName,<br class="">+ StringRef ModuleMapPath) {<br class=""> // If we don't have a module cache path, we can't do anything.<br class=""> if (ModuleCachePath.empty())<br class=""> return std::string();<br class="">-<br class="">-<br class="">+<br class=""> SmallString<256> Result(ModuleCachePath);<br class="">- llvm::sys::path::append(Result, ModuleName + ".pcm");<br class="">+ llvm::sys::fs::make_absolute(Result);<br class="">+<br class="">+ if (HSOpts->DisableModuleHash) {<br class="">+ llvm::sys::path::append(Result, ModuleName + ".pcm");<br class="">+ } else {<br class="">+ // Construct the name <ModuleName>-<hash of ModuleMapPath>.pcm which should<br class="">+ // be globally unique to this particular module. To avoid false-negatives<br class="">+ // on case-insensitive filesystems, we use lower-case, which is safe because<br class="">+ // to cause a collision the modules must have the same name, which is an<br class="">+ // error if they are imported in the same translation.<br class=""></blockquote><div class=""><br class=""></div><div class="">Consider:</div><div class=""><br class=""></div><div class=""> foo/module.modulemap defines a module X</div><div class=""> FOO/module.modulemap also defines a module X</div><div class=""><br class=""></div><div class="">If we cause foo/module.modulemap's X to be built, and then we try to import X from FOO/module.modulemap, won't we import the wrong module from the module cache? (Put another way, if this were correct, why would we ever need to include the module map file's hash in the filename?)</div></div></div></div></div></blockquote><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">The hash in the filename isn’t functionally necessary, since we can rebuild a module if the module map path has changed since it was built. If we attempt to load a module with a hash collision (as in this case) we will discover that the module map path has changed in ReadModuleMapFileBlock, and rebuild it. Obviously that sucks if you really have both FOO and foo.</div></div></blockquote><div><br class=""></div><div>To be clear: the hash prevents excessive rebuilding, but currently falls over in edge case.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">The problem this code solves on a case-insensitive filesystem:</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">* I have two modules, A and B. A imports B. B is in some directory name foo.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">* I build A.pcm with -I FOO</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">* I build a TU that imports B and then A, but specify -I foo.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">So when I import B, it will be “missing” if the hash of “foo" is different than “FOO". And then when I load A, it will pull in the other B.pcm, leading to an error.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">I’m open to solving this some other way if you have ideas :-) I looked at getting the canonical casing for the path, but IIRC it was really expensive on Windows and basically required doing a listdir on every component of the path.</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Ben</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><blockquote type="cite" class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">+ SmallString<256> AbsModuleMapPath(ModuleMapPath);<br class="">+ llvm::sys::fs::make_absolute(AbsModuleMapPath);<br class="">+ llvm::APInt Code(64, llvm::hash_value(AbsModuleMapPath.str().lower()));<br class="">+ SmallString<128> HashStr;<br class="">+ Code.toStringUnsigned(HashStr, /*Radix*/36);<br class="">+ llvm::sys::path::append(Result, ModuleName + "-" + HashStr.str() + ".pcm");<br class="">+ }<br class=""> return Result.str().str();<br class=""> }<br class=""><br class=""><br class="">Modified: cfe/trunk/lib/Lex/ModuleMap.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)<br class="">+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -363,8 +363,8 @@ ModuleMap::findModuleForHeader(const Fil<br class=""> SmallString<32> NameBuf;<br class=""> StringRef Name = sanitizeFilenameAsIdentifier(<br class=""> llvm::sys::path::stem(SkippedDirs[I-1]->getName()), NameBuf);<br class="">- Result = findOrCreateModule(Name, Result, /*IsFramework=*/false,<br class="">- Explicit).first;<br class="">+ Result = findOrCreateModule(Name, Result, UmbrellaModule->ModuleMap,<br class="">+ /*IsFramework=*/false, Explicit).first;<br class=""><br class=""> // Associate the module and the directory.<br class=""> UmbrellaDirs[SkippedDirs[I-1]] = Result;<br class="">@@ -378,9 +378,9 @@ ModuleMap::findModuleForHeader(const Fil<br class=""> // Infer a submodule with the same name as this header file.<br class=""> SmallString<32> NameBuf;<br class=""> StringRef Name = sanitizeFilenameAsIdentifier(<br class="">- llvm::sys::path::stem(File->getName()), NameBuf);<br class="">- Result = findOrCreateModule(Name, Result, /*IsFramework=*/false,<br class="">- Explicit).first;<br class="">+ llvm::sys::path::stem(File->getName()), NameBuf);<br class="">+ Result = findOrCreateModule(Name, Result, UmbrellaModule->ModuleMap,<br class="">+ /*IsFramework=*/false, Explicit).first;<br class=""> Result->addTopHeader(File);<br class=""><br class=""> // If inferred submodules export everything they import, add a<br class="">@@ -518,15 +518,16 @@ Module *ModuleMap::lookupModuleQualified<br class=""> }<br class=""><br class=""> std::pair<Module *, bool><br class="">-ModuleMap::findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,<br class="">+ModuleMap::findOrCreateModule(StringRef Name, Module *Parent,<br class="">+ const FileEntry *ModuleMap, bool IsFramework,<br class=""> bool IsExplicit) {<br class=""> // Try to find an existing module with this name.<br class=""> if (Module *Sub = lookupModuleQualified(Name, Parent))<br class=""> return std::make_pair(Sub, false);<br class=""><br class=""> // Create a new module with this name.<br class="">- Module *Result = new Module(Name, SourceLocation(), Parent, IsFramework,<br class="">- IsExplicit);<br class="">+ Module *Result = new Module(Name, SourceLocation(), Parent, ModuleMap,<br class="">+ IsFramework, IsExplicit);<br class=""> if (LangOpts.CurrentModule == Name) {<br class=""> SourceModule = Result;<br class=""> SourceModuleName = Name;<br class="">@@ -595,6 +596,7 @@ ModuleMap::inferFrameworkModule(StringRe<br class=""><br class=""> // If the framework has a parent path from which we're allowed to infer<br class=""> // a framework module, do so.<br class="">+ const FileEntry *ModuleMapFile = nullptr;<br class=""> if (!Parent) {<br class=""> // Determine whether we're allowed to infer a module map.<br class=""><br class="">@@ -639,6 +641,7 @@ ModuleMap::inferFrameworkModule(StringRe<br class=""><br class=""> if (inferred->second.InferSystemModules)<br class=""> IsSystem = true;<br class="">+ ModuleMapFile = inferred->second.ModuleMapFile;<br class=""> }<br class=""> }<br class=""> }<br class="">@@ -646,7 +649,8 @@ ModuleMap::inferFrameworkModule(StringRe<br class=""> // If we're not allowed to infer a framework module, don't.<br class=""> if (!canInfer)<br class=""> return 0;<br class="">- }<br class="">+ } else<br class="">+ ModuleMapFile = Parent->ModuleMap;<br class=""><br class=""><br class=""> // Look for an umbrella header.<br class="">@@ -660,7 +664,7 @@ ModuleMap::inferFrameworkModule(StringRe<br class=""> if (!UmbrellaHeader)<br class=""> return 0;<br class=""><br class="">- Module *Result = new Module(ModuleName, SourceLocation(), Parent,<br class="">+ Module *Result = new Module(ModuleName, SourceLocation(), Parent, ModuleMapFile,<br class=""> /*IsFramework=*/true, /*IsExplicit=*/false);<br class=""> if (LangOpts.CurrentModule == ModuleName) {<br class=""> SourceModule = Result;<br class="">@@ -954,6 +958,9 @@ namespace clang {<br class=""><br class=""> DiagnosticsEngine &Diags;<br class=""> ModuleMap ⤅<br class="">+<br class="">+ /// \brief The current module map file.<br class="">+ const FileEntry *ModuleMapFile;<br class=""><br class=""> /// \brief The directory that this module map resides in.<br class=""> const DirectoryEntry *Directory;<br class="">@@ -1007,12 +1014,14 @@ namespace clang {<br class=""> const TargetInfo *Target,<br class=""> DiagnosticsEngine &Diags,<br class=""> ModuleMap &Map,<br class="">+ const FileEntry *ModuleMapFile,<br class=""> const DirectoryEntry *Directory,<br class=""> const DirectoryEntry *BuiltinIncludeDir,<br class=""> bool IsSystem)<br class=""> : L(L), SourceMgr(SourceMgr), Target(Target), Diags(Diags), Map(Map),<br class="">- Directory(Directory), BuiltinIncludeDir(BuiltinIncludeDir),<br class="">- IsSystem(IsSystem), HadError(false), ActiveModule(0)<br class="">+ ModuleMapFile(ModuleMapFile), Directory(Directory),<br class="">+ BuiltinIncludeDir(BuiltinIncludeDir), IsSystem(IsSystem),<br class="">+ HadError(false), ActiveModule(0)<br class=""> {<br class=""> Tok.clear();<br class=""> consumeToken();<br class="">@@ -1359,9 +1368,14 @@ void ModuleMapParser::parseModuleDecl()<br class=""> return;<br class=""> }<br class=""><br class="">+ // If this is a submodule, use the parent's module map, since we don't want<br class="">+ // the private module map file.<br class="">+ const FileEntry *ModuleMap = ActiveModule ? ActiveModule->ModuleMap<br class="">+ : ModuleMapFile;<br class="">+<br class=""> // Start defining this module.<br class="">- ActiveModule = Map.findOrCreateModule(ModuleName, ActiveModule, Framework,<br class="">- Explicit).first;<br class="">+ ActiveModule = Map.findOrCreateModule(ModuleName, ActiveModule, ModuleMap,<br class="">+ Framework, Explicit).first;<br class=""> ActiveModule->DefinitionLoc = ModuleNameLoc;<br class=""> if (Attrs.IsSystem || IsSystem)<br class=""> ActiveModule->IsSystem = true;<br class="">@@ -2020,6 +2034,7 @@ void ModuleMapParser::parseInferredModul<br class=""> // We'll be inferring framework modules for this directory.<br class=""> Map.InferredDirectories[Directory].InferModules = true;<br class=""> Map.InferredDirectories[Directory].InferSystemModules = Attrs.IsSystem;<br class="">+ Map.InferredDirectories[Directory].ModuleMapFile = ModuleMapFile;<br class=""> // FIXME: Handle the 'framework' keyword.<br class=""> }<br class=""><br class="">@@ -2256,7 +2271,7 @@ bool ModuleMap::parseModuleMapFile(const<br class=""><br class=""> // Parse this module map file.<br class=""> Lexer L(ID, SourceMgr.getBuffer(ID), SourceMgr, MMapLangOpts);<br class="">- ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, Dir,<br class="">+ ModuleMapParser Parser(L, SourceMgr, Target, Diags, *this, File, Dir,<br class=""> BuiltinIncludeDir, IsSystem);<br class=""> bool Result = Parser.parseModuleMapFile();<br class=""> ParsedModuleMap[File] = Result;<br class=""><br class="">Modified: cfe/trunk/lib/Serialization/ASTReader.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)<br class="">+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -1161,7 +1161,7 @@ std::pair<SourceLocation, StringRef> AST<br class=""><br class=""> // FIXME: Can we map this down to a particular submodule? That would be<br class=""> // ideal.<br class="">- return std::make_pair(M->ImportLoc, llvm::sys::path::stem(M->FileName));<br class="">+ return std::make_pair(M->ImportLoc, StringRef(M->ModuleName));<br class=""> }<br class=""><br class=""> /// \brief Find the location where the module F is imported.<br class="">@@ -1172,14 +1172,10 @@ SourceLocation ASTReader::getImportLocat<br class=""> // Otherwise we have a PCH. It's considered to be "imported" at the first<br class=""> // location of its includer.<br class=""> if (F->ImportedBy.empty() || !F->ImportedBy[0]) {<br class="">- // Main file is the importer. We assume that it is the first entry in the<br class="">- // entry table. We can't ask the manager, because at the time of PCH loading<br class="">- // the main file entry doesn't exist yet.<br class="">- // The very first entry is the invalid instantiation loc, which takes up<br class="">- // offsets 0 and 1.<br class="">- return SourceLocation::getFromRawEncoding(2U);<br class="">+ // Main file is the importer.<br class="">+ assert(!SourceMgr.getMainFileID().isInvalid() && "missing main file");<br class="">+ return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());<br class=""> }<br class="">- //return F->Loaders[0]->FirstLoc;<br class=""> return F->ImportedBy[0]->FirstLoc;<br class=""> }<br class=""><br class="">@@ -2089,6 +2085,7 @@ void ASTReader::MaybeAddSystemRootToFile<br class=""> ASTReader::ASTReadResult<br class=""> ASTReader::ReadControlBlock(ModuleFile &F,<br class=""> SmallVectorImpl<ImportedModule> &Loaded,<br class="">+ const ModuleFile *ImportedBy,<br class=""> unsigned ClientLoadCapabilities) {<br class=""> BitstreamCursor &Stream = F.Stream;<br class=""><br class="">@@ -2314,6 +2311,44 @@ ASTReader::ReadControlBlock(ModuleFile &<br class=""> F.OriginalDir = Blob;<br class=""> break;<br class=""><br class="">+ case MODULE_NAME:<br class="">+ F.ModuleName = Blob;<br class="">+ break;<br class="">+<br class="">+ case MODULE_MAP_FILE:<br class="">+ F.ModuleMapPath = Blob;<br class="">+<br class="">+ // Try to resolve ModuleName in the current header search context and<br class="">+ // verify that it is found in the same module map file as we saved. If the<br class="">+ // top-level AST file is a main file, skip this check because there is no<br class="">+ // usable header search context.<br class="">+ assert(!F.ModuleName.empty() &&<br class="">+ "MODULE_NAME should come before MOUDLE_MAP_FILE");<br class="">+ if (F.Kind == MK_Module &&<br class="">+ (*ModuleMgr.begin())->Kind != MK_MainFile) {<br class="">+ Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);<br class="">+ if (!M) {<br class="">+ assert(ImportedBy && "top-level import should be verified");<br class="">+ if ((ClientLoadCapabilities & ARR_Missing) == 0)<br class="">+ Diag(diag::err_imported_module_not_found)<br class="">+ << F.ModuleName << ImportedBy->FileName;<br class="">+ return Missing;<br class="">+ }<br class="">+<br class="">+ const FileEntry *StoredModMap = FileMgr.getFile(F.ModuleMapPath);<br class="">+ if (StoredModMap == nullptr || StoredModMap != M->ModuleMap) {<br class="">+ assert(M->ModuleMap && "found module is missing module map file");<br class="">+ assert(M->Name == F.ModuleName && "found module with different name");<br class="">+ assert(ImportedBy && "top-level import should be verified");<br class="">+ if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)<br class="">+ Diag(diag::err_imported_module_modmap_changed)<br class="">+ << F.ModuleName << ImportedBy->FileName<br class="">+ << M->ModuleMap->getName() << F.ModuleMapPath;<br class="">+ return OutOfDate;<br class="">+ }<br class="">+ }<br class="">+ break;<br class="">+<br class=""> case INPUT_FILE_OFFSETS:<br class=""> F.InputFileOffsets = (const uint32_t *)Blob.data();<br class=""> F.InputFilesLoaded.resize(Record[0]);<br class="">@@ -3537,7 +3572,7 @@ ASTReader::ReadASTCore(StringRef FileNam<br class=""> break;<br class=""> case CONTROL_BLOCK_ID:<br class=""> HaveReadControlBlock = true;<br class="">- switch (ReadControlBlock(F, Loaded, ClientLoadCapabilities)) {<br class="">+ switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {<br class=""> case Success:<br class=""> break;<br class=""><br class="">@@ -4059,13 +4094,19 @@ ASTReader::ReadSubmoduleBlock(ModuleFile<br class=""> bool InferExportWildcard = Record[Idx++];<br class=""> bool ConfigMacrosExhaustive = Record[Idx++];<br class=""><br class="">- Module *ParentModule = 0;<br class="">- if (Parent)<br class="">+ Module *ParentModule = nullptr;<br class="">+ const FileEntry *ModuleMap = nullptr;<br class="">+ if (Parent) {<br class=""> ParentModule = getSubmodule(Parent);<br class="">-<br class="">+ ModuleMap = ParentModule->ModuleMap;<br class="">+ }<br class="">+<br class="">+ if (!F.ModuleMapPath.empty())<br class="">+ ModuleMap = FileMgr.getFile(F.ModuleMapPath);<br class="">+<br class=""> // Retrieve this (sub)module from the module map, creating it if<br class=""> // necessary.<br class="">- CurrentModule = ModMap.findOrCreateModule(Name, ParentModule,<br class="">+ CurrentModule = ModMap.findOrCreateModule(Name, ParentModule, ModuleMap,<br class=""> IsFramework,<br class=""> IsExplicit).first;<br class=""> SubmoduleID GlobalIndex = GlobalID - NUM_PREDEF_SUBMODULE_IDS;<br class="">@@ -4090,7 +4131,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile<br class=""><br class=""> CurrentModule->setASTFile(F.File);<br class=""> }<br class="">-<br class="">+<br class=""> CurrentModule->IsFromModuleFile = true;<br class=""> CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem;<br class=""> CurrentModule->IsExternC = IsExternC;<br class=""><br class="">Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)<br class="">+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -798,6 +798,8 @@ void ASTWriter::WriteBlockInfoBlock() {<br class=""> // Control Block.<br class=""> BLOCK(CONTROL_BLOCK);<br class=""> RECORD(METADATA);<br class="">+ RECORD(MODULE_NAME);<br class="">+ RECORD(MODULE_MAP_FILE);<br class=""> RECORD(IMPORTS);<br class=""> RECORD(LANGUAGE_OPTIONS);<br class=""> RECORD(TARGET_OPTIONS);<br class="">@@ -1050,6 +1052,32 @@ void ASTWriter::WriteControlBlock(Prepro<br class=""> Stream.EmitRecordWithBlob(MetadataAbbrevCode, Record,<br class=""> getClangFullRepositoryVersion());<br class=""><br class="">+ // Module name<br class="">+ if (WritingModule) {<br class="">+ BitCodeAbbrev *Abbrev = new BitCodeAbbrev();<br class="">+ Abbrev->Add(BitCodeAbbrevOp(MODULE_NAME));<br class="">+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Name<br class="">+ unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);<br class="">+ RecordData Record;<br class="">+ Record.push_back(MODULE_NAME);<br class="">+ Stream.EmitRecordWithBlob(AbbrevCode, Record, WritingModule->Name);<br class="">+ }<br class="">+<br class="">+ // Module map file<br class="">+ if (WritingModule) {<br class="">+ BitCodeAbbrev *Abbrev = new BitCodeAbbrev();<br class="">+ Abbrev->Add(BitCodeAbbrevOp(MODULE_MAP_FILE));<br class="">+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Filename<br class="">+ unsigned AbbrevCode = Stream.EmitAbbrev(Abbrev);<br class="">+<br class="">+ assert(WritingModule->ModuleMap && "missing module map");<br class="">+ SmallString<128> ModuleMap(WritingModule->ModuleMap->getName());<br class="">+ llvm::sys::fs::make_absolute(ModuleMap);<br class="">+ RecordData Record;<br class="">+ Record.push_back(MODULE_MAP_FILE);<br class="">+ Stream.EmitRecordWithBlob(AbbrevCode, Record, ModuleMap.str());<br class="">+ }<br class="">+<br class=""> // Imports<br class=""> if (Chain) {<br class=""> serialization::ModuleManager &Mgr = Chain->getModuleManager();<br class="">@@ -1065,7 +1093,6 @@ void ASTWriter::WriteControlBlock(Prepro<br class=""> AddSourceLocation((*M)->ImportLoc, Record);<br class=""> Record.push_back((*M)->File->getSize());<br class=""> Record.push_back((*M)->File->getModificationTime());<br class="">- // FIXME: This writes the absolute path for AST files we depend on.<br class=""> const std::string &FileName = (*M)->FileName;<br class=""> Record.push_back(FileName.size());<br class=""> Record.append(FileName.begin(), FileName.end());<br class=""><br class="">Modified: cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp (original)<br class="">+++ cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -14,6 +14,7 @@<br class=""> #include "ASTReaderInternals.h"<br class=""> #include "clang/Basic/FileManager.h"<br class=""> #include "clang/Basic/OnDiskHashTable.h"<br class="">+#include "clang/Lex/HeaderSearch.h"<br class=""> #include "clang/Serialization/ASTBitCodes.h"<br class=""> #include "clang/Serialization/GlobalModuleIndex.h"<br class=""> #include "clang/Serialization/Module.h"<br class="">@@ -203,7 +204,12 @@ GlobalModuleIndex::GlobalModuleIndex(llv<br class=""> assert(Idx == Record.size() && "More module info?");<br class=""><br class=""> // Record this module as an unresolved module.<br class="">- UnresolvedModules[llvm::sys::path::stem(Modules[ID].FileName)] = ID;<br class="">+ // FIXME: this doesn't work correctly for module names containing path<br class="">+ // separators.<br class="">+ StringRef ModuleName = llvm::sys::path::stem(Modules[ID].FileName);<br class="">+ // Remove the -<hash of ModuleMapPath><br class="">+ ModuleName = ModuleName.rsplit('-').first;<br class="">+ UnresolvedModules[ModuleName] = ID;<br class=""> break;<br class=""> }<br class=""><br class="">@@ -308,7 +314,7 @@ bool GlobalModuleIndex::lookupIdentifier<br class=""><br class=""> bool GlobalModuleIndex::loadedModuleFile(ModuleFile *File) {<br class=""> // Look for the module in the global module index based on the module name.<br class="">- StringRef Name = llvm::sys::path::stem(File->FileName);<br class="">+ StringRef Name = File->ModuleName;<br class=""> llvm::StringMap<unsigned>::iterator Known = UnresolvedModules.find(Name);<br class=""> if (Known == UnresolvedModules.end()) {<br class=""> return true;<br class=""><br class="">Modified: cfe/trunk/lib/Serialization/ModuleManager.cpp<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ModuleManager.cpp?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/lib/Serialization/ModuleManager.cpp (original)<br class="">+++ cfe/trunk/lib/Serialization/ModuleManager.cpp Mon Apr 14 13:00:01 2014<br class="">@@ -11,6 +11,7 @@<br class=""> // modules for the ASTReader.<br class=""> //<br class=""> //===----------------------------------------------------------------------===//<br class="">+#include "clang/Lex/HeaderSearch.h"<br class=""> #include "clang/Lex/ModuleMap.h"<br class=""> #include "clang/Serialization/GlobalModuleIndex.h"<br class=""> #include "clang/Serialization/ModuleManager.h"<br class="">@@ -155,7 +156,7 @@ void ModuleManager::removeModules(Module<br class=""><br class=""> FileMgr.invalidateCache((*victim)->File);<br class=""> if (modMap) {<br class="">- StringRef ModuleName = llvm::sys::path::stem((*victim)->FileName);<br class="">+ StringRef ModuleName = (*victim)->ModuleName;<br class=""> if (Module *mod = modMap->findModule(ModuleName)) {<br class=""> mod->setASTFile(0);<br class=""> }<br class="">@@ -429,7 +430,7 @@ namespace llvm {<br class=""> }<br class=""><br class=""> std::string getNodeLabel(ModuleFile *M, const ModuleManager&) {<br class="">- return llvm::sys::path::stem(M->FileName);<br class="">+ return M->ModuleName;<br class=""> }<br class=""> };<br class=""> }<br class=""><br class="">Modified: cfe/trunk/test/Index/annotate-module.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-module.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/annotate-module.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Index/annotate-module.m (original)<br class="">+++ cfe/trunk/test/Index/annotate-module.m Mon Apr 14 13:00:01 2014<br class="">@@ -44,6 +44,6 @@ int glob;<br class=""> // RUN: c-index-test -cursor-at=%s:3:11 %s -fmodules-cache-path=%t.cache -fmodules -F %S/../Modules/Inputs \<br class=""> // RUN: | FileCheck %s -check-prefix=CHECK-CURSOR<br class=""><br class="">-// CHECK-CURSOR: 3:1 ModuleImport=DependsOnModule:3:1 (Definition) Extent=[3:1 - 3:24] Spelling=DependsOnModule ([3:9 - 3:24]) ModuleName=DependsOnModule ({{.*}}DependsOnModule.pcm) Headers(2):<br class="">+// CHECK-CURSOR: 3:1 ModuleImport=DependsOnModule:3:1 (Definition) Extent=[3:1 - 3:24] Spelling=DependsOnModule ([3:9 - 3:24]) ModuleName=DependsOnModule ({{.*}}DependsOnModule-{{[^.]*}}.pcm) Headers(2):<br class=""> // CHECK-CURSOR-NEXT: {{.*}}other.h<br class=""> // CHECK-CURSOR-NEXT: {{.*}}DependsOnModule.h<br class=""><br class="">Modified: cfe/trunk/test/Index/pch-depending-on-deleted-module.c<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pch-depending-on-deleted-module.c?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/pch-depending-on-deleted-module.c?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Index/pch-depending-on-deleted-module.c (original)<br class="">+++ cfe/trunk/test/Index/pch-depending-on-deleted-module.c Mon Apr 14 13:00:01 2014<br class="">@@ -4,10 +4,10 @@<br class=""> // RUN: mkdir %t<br class=""><br class=""> // RUN: %clang_cc1 -x c-header -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -emit-pch -I %S/Inputs/Headers -o %t/use_LibA.pch %s<br class="">-// RUN: %clang_cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -verify-pch %t/use_LibA.pch<br class="">+// RUN: %clang_cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -I %S/Inputs/Headers -verify-pch %t/use_LibA.pch<br class=""> // RUN: rm -f %t/modules-cache/LibA.pcm<br class="">-// RUN: not %clang_cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=modules-cache -verify-pch %t/use_LibA.pch 2>&1 | FileCheck -check-prefix=VERIFY %s<br class="">-// RUN: not c-index-test -test-load-source all -x c -fmodules -fdisable-module-hash -fmodules-cache-path=modules-cache -include-pch %t/use_LibA.pch %s 2>&1 | FileCheck -check-prefix=INDEX %s<br class="">+// RUN: not %clang_cc1 -fmodules -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -I %S/Inputs/Headers -verify-pch %t/use_LibA.pch 2>&1 | FileCheck -check-prefix=VERIFY %s<br class="">+// RUN: not c-index-test -test-load-source all -x c -fmodules -Xclang -fdisable-module-hash -fmodules-cache-path=%t/modules-cache -I %S/Inputs/Headers -include-pch %t/use_LibA.pch %s 2>&1 | FileCheck -check-prefix=INDEX %s<br class=""><br class=""> // VERIFY: fatal error: malformed or corrupted AST file: 'Unable to load module<br class=""> // INDEX: {{^}}Failure: AST deserialization error occurred{{$}}<br class=""><br class="">Added: cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h (added)<br class="">+++ cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/DependsOnA.h Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1 @@<br class="">+@import A;<br class=""><br class="">Added: cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap (added)<br class="">+++ cfe/trunk/test/Modules/Inputs/modules-with-same-name/DependsOnA/module.modulemap Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1,4 @@<br class="">+module DependsOnA {<br class="">+ header "DependsOnA.h"<br class="">+ export *<br class="">+}<br class=""><br class="">Added: cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/a.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/a.h?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/a.h?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/a.h (added)<br class="">+++ cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/a.h Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1 @@<br class="">+#define FROM_PATH 1<br class=""><br class="">Added: cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap (added)<br class="">+++ cfe/trunk/test/Modules/Inputs/modules-with-same-name/path1/A/module.modulemap Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1,3 @@<br class="">+module A {<br class="">+ header "a.h"<br class="">+}<br class=""><br class="">Added: cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/a.h<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/a.h?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/a.h?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/a.h (added)<br class="">+++ cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/a.h Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1 @@<br class="">+#define FROM_PATH 2<br class=""><br class="">Added: cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap (added)<br class="">+++ cfe/trunk/test/Modules/Inputs/modules-with-same-name/path2/A/module.modulemap Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1,3 @@<br class="">+module A {<br class="">+ header "a.h"<br class="">+}<br class=""><br class="">Modified: cfe/trunk/test/Modules/dependency-gen-pch.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/dependency-gen-pch.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/dependency-gen-pch.m (original)<br class="">+++ cfe/trunk/test/Modules/dependency-gen-pch.m Mon Apr 14 13:00:01 2014<br class="">@@ -1,7 +1,7 @@<br class=""> // RUN: rm -rf %t-mcp<br class=""> // RUN: mkdir -p %t-mcp<br class=""><br class="">-// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -module-file-deps -dependency-file %t.d -MT %s.o -I %S/Inputs -fmodules -fmodules-cache-path=%t-mcp -emit-pch -o %t.pch %s<br class="">+// RUN: %clang_cc1 -isysroot %S/Inputs/System -triple x86_64-apple-darwin10 -module-file-deps -dependency-file %t.d -MT %s.o -I %S/Inputs -fmodules -fdisable-module-hash -fmodules-cache-path=%t-mcp -emit-pch -o %t.pch %s<br class=""> // RUN: FileCheck %s < %t.d<br class=""> // CHECK: dependency-gen-pch.m.o<br class=""> // CHECK-NEXT: dependency-gen-pch.m<br class=""><br class="">Modified: cfe/trunk/test/Modules/diamond-pch.c<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diamond-pch.c?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/diamond-pch.c?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/diamond-pch.c (original)<br class="">+++ cfe/trunk/test/Modules/diamond-pch.c Mon Apr 14 13:00:01 2014<br class="">@@ -4,7 +4,7 @@<br class=""> // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_right %S/Inputs/module.map<br class=""> // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodules-cache-path=%t -fmodule-name=diamond_bottom %S/Inputs/module.map<br class=""> // RUN: %clang_cc1 -fmodules -x objective-c -emit-pch -fmodules-cache-path=%t -I %S/Inputs -o %t.pch %S/Inputs/diamond.h<br class="">-// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -verify<br class="">+// RUN: %clang_cc1 -fmodules -x objective-c -fmodules-cache-path=%t -include-pch %t.pch %s -I %S/Inputs -verify<br class=""> // FIXME: When we have a syntax for modules in C, use that.<br class=""><br class=""> void test_diamond(int i, float f, double d, char c) {<br class=""><br class="">Modified: cfe/trunk/test/Modules/macro-undef-through-pch.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macro-undef-through-pch.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/macro-undef-through-pch.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/macro-undef-through-pch.m (original)<br class="">+++ cfe/trunk/test/Modules/macro-undef-through-pch.m Mon Apr 14 13:00:01 2014<br class="">@@ -2,7 +2,9 @@<br class=""> // RUN: %clang_cc1 -x objective-c-header -fmodules -fmodules-cache-path=%t \<br class=""> // RUN: -I%S/Inputs/macro-undef-through-pch -emit-pch \<br class=""> // RUN: %S/Inputs/macro-undef-through-pch/foo.h -o %t.pch<br class="">-// RUN: %clang_cc1 -x objective-c -fmodules -fmodules-cache-path=%t -include-pch %t.pch %s<br class="">+// RUN: %clang_cc1 -x objective-c -fmodules -fmodules-cache-path=%t \<br class="">+// RUN: -I%S/Inputs/macro-undef-through-pch -emit-pch \<br class="">+// RUN: -include-pch %t.pch %s<br class=""><br class=""> // PR19215<br class=""> #undef AB<br class=""><br class="">Added: cfe/trunk/test/Modules/modules-with-same-name.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modules-with-same-name.m?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modules-with-same-name.m?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/modules-with-same-name.m (added)<br class="">+++ cfe/trunk/test/Modules/modules-with-same-name.m Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1,35 @@<br class="">+// REQUIRES: shell<br class="">+// RUN: rm -rf %t<br class="">+<br class="">+// A from path 1<br class="">+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/path1/A -DDIRECT -DEXPECTED_PATH=1<br class="">+<br class="">+// A from path 2<br class="">+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/path2/A -DDIRECT -DEXPECTED_PATH=2<br class="">+<br class="">+// Confirm that we have two pcm files (one for each 'A').<br class="">+// RUN: find %t -name "A-*.pcm" | count 2<br class="">+<br class="">+// DependsOnA, using A from path 1<br class="">+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -DEXPECTED_PATH=1<br class="">+<br class="">+// Confirm that we have three pcm files (one for each 'A', and one for 'DependsOnA')<br class="">+// RUN: find %t -name "*.pcm" | count 3<br class="">+<br class="">+// DependsOnA, using A from path 2<br class="">+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fmodules-ignore-macro=EXPECTED_PATH -fmodules-ignore-macro=DIRECT -fsyntax-only %s -verify -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -DEXPECTED_PATH=2<br class="">+<br class="">+// Confirm that we still have three pcm files, since DependsOnA will be rebuilt<br class="">+// RUN: find %t -name "*.pcm" | count 3<br class="">+<br class="">+#ifdef DIRECT<br class="">+@import A;<br class="">+#else<br class="">+@import DependsOnA;<br class="">+#endif<br class="">+<br class="">+#if FROM_PATH != EXPECTED_PATH<br class="">+#error "Got the wrong module!"<br class="">+#endif<br class="">+<br class="">+// expected-no-diagnostics<br class=""><br class="">Modified: cfe/trunk/test/Modules/prune.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/prune.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/prune.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/prune.m (original)<br class="">+++ cfe/trunk/test/Modules/prune.m Mon Apr 14 13:00:01 2014<br class="">@@ -14,33 +14,33 @@<br class=""> // RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -F %S/Inputs -fmodules-cache-path=%t %s -verify<br class=""> // RUN: %clang_cc1 -DIMPORT_DEPENDS_ON_MODULE -fmodules-ignore-macro=DIMPORT_DEPENDS_ON_MODULE -fmodules -F %S/Inputs -fmodules-cache-path=%t %s -verify<br class=""> // RUN: ls %t | grep modules.timestamp<br class="">-// RUN: ls -R %t | grep ^Module.pcm<br class="">-// RUN: ls -R %t | grep DependsOnModule.pcm<br class="">+// RUN: ls -R %t | grep ^Module.*pcm<br class="">+// RUN: ls -R %t | grep DependsOnModule.*pcm<br class=""><br class=""> // Set the timestamp back more than two days. We should try to prune,<br class=""> // but nothing gets pruned because the module files are new enough.<br class=""> // RUN: touch -m -a -t 201101010000 %t/modules.timestamp<br class=""> // RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify<br class=""> // RUN: ls %t | grep modules.timestamp<br class="">-// RUN: ls -R %t | grep ^Module.pcm<br class="">-// RUN: ls -R %t | grep DependsOnModule.pcm<br class="">+// RUN: ls -R %t | grep ^Module.*pcm<br class="">+// RUN: ls -R %t | grep DependsOnModule.*pcm<br class=""><br class=""> // Set the DependsOnModule access time back more than four days.<br class=""> // This shouldn't prune anything, because the timestamp has been updated, so<br class=""> // the pruning mechanism won't fire.<br class="">-// RUN: find %t -name DependsOnModule.pcm | xargs touch -a -t 201101010000<br class="">+// RUN: find %t -name DependsOnModule*.pcm | xargs touch -a -t 201101010000<br class=""> // RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify<br class=""> // RUN: ls %t | grep modules.timestamp<br class="">-// RUN: ls -R %t | grep ^Module.pcm<br class="">-// RUN: ls -R %t | grep DependsOnModule.pcm<br class="">+// RUN: ls -R %t | grep ^Module.*pcm<br class="">+// RUN: ls -R %t | grep DependsOnModule.*pcm<br class=""><br class=""> // Set both timestamp and DependsOnModule.pcm back beyond the cutoff.<br class=""> // This should trigger pruning, which will remove DependsOnModule but not Module.<br class=""> // RUN: touch -m -a -t 201101010000 %t/modules.timestamp<br class="">-// RUN: find %t -name DependsOnModule.pcm | xargs touch -a -t 201101010000<br class="">+// RUN: find %t -name DependsOnModule..pcm | xargs touch -a -t 201101010000<br class=""> // RUN: %clang_cc1 -fmodules -F %S/Inputs -fmodules-cache-path=%t -fmodules -fmodules-prune-interval=172800 -fmodules-prune-after=345600 %s -verify<br class=""> // RUN: ls %t | grep modules.timestamp<br class="">-// RUN: ls -R %t | grep ^Module.pcm<br class="">-// RUN: ls -R %t | not grep DependsOnModule.pcm<br class="">+// RUN: ls -R %t | grep ^Module.*pcm<br class="">+// RUN: ls -R %t | not grep DependsOnModule.*pcm<br class=""><br class=""> // expected-no-diagnostics<br class=""><br class="">Modified: cfe/trunk/test/Modules/redecls/main.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/redecls/main.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/redecls/main.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/redecls/main.m (original)<br class="">+++ cfe/trunk/test/Modules/redecls/main.m Mon Apr 14 13:00:01 2014<br class="">@@ -3,7 +3,7 @@<br class=""> // RUN: %clang_cc1 -fmodules -x objective-c -emit-module -fmodule-name=b %S/module.map -fmodules-cache-path=%t.mcp<br class=""> // RUN: %clang_cc1 -fmodules %s -emit-pch -o %t1.pch -fmodules-cache-path=%t.mcp -I %S<br class=""> // RUN: %clang_cc1 -fmodules %s -emit-pch -o %t2.pch -include-pch %t1.pch -fmodules-cache-path=%t.mcp -I %S<br class="">-// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -fmodules-cache-path=%t.mcp -verify<br class="">+// RUN: %clang_cc1 -fmodules %s -fsyntax-only -include-pch %t2.pch -I %S -fmodules-cache-path=%t.mcp -verify<br class=""><br class=""> #ifndef HEADER1<br class=""> #define HEADER1<br class=""><br class="">Added: cfe/trunk/test/Modules/resolution-change.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/resolution-change.m?rev=206201&view=auto" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/resolution-change.m?rev=206201&view=auto</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/resolution-change.m (added)<br class="">+++ cfe/trunk/test/Modules/resolution-change.m Mon Apr 14 13:00:01 2014<br class="">@@ -0,0 +1,24 @@<br class="">+// RUN: rm -rf %t<br class="">+<br class="">+// Build PCH using A from path 1<br class="">+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -emit-pch -o %t-A.pch %s<br class="">+<br class="">+// Use the PCH with the same header search options; should be fine<br class="">+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path1/A -include-pch %t-A.pch %s -fsyntax-only -Werror<br class="">+<br class="">+// Use the PCH with no way to resolve DependsOnA<br class="">+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NODOA %s<br class="">+// CHECK-NODOA: module 'DependsOnA' imported by AST file '{{.*A.pch}}' not found<br class="">+<br class="">+// Use the PCH with no way to resolve A<br class="">+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-NOA %s<br class="">+// CHECK-NOA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' not found<br class="">+<br class="">+// Use the PCH and have it resolve the the other A<br class="">+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t -I %S/Inputs/modules-with-same-name/DependsOnA -I %S/Inputs/modules-with-same-name/path2/A -include-pch %t-A.pch %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-WRONGA %s<br class="">+// CHECK-WRONGA: module 'A' imported by AST file '{{.*DependsOnA.*pcm}}' found in a different module map file ({{.*path2.*}}) than when the importing AST file was built ({{.*path1.*}})<br class="">+<br class="">+#ifndef HEADER<br class="">+#define HEADER<br class="">+@import DependsOnA;<br class="">+#endif<br class=""><br class="">Modified: cfe/trunk/test/Modules/system_version.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/system_version.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/system_version.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/Modules/system_version.m (original)<br class="">+++ cfe/trunk/test/Modules/system_version.m Mon Apr 14 13:00:01 2014<br class="">@@ -11,21 +11,21 @@<br class=""><br class=""> // Run once with no system version file. We should end up with one module.<br class=""> // RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify<br class="">-// RUN: ls -R %t | grep -c ModA.pcm| grep 1<br class="">+// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 1<br class=""><br class=""> // Add a system version file and run again. We should now have two<br class=""> // module variants.<br class=""> // RUN: mkdir -p %t/System/Library/CoreServices<br class=""> // RUN: echo "hello" > %t/System/Library/CoreServices/SystemVersion.plist<br class=""> // RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify<br class="">-// RUN: ls -R %t | grep -c ModA.pcm| grep 2<br class="">+// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 2<br class=""><br class=""> // Change the system version file and run again. We should now have three<br class=""> // module variants.<br class=""> // RUN: mkdir -p %t/System/Library/CoreServices<br class=""> // RUN: echo "modules" > %t/System/Library/CoreServices/SystemVersion.plist<br class=""> // RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules -isysroot %t -I %t/usr/include %s -verify<br class="">-// RUN: ls -R %t | grep -c ModA.pcm| grep 3<br class="">+// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 3<br class=""><br class=""> // expected-no-diagnostics<br class=""> @import ModA;<br class=""><br class="">Modified: cfe/trunk/test/PCH/modified-module-dependency.m<br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/modified-module-dependency.m?rev=206201&r1=206200&r2=206201&view=diff" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/modified-module-dependency.m?rev=206201&r1=206200&r2=206201&view=diff</a><br class="">==============================================================================<br class="">--- cfe/trunk/test/PCH/modified-module-dependency.m (original)<br class="">+++ cfe/trunk/test/PCH/modified-module-dependency.m Mon Apr 14 13:00:01 2014<br class="">@@ -5,13 +5,13 @@<br class=""> // RUN: cp %S/modified-module-dependency.module.map %t-dir/module.map<br class=""><br class=""> // Precompile prefix.pch.<br class="">-// RUN: %clang_cc1 -x objective-c -I %t-dir -fmodules -fmodules-cache-path=%t-dir/cache -emit-pch %t-dir/prefix.h -o %t-dir/prefix.pch<br class="">+// RUN: %clang_cc1 -x objective-c -I %t-dir -fmodules -fmodules-cache-path=%t-dir/cache -fdisable-module-hash -emit-pch %t-dir/prefix.h -o %t-dir/prefix.pch<br class=""><br class=""> // Modify the dependency.<br class=""> // RUN: echo ' ' >> %t-dir/test.h<br class=""><br class=""> // Run and check the diagnostics.<br class="">-// RUN: not %clang_cc1 -x objective-c -include-pch %t-dir/prefix.pch -fmodules -fmodules-cache-path=%t-dir/cache -fsyntax-only %s 2> %t-dir/log<br class="">+// RUN: not %clang_cc1 -x objective-c -I %t-dir -include-pch %t-dir/prefix.pch -fmodules -fmodules-cache-path=%t-dir/cache -fdisable-module-hash -fsyntax-only %s 2> %t-dir/log<br class=""> // RUN: FileCheck %s < %t-dir/log<br class=""><br class=""> // CHECK: file '[[TEST_H:.*[/\\]test\.h]]' has been modified since the precompiled header '[[PREFIX_PCH:.*/prefix\.pch]]' was built<br class=""><br class=""><br class="">_______________________________________________<br class="">cfe-commits mailing list<br class=""><a href="mailto:cfe-commits@cs.uiuc.edu" class="">cfe-commits@cs.uiuc.edu</a><br class=""><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank" class="">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a></blockquote></div></div></div></div></blockquote></div></blockquote></div><br class=""></body></html>