mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #85100 from adrian-prantl/163302154
Add a -debug-module-path frontend option
This commit is contained in:
@@ -278,6 +278,9 @@ class IRGenOptions {
|
||||
public:
|
||||
std::string ModuleName;
|
||||
|
||||
/// The path to the main binary swiftmodule for the debug info.
|
||||
std::string DebugModulePath;
|
||||
|
||||
/// The compilation directory for the debug info.
|
||||
std::string DebugCompilationDir;
|
||||
|
||||
|
||||
@@ -653,6 +653,12 @@ def project_name : Separate<["-"], "project-name">,
|
||||
def module_name_EQ : Joined<["-"], "module-name=">, Flags<[FrontendOption]>,
|
||||
Alias<module_name>;
|
||||
|
||||
def debug_module_path : Separate<["-"], "debug-module-path">,
|
||||
Flags<[FrontendOption]>,
|
||||
HelpText<"Path to this module's binary swiftmodule artifact (required by debug info)">;
|
||||
def debug_module_path_EQ : Joined<["-"], "debug-module-path=">, Flags<[FrontendOption]>,
|
||||
Alias<debug_module_path>;
|
||||
|
||||
def module_alias : Separate<["-"], "module-alias">,
|
||||
Flags<[FrontendOption, ModuleInterfaceOption]>,
|
||||
MetaVarName<"<alias_name=real_name>">,
|
||||
|
||||
@@ -3462,6 +3462,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
|
||||
A->getAsString(Args), A->getValue());
|
||||
}
|
||||
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_debug_module_path))
|
||||
Opts.DebugModulePath = A->getValue();
|
||||
|
||||
for (auto A : Args.getAllArgValues(options::OPT_file_prefix_map)) {
|
||||
auto SplitMap = StringRef(A).split('=');
|
||||
Opts.FilePrefixMap.addMapping(SplitMap.first, SplitMap.second);
|
||||
|
||||
@@ -864,7 +864,7 @@ private:
|
||||
llvm::DIModule *getOrCreateModule(const void *Key, llvm::DIScope *Parent,
|
||||
StringRef Name, StringRef IncludePath,
|
||||
uint64_t Signature = ~1ULL,
|
||||
StringRef ASTFile = StringRef()) {
|
||||
StringRef ASTFile = {}) {
|
||||
// Look in the cache first.
|
||||
auto Val = DIModuleCache.find(Key);
|
||||
if (Val != DIModuleCache.end())
|
||||
@@ -2823,8 +2823,12 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
|
||||
|
||||
// Create a module for the current compile unit.
|
||||
auto *MDecl = IGM.getSwiftModule();
|
||||
StringRef Path = Opts.DebugModulePath;
|
||||
if (Path.empty()) {
|
||||
llvm::sys::path::remove_filename(SourcePath);
|
||||
MainModule = getOrCreateModule(MDecl, TheCU, Opts.ModuleName, SourcePath);
|
||||
Path = SourcePath;
|
||||
}
|
||||
MainModule = getOrCreateModule(MDecl, TheCU, Opts.ModuleName, Path);
|
||||
DBuilder.createImportedModule(MainFile, MainModule, MainFile, 0);
|
||||
|
||||
// Macro definitions that were defined by the user with "-Xcc -D" on the
|
||||
|
||||
4
test/DebugInfo/ebm_module_path.swift
Normal file
4
test/DebugInfo/ebm_module_path.swift
Normal file
@@ -0,0 +1,4 @@
|
||||
// RUN: %target-swift-frontend -primary-file %s -emit-ir -g -module-name=A -debug-module-path %t/MY_MODULE_PATH.swiftmodule -emit-ir -o - | %FileCheck %s
|
||||
|
||||
// CHECK: DIModule(scope: null, name: "A", includePath: "{{.*}}MY_MODULE_PATH.swiftmodule")
|
||||
|
||||
Reference in New Issue
Block a user