Skip to content

Commit ab174a1

Browse files
committed
[lldb] Prefer triple from module in precise invocations
1 parent 97d4829 commit ab174a1

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,20 +2909,32 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
29092909
return exe_module_sp->GetArchitecture().GetTriple();
29102910
};
29112911

2912+
ArchSpec active_arch;
2913+
llvm::Triple active_triple;
2914+
if (sc.module_sp) {
2915+
active_arch = sc.module_sp->GetArchitecture();
2916+
active_triple = active_arch.GetTriple();
2917+
}
2918+
2919+
// When no module triple, fallback to the target triple.
2920+
if (!active_arch || active_triple == llvm::Triple()) {
2921+
active_arch = target.GetArchitecture();
2922+
active_triple = active_arch.GetTriple();
2923+
}
2924+
29122925
llvm::Triple computed_triple;
2913-
llvm::Triple target_triple = target.GetArchitecture().GetTriple();
29142926

2915-
if (target.GetArchitecture().IsFullySpecifiedTriple()) {
2927+
if (active_arch.IsFullySpecifiedTriple()) {
29162928
// If a fully specified triple was passed in, for example
29172929
// through CreateTargetWithFileAndTargetTriple(), prefer that.
29182930
LOG_PRINTF(GetLog(LLDBLog::Types), "Fully specified target triple %s.",
2919-
target_triple.str().c_str());
2920-
computed_triple = target_triple;
2931+
active_triple.str().c_str());
2932+
computed_triple = active_arch.GetTriple();
29212933
} else {
29222934
// Underspecified means that one or more of vendor, os, or os
29232935
// version (Darwin only) is missing.
29242936
LOG_PRINTF(GetLog(LLDBLog::Types), "Underspecified target triple %s.",
2925-
target_triple.str().c_str());
2937+
active_triple.str().c_str());
29262938
llvm::VersionTuple platform_version;
29272939
PlatformSP platform_sp(target.GetPlatform());
29282940
if (platform_sp)
@@ -2940,15 +2952,15 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
29402952
// plaform (e.g., ios-macabi runs on the macOS, but uses iOS
29412953
// version numbers).
29422954
if (!platform_version.empty() &&
2943-
target_triple.getEnvironment() == llvm::Triple::UnknownEnvironment) {
2955+
active_triple.getEnvironment() == llvm::Triple::UnknownEnvironment) {
29442956
LOG_PRINTF(GetLog(LLDBLog::Types), "Completing triple based on platform.");
29452957

29462958
llvm::SmallString<32> buffer;
29472959
{
29482960
llvm::raw_svector_ostream os(buffer);
2949-
os << target_triple.getArchName() << '-';
2950-
os << target_triple.getVendorName() << '-';
2951-
os << llvm::Triple::getOSTypeName(target_triple.getOS());
2961+
os << active_triple.getArchName() << '-';
2962+
os << active_triple.getVendorName() << '-';
2963+
os << llvm::Triple::getOSTypeName(active_triple.getOS());
29522964
os << platform_version.getAsString();
29532965
}
29542966
computed_triple = llvm::Triple(buffer);

0 commit comments

Comments
 (0)