diff --git a/llvm/include/llvm/InterfaceStub/ELFStub.h b/llvm/include/llvm/InterfaceStub/ELFStub.h --- a/llvm/include/llvm/InterfaceStub/ELFStub.h +++ b/llvm/include/llvm/InterfaceStub/ELFStub.h @@ -45,12 +45,18 @@ bool operator<(const ELFSymbol &RHS) const { return Name < RHS.Name; } }; +class TBEVersion : public VersionTuple { +public: + TBEVersion(unsigned Major, unsigned Minor) : VersionTuple(Major, Minor) {} + TBEVersion() : VersionTuple() {} +}; + // A cumulative representation of ELF stubs. // Both textual and binary stubs will read into and write from this object. class ELFStub { // TODO: Add support for symbol versioning. public: - VersionTuple TbeVersion; + TBEVersion TbeVersion; Optional SoName; ELFArch Arch; std::vector NeededLibs; diff --git a/llvm/include/llvm/InterfaceStub/TBEHandler.h b/llvm/include/llvm/InterfaceStub/TBEHandler.h --- a/llvm/include/llvm/InterfaceStub/TBEHandler.h +++ b/llvm/include/llvm/InterfaceStub/TBEHandler.h @@ -15,8 +15,8 @@ #ifndef LLVM_TEXTAPI_ELF_TBEHANDLER_H #define LLVM_TEXTAPI_ELF_TBEHANDLER_H +#include "llvm/InterfaceStub/ELFStub.h" #include "llvm/Support/Error.h" -#include "llvm/Support/VersionTuple.h" #include namespace llvm { @@ -27,9 +27,7 @@ namespace elfabi { -class ELFStub; - -const VersionTuple TBEVersionCurrent(1, 0); +const TBEVersion TBEVersionCurrent(1, 0); /// Attempts to read an ELF interface file from a StringRef buffer. Expected> readTBEFromBuffer(StringRef Buf); diff --git a/llvm/lib/InterfaceStub/TBEHandler.cpp b/llvm/lib/InterfaceStub/TBEHandler.cpp --- a/llvm/lib/InterfaceStub/TBEHandler.cpp +++ b/llvm/lib/InterfaceStub/TBEHandler.cpp @@ -70,13 +70,13 @@ }; /// YAML traits for TbeVersion. -template <> struct ScalarTraits { - static void output(const VersionTuple &Value, void *, - llvm::raw_ostream &Out) { + +template <> struct ScalarTraits { + static void output(const TBEVersion &Value, void *, llvm::raw_ostream &Out) { Out << Value.getAsString(); } - static StringRef input(StringRef Scalar, void *, VersionTuple &Value) { + static StringRef input(StringRef Scalar, void *, TBEVersion &Value) { if (Value.tryParse(Scalar)) return StringRef("Can't parse version: invalid version format."); diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -34,10 +34,6 @@ #define DEBUG_TYPE "llvm-ifs" -namespace { -const VersionTuple IFSVersionCurrent(2, 0); -} // end anonymous namespace - static cl::opt Action("action", cl::desc(""), cl::value_desc("write-ifs | write-bin"), cl::init("write-ifs")); @@ -89,6 +85,16 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(IFSSymbol) +class IFSVersion : public VersionTuple { +public: + IFSVersion(unsigned Major, unsigned Minor) : VersionTuple(Major, Minor) {} + IFSVersion() : VersionTuple() {} +}; + +namespace { +const IFSVersion IFSVersionCurrent(2, 0); +} // end anonymous namespace + namespace llvm { namespace yaml { /// YAML traits for IFSSymbolType. @@ -104,13 +110,12 @@ } }; -template <> struct ScalarTraits { - static void output(const VersionTuple &Value, void *, - llvm::raw_ostream &Out) { +template <> struct ScalarTraits { + static void output(const IFSVersion &Value, void *, llvm::raw_ostream &Out) { Out << Value.getAsString(); } - static StringRef input(StringRef Scalar, void *, VersionTuple &Value) { + static StringRef input(StringRef Scalar, void *, IFSVersion &Value) { if (Value.tryParse(Scalar)) return StringRef("Can't parse version: invalid version format."); @@ -153,7 +158,7 @@ class IFSStub { // TODO: Add support for symbol versioning. public: - VersionTuple IfsVersion; + IFSVersion IfsVersion; std::string Triple; std::string ObjectFileFormat; Optional SOName; diff --git a/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp b/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp --- a/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp +++ b/llvm/unittests/InterfaceStub/ELFYAMLTest.cpp @@ -156,7 +156,7 @@ " not: { Type: Unknown, Size: 12345678901234 }\n" "...\n"; ELFStub Stub; - Stub.TbeVersion = VersionTuple(1, 0); + Stub.TbeVersion = TBEVersion(1, 0); Stub.Arch = ELF::EM_AARCH64; ELFSymbol SymFoo("foo"); @@ -212,7 +212,7 @@ "Symbols: {}\n" "...\n"; ELFStub Stub; - Stub.TbeVersion = VersionTuple(1, 0); + Stub.TbeVersion = TBEVersion(1, 0); Stub.SoName = "nosyms.so"; Stub.Arch = ELF::EM_X86_64; Stub.NeededLibs.push_back("libc.so");