diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Basic/LangOptions.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 7 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 3 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 4 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 3 |
5 files changed, 16 insertions, 3 deletions
diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index 5f479dbb77..991992a477 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -26,5 +26,7 @@ void LangOptions::resetNonModularOptions() { #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ Name = Default; #include "clang/Basic/LangOptions.def" + + CurrentModule.clear(); } diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 0e3b25168f..ea2c3bd6c6 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -278,9 +278,7 @@ void CompilerInstance::createPreprocessor() { llvm::sys::path::append(SpecificModuleCache, getInvocation().getModuleHash()); PP->getHeaderSearchInfo().configureModules(SpecificModuleCache, - getPreprocessorOpts().ModuleBuildPath.empty() - ? std::string() - : getPreprocessorOpts().ModuleBuildPath.back()); + getLangOpts().CurrentModule); // Handle generating dependencies, if requested. const DependencyOutputOptions &DepOpts = getDependencyOutputOpts(); @@ -992,6 +990,9 @@ static void compileModule(CompilerInstance &ImportingInstance, Invocation->getLangOpts().resetNonModularOptions(); Invocation->getPreprocessorOpts().resetNonModularOptions(); + // Note the name of the module we're building. + Invocation->getLangOpts().CurrentModule = ModuleName; + // Note that this module is part of the module build path, so that we // can detect cycles in the module graph. Invocation->getPreprocessorOpts().ModuleBuildPath.push_back(ModuleName); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index c247e21737..015288c853 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -788,6 +788,8 @@ static void LangOptsToArgs(const LangOptions &Opts, Res.push_back("-fdeprecated-macro"); if (Opts.ApplePragmaPack) Res.push_back("-fapple-pragma-pack"); + if (!Opts.CurrentModule.empty()) + Res.push_back("-fmodule-name=" + Opts.CurrentModule); } static void PreprocessorOptsToArgs(const PreprocessorOptions &Opts, @@ -1785,6 +1787,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Opts.ParseUnknownAnytype = Args.hasArg(OPT_funknown_anytype); Opts.DebuggerSupport = Args.hasArg(OPT_fdebugger_support); Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack); + Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name); // Record whether the __DEPRECATED define was requested. Opts.Deprecated = Args.hasFlag(OPT_fdeprecated_macro, diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 6192fb7751..8961974856 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -2789,6 +2789,10 @@ bool ASTReader::ParseLanguageOptions( LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++])); #include "clang/Basic/LangOptions.def" + unsigned Length = Record[Idx++]; + LangOpts.CurrentModule.assign(Record.begin() + Idx, + Record.begin() + Idx + Length); + Idx += Length; return Listener->ReadLanguageOptions(LangOpts); } diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 4fa3cf8756..6893dbd9f5 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1063,6 +1063,9 @@ void ASTWriter::WriteLanguageOptions(const LangOptions &LangOpts) { #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \ Record.push_back(static_cast<unsigned>(LangOpts.get##Name())); #include "clang/Basic/LangOptions.def" + + Record.push_back(LangOpts.CurrentModule.size()); + Record.append(LangOpts.CurrentModule.begin(), LangOpts.CurrentModule.end()); Stream.EmitRecord(LANGUAGE_OPTIONS, Record); } |