[llvm] 5d806e2 - [XCOFF] Clean-up enum use in BinaryFormat/XCOFF.h; NFC

Hubert Tong via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 17:48:37 PDT 2020


Author: Hubert Tong
Date: 2020-04-30T20:48:30-04:00
New Revision: 5d806e254e81411698089761aa4b441882a86b07

URL: https://github.com/llvm/llvm-project/commit/5d806e254e81411698089761aa4b441882a86b07
DIFF: https://github.com/llvm/llvm-project/commit/5d806e254e81411698089761aa4b441882a86b07.diff

LOG: [XCOFF] Clean-up enum use in BinaryFormat/XCOFF.h; NFC

Summary:
This patch splits mostly unrelated size constants into separate
constexpr variables, sets explicit underlying types for the enumerations
to match the fields they are used for, and improves various comments.

This patch also replaces `<cname>` headers with `<name.h>` headers to
match the usage of the declared names as global namespace members in the
file.

Reviewers: jasonliu, DiggerLin, daltenty, sfertile

Reviewed By: jasonliu, sfertile

Differential Revision: https://reviews.llvm.org/D79136

Added: 
    

Modified: 
    llvm/include/llvm/BinaryFormat/XCOFF.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/BinaryFormat/XCOFF.h b/llvm/include/llvm/BinaryFormat/XCOFF.h
index f09938a5788f..130e1d8262b1 100644
--- a/llvm/include/llvm/BinaryFormat/XCOFF.h
+++ b/llvm/include/llvm/BinaryFormat/XCOFF.h
@@ -13,7 +13,8 @@
 #ifndef LLVM_BINARYFORMAT_XCOFF_H
 #define LLVM_BINARYFORMAT_XCOFF_H
 
-#include <cstdint>
+#include <stddef.h>
+#include <stdint.h>
 
 namespace llvm {
 class StringRef;
@@ -21,14 +22,13 @@ class StringRef;
 namespace XCOFF {
 
 // Constants used in the XCOFF definition.
-enum {
-  FileNamePadSize = 6,
-  NameSize = 8,
-  SymbolTableEntrySize = 18,
-  RelocationSerializationSize32 = 10
-};
 
-enum ReservedSectionNum { N_DEBUG = -2, N_ABS = -1, N_UNDEF = 0 };
+constexpr size_t FileNamePadSize = 6;
+constexpr size_t NameSize = 8;
+constexpr size_t SymbolTableEntrySize = 18;
+constexpr size_t RelocationSerializationSize32 = 10;
+
+enum ReservedSectionNum : int16_t { N_DEBUG = -2, N_ABS = -1, N_UNDEF = 0 };
 
 // x_smclas field of x_csect from system header: /usr/include/syms.h
 /// Storage Mapping Class definitions.
@@ -60,9 +60,10 @@ enum StorageMappingClass : uint8_t {
   XMC_TE = 22  ///< Symbol mapped at the end of TOC
 };
 
-// Flags for defining the section type. Used for the s_flags field of
-// the section header structure. Defined in the system header `scnhdr.h`.
-enum SectionTypeFlags {
+// Flags for defining the section type. Masks for use with the (signed, 32-bit)
+// s_flags field of the section header structure, selecting for values in the
+// lower 16 bits. Defined in the system header `scnhdr.h`.
+enum SectionTypeFlags : int32_t {
   STYP_PAD = 0x0008,
   STYP_DWARF = 0x0010,
   STYP_TEXT = 0x0020,
@@ -147,7 +148,10 @@ enum StorageClass : uint8_t {
   C_TCSYM = 134 // Reserved
 };
 
-enum SymbolType {
+// Flags for defining the symbol type. Values to be encoded into the lower 3
+// bits of the (unsigned, 8-bit) x_smtyp field of csect auxiliary symbol table
+// entries. Defined in the system header `syms.h`.
+enum SymbolType : uint8_t {
   XTY_ER = 0, ///< External reference.
   XTY_SD = 1, ///< Csect definition for initialized storage.
   XTY_LD = 2, ///< Label definition.


        


More information about the llvm-commits mailing list