[llvm] WIP [readobj][AArch64] Parse AArch64 build attributes (PR #124276)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 07:45:42 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 3019e49ebfc5d710191712b6d437c56c01e65b87 c924bb0e94748c354e9cf7f279e1fb7617346ed3 --extensions h,cpp -- llvm/include/llvm/Support/AArch64AttributeParser.h llvm/lib/Support/AArch64AttributeParser.cpp llvm/include/llvm/Object/ELFObjectFile.h llvm/include/llvm/Support/AArch64BuildAttributes.h llvm/include/llvm/Support/ELFAttributeParser.h llvm/lib/Support/AArch64BuildAttributes.cpp llvm/lib/Support/ELFAttributeParser.cpp llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.cpp llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h llvm/tools/llvm-readobj/ELFDumper.cpp llvm/unittests/Support/ELFAttributeParserTest.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 454dab9310..982555527a 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -477,35 +477,45 @@ void AArch64AsmPrinter::emitAttributes(unsigned Flags,
 
   if (PAuthABIPlatform || PAuthABIVersion) {
     TS->emitAtributesSubsection(
-        AArch64BuildAttributes::getVendorName(AArch64BuildAttributes::AEABI_PAUTHABI),
+        AArch64BuildAttributes::getVendorName(
+            AArch64BuildAttributes::AEABI_PAUTHABI),
         AArch64BuildAttributes::SubsectionOptional::REQUIRED,
         AArch64BuildAttributes::SubsectionType::ULEB128);
-    TS->emitAttribute(
-        AArch64BuildAttributes::getVendorName(AArch64BuildAttributes::AEABI_PAUTHABI),
-        AArch64BuildAttributes::TAG_PAUTH_PLATFORM, PAuthABIPlatform, "", false);
-    TS->emitAttribute(
-        AArch64BuildAttributes::getVendorName(AArch64BuildAttributes::AEABI_PAUTHABI),
-        AArch64BuildAttributes::TAG_PAUTH_SCHEMA, PAuthABIVersion, "", false);
+    TS->emitAttribute(AArch64BuildAttributes::getVendorName(
+                          AArch64BuildAttributes::AEABI_PAUTHABI),
+                      AArch64BuildAttributes::TAG_PAUTH_PLATFORM,
+                      PAuthABIPlatform, "", false);
+    TS->emitAttribute(AArch64BuildAttributes::getVendorName(
+                          AArch64BuildAttributes::AEABI_PAUTHABI),
+                      AArch64BuildAttributes::TAG_PAUTH_SCHEMA, PAuthABIVersion,
+                      "", false);
   }
 
-  unsigned BTIValue = (Flags & AArch64BuildAttributes::Feature_BTI_Flag) ? 1 : 0;
-  unsigned PACValue = (Flags & AArch64BuildAttributes::Feature_PAC_Flag) ? 1 : 0;
-  unsigned GCSValue = (Flags & AArch64BuildAttributes::Feature_GCS_Flag) ? 1 : 0;
+  unsigned BTIValue =
+      (Flags & AArch64BuildAttributes::Feature_BTI_Flag) ? 1 : 0;
+  unsigned PACValue =
+      (Flags & AArch64BuildAttributes::Feature_PAC_Flag) ? 1 : 0;
+  unsigned GCSValue =
+      (Flags & AArch64BuildAttributes::Feature_GCS_Flag) ? 1 : 0;
 
   if (BTIValue || PACValue || GCSValue) {
-    TS->emitAtributesSubsection(AArch64BuildAttributes::getVendorName(
-                                    AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
-                                AArch64BuildAttributes::SubsectionOptional::OPTIONAL,
-                                AArch64BuildAttributes::SubsectionType::ULEB128);
+    TS->emitAtributesSubsection(
+        AArch64BuildAttributes::getVendorName(
+            AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
+        AArch64BuildAttributes::SubsectionOptional::OPTIONAL,
+        AArch64BuildAttributes::SubsectionType::ULEB128);
     TS->emitAttribute(AArch64BuildAttributes::getVendorName(
                           AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
-                      AArch64BuildAttributes::TAG_FEATURE_BTI, BTIValue, "", false);
+                      AArch64BuildAttributes::TAG_FEATURE_BTI, BTIValue, "",
+                      false);
     TS->emitAttribute(AArch64BuildAttributes::getVendorName(
                           AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
-                      AArch64BuildAttributes::TAG_FEATURE_PAC, PACValue, "", false);
+                      AArch64BuildAttributes::TAG_FEATURE_PAC, PACValue, "",
+                      false);
     TS->emitAttribute(AArch64BuildAttributes::getVendorName(
                           AArch64BuildAttributes::AEABI_FEATURE_AND_BITS),
-                      AArch64BuildAttributes::TAG_FEATURE_GCS, GCSValue, "", false);
+                      AArch64BuildAttributes::TAG_FEATURE_GCS, GCSValue, "",
+                      false);
   }
 }
 
diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
index 9cd74022cb..5b42a7e2b5 100644
--- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -7923,12 +7923,13 @@ bool AArch64AsmParser::parseDirectiveAeabiSubSectionHeader(SMLoc L) {
     }
     if (SubsectionExists) {
       if (Type != SubsectionExists->ParameterType) {
-        Error(
-            Parser.getTok().getLoc(),
-            "type mismatch! subsection '" + SubsectionName +
-                "' already exists with type defined as '" +
-                AArch64BuildAttributes::getTypeStr(SubsectionExists->ParameterType) +
-                "' and not '" + AArch64BuildAttributes::getTypeStr(Type) + "'");
+        Error(Parser.getTok().getLoc(),
+              "type mismatch! subsection '" + SubsectionName +
+                  "' already exists with type defined as '" +
+                  AArch64BuildAttributes::getTypeStr(
+                      SubsectionExists->ParameterType) +
+                  "' and not '" + AArch64BuildAttributes::getTypeStr(Type) +
+                  "'");
         return true;
       }
     }
@@ -7981,11 +7982,12 @@ bool AArch64AsmParser::parseDirectiveAeabiAArch64Attr(SMLoc L) {
   unsigned ActiveSubsectionType = ActiveSubsection->ParameterType;
 
   unsigned ActiveSubsectionID = AArch64BuildAttributes::VENDOR_UNKNOWN;
-  if (AArch64BuildAttributes::getVendorName(AArch64BuildAttributes::AEABI_PAUTHABI) ==
-      ActiveSubsectionName)
+  if (AArch64BuildAttributes::getVendorName(
+          AArch64BuildAttributes::AEABI_PAUTHABI) == ActiveSubsectionName)
     ActiveSubsectionID = AArch64BuildAttributes::AEABI_PAUTHABI;
   if (AArch64BuildAttributes::getVendorName(
-          AArch64BuildAttributes::AEABI_FEATURE_AND_BITS) == ActiveSubsectionName)
+          AArch64BuildAttributes::AEABI_FEATURE_AND_BITS) ==
+      ActiveSubsectionName)
     ActiveSubsectionID = AArch64BuildAttributes::AEABI_FEATURE_AND_BITS;
 
   StringRef TagStr = "";
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
index fc7273d85a..bdb4454b02 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -222,7 +222,8 @@ class AArch64TargetAsmStreamer : public AArch64TargetStreamer {
   }
 
   void emitAtributesSubsection(
-      StringRef SubsectionName, AArch64BuildAttributes::SubsectionOptional Optional,
+      StringRef SubsectionName,
+      AArch64BuildAttributes::SubsectionOptional Optional,
       AArch64BuildAttributes::SubsectionType ParameterType) override {
     // The AArch64 build attributes assembly subsection header format:
     // ".aeabi_subsection name, optional, parameter type"
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
index 68bd69fcdd..0e450bdd9a 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
@@ -124,7 +124,8 @@ private:
 
   /// Build attributes implementation
   void emitAtributesSubsection(
-      StringRef VendorName, AArch64BuildAttributes::SubsectionOptional IsOptional,
+      StringRef VendorName,
+      AArch64BuildAttributes::SubsectionOptional IsOptional,
       AArch64BuildAttributes::SubsectionType ParameterType) override;
   void emitAttribute(StringRef VendorName, unsigned Tag, unsigned Value,
                      std::string String, bool Override = false) override;

``````````

</details>


https://github.com/llvm/llvm-project/pull/124276


More information about the llvm-commits mailing list