<p dir="ltr">On 3 Mar 2016 3:18 a.m., "Argyrios Kyrtzidis via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Mind if we keep -fmodule-implementation-of as an alias so that we can gradually transition to -fmodule-name ?</p>
<p dir="ltr">Sure, no problem.</p>
<p dir="ltr">> > On Feb 19, 2016, at 2:25 PM, Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br>
> ><br>
> > Author: rsmith<br>
> > Date: Fri Feb 19 16:25:36 2016<br>
> > New Revision: 261372<br>
> ><br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=261372&view=rev">http://llvm.org/viewvc/llvm-project?rev=261372&view=rev</a><br>
> > Log:<br>
> > [modules] Flatten -fmodule-name= and -fmodule-implementation-of= into a single<br>
> > option. Previously these options could both be used to specify that you were<br>
> > compiling the implementation file of a module, with a different set of minor<br>
> > bugs in each case.<br>
> ><br>
> > This change removes -fmodule-implementation-of, and instead tracks a flag to<br>
> > determine whether we're currently building a module. -fmodule-name now behaves<br>
> > the same way that -fmodule-implementation-of previously did.<br>
> ><br>
> > Modified:<br>
> > cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td<br>
> > cfe/trunk/include/clang/Basic/LangOptions.def<br>
> > cfe/trunk/include/clang/Basic/LangOptions.h<br>
> > cfe/trunk/include/clang/Driver/CC1Options.td<br>
> > cfe/trunk/include/clang/Driver/Options.td<br>
> > cfe/trunk/include/clang/Lex/ModuleMap.h<br>
> > cfe/trunk/lib/Basic/LangOptions.cpp<br>
> > cfe/trunk/lib/Driver/Tools.cpp<br>
> > cfe/trunk/lib/Frontend/ASTUnit.cpp<br>
> > cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
> > cfe/trunk/lib/Frontend/FrontendActions.cpp<br>
> > cfe/trunk/lib/Lex/ModuleMap.cpp<br>
> > cfe/trunk/lib/Lex/PPDirectives.cpp<br>
> > cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
> > cfe/trunk/lib/Lex/Preprocessor.cpp<br>
> > cfe/trunk/lib/Sema/SemaDecl.cpp<br>
> > cfe/trunk/lib/Sema/SemaDeclObjC.cpp<br>
> > cfe/trunk/test/Modules/Inputs/explicit-build/a.h<br>
> > cfe/trunk/test/Modules/explicit-build.cpp<br>
> > cfe/trunk/test/Modules/implementation-of-module.m<br>
> > cfe/trunk/test/Modules/import-self.m<br>
> ><br>
> > Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)<br>
> > +++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Fri Feb 19 16:25:36 2016<br>
> > @@ -210,10 +210,6 @@ def err_test_module_file_extension_versi<br>
> > "test module file extension '%0' has different version (%1.%2) than expected "<br>
> > "(%3.%4)">;<br>
> ><br>
> > -def err_conflicting_module_names : Error<<br>
> > - "conflicting module names specified: '-fmodule-name=%0' and "<br>
> > - "'-fmodule-implementation-of %1'">;<br>
> > -<br>
> > def err_missing_vfs_overlay_file : Error<<br>
> > "virtual filesystem overlay file '%0' not found">, DefaultFatal;<br>
> > def err_invalid_vfs_overlay : Error<<br>
> ><br>
> > Modified: cfe/trunk/include/clang/Basic/LangOptions.def<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/include/clang/Basic/LangOptions.def (original)<br>
> > +++ cfe/trunk/include/clang/Basic/LangOptions.def Fri Feb 19 16:25:36 2016<br>
> > @@ -127,6 +127,7 @@ BENIGN_LANGOPT(EmitAllDecls , 1, 0,<br>
> > LANGOPT(MathErrno , 1, 1, "errno support for math functions")<br>
> > BENIGN_LANGOPT(HeinousExtensions , 1, 0, "Extensions that we really don't like and may be ripped out at any time")<br>
> > LANGOPT(Modules , 1, 0, "modules extension to C")<br>
> > +BENIGN_LANGOPT(CompilingModule, 1, 0, "compiling a module interface")<br>
> > COMPATIBLE_LANGOPT(ModulesDeclUse , 1, 0, "require declaration of module uses")<br>
> > LANGOPT(ModulesSearchAll , 1, 1, "search even non-imported modules to find unresolved references")<br>
> > COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "require declaration of module uses and all headers to be in modules")<br>
> ><br>
> > Modified: cfe/trunk/include/clang/Basic/LangOptions.h<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/include/clang/Basic/LangOptions.h (original)<br>
> > +++ cfe/trunk/include/clang/Basic/LangOptions.h Fri Feb 19 16:25:36 2016<br>
> > @@ -92,14 +92,12 @@ public:<br>
> > /// If none is specified, abort (GCC-compatible behaviour).<br>
> > std::string OverflowHandler;<br>
> ><br>
> > - /// \brief The name of the current module.<br>
> > + /// \brief The name of the current module, of which the main source file<br>
> > + /// is a part. If CompilingModule is set, we are compiling the interface<br>
> > + /// of this module, otherwise we are compiling an implementation file of<br>
> > + /// it.<br>
> > std::string CurrentModule;<br>
> ><br>
> > - /// \brief The name of the module that the translation unit is an<br>
> > - /// implementation of. Prevents semantic imports, but does not otherwise<br>
> > - /// treat this as the CurrentModule.<br>
> > - std::string ImplementationOfModule;<br>
> > -<br>
> > /// \brief The names of any features to enable in module 'requires' decls<br>
> > /// in addition to the hard-coded list in Module.cpp and the target features.<br>
> > ///<br>
> ><br>
> > Modified: cfe/trunk/include/clang/Driver/CC1Options.td<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/include/clang/Driver/CC1Options.td (original)<br>
> > +++ cfe/trunk/include/clang/Driver/CC1Options.td Fri Feb 19 16:25:36 2016<br>
> > @@ -382,9 +382,6 @@ def fno_modules_global_index : Flag<["-"<br>
> > HelpText<"Do not automatically generate or update the global module index">;<br>
> > def fno_modules_error_recovery : Flag<["-"], "fno-modules-error-recovery">,<br>
> > HelpText<"Do not automatically import modules for error recovery">;<br>
> > -def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,<br>
> > - MetaVarName<"<name>">,<br>
> > - HelpText<"Specify the name of the module whose implementation file this is">;<br>
> > def fmodule_map_file_home_is_cwd : Flag<["-"], "fmodule-map-file-home-is-cwd">,<br>
> > HelpText<"Use the current working directory as the home directory of "<br>
> > "module maps specified by -fmodule-map-file=<FILE>">;<br>
> ><br>
> > Modified: cfe/trunk/include/clang/Driver/Options.td<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/include/clang/Driver/Options.td (original)<br>
> > +++ cfe/trunk/include/clang/Driver/Options.td Fri Feb 19 16:25:36 2016<br>
> > @@ -786,9 +786,10 @@ def fimplicit_module_maps : Flag <["-"],<br>
> > Flags<[DriverOption, CC1Option]>,<br>
> > HelpText<"Implicitly search the file system for module map files.">;<br>
> > def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias<fimplicit_module_maps>;<br>
> > -def fmodule_name : JoinedOrSeparate<["-"], "fmodule-name=">, Group<f_Group>,<br>
> > +def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group<f_Group>,<br>
> > Flags<[DriverOption,CC1Option]>, MetaVarName<"<name>">,<br>
> > HelpText<"Specify the name of the module to build">;<br>
> > +def fmodule_name : Separate<["-"], "fmodule-name">, Alias<fmodule_name_EQ>;<br>
> > def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,<br>
> > Group<f_Group>, Flags<[DriverOption,CC1Option]>, MetaVarName<"<file>">,<br>
> > HelpText<"Load this module map file">;<br>
> ><br>
> > Modified: cfe/trunk/include/clang/Lex/ModuleMap.h<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/include/clang/Lex/ModuleMap.h (original)<br>
> > +++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri Feb 19 16:25:36 2016<br>
> > @@ -70,15 +70,10 @@ class ModuleMap {<br>
> > /// These are always simple C language options.<br>
> > LangOptions MMapLangOpts;<br>
> ><br>
> > - // The module that we are building; related to \c LangOptions::CurrentModule.<br>
> > - Module *CompilingModule;<br>
> > -<br>
> > -public:<br>
> > - // The module that the .cc source file is associated with.<br>
> > + // The module that the main source file is associated with (the module<br>
> > + // named LangOpts::CurrentModule, if we've loaded it).<br>
> > Module *SourceModule;<br>
> > - std::string SourceModuleName;<br>
> ><br>
> > -private:<br>
> > /// \brief The top-level modules that are known.<br>
> > llvm::StringMap<Module *> Modules;<br>
> ><br>
> ><br>
> > Modified: cfe/trunk/lib/Basic/LangOptions.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/LangOptions.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/LangOptions.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Basic/LangOptions.cpp (original)<br>
> > +++ cfe/trunk/lib/Basic/LangOptions.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -34,7 +34,6 @@ void LangOptions::resetNonModularOptions<br>
> > SanitizerBlacklistFiles.clear();<br>
> ><br>
> > CurrentModule.clear();<br>
> > - ImplementationOfModule.clear();<br>
> > }<br>
> ><br>
> > bool LangOptions::isNoBuiltinFunc(const char *Name) const {<br>
> ><br>
> > Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
> > +++ cfe/trunk/lib/Driver/Tools.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -4909,7 +4909,7 @@ void Clang::ConstructJob(Compilation &C,<br>
> ><br>
> > // -fmodule-name specifies the module that is currently being built (or<br>
> > // used for header checking by -fmodule-maps).<br>
> > - Args.AddLastArg(CmdArgs, options::OPT_fmodule_name);<br>
> > + Args.AddLastArg(CmdArgs, options::OPT_fmodule_name_EQ);<br>
> ><br>
> > // -fmodule-map-file can be used to specify files containing module<br>
> > // definitions.<br>
> ><br>
> > Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)<br>
> > +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -2814,7 +2814,7 @@ const FileEntry *ASTUnit::getPCHFile() {<br>
> > }<br>
> ><br>
> > bool ASTUnit::isModuleFile() {<br>
> > - return isMainFileAST() && !ASTFileLangOpts.CurrentModule.empty();<br>
> > + return isMainFileAST() && ASTFileLangOpts.CompilingModule;<br>
> > }<br>
> ><br>
> > void ASTUnit::PreambleData::countLines() const {<br>
> ><br>
> > Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)<br>
> > +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -1386,8 +1386,7 @@ CompilerInstance::loadModule(SourceLocat<br>
> > // when both the preprocessor and parser see the same import declaration.<br>
> > if (ImportLoc.isValid() && LastModuleImportLoc == ImportLoc) {<br>
> > // Make the named module visible.<br>
> > - if (LastModuleImportResult && ModuleName != getLangOpts().CurrentModule &&<br>
> > - ModuleName != getLangOpts().ImplementationOfModule)<br>
> > + if (LastModuleImportResult && ModuleName != getLangOpts().CurrentModule)<br>
> > ModuleManager->makeModuleVisible(LastModuleImportResult, Visibility,<br>
> > ImportLoc);<br>
> > return LastModuleImportResult;<br>
> > @@ -1401,8 +1400,7 @@ CompilerInstance::loadModule(SourceLocat<br>
> > if (Known != KnownModules.end()) {<br>
> > // Retrieve the cached top-level module.<br>
> > Module = Known->second;<br>
> > - } else if (ModuleName == getLangOpts().CurrentModule ||<br>
> > - ModuleName == getLangOpts().ImplementationOfModule) {<br>
> > + } else if (ModuleName == getLangOpts().CurrentModule) {<br>
> > // This is the module we're building.<br>
> > Module = PP->getHeaderSearchInfo().lookupModule(ModuleName);<br>
> > Known = KnownModules.insert(std::make_pair(Path[0].first, Module)).first;<br>
> > @@ -1580,10 +1578,6 @@ CompilerInstance::loadModule(SourceLocat<br>
> > }<br>
> > }<br>
> ><br>
> > - // Don't make the module visible if we are in the implementation.<br>
> > - if (ModuleName == getLangOpts().ImplementationOfModule)<br>
> > - return ModuleLoadResult(Module, false);<br>
> > -<br>
> > // Make the named module visible, if it's not already part of the module<br>
> > // we are parsing.<br>
> > if (ModuleName != getLangOpts().CurrentModule) {<br>
> ><br>
> > Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
> > +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -1763,10 +1763,8 @@ static void ParseLangArgs(LangOptions &O<br>
> > Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);<br>
> > Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);<br>
> > Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);<br>
> > - Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name);<br>
> > + Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name_EQ);<br>
> > Opts.AppExt = Args.hasArg(OPT_fapplication_extension);<br>
> > - Opts.ImplementationOfModule =<br>
> > - Args.getLastArgValue(OPT_fmodule_implementation_of);<br>
> > Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature);<br>
> > std::sort(Opts.ModuleFeatures.begin(), Opts.ModuleFeatures.end());<br>
> > Opts.NativeHalfType |= Args.hasArg(OPT_fnative_half_type);<br>
> > @@ -1784,12 +1782,6 @@ static void ParseLangArgs(LangOptions &O<br>
> > Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,<br>
> > (Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));<br>
> ><br>
> > - if (!Opts.CurrentModule.empty() && !Opts.ImplementationOfModule.empty() &&<br>
> > - Opts.CurrentModule != Opts.ImplementationOfModule) {<br>
> > - Diags.Report(diag::err_conflicting_module_names)<br>
> > - << Opts.CurrentModule << Opts.ImplementationOfModule;<br>
> > - }<br>
> > -<br>
> > // For now, we only support local submodule visibility in C++ (because we<br>
> > // heavily depend on the ODR for merging redefinitions).<br>
> > if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)<br>
> ><br>
> > Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)<br>
> > +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -270,6 +270,8 @@ collectModuleHeaderIncludes(const LangOp<br>
> ><br>
> > bool GenerateModuleAction::BeginSourceFileAction(CompilerInstance &CI,<br>
> > StringRef Filename) {<br>
> > + CI.getLangOpts().CompilingModule = true;<br>
> > +<br>
> > // Find the module map file.<br>
> > const FileEntry *ModuleMap =<br>
> > CI.getFileManager().getFile(Filename, /*openFile*/true);<br>
> ><br>
> > Modified: cfe/trunk/lib/Lex/ModuleMap.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Lex/ModuleMap.cpp (original)<br>
> > +++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -89,7 +89,7 @@ ModuleMap::ModuleMap(SourceManager &Sour<br>
> > HeaderSearch &HeaderInfo)<br>
> > : SourceMgr(SourceMgr), Diags(Diags), LangOpts(LangOpts), Target(Target),<br>
> > HeaderInfo(HeaderInfo), BuiltinIncludeDir(nullptr),<br>
> > - CompilingModule(nullptr), SourceModule(nullptr), NumCreatedModules(0) {<br>
> > + SourceModule(nullptr), NumCreatedModules(0) {<br>
> > MMapLangOpts.LineComment = true;<br>
> > }<br>
> ><br>
> > @@ -343,8 +343,8 @@ ModuleMap::KnownHeader ModuleMap::findMo<br>
> > ModuleMap::KnownHeader Result;<br>
> > // Iterate over all modules that 'File' is part of to find the best fit.<br>
> > for (KnownHeader &H : Known->second) {<br>
> > - // Prefer a header from the current module over all others.<br>
> > - if (H.getModule()->getTopLevelModule() == CompilingModule)<br>
> > + // Prefer a header from the source module over all others.<br>
> > + if (H.getModule()->getTopLevelModule() == SourceModule)<br>
> > return MakeResult(H);<br>
> > if (!Result || isBetterKnownHeader(H, Result))<br>
> > Result = H;<br>
> > @@ -556,16 +556,10 @@ ModuleMap::findOrCreateModule(StringRef<br>
> > // Create a new module with this name.<br>
> > Module *Result = new Module(Name, SourceLocation(), Parent,<br>
> > IsFramework, IsExplicit, NumCreatedModules++);<br>
> > - if (LangOpts.CurrentModule == Name) {<br>
> > - SourceModule = Result;<br>
> > - SourceModuleName = Name;<br>
> > - }<br>
> > if (!Parent) {<br>
> > + if (LangOpts.CurrentModule == Name)<br>
> > + SourceModule = Result;<br>
> > Modules[Name] = Result;<br>
> > - if (!LangOpts.CurrentModule.empty() && !CompilingModule &&<br>
> > - Name == LangOpts.CurrentModule) {<br>
> > - CompilingModule = Result;<br>
> > - }<br>
> > }<br>
> > return std::make_pair(Result, true);<br>
> > }<br>
> > @@ -693,9 +687,10 @@ Module *ModuleMap::inferFrameworkModule(<br>
> > NumCreatedModules++);<br>
> > InferredModuleAllowedBy[Result] = ModuleMapFile;<br>
> > Result->IsInferred = true;<br>
> > - if (LangOpts.CurrentModule == ModuleName) {<br>
> > - SourceModule = Result;<br>
> > - SourceModuleName = ModuleName;<br>
> > + if (!Parent) {<br>
> > + if (LangOpts.CurrentModule == ModuleName)<br>
> > + SourceModule = Result;<br>
> > + Modules[ModuleName] = Result;<br>
> > }<br>
> ><br>
> > Result->IsSystem |= Attrs.IsSystem;<br>
> > @@ -703,9 +698,6 @@ Module *ModuleMap::inferFrameworkModule(<br>
> > Result->ConfigMacrosExhaustive |= Attrs.IsExhaustive;<br>
> > Result->Directory = FrameworkDir;<br>
> ><br>
> > - if (!Parent)<br>
> > - Modules[ModuleName] = Result;<br>
> > -<br>
> > // umbrella header "umbrella-header-name"<br>
> > //<br>
> > // The "Headers/" component of the name is implied because this is<br>
> > @@ -812,7 +804,8 @@ void ModuleMap::addHeader(Module *Mod, M<br>
> > HeaderList.push_back(KH);<br>
> > Mod->Headers[headerRoleToKind(Role)].push_back(std::move(Header));<br>
> ><br>
> > - bool isCompilingModuleHeader = Mod->getTopLevelModule() == CompilingModule;<br>
> > + bool isCompilingModuleHeader =<br>
> > + LangOpts.CompilingModule && Mod->getTopLevelModule() == SourceModule;<br>
> > if (!Imported || isCompilingModuleHeader) {<br>
> > // When we import HeaderFileInfo, the external source is expected to<br>
> > // set the isModuleHeader flag itself.<br>
> ><br>
> > Modified: cfe/trunk/lib/Lex/PPDirectives.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Lex/PPDirectives.cpp (original)<br>
> > +++ cfe/trunk/lib/Lex/PPDirectives.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -573,23 +573,23 @@ void Preprocessor::PTHSkipExcludedCondit<br>
> > }<br>
> ><br>
> > Module *Preprocessor::getModuleForLocation(SourceLocation Loc) {<br>
> > - ModuleMap &ModMap = HeaderInfo.getModuleMap();<br>
> > - if (SourceMgr.isInMainFile(Loc)) {<br>
> > - if (Module *CurMod = getCurrentModule())<br>
> > - return CurMod; // Compiling a module.<br>
> > - return HeaderInfo.getModuleMap().SourceModule; // Compiling a source.<br>
> > - }<br>
> > - // Try to determine the module of the include directive.<br>
> > - // FIXME: Look into directly passing the FileEntry from LookupFile instead.<br>
> > - FileID IDOfIncl = SourceMgr.getFileID(SourceMgr.getExpansionLoc(Loc));<br>
> > - if (const FileEntry *EntryOfIncl = SourceMgr.getFileEntryForID(IDOfIncl)) {<br>
> > - // The include comes from a file.<br>
> > - return ModMap.findModuleForHeader(EntryOfIncl).getModule();<br>
> > - } else {<br>
> > - // The include does not come from a file,<br>
> > - // so it is probably a module compilation.<br>
> > - return getCurrentModule();<br>
> > + if (!SourceMgr.isInMainFile(Loc)) {<br>
> > + // Try to determine the module of the include directive.<br>
> > + // FIXME: Look into directly passing the FileEntry from LookupFile instead.<br>
> > + FileID IDOfIncl = SourceMgr.getFileID(SourceMgr.getExpansionLoc(Loc));<br>
> > + if (const FileEntry *EntryOfIncl = SourceMgr.getFileEntryForID(IDOfIncl)) {<br>
> > + // The include comes from an included file.<br>
> > + return HeaderInfo.getModuleMap()<br>
> > + .findModuleForHeader(EntryOfIncl)<br>
> > + .getModule();<br>
> > + }<br>
> > }<br>
> > +<br>
> > + // This is either in the main file or not in a file at all. It belongs<br>
> > + // to the current module, if there is one.<br>
> > + return getLangOpts().CurrentModule.empty()<br>
> > + ? nullptr<br>
> > + : HeaderInfo.lookupModule(getLangOpts().CurrentModule);<br>
> > }<br>
> ><br>
> > Module *Preprocessor::getModuleContainingLocation(SourceLocation Loc) {<br>
> > @@ -1668,10 +1668,7 @@ void Preprocessor::HandleIncludeDirectiv<br>
> > // are processing this module textually (because we're building the module).<br>
> > if (File && SuggestedModule && getLangOpts().Modules &&<br>
> > SuggestedModule.getModule()->getTopLevelModuleName() !=<br>
> > - getLangOpts().CurrentModule &&<br>
> > - SuggestedModule.getModule()->getTopLevelModuleName() !=<br>
> > - getLangOpts().ImplementationOfModule) {<br>
> > -<br>
> > + getLangOpts().CurrentModule) {<br>
> > // If this include corresponds to a module but that module is<br>
> > // unavailable, diagnose the situation and bail out.<br>
> > if (!SuggestedModule.getModule()->isAvailable()) {<br>
> ><br>
> > Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)<br>
> > +++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -1438,8 +1438,9 @@ static bool EvaluateBuildingModule(Token<br>
> > return false;<br>
> > }<br>
> ><br>
> > - bool Result<br>
> > - = Tok.getIdentifierInfo()->getName() == PP.getLangOpts().CurrentModule;<br>
> > + bool Result =<br>
> > + PP.getLangOpts().CompilingModule &&<br>
> > + Tok.getIdentifierInfo()->getName() == PP.getLangOpts().CurrentModule;<br>
> ><br>
> > // Get ')'.<br>
> > PP.LexNonComment(Tok);<br>
> ><br>
> > Modified: cfe/trunk/lib/Lex/Preprocessor.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Lex/Preprocessor.cpp (original)<br>
> > +++ cfe/trunk/lib/Lex/Preprocessor.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -477,7 +477,7 @@ void Preprocessor::CreateString(StringRe<br>
> > }<br>
> ><br>
> > Module *Preprocessor::getCurrentModule() {<br>
> > - if (getLangOpts().CurrentModule.empty())<br>
> > + if (!getLangOpts().CompilingModule)<br>
> > return nullptr;<br>
> ><br>
> > return getHeaderSearchInfo().lookupModule(getLangOpts().CurrentModule);<br>
> ><br>
> > Modified: cfe/trunk/lib/Sema/SemaDecl.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)<br>
> > +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -14752,11 +14752,10 @@ DeclResult Sema::ActOnModuleImport(Sourc<br>
> > // of the same top-level module. Until we do, make it an error rather than<br>
> > // silently ignoring the import.<br>
> > if (Mod->getTopLevelModuleName() == getLangOpts().CurrentModule)<br>
> > - Diag(ImportLoc, diag::err_module_self_import)<br>
> > + Diag(ImportLoc, getLangOpts().CompilingModule<br>
> > + ? diag::err_module_self_import<br>
> > + : diag::err_module_import_in_implementation)<br>
> > << Mod->getFullModuleName() << getLangOpts().CurrentModule;<br>
> > - else if (Mod->getTopLevelModuleName() == getLangOpts().ImplementationOfModule)<br>
> > - Diag(ImportLoc, diag::err_module_import_in_implementation)<br>
> > - << Mod->getFullModuleName() << getLangOpts().ImplementationOfModule;<br>
> ><br>
> > SmallVector<SourceLocation, 2> IdentifierLocs;<br>
> > Module *ModCheck = Mod;<br>
> > @@ -14790,11 +14789,13 @@ void Sema::ActOnModuleInclude(SourceLoca<br>
> > TUKind == TU_Module &&<br>
> > getSourceManager().isWrittenInMainFile(DirectiveLoc);<br>
> ><br>
> > - // Similarly, if this module is specified by -fmodule-implementation-of<br>
> > - // don't actually synthesize an illegal module import.<br>
> > - bool ShouldAddImport = !IsInModuleIncludes &&<br>
> > - (getLangOpts().ImplementationOfModule.empty() ||<br>
> > - getLangOpts().ImplementationOfModule != Mod->getTopLevelModuleName());<br>
> > + // Similarly, if we're in the implementation of a module, don't<br>
> > + // synthesize an illegal module import. FIXME: Why not?<br>
> > + bool ShouldAddImport =<br>
> > + !IsInModuleIncludes &&<br>
> > + (getLangOpts().CompilingModule ||<br>
> > + getLangOpts().CurrentModule.empty() ||<br>
> > + getLangOpts().CurrentModule != Mod->getTopLevelModuleName());<br>
> ><br>
> > // If this module import was due to an inclusion directive, create an<br>
> > // implicit import declaration to capture it in the AST.<br>
> ><br>
> > Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)<br>
> > +++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -3171,7 +3171,7 @@ void Sema::addMethodToGlobalList(ObjCMet<br>
> > ObjCMethodList *Previous = List;<br>
> > for (; List; Previous = List, List = List->getNext()) {<br>
> > // If we are building a module, keep all of the methods.<br>
> > - if (getLangOpts().Modules && !getLangOpts().CurrentModule.empty())<br>
> > + if (getLangOpts().CompilingModule)<br>
> > continue;<br>
> ><br>
> > if (!MatchTwoMethodDeclarations(Method, List->getMethod())) {<br>
> ><br>
> > Modified: cfe/trunk/test/Modules/Inputs/explicit-build/a.h<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build/a.h?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/explicit-build/a.h?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/test/Modules/Inputs/explicit-build/a.h (original)<br>
> > +++ cfe/trunk/test/Modules/Inputs/explicit-build/a.h Fri Feb 19 16:25:36 2016<br>
> > @@ -1,4 +1,4 @@<br>
> > -#if !__building_module(a)<br>
> > +#if !__building_module(a) && !BUILDING_A_PCH<br>
> > #error "should only get here when building module a"<br>
> > #endif<br>
> ><br>
> ><br>
> > Modified: cfe/trunk/test/Modules/explicit-build.cpp<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build.cpp?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/explicit-build.cpp?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/test/Modules/explicit-build.cpp (original)<br>
> > +++ cfe/trunk/test/Modules/explicit-build.cpp Fri Feb 19 16:25:36 2016<br>
> > @@ -143,7 +143,7 @@<br>
> > // -------------------------------<br>
> > // Try to import a PCH with -fmodule-file=<br>
> > // RUN: %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \<br>
> > -// RUN: -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch \<br>
> > +// RUN: -fmodule-name=a -emit-pch %S/Inputs/explicit-build/a.h -o %t/a.pch -DBUILDING_A_PCH \<br>
> > // RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-IMPLICIT-BUILD %s --allow-empty<br>
> > //<br>
> > // RUN: not %clang_cc1 -x c++ -std=c++11 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -Rmodule-build -fno-modules-error-recovery \<br>
> ><br>
> > Modified: cfe/trunk/test/Modules/implementation-of-module.m<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implementation-of-module.m?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implementation-of-module.m?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/test/Modules/implementation-of-module.m (original)<br>
> > +++ cfe/trunk/test/Modules/implementation-of-module.m Fri Feb 19 16:25:36 2016<br>
> > @@ -1,22 +1,18 @@<br>
> > -// RUN: not %clang_cc1 -fmodule-implementation-of Foo -fmodule-name=Bar %s 2>&1 \<br>
> > -// RUN: | FileCheck -check-prefix=CHECK-IMPL-OF-ERR %s<br>
> > -// CHECK-IMPL-OF-ERR: conflicting module names specified: '-fmodule-name=Bar' and '-fmodule-implementation-of Foo'<br>
> > -<br>
> > // RUN: rm -rf %t<br>
> > // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \<br>
> > -// RUN: -fmodule-implementation-of category_right -fsyntax-only<br>
> > +// RUN: -fmodule-name=category_right -fsyntax-only<br>
> ><br>
> > // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \<br>
> > -// RUN: -fmodule-implementation-of category_right -dM -E -o - 2>&1 | FileCheck %s<br>
> > +// RUN: -fmodule-name=category_right -dM -E -o - 2>&1 | FileCheck %s<br>
> > // CHECK-NOT: __building_module<br>
> ><br>
> > // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \<br>
> > -// RUN: -fmodule-implementation-of category_left -verify<br>
> > +// RUN: -fmodule-name=category_left -verify<br>
> ><br>
> > // RUN: %clang_cc1 -x objective-c-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \<br>
> > -// RUN: -fmodule-implementation-of category_right -emit-pch -o %t.pch<br>
> > +// RUN: -fmodule-name=category_right -emit-pch -o %t.pch<br>
> > // RUN: %clang_cc1 -x objective-c-header -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -w -Werror=auto-import %s -I %S/Inputs \<br>
> > -// RUN: -DWITH_PREFIX -fmodules-ignore-macro=WITH_PREFIX -include-pch %t.pch -fmodule-implementation-of category_right<br>
> > +// RUN: -DWITH_PREFIX -fmodules-ignore-macro=WITH_PREFIX -include-pch %t.pch -fmodule-name=category_right<br>
> ><br>
> > #ifndef WITH_PREFIX<br>
> ><br>
> ><br>
> > Modified: cfe/trunk/test/Modules/import-self.m<br>
> > URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-self.m?rev=261372&r1=261371&r2=261372&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-self.m?rev=261372&r1=261371&r2=261372&view=diff</a><br>
> > ==============================================================================<br>
> > --- cfe/trunk/test/Modules/import-self.m (original)<br>
> > +++ cfe/trunk/test/Modules/import-self.m Fri Feb 19 16:25:36 2016<br>
> > @@ -6,6 +6,6 @@<br>
> > // RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \<br>
> > // RUN: -I %S/Inputs/submodules -fmodule-name=import_self %s \<br>
> > // RUN: 2>&1 | FileCheck -check-prefix=CHECK-fmodule-name %s<br>
> > -// CHECK-fmodule-name: import of module 'import_self.b' appears within same top-level module 'import_self'<br>
> > +// CHECK-fmodule-name: @import of module 'import_self.b' in implementation of 'import_self'<br>
> ><br>
> > @import import_self.b;<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > cfe-commits mailing list<br>
> > <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</p>