[llvm] [TextAPI] Update RecordSlice attributes to follow code guidelines (PR #74743)

Cyndy Ishida via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 10:35:44 PST 2023


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

Came across simple code cleanup while upstreaming more code, this is primarily an NFC.

>From d4f84b209ae543b8c4d55ca3e389a2e943f41964 Mon Sep 17 00:00:00 2001
From: Cyndy Ishida <cyndy_ishida at apple.com>
Date: Thu, 7 Dec 2023 10:31:56 -0800
Subject: [PATCH] [TextAPI] Update RecordSlice attributes to follow code
 guidelines

Came across simple code cleanup while upstreaming more code, this is primarily an NFC.
---
 llvm/include/llvm/TextAPI/RecordsSlice.h | 9 ++++++---
 llvm/unittests/TextAPI/RecordTests.cpp   | 6 +++---
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/llvm/include/llvm/TextAPI/RecordsSlice.h b/llvm/include/llvm/TextAPI/RecordsSlice.h
index 779321c96efdc7..8d733fd797ec51 100644
--- a/llvm/include/llvm/TextAPI/RecordsSlice.h
+++ b/llvm/include/llvm/TextAPI/RecordsSlice.h
@@ -128,7 +128,7 @@ class RecordsSlice {
   bool hasBinaryAttrs() const { return BA.get(); }
 
   // Determine if record slice is unassigned.
-  bool isEmpty() const {
+  bool empty() const {
     return !hasBinaryAttrs() && Globals.empty() && Classes.empty() &&
            Categories.empty();
   }
@@ -141,7 +141,7 @@ class RecordsSlice {
     StringRef InstallName;
     StringRef UUID;
     StringRef Path;
-    FileType fileType = FileType::Invalid;
+    FileType File = FileType::Invalid;
     llvm::MachO::PackedVersion CurrentVersion;
     llvm::MachO::PackedVersion CompatVersion;
     uint8_t SwiftABI = 0;
@@ -153,6 +153,10 @@ class RecordsSlice {
   /// Return reference to BinaryAttrs.
   BinaryAttrs &getBinaryAttrs();
 
+  /// Store any strings owned by RecordSlice into allocator and return back
+  /// reference to that.
+  StringRef copyString(StringRef String);
+
 private:
   const llvm::Triple TargetTriple;
   // Hold tapi converted triple to avoid unecessary casts.
@@ -160,7 +164,6 @@ class RecordsSlice {
 
   /// BumpPtrAllocator to store generated/copied strings.
   llvm::BumpPtrAllocator StringAllocator;
-  StringRef copyString(StringRef String);
 
   /// Promote linkage of requested record. It is no-op if linkage type is lower
   /// than the current assignment.
diff --git a/llvm/unittests/TextAPI/RecordTests.cpp b/llvm/unittests/TextAPI/RecordTests.cpp
index 076137de6ff1f4..dbe58ca0eea59d 100644
--- a/llvm/unittests/TextAPI/RecordTests.cpp
+++ b/llvm/unittests/TextAPI/RecordTests.cpp
@@ -48,7 +48,7 @@ TEST(TAPIRecord, SimpleObjC) {
 TEST(TAPIRecord, SimpleSlice) {
   Triple T("arm64-apple-macosx13.3");
   RecordsSlice Slice(T);
-  EXPECT_TRUE(Slice.isEmpty());
+  EXPECT_TRUE(Slice.empty());
   Slice.addRecord("_OBJC_CLASS_$_NSObject", SymbolFlags::None,
                   GlobalRecord::Kind::Unknown, RecordLinkage::Rexported);
   Slice.addRecord("_OBJC_METACLASS_$_NSObject", SymbolFlags::None,
@@ -59,7 +59,7 @@ TEST(TAPIRecord, SimpleSlice) {
                   GlobalRecord::Kind::Unknown, RecordLinkage::Exported);
   Slice.addRecord("_foo", SymbolFlags::WeakDefined | SymbolFlags::Rexported,
                   GlobalRecord::Kind::Variable, RecordLinkage::Rexported);
-  EXPECT_FALSE(Slice.isEmpty());
+  EXPECT_FALSE(Slice.empty());
 
   // Check global.
   EXPECT_FALSE(Slice.findGlobal("_foo", GlobalRecord::Kind::Function));
@@ -108,7 +108,7 @@ TEST(TAPIRecord, SimpleSlice) {
 TEST(TAPIRecord, LibraryAttrs) {
   Triple T("arm64-apple-ios15.1");
   RecordsSlice Slice(T);
-  EXPECT_TRUE(Slice.isEmpty());
+  EXPECT_TRUE(Slice.empty());
 
   auto BA = Slice.getBinaryAttrs();
   EXPECT_TRUE(Slice.hasBinaryAttrs());



More information about the llvm-commits mailing list