Skip to content

Commit ad7ff2b

Browse files
make function local to the file
1 parent c5dafab commit ad7ff2b

File tree

2 files changed

+34
-38
lines changed

2 files changed

+34
-38
lines changed

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,40 @@ PlatformDarwin::ExtractAppSpecificInfo(Process &process) {
10301030
return dict_sp;
10311031
}
10321032

1033+
static llvm::Expected<lldb_private::FileSpec>
1034+
ResolveSDKPathFromDebugInfo(lldb_private::Target *target) {
1035+
1036+
ModuleSP exe_module_sp = target->GetExecutableModule();
1037+
if (!exe_module_sp)
1038+
return llvm::createStringError("Failed to get module from target");
1039+
1040+
SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1041+
if (!sym_file)
1042+
return llvm::createStringError("Failed to get symbol file from module");
1043+
1044+
XcodeSDK merged_sdk;
1045+
for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
1046+
if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
1047+
auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
1048+
merged_sdk.Merge(cu_sdk);
1049+
}
1050+
}
1051+
1052+
// TODO: The result of this loop is almost equivalent to deriving the SDK
1053+
// from the target triple, which would be a lot cheaper.
1054+
FileSpec sdk_path = merged_sdk.GetSysroot();
1055+
if (FileSystem::Instance().Exists(sdk_path)) {
1056+
return sdk_path;
1057+
}
1058+
auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
1059+
if (!path_or_err)
1060+
return llvm::createStringError(
1061+
llvm::formatv("Failed to resolve SDK path: {0}",
1062+
llvm::toString(path_or_err.takeError())));
1063+
1064+
return FileSpec(*path_or_err);
1065+
}
1066+
10331067
void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
10341068
Target *target, std::vector<std::string> &options, XcodeSDK::Type sdk_type) {
10351069
const std::vector<std::string> apple_arguments = {
@@ -1150,41 +1184,6 @@ void PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
11501184
}
11511185
}
11521186

1153-
llvm::Expected<lldb_private::FileSpec>
1154-
lldb_private::PlatformDarwin::ResolveSDKPathFromDebugInfo(
1155-
lldb_private::Target *target) {
1156-
1157-
ModuleSP exe_module_sp = target->GetExecutableModule();
1158-
if (!exe_module_sp)
1159-
return llvm::createStringError("Failed to get module from target");
1160-
1161-
SymbolFile *sym_file = exe_module_sp->GetSymbolFile();
1162-
if (!sym_file)
1163-
return llvm::createStringError("Failed to get symbol file from module");
1164-
1165-
XcodeSDK merged_sdk;
1166-
for (unsigned i = 0; i < sym_file->GetNumCompileUnits(); ++i) {
1167-
if (auto cu_sp = sym_file->GetCompileUnitAtIndex(i)) {
1168-
auto cu_sdk = sym_file->ParseXcodeSDK(*cu_sp);
1169-
merged_sdk.Merge(cu_sdk);
1170-
}
1171-
}
1172-
1173-
// TODO: The result of this loop is almost equivalent to deriving the SDK
1174-
// from the target triple, which would be a lot cheaper.
1175-
FileSpec sdk_path = merged_sdk.GetSysroot();
1176-
if (FileSystem::Instance().Exists(sdk_path)) {
1177-
return sdk_path;
1178-
}
1179-
auto path_or_err = HostInfo::GetSDKRoot(HostInfo::SDKOptions{merged_sdk});
1180-
if (path_or_err)
1181-
return FileSpec(*path_or_err);
1182-
1183-
return llvm::createStringError(
1184-
llvm::formatv("Failed to resolve SDK path: {0}",
1185-
llvm::toString(path_or_err.takeError()));
1186-
}
1187-
11881187
ConstString PlatformDarwin::GetFullNameForDylib(ConstString basename) {
11891188
if (basename.IsEmpty())
11901189
return basename;

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ class PlatformDarwin : public PlatformPOSIX {
187187
std::vector<std::string> &options,
188188
XcodeSDK::Type sdk_type);
189189

190-
static llvm::Expected<FileSpec>
191-
ResolveSDKPathFromDebugInfo(lldb_private::Target *target);
192-
193190
Status FindBundleBinaryInExecSearchPaths(
194191
const ModuleSpec &module_spec, Process *process,
195192
lldb::ModuleSP &module_sp, const FileSpecList *module_search_paths_ptr,

0 commit comments

Comments
 (0)