[llvm] [TextAPI] Add an assertion for adding duplicate libraries into a single TBD file (PR #101744)

Cyndy Ishida via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 12:55:07 PDT 2024


https://github.com/cyndyishida created https://github.com/llvm/llvm-project/pull/101744

This would lead to a malformed TBD file.

>From 3d811fd37ea7e770ea20386a1dfe5c78b49101a0 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida <cyndy_ishida at apple.com>
Date: Fri, 2 Aug 2024 12:40:05 -0700
Subject: [PATCH] [TextAPI] Add an assertion for adding duplicate libraries
 into a single TBD file

This would lead to a malformed TBD file.
---
 llvm/lib/TextAPI/InterfaceFile.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp
index 79694c90370f4..efbf33b74776e 100644
--- a/llvm/lib/TextAPI/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/InterfaceFile.cpp
@@ -87,6 +87,9 @@ void InterfaceFile::addDocument(std::shared_ptr<InterfaceFile> &&Document) {
                                   const std::shared_ptr<InterfaceFile> &RHS) {
                                  return LHS->InstallName < RHS->InstallName;
                                });
+  assert((Pos == Documents.end() ||
+          (*Pos)->InstallName != Document->InstallName) &&
+         "Unexpected duplicate document added");
   Document->Parent = this;
   Documents.insert(Pos, Document);
 }



More information about the llvm-commits mailing list