@@ -2909,32 +2909,39 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2909
2909
return exe_module_sp->GetArchitecture ().GetTriple ();
2910
2910
};
2911
2911
2912
- ArchSpec active_arch ;
2913
- llvm::Triple active_triple ;
2912
+ ArchSpec module_arch ;
2913
+ llvm::Triple module_triple ;
2914
2914
if (sc.module_sp ) {
2915
- active_arch = sc.module_sp ->GetArchitecture ();
2916
- active_triple = active_arch .GetTriple ();
2915
+ module_arch = sc.module_sp ->GetArchitecture ();
2916
+ module_triple = module_arch .GetTriple ();
2917
2917
}
2918
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 ();
2919
+ ArchSpec target_arch = target.GetArchitecture ();
2920
+ llvm::Triple target_triple = target_arch.GetTriple ();
2921
+
2922
+ ArchSpec preferred_arch;
2923
+ llvm::Triple preferred_triple;
2924
+ if (module_arch && module_triple != llvm::Triple ()) {
2925
+ preferred_arch = module_arch;
2926
+ preferred_triple = module_triple;
2927
+ } else {
2928
+ // When no module triple, fallback to the target triple.
2929
+ preferred_arch = target_arch;
2930
+ preferred_triple = target_triple;
2923
2931
}
2924
2932
2925
2933
llvm::Triple computed_triple;
2926
-
2927
- if (active_arch.IsFullySpecifiedTriple ()) {
2934
+ if (preferred_arch.IsFullySpecifiedTriple ()) {
2928
2935
// If a fully specified triple was passed in, for example
2929
2936
// through CreateTargetWithFileAndTargetTriple(), prefer that.
2930
2937
LOG_PRINTF (GetLog (LLDBLog::Types), " Fully specified target triple %s." ,
2931
- active_triple .str ().c_str ());
2932
- computed_triple = active_arch. GetTriple () ;
2938
+ preferred_triple .str ().c_str ());
2939
+ computed_triple = preferred_triple ;
2933
2940
} else {
2934
2941
// Underspecified means that one or more of vendor, os, or os
2935
2942
// version (Darwin only) is missing.
2936
2943
LOG_PRINTF (GetLog (LLDBLog::Types), " Underspecified target triple %s." ,
2937
- active_triple .str ().c_str ());
2944
+ preferred_triple .str ().c_str ());
2938
2945
llvm::VersionTuple platform_version;
2939
2946
PlatformSP platform_sp (target.GetPlatform ());
2940
2947
if (platform_sp)
@@ -2951,16 +2958,16 @@ lldb::TypeSystemSP SwiftASTContext::CreateInstance(
2951
2958
// present, since there might be some ambiguity about the
2952
2959
// plaform (e.g., ios-macabi runs on the macOS, but uses iOS
2953
2960
// version numbers).
2954
- if (!platform_version.empty () &&
2955
- active_triple. getEnvironment () == llvm::Triple::UnknownEnvironment) {
2961
+ if (!platform_version.empty () && preferred_triple. getEnvironment () ==
2962
+ llvm::Triple::UnknownEnvironment) {
2956
2963
LOG_PRINTF (GetLog (LLDBLog::Types), " Completing triple based on platform." );
2957
2964
2958
2965
llvm::SmallString<32 > buffer;
2959
2966
{
2960
2967
llvm::raw_svector_ostream os (buffer);
2961
- os << active_triple .getArchName () << ' -' ;
2962
- os << active_triple .getVendorName () << ' -' ;
2963
- os << llvm::Triple::getOSTypeName (active_triple .getOS ());
2968
+ os << preferred_triple .getArchName () << ' -' ;
2969
+ os << preferred_triple .getVendorName () << ' -' ;
2970
+ os << llvm::Triple::getOSTypeName (preferred_triple .getOS ());
2964
2971
os << platform_version.getAsString ();
2965
2972
}
2966
2973
computed_triple = llvm::Triple (buffer);
0 commit comments