[llvm] a76f3d0 - [dsymutil] Make copySwiftInterfaces a member of DwarfLinkerForBinary (NFC)
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 4 21:57:48 PDT 2023
Author: Jonas Devlieghere
Date: 2023-04-04T21:57:41-07:00
New Revision: a76f3d0d4ec992ba1efd94f34810161e847e976d
URL: https://github.com/llvm/llvm-project/commit/a76f3d0d4ec992ba1efd94f34810161e847e976d
DIFF: https://github.com/llvm/llvm-project/commit/a76f3d0d4ec992ba1efd94f34810161e847e976d.diff
LOG: [dsymutil] Make copySwiftInterfaces a member of DwarfLinkerForBinary (NFC)
Make copySwiftInterfaces a member of DwarfLinkerForBinary instead of a
static function.
Added:
Modified:
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.h
Removed:
################################################################################
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
index 6d2b4c593edb..4ece4767c329 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
@@ -105,42 +105,6 @@ static mc::RegisterMCTargetOptionsFlags MOF;
namespace dsymutil {
-static Error copySwiftInterfaces(
- const std::map<std::string, std::string> &ParseableSwiftInterfaces,
- StringRef Architecture, const LinkOptions &Options) {
- std::error_code EC;
- SmallString<128> InputPath;
- SmallString<128> Path;
- sys::path::append(Path, *Options.ResourceDir, "Swift", Architecture);
- if ((EC = sys::fs::create_directories(Path.str(), true,
- sys::fs::perms::all_all)))
- return make_error<StringError>(
- "cannot create directory: " + toString(errorCodeToError(EC)), EC);
- unsigned BaseLength = Path.size();
-
- for (auto &I : ParseableSwiftInterfaces) {
- StringRef ModuleName = I.first;
- StringRef InterfaceFile = I.second;
- if (!Options.PrependPath.empty()) {
- InputPath.clear();
- sys::path::append(InputPath, Options.PrependPath, InterfaceFile);
- InterfaceFile = InputPath;
- }
- sys::path::append(Path, ModuleName);
- Path.append(".swiftinterface");
- if (Options.Verbose)
- outs() << "copy parseable Swift interface " << InterfaceFile << " -> "
- << Path.str() << '\n';
-
- // copy_file attempts an APFS clone first, so this should be cheap.
- if ((EC = sys::fs::copy_file(InterfaceFile, Path.str())))
- warn(Twine("cannot copy parseable Swift interface ") + InterfaceFile +
- ": " + toString(errorCodeToError(EC)));
- Path.resize(BaseLength);
- }
- return Error::success();
-}
-
/// Report a warning to the user, optionally including information about a
/// specific \p DIE related to the warning.
void DwarfLinkerForBinary::reportWarning(const Twine &Warning,
@@ -490,6 +454,40 @@ void DwarfLinkerForBinary::collectRelocationsToApplyToSwiftReflectionSections(
}
}
+Error DwarfLinkerForBinary::copySwiftInterfaces(StringRef Architecture) const {
+ std::error_code EC;
+ SmallString<128> InputPath;
+ SmallString<128> Path;
+ sys::path::append(Path, *Options.ResourceDir, "Swift", Architecture);
+ if ((EC = sys::fs::create_directories(Path.str(), true,
+ sys::fs::perms::all_all)))
+ return make_error<StringError>(
+ "cannot create directory: " + toString(errorCodeToError(EC)), EC);
+ unsigned BaseLength = Path.size();
+
+ for (auto &I : ParseableSwiftInterfaces) {
+ StringRef ModuleName = I.first;
+ StringRef InterfaceFile = I.second;
+ if (!Options.PrependPath.empty()) {
+ InputPath.clear();
+ sys::path::append(InputPath, Options.PrependPath, InterfaceFile);
+ InterfaceFile = InputPath;
+ }
+ sys::path::append(Path, ModuleName);
+ Path.append(".swiftinterface");
+ if (Options.Verbose)
+ outs() << "copy parseable Swift interface " << InterfaceFile << " -> "
+ << Path.str() << '\n';
+
+ // copy_file attempts an APFS clone first, so this should be cheap.
+ if ((EC = sys::fs::copy_file(InterfaceFile, Path.str())))
+ warn(Twine("cannot copy parseable Swift interface ") + InterfaceFile +
+ ": " + toString(errorCodeToError(EC)));
+ Path.resize(BaseLength);
+ }
+ return Error::success();
+}
+
void DwarfLinkerForBinary::copySwiftReflectionMetadata(
const llvm::dsymutil::DebugMapObject *Obj, DwarfStreamer *Streamer,
std::vector<uint64_t> &SectionToOffsetInDwarf,
@@ -762,8 +760,7 @@ bool DwarfLinkerForBinary::link(const DebugMap &Map) {
if (Options.ResourceDir && !ParseableSwiftInterfaces.empty()) {
StringRef ArchName = Triple::getArchTypeName(Map.getTriple().getArch());
- if (auto E =
- copySwiftInterfaces(ParseableSwiftInterfaces, ArchName, Options))
+ if (auto E = copySwiftInterfaces(ArchName))
return error(toString(std::move(E)));
}
diff --git a/llvm/tools/dsymutil/DwarfLinkerForBinary.h b/llvm/tools/dsymutil/DwarfLinkerForBinary.h
index 7fd15a1eb71f..742580f27248 100644
--- a/llvm/tools/dsymutil/DwarfLinkerForBinary.h
+++ b/llvm/tools/dsymutil/DwarfLinkerForBinary.h
@@ -211,6 +211,8 @@ class DwarfLinkerForBinary {
std::vector<MachOUtils::DwarfRelocationApplicationInfo>
&RelocationsToApply) const;
+ Error copySwiftInterfaces(StringRef Architecture) const;
+
void copySwiftReflectionMetadata(
const llvm::dsymutil::DebugMapObject *Obj, DwarfStreamer *Streamer,
std::vector<uint64_t> &SectionToOffsetInDwarf,
More information about the llvm-commits
mailing list