[llvm] r328093 - Fix build broken by r328090

Pavel Labath via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 21 05:18:03 PDT 2018


Author: labath
Date: Wed Mar 21 05:18:03 2018
New Revision: 328093

URL: http://llvm.org/viewvc/llvm-project?rev=328093&view=rev
Log:
Fix build broken by r328090

- constexpr is needed for out-of-class definition of the Type static
  member by some compilers
- MSVC is confused by the initialization of the static constexpr char[]
  member when it happens in a template specialization. Explicitly
  specifying the length of the array seems to be enough to help it
  figure things out.

Modified:
    llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
    llvm/trunk/lib/BinaryFormat/Dwarf.cpp

Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.h?rev=328093&r1=328092&r2=328093&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Dwarf.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.h Wed Mar 21 05:18:03 2018
@@ -578,22 +578,22 @@ private:
 template <typename Enum> struct EnumTraits : public std::false_type {};
 
 template <> struct EnumTraits<Attribute> : public std::true_type {
-  static constexpr char Type[] = "AT";
+  static constexpr char Type[3] = "AT";
   static constexpr StringRef (*StringFn)(unsigned) = &AttributeString;
 };
 
 template <> struct EnumTraits<Form> : public std::true_type {
-  static constexpr char Type[] = "FORM";
+  static constexpr char Type[5] = "FORM";
   static constexpr StringRef (*StringFn)(unsigned) = &FormEncodingString;
 };
 
 template <> struct EnumTraits<Index> : public std::true_type {
-  static constexpr char Type[] = "IDX";
+  static constexpr char Type[4] = "IDX";
   static constexpr StringRef (*StringFn)(unsigned) = &IndexString;
 };
 
 template <> struct EnumTraits<Tag> : public std::true_type {
-  static constexpr char Type[] = "TAG";
+  static constexpr char Type[4] = "TAG";
   static constexpr StringRef (*StringFn)(unsigned) = &TagString;
 };
 } // End of namespace dwarf

Modified: llvm/trunk/lib/BinaryFormat/Dwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/BinaryFormat/Dwarf.cpp?rev=328093&r1=328092&r2=328093&view=diff
==============================================================================
--- llvm/trunk/lib/BinaryFormat/Dwarf.cpp (original)
+++ llvm/trunk/lib/BinaryFormat/Dwarf.cpp Wed Mar 21 05:18:03 2018
@@ -676,7 +676,7 @@ bool llvm::dwarf::isValidFormForVersion(
   return ExtensionsOk;
 }
 
-const char llvm::dwarf::EnumTraits<Attribute>::Type[];
-const char llvm::dwarf::EnumTraits<Form>::Type[];
-const char llvm::dwarf::EnumTraits<Index>::Type[];
-const char llvm::dwarf::EnumTraits<Tag>::Type[];
+constexpr char llvm::dwarf::EnumTraits<Attribute>::Type[];
+constexpr char llvm::dwarf::EnumTraits<Form>::Type[];
+constexpr char llvm::dwarf::EnumTraits<Index>::Type[];
+constexpr char llvm::dwarf::EnumTraits<Tag>::Type[];




More information about the llvm-commits mailing list