[llvm] [TextAPI] Skip adding empty attributes (PR #77400)

Cyndy Ishida via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 17:09:54 PST 2024


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

An empty string attribute value (e.g. a parent-umbrella: "") is equivalent to omitting it. Theres no reason to write it out.

>From 9dabaa6463737ae5945b4dbca37a04b6217a6e8c Mon Sep 17 00:00:00 2001
From: Cyndy Ishida <cyndy_ishida at apple.com>
Date: Mon, 8 Jan 2024 17:06:46 -0800
Subject: [PATCH] [TextAPI] Skip adding empty attributes

An empty string attribute value (e.g. a parent-umbrella: "") is
equivalent to omitting it. Theres no reason to write it out.
---
 llvm/lib/TextAPI/InterfaceFile.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp
index 3689ab9191915a..d712ed3868258d 100644
--- a/llvm/lib/TextAPI/InterfaceFile.cpp
+++ b/llvm/lib/TextAPI/InterfaceFile.cpp
@@ -24,17 +24,23 @@ void InterfaceFileRef::addTarget(const Target &Target) {
 
 void InterfaceFile::addAllowableClient(StringRef InstallName,
                                        const Target &Target) {
+  if (InstallName.empty())
+    return;
   auto Client = addEntry(AllowableClients, InstallName);
   Client->addTarget(Target);
 }
 
 void InterfaceFile::addReexportedLibrary(StringRef InstallName,
                                          const Target &Target) {
+  if (InstallName.empty())
+    return;
   auto Lib = addEntry(ReexportedLibraries, InstallName);
   Lib->addTarget(Target);
 }
 
 void InterfaceFile::addParentUmbrella(const Target &Target_, StringRef Parent) {
+  if (Parent.empty())
+    return;
   auto Iter = lower_bound(ParentUmbrellas, Target_,
                           [](const std::pair<Target, std::string> &LHS,
                              Target RHS) { return LHS.first < RHS; });
@@ -48,6 +54,8 @@ void InterfaceFile::addParentUmbrella(const Target &Target_, StringRef Parent) {
 }
 
 void InterfaceFile::addRPath(const Target &InputTarget, StringRef RPath) {
+  if (RPath.empty())
+    return;
   using RPathEntryT = const std::pair<Target, std::string>;
   RPathEntryT Entry(InputTarget, RPath);
   auto Iter =



More information about the llvm-commits mailing list