/// If none is specified, abort (GCC-compatible behaviour).
std::string OverflowHandler;
+ /// \brief The name of the current module.
+ std::string CurrentModule;
+
LangOptions();
// Define accessors/mutators for language options of enumeration type.
def fmodule_cache_path : Separate<"-fmodule-cache-path">,
MetaVarName<"<directory>">,
HelpText<"Specify the module cache path">;
+def fmodule_name : Joined<"-fmodule-name=">,
+ MetaVarName<"<name>">,
+ HelpText<"Specify the name of the module to build">;
def fdisable_module_hash : Flag<"-fdisable-module-hash">,
HelpText<"Disable the module hash">;
def fauto_module_import : Flag<"-fauto-module-import">,
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
Name = Default;
#include "clang/Basic/LangOptions.def"
+
+ CurrentModule.clear();
}
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();
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);
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,
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,
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);
}
#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);
}