Fix build broken by r328090
authorPavel Labath <labath@google.com>
Wed, 21 Mar 2018 12:18:03 +0000 (12:18 +0000)
committerPavel Labath <labath@google.com>
Wed, 21 Mar 2018 12:18:03 +0000 (12:18 +0000)
- 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.

llvm-svn: 328093

llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/lib/BinaryFormat/Dwarf.cpp

index 3ba83db..15724a9 100644 (file)
@@ -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
index 3a97dde..dd1ecea 100644 (file)
@@ -676,7 +676,7 @@ bool llvm::dwarf::isValidFormForVersion(Form F, unsigned Version,
   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[];