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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@328093 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Pavel Labath 2018-03-21 12:18:03 +00:00
parent 8abcf8e6ef
commit 88eab22187
2 changed files with 8 additions and 8 deletions

View 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

View 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[];