[llvm] r259123 - Silence gcc warning about ternary and enumerations

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 15:59:36 PST 2016


Author: rnk
Date: Thu Jan 28 17:59:35 2016
New Revision: 259123

URL: http://llvm.org/viewvc/llvm-project?rev=259123&view=rev
Log:
Silence gcc warning about ternary and enumerations

Modified:
    llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
    llvm/trunk/lib/MC/MCCodeView.cpp
    llvm/trunk/tools/llvm-readobj/CodeView.h

Modified: llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h?rev=259123&r1=259122&r2=259123&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/CodeView/TypeRecord.h Thu Jan 28 17:59:35 2016
@@ -19,6 +19,10 @@
 namespace llvm {
 namespace codeview {
 
+using llvm::support::little32_t;
+using llvm::support::ulittle16_t;
+using llvm::support::ulittle32_t;
+
 class TypeRecord {
 protected:
   explicit TypeRecord(TypeRecordKind Kind) : Kind(Kind) {}
@@ -264,6 +268,305 @@ public:
 private:
   ArrayRef<VirtualTableSlotKind> Slots;
 };
+
+//===----------------------------------------------------------------------===//
+// On-disk representation of type information
+
+// A CodeView type stream is a sequence of TypeRecords. Records larger than
+// 65536 must chain on to a second record. Each TypeRecord is followed by one of
+// the leaf types described below.
+struct TypeRecordPrefix {
+  ulittle16_t Len;  // Type record length, starting from &Leaf.
+  ulittle16_t Leaf; // Type record kind (TypeLeafKind)
+};
+
+// LF_TYPESERVER2
+struct TypeServer2 {
+  char Signature[16];  // GUID
+  ulittle32_t Age;
+  // Name: Name of the PDB as a null-terminated string
+};
+
+// LF_STRING_ID
+struct StringId {
+  TypeIndex id;
+};
+
+// LF_FUNC_ID
+struct FuncId {
+  TypeIndex ParentScope;
+  TypeIndex FunctionType;
+  // Name: The null-terminated name follows.
+};
+
+// LF_CLASS, LF_STRUCT, LF_INTERFACE
+struct ClassType {
+  ulittle16_t MemberCount; // Number of members in FieldList.
+  ulittle16_t Properties;  // ClassOptions bitset
+  TypeIndex FieldList;     // LF_FIELDLIST: List of all kinds of members
+  TypeIndex DerivedFrom;   // LF_DERIVED: List of known derived classes
+  TypeIndex VShape;        // LF_VTSHAPE: Shape of the vftable
+  // SizeOf: The 'sizeof' the UDT in bytes is encoded as an LF_NUMERIC integer.
+  // Name: The null-terminated name follows.
+};
+
+// LF_UNION
+struct UnionType {
+  ulittle16_t MemberCount; // Number of members in FieldList.
+  ulittle16_t Properties;  // ClassOptions bitset
+  TypeIndex FieldList;     // LF_FIELDLIST: List of all kinds of members
+  // SizeOf: The 'sizeof' the UDT in bytes is encoded as an LF_NUMERIC integer.
+  // Name: The null-terminated name follows.
+};
+
+// LF_POINTER
+struct PointerType {
+  TypeIndex PointeeType;
+  ulittle32_t Attrs; // pointer attributes
+  // if pointer to member:
+  //   PointerToMemberTail
+
+  PointerKind getPtrKind() const { return PointerKind(Attrs & 0x1f); }
+  PointerMode getPtrMode() const { return PointerMode((Attrs >> 5) & 0x07); }
+  bool isFlat() const { return Attrs & (1 << 8); }
+  bool isVolatile() const { return Attrs & (1 << 9); }
+  bool isConst() const { return Attrs & (1 << 10); }
+  bool isUnaligned() const { return Attrs & (1 << 11); }
+
+  bool isPointerToDataMember() const {
+    return getPtrMode() == PointerMode::PointerToDataMember;
+  }
+  bool isPointerToMemberFunction() const {
+    return getPtrMode() == PointerMode::PointerToMemberFunction;
+  }
+  bool isPointerToMember() const {
+    return isPointerToMemberFunction() || isPointerToDataMember();
+  }
+};
+
+struct PointerToMemberTail {
+  TypeIndex ClassType;
+  ulittle16_t Representation; // PointerToMemberRepresentation
+};
+
+/// In Clang parlance, these are "qualifiers".  LF_MODIFIER
+struct TypeModifier {
+  TypeIndex ModifiedType;
+  ulittle16_t Modifiers; // ModifierOptions
+};
+
+// LF_VTSHAPE
+struct VTableShape {
+  // Number of vftable entries. Each method may have more than one entry due to
+  // things like covariant return types.
+  ulittle16_t VFEntryCount;
+  // Descriptors[]: 4-bit virtual method descriptors of type CV_VTS_desc_e.
+};
+
+// LF_UDT_SRC_LINE
+struct UDTSrcLine {
+  TypeIndex UDT;        // The user-defined type
+  TypeIndex SourceFile; // StringID containing the source filename
+  ulittle32_t LineNumber;
+};
+
+// LF_ARGLIST, LF_SUBSTR_LIST
+struct ArgList {
+  ulittle32_t NumArgs; // Number of arguments
+  // ArgTypes[]: Type indicies of arguments
+};
+
+// LF_BUILDINFO
+struct BuildInfo {
+  ulittle16_t NumArgs; // Number of arguments
+  // ArgTypes[]: Type indicies of arguments
+};
+
+// LF_ENUM
+struct EnumType {
+  ulittle16_t NumEnumerators; // Number of enumerators
+  ulittle16_t Properties;
+  TypeIndex UnderlyingType;
+  TypeIndex FieldListType;
+  // Name: The null-terminated name follows.
+};
+
+// LF_ARRAY
+struct ArrayType {
+  TypeIndex ElementType;
+  TypeIndex IndexType;
+  // SizeOf: LF_NUMERIC encoded size in bytes. Not element count!
+  // Name: The null-terminated name follows.
+};
+
+// LF_VFTABLE
+struct VFTableType {
+  TypeIndex CompleteClass;     // Class that owns this vftable.
+  TypeIndex OverriddenVFTable; // VFTable that this overrides.
+  ulittle32_t VFPtrOffset;     // VFPtr offset in CompleteClass
+  ulittle32_t NamesLen;        // Length of subsequent names array in bytes.
+  // Names: A sequence of null-terminated strings. First string is vftable
+  // names.
+};
+
+// LF_MFUNC_ID
+struct MemberFuncId {
+  TypeIndex ClassType;
+  TypeIndex FunctionType;
+  // Name: The null-terminated name follows.
+};
+
+// LF_PROCEDURE
+struct ProcedureType {
+  TypeIndex ReturnType;
+  CallingConvention CallConv;
+  FunctionOptions Options;
+  ulittle16_t NumParameters;
+  TypeIndex ArgListType;
+};
+
+// LF_MFUNCTION
+struct MemberFunctionType {
+  TypeIndex ReturnType;
+  TypeIndex ClassType;
+  TypeIndex ThisType;
+  CallingConvention CallConv;
+  FunctionOptions Options;
+  ulittle16_t NumParameters;
+  TypeIndex ArgListType;
+  little32_t ThisAdjustment;
+};
+
+//===----------------------------------------------------------------------===//
+// Field list records, which do not include leafs or sizes
+
+/// Equvalent to CV_fldattr_t in cvinfo.h.
+struct MemberAttributes {
+  ulittle16_t Attrs;
+
+  /// Get the access specifier. Valid for any kind of member.
+  MemberAccess getAccess() const {
+    return MemberAccess(unsigned(Attrs) & unsigned(MethodOptions::AccessMask));
+  }
+
+  /// Indicates if a method is defined with friend, virtual, static, etc.
+  MethodKind getMethodKind() const {
+    return MethodKind(
+        (unsigned(Attrs) & unsigned(MethodOptions::MethodKindMask)) >> 2);
+  }
+
+  /// Get the flags that are not included in access control or method
+  /// properties.
+  MethodOptions getFlags() const {
+    return MethodOptions(
+        unsigned(Attrs) &
+        ~unsigned(MethodOptions::AccessMask | MethodOptions::MethodKindMask));
+  }
+
+  /// Is this method virtual.
+  bool isVirtual() const {
+    auto MP = getMethodKind();
+    return MP != MethodKind::Vanilla && MP != MethodKind::Friend &&
+           MP != MethodKind::Static;
+  }
+
+  /// Does this member introduce a new virtual method.
+  bool isIntroducedVirtual() const {
+    auto MP = getMethodKind();
+    return MP == MethodKind::IntroducingVirtual ||
+           MP == MethodKind::PureIntroducingVirtual;
+  }
+};
+
+// LF_NESTTYPE
+struct NestedType {
+  ulittle16_t Pad0; // Should be zero
+  TypeIndex Type;   // Type index of nested type
+  // Name: Null-terminated string
+};
+
+// LF_ONEMETHOD
+struct OneMethod {
+  MemberAttributes Attrs;
+  TypeIndex Type;
+  // If is introduced virtual method:
+  //   VFTableOffset: int32_t offset in vftable
+  // Name: Null-terminated string
+
+  MethodKind getMethodKind() const {
+    return Attrs.getMethodKind();
+  }
+
+  bool isVirtual() const { return Attrs.isVirtual(); }
+  bool isIntroducedVirtual() const { return Attrs.isIntroducedVirtual(); }
+};
+
+struct MethodListEntry {
+  MemberAttributes Attrs;
+  ulittle16_t Padding;
+
+  TypeIndex Type;
+  // If is introduced virtual method:
+  //   VFTableOffset: int32_t offset in vftable
+
+  MethodKind getMethodKind() const {
+    return Attrs.getMethodKind();
+  }
+
+  bool isVirtual() const { return Attrs.isVirtual(); }
+  bool isIntroducedVirtual() const { return Attrs.isIntroducedVirtual(); }
+};
+
+/// For method overload sets.  LF_METHOD
+struct OverloadedMethod {
+  ulittle16_t MethodCount; // Size of overload set
+  TypeIndex MethList;      // Type index of methods in overload set
+  // Name: Null-terminated string
+};
+
+// LF_VFUNCTAB
+struct VirtualFunctionPointer {
+  ulittle16_t Pad0;
+  TypeIndex Type;   // Type of vfptr
+};
+
+// LF_MEMBER
+struct DataMember {
+  MemberAttributes Attrs; // Access control attributes, etc
+  TypeIndex Type;
+  // FieldOffset: LF_NUMERIC encoded byte offset
+  // Name: Null-terminated string
+};
+
+// LF_STMEMBER
+struct StaticDataMember {
+  MemberAttributes Attrs; // Access control attributes, etc
+  TypeIndex Type;
+  // Name: Null-terminated string
+};
+
+// LF_ENUMERATE
+struct Enumerator {
+  MemberAttributes Attrs; // Access control attributes, etc
+  // EnumValue: LF_NUMERIC encoded enumerator value
+  // Name: Null-terminated string
+};
+
+// LF_BCLASS, LF_BINTERFACE
+struct BaseClass {
+  MemberAttributes Attrs; // Access control attributes, etc
+  TypeIndex BaseType;     // Base class type
+  // BaseOffset: LF_NUMERIC encoded byte offset of base from derived.
+};
+
+// LF_VBCLASS | LV_IVBCLASS
+struct VirtualBaseClass {
+  MemberAttributes Attrs; // Access control attributes, etc.
+  TypeIndex BaseType;     // Base class type
+  TypeIndex VBPtrType;    // Virtual base pointer type
+  // VBPtrOffset: Offset of vbptr from vfptr encoded as LF_NUMERIC.
+  // VBTableIndex: Index of vbase within vbtable encoded as LF_NUMERIC.
+};
 }
 }
 

Modified: llvm/trunk/lib/MC/MCCodeView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCCodeView.cpp?rev=259123&r1=259122&r2=259123&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCCodeView.cpp (original)
+++ llvm/trunk/lib/MC/MCCodeView.cpp Thu Jan 28 17:59:35 2016
@@ -155,7 +155,7 @@ void CodeViewContext::emitLineTableForFu
   bool HaveColumns = any_of(Locs, [](const MCCVLineEntry &LineEntry) {
     return LineEntry.getColumn() != 0;
   });
-  OS.EmitIntValue(HaveColumns ? codeview::LineFlags::HaveColumns : 0, 2);
+  OS.EmitIntValue(HaveColumns ? int(codeview::LineFlags::HaveColumns) : 0, 2);
   OS.emitAbsoluteSymbolDiff(FuncEnd, FuncBegin, 4);
 
   for (auto I = Locs.begin(), E = Locs.end(); I != E;) {

Modified: llvm/trunk/tools/llvm-readobj/CodeView.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/CodeView.h?rev=259123&r1=259122&r2=259123&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/CodeView.h (original)
+++ llvm/trunk/tools/llvm-readobj/CodeView.h Thu Jan 28 17:59:35 2016
@@ -26,7 +26,6 @@
 namespace llvm {
 namespace codeview {
 
-using llvm::support::little32_t;
 using llvm::support::ulittle16_t;
 using llvm::support::ulittle32_t;
 
@@ -48,304 +47,6 @@ struct FrameData {
   };
 };
 
-//===----------------------------------------------------------------------===//
-// On-disk representation of type information
-
-// A CodeView type stream is a sequence of TypeRecords. Records larger than
-// 65536 must chain on to a second record. Each TypeRecord is followed by one of
-// the leaf types described below.
-struct TypeRecordPrefix {
-  ulittle16_t Len;  // Type record length, starting from &Leaf.
-  ulittle16_t Leaf; // Type record kind (TypeLeafKind)
-};
-
-// LF_TYPESERVER2
-struct TypeServer2 {
-  char Signature[16];  // GUID
-  ulittle32_t Age;
-  // Name: Name of the PDB as a null-terminated string
-};
-
-// LF_STRING_ID
-struct StringId {
-  TypeIndex id;
-};
-
-// LF_FUNC_ID
-struct FuncId {
-  TypeIndex ParentScope;
-  TypeIndex FunctionType;
-  // Name: The null-terminated name follows.
-};
-
-// LF_CLASS, LF_STRUCT, LF_INTERFACE
-struct ClassType {
-  ulittle16_t MemberCount; // Number of members in FieldList.
-  ulittle16_t Properties;  // ClassOptions bitset
-  TypeIndex FieldList;     // LF_FIELDLIST: List of all kinds of members
-  TypeIndex DerivedFrom;   // LF_DERIVED: List of known derived classes
-  TypeIndex VShape;        // LF_VTSHAPE: Shape of the vftable
-  // SizeOf: The 'sizeof' the UDT in bytes is encoded as an LF_NUMERIC integer.
-  // Name: The null-terminated name follows.
-};
-
-// LF_UNION
-struct UnionType {
-  ulittle16_t MemberCount; // Number of members in FieldList.
-  ulittle16_t Properties;  // ClassOptions bitset
-  TypeIndex FieldList;     // LF_FIELDLIST: List of all kinds of members
-  // SizeOf: The 'sizeof' the UDT in bytes is encoded as an LF_NUMERIC integer.
-  // Name: The null-terminated name follows.
-};
-
-// LF_POINTER
-struct PointerType {
-  TypeIndex PointeeType;
-  ulittle32_t Attrs; // pointer attributes
-  // if pointer to member:
-  //   PointerToMemberTail
-
-  PointerKind getPtrKind() const { return PointerKind(Attrs & 0x1f); }
-  PointerMode getPtrMode() const { return PointerMode((Attrs >> 5) & 0x07); }
-  bool isFlat() const { return Attrs & (1 << 8); }
-  bool isVolatile() const { return Attrs & (1 << 9); }
-  bool isConst() const { return Attrs & (1 << 10); }
-  bool isUnaligned() const { return Attrs & (1 << 11); }
-
-  bool isPointerToDataMember() const {
-    return getPtrMode() == PointerMode::PointerToDataMember;
-  }
-  bool isPointerToMemberFunction() const {
-    return getPtrMode() == PointerMode::PointerToMemberFunction;
-  }
-  bool isPointerToMember() const {
-    return isPointerToMemberFunction() || isPointerToDataMember();
-  }
-};
-
-struct PointerToMemberTail {
-  TypeIndex ClassType;
-  ulittle16_t Representation; // PointerToMemberRepresentation
-};
-
-/// In Clang parlance, these are "qualifiers".  LF_MODIFIER
-struct TypeModifier {
-  TypeIndex ModifiedType;
-  ulittle16_t Modifiers; // ModifierOptions
-};
-
-// LF_VTSHAPE
-struct VTableShape {
-  // Number of vftable entries. Each method may have more than one entry due to
-  // things like covariant return types.
-  ulittle16_t VFEntryCount;
-  // Descriptors[]: 4-bit virtual method descriptors of type CV_VTS_desc_e.
-};
-
-// LF_UDT_SRC_LINE
-struct UDTSrcLine {
-  TypeIndex UDT;        // The user-defined type
-  TypeIndex SourceFile; // StringID containing the source filename
-  ulittle32_t LineNumber;
-};
-
-// LF_ARGLIST, LF_SUBSTR_LIST
-struct ArgList {
-  ulittle32_t NumArgs; // Number of arguments
-  // ArgTypes[]: Type indicies of arguments
-};
-
-// LF_BUILDINFO
-struct BuildInfo {
-  ulittle16_t NumArgs; // Number of arguments
-  // ArgTypes[]: Type indicies of arguments
-};
-
-// LF_ENUM
-struct EnumType {
-  ulittle16_t NumEnumerators; // Number of enumerators
-  ulittle16_t Properties;
-  TypeIndex UnderlyingType;
-  TypeIndex FieldListType;
-  // Name: The null-terminated name follows.
-};
-
-// LF_ARRAY
-struct ArrayType {
-  TypeIndex ElementType;
-  TypeIndex IndexType;
-  // SizeOf: LF_NUMERIC encoded size in bytes. Not element count!
-  // Name: The null-terminated name follows.
-};
-
-// LF_VFTABLE
-struct VFTableType {
-  TypeIndex CompleteClass;     // Class that owns this vftable.
-  TypeIndex OverriddenVFTable; // VFTable that this overrides.
-  ulittle32_t VFPtrOffset;     // VFPtr offset in CompleteClass
-  ulittle32_t NamesLen;        // Length of subsequent names array in bytes.
-  // Names: A sequence of null-terminated strings. First string is vftable
-  // names.
-};
-
-// LF_MFUNC_ID
-struct MemberFuncId {
-  TypeIndex ClassType;
-  TypeIndex FunctionType;
-  // Name: The null-terminated name follows.
-};
-
-// LF_PROCEDURE
-struct ProcedureType {
-  TypeIndex ReturnType;
-  CallingConvention CallConv;
-  FunctionOptions Options;
-  ulittle16_t NumParameters;
-  TypeIndex ArgListType;
-};
-
-// LF_MFUNCTION
-struct MemberFunctionType {
-  TypeIndex ReturnType;
-  TypeIndex ClassType;
-  TypeIndex ThisType;
-  CallingConvention CallConv;
-  FunctionOptions Options;
-  ulittle16_t NumParameters;
-  TypeIndex ArgListType;
-  little32_t ThisAdjustment;
-};
-
-//===----------------------------------------------------------------------===//
-// Field list records, which do not include leafs or sizes
-
-/// Equvalent to CV_fldattr_t in cvinfo.h.
-struct MemberAttributes {
-  ulittle16_t Attrs;
-
-  /// Get the access specifier. Valid for any kind of member.
-  MemberAccess getAccess() const {
-    return MemberAccess(unsigned(Attrs) & unsigned(MethodOptions::AccessMask));
-  }
-
-  /// Indicates if a method is defined with friend, virtual, static, etc.
-  MethodKind getMethodKind() const {
-    return MethodKind(
-        (unsigned(Attrs) & unsigned(MethodOptions::MethodKindMask)) >> 2);
-  }
-
-  /// Get the flags that are not included in access control or method
-  /// properties.
-  MethodOptions getFlags() const {
-    return MethodOptions(
-        unsigned(Attrs) &
-        ~unsigned(MethodOptions::AccessMask | MethodOptions::MethodKindMask));
-  }
-
-  /// Is this method virtual.
-  bool isVirtual() const {
-    auto MP = getMethodKind();
-    return MP != MethodKind::Vanilla && MP != MethodKind::Friend &&
-           MP != MethodKind::Static;
-  }
-
-  /// Does this member introduce a new virtual method.
-  bool isIntroducedVirtual() const {
-    auto MP = getMethodKind();
-    return MP == MethodKind::IntroducingVirtual ||
-           MP == MethodKind::PureIntroducingVirtual;
-  }
-};
-
-// LF_NESTTYPE
-struct NestedType {
-  ulittle16_t Pad0; // Should be zero
-  TypeIndex Type;   // Type index of nested type
-  // Name: Null-terminated string
-};
-
-// LF_ONEMETHOD
-struct OneMethod {
-  MemberAttributes Attrs;
-  TypeIndex Type;
-  // If is introduced virtual method:
-  //   VFTableOffset: int32_t offset in vftable
-  // Name: Null-terminated string
-
-  MethodKind getMethodKind() const {
-    return Attrs.getMethodKind();
-  }
-
-  bool isVirtual() const { return Attrs.isVirtual(); }
-  bool isIntroducedVirtual() const { return Attrs.isIntroducedVirtual(); }
-};
-
-struct MethodListEntry {
-  MemberAttributes Attrs;
-  ulittle16_t Padding;
-
-  TypeIndex Type;
-  // If is introduced virtual method:
-  //   VFTableOffset: int32_t offset in vftable
-
-  MethodKind getMethodKind() const {
-    return Attrs.getMethodKind();
-  }
-
-  bool isVirtual() const { return Attrs.isVirtual(); }
-  bool isIntroducedVirtual() const { return Attrs.isIntroducedVirtual(); }
-};
-
-/// For method overload sets.  LF_METHOD
-struct OverloadedMethod {
-  ulittle16_t MethodCount; // Size of overload set
-  TypeIndex MethList;      // Type index of methods in overload set
-  // Name: Null-terminated string
-};
-
-// LF_VFUNCTAB
-struct VirtualFunctionPointer {
-  ulittle16_t Pad0;
-  TypeIndex Type;   // Type of vfptr
-};
-
-// LF_MEMBER
-struct DataMember {
-  MemberAttributes Attrs; // Access control attributes, etc
-  TypeIndex Type;
-  // FieldOffset: LF_NUMERIC encoded byte offset
-  // Name: Null-terminated string
-};
-
-// LF_STMEMBER
-struct StaticDataMember {
-  MemberAttributes Attrs; // Access control attributes, etc
-  TypeIndex Type;
-  // Name: Null-terminated string
-};
-
-// LF_ENUMERATE
-struct Enumerator {
-  MemberAttributes Attrs; // Access control attributes, etc
-  // EnumValue: LF_NUMERIC encoded enumerator value
-  // Name: Null-terminated string
-};
-
-// LF_BCLASS, LF_BINTERFACE
-struct BaseClass {
-  MemberAttributes Attrs; // Access control attributes, etc
-  TypeIndex BaseType;     // Base class type
-  // BaseOffset: LF_NUMERIC encoded byte offset of base from derived.
-};
-
-// LF_VBCLASS | LV_IVBCLASS
-struct VirtualBaseClass {
-  MemberAttributes Attrs; // Access control attributes, etc.
-  TypeIndex BaseType;     // Base class type
-  TypeIndex VBPtrType;    // Virtual base pointer type
-  // VBPtrOffset: Offset of vbptr from vfptr encoded as LF_NUMERIC.
-  // VBTableIndex: Index of vbase within vbtable encoded as LF_NUMERIC.
-};
 
 } // namespace codeview
 } // namespace llvm




More information about the llvm-commits mailing list