From bc85cf1687435f28fb01b1aa5303317e6118490c Mon Sep 17 00:00:00 2001 From: Cyndy Ishida Date: Wed, 22 Feb 2023 17:13:14 -0800 Subject: [TextAPI] Add support for TBDv5 Files to nm & tapi-diff This includes handling of new attributes for symbols & rpath. In the event that an older format file is compared to tbd_v5, ignore these new attributes. Reviewed By: ributzka Differential Revision: https://reviews.llvm.org/D144529 --- llvm/lib/TextAPI/InterfaceFile.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'llvm/lib/TextAPI/InterfaceFile.cpp') diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp index f9b5e95d5f6f..5d3cf851dadc 100644 --- a/llvm/lib/TextAPI/InterfaceFile.cpp +++ b/llvm/lib/TextAPI/InterfaceFile.cpp @@ -141,6 +141,10 @@ void InterfaceFile::addDocument(std::shared_ptr &&Document) { Documents.insert(Pos, Document); } +static bool isYAMLTextStub(const FileType &Kind) { + return (Kind >= FileType::TBD_V1) && (Kind < FileType::TBD_V5); +} + bool InterfaceFile::operator==(const InterfaceFile &O) const { if (Targets != O.Targets) return false; @@ -165,6 +169,13 @@ bool InterfaceFile::operator==(const InterfaceFile &O) const { return false; if (Symbols != O.Symbols) return false; + // Don't compare run search paths for older filetypes that cannot express + // them. + if (!(isYAMLTextStub(FileKind)) && !(isYAMLTextStub(O.FileKind))) { + if (RPaths != O.RPaths) + return false; + } + if (!std::equal(Documents.begin(), Documents.end(), O.Documents.begin(), O.Documents.end(), [](const std::shared_ptr LHS, -- cgit v1.2.3