1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[AccelTable] Workaround for MSVC bug

Microsoft Visual Studio rejects the static constexpr static list of
atoms even though it's valid C++. This provides a workaround to unbreak
the bots.

llvm-svn: 323667
This commit is contained in:
Jonas Devlieghere 2018-01-29 17:28:51 +00:00
parent ea1517134b
commit 6929b5eaef
2 changed files with 85 additions and 10 deletions

View File

@ -153,10 +153,18 @@ private:
/// base is used to describe the offset for all forms in the list of atoms.
uint32_t DieOffsetBase;
SmallVector<Atom, 3> Atoms;
const SmallVector<Atom, 4> Atoms;
#ifndef _MSC_VER
// See the `static constexpr` below why we need an alternative
// implementation for MSVC.
HeaderData(ArrayRef<Atom> AtomList, uint32_t Offset = 0)
: DieOffsetBase(Offset), Atoms(AtomList.begin(), AtomList.end()) {}
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
HeaderData(const SmallVectorImpl<Atom> &Atoms, uint32_t Offset = 0)
: DieOffsetBase(Offset), Atoms(Atoms.begin(), Atoms.end()) {}
#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const {
@ -174,8 +182,16 @@ private:
public:
/// The length of the header data is always going to be 4 + 4 + 4*NumAtoms.
#ifndef _MSC_VER
// See the `static constexpr` below why we need an alternative implementation
// for MSVC.
AppleAccelTableHeader(ArrayRef<AppleAccelTableHeader::Atom> Atoms)
: Header(8 + (Atoms.size() * 4)), HeaderData(Atoms) {}
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
AppleAccelTableHeader(const SmallVectorImpl<Atom> &Atoms)
: Header(8 + (Atoms.size() * 4)), HeaderData(Atoms) {}
#endif
/// Update header with hash and bucket count.
void setBucketAndHashCount(uint32_t HashCount);
@ -270,8 +286,16 @@ protected:
using BucketList = std::vector<HashList>;
BucketList Buckets;
#ifndef _MSC_VER
// See the `static constexpr` below why we need an alternative implementation
// for MSVC.
AppleAccelTableBase(ArrayRef<AppleAccelTableHeader::Atom> Atoms)
: Header(Atoms), Entries(Allocator) {}
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
AppleAccelTableBase(const SmallVectorImpl<AppleAccelTableHeader::Atom> &Atoms)
: Header(Atoms), Entries(Allocator) {}
#endif
private:
/// Emits the header for the table via the AsmPrinter.
@ -368,9 +392,15 @@ public:
void emit(AsmPrinter *Asm) const override;
static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
#ifndef _MSC_VER
// The line below is rejected by older versions (TBD) of MSVC.
static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4)};
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
@ -391,12 +421,18 @@ public:
void emit(AsmPrinter *Asm) const override;
static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
#ifndef _MSC_VER
// The line below is rejected by older versions (TBD) of MSVC.
static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_type_flags,
dwarf::DW_FORM_data1)};
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
@ -414,9 +450,15 @@ public:
void emit(AsmPrinter *Asm) const override;
static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
#ifndef _MSC_VER
// The line below is rejected by older versions (TBD) of MSVC.
static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4)};
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {
@ -443,12 +485,18 @@ public:
void emit(AsmPrinter *Asm) const override;
static constexpr const AppleAccelTableHeader::Atom Atoms[] = {
#ifndef _MSC_VER
// The line below is rejected by older versions (TBD) of MSVC.
static constexpr AppleAccelTableHeader::Atom Atoms[] = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),
AppleAccelTableHeader::Atom(5, dwarf::DW_FORM_data1),
AppleAccelTableHeader::Atom(6, dwarf::DW_FORM_data4)};
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
static const SmallVector<AppleAccelTableHeader::Atom, 4> Atoms;
#endif
#ifndef NDEBUG
void print(raw_ostream &OS) const override {

View File

@ -70,11 +70,6 @@ void AppleAccelTableHeader::setBucketAndHashCount(uint32_t HashCount) {
Header.HashCount = HashCount;
}
constexpr const AppleAccelTableHeader::Atom AppleAccelTableTypeData::Atoms[];
constexpr const AppleAccelTableHeader::Atom AppleAccelTableOffsetData::Atoms[];
constexpr const AppleAccelTableHeader::Atom AppleAccelTableStaticOffsetData::Atoms[];
constexpr const AppleAccelTableHeader::Atom AppleAccelTableStaticTypeData::Atoms[];
void AppleAccelTableBase::emitHeader(AsmPrinter *Asm) { Header.emit(Asm); }
void AppleAccelTableBase::emitBuckets(AsmPrinter *Asm) {
@ -233,3 +228,35 @@ void AppleAccelTableStaticTypeData::emit(AsmPrinter *Asm) const {
: 0);
Asm->EmitInt32(QualifiedNameHash);
}
#ifndef _MSC_VER
// The lines below are rejected by older versions (TBD) of MSVC.
constexpr AppleAccelTableHeader::Atom AppleAccelTableTypeData::Atoms[];
constexpr AppleAccelTableHeader::Atom AppleAccelTableOffsetData::Atoms[];
constexpr AppleAccelTableHeader::Atom AppleAccelTableStaticOffsetData::Atoms[];
constexpr AppleAccelTableHeader::Atom AppleAccelTableStaticTypeData::Atoms[];
#else
// FIXME: Erase this path once the minimum MSCV version has been bumped.
const SmallVector<AppleAccelTableHeader::Atom, 4>
AppleAccelTableOffsetData::Atoms = {AppleAccelTableHeader::Atom(
dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4)};
const SmallVector<AppleAccelTableHeader::Atom, 4>
AppleAccelTableTypeData::Atoms = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag,
dwarf::DW_FORM_data2),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_type_flags,
dwarf::DW_FORM_data1)};
const SmallVector<AppleAccelTableHeader::Atom, 4>
AppleAccelTableStaticOffsetData::Atoms = {AppleAccelTableHeader::Atom(
dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4)};
const SmallVector<AppleAccelTableHeader::Atom, 4>
AppleAccelTableStaticTypeData::Atoms = {
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_offset,
dwarf::DW_FORM_data4),
AppleAccelTableHeader::Atom(dwarf::DW_ATOM_die_tag,
dwarf::DW_FORM_data2),
AppleAccelTableHeader::Atom(5, dwarf::DW_FORM_data1),
AppleAccelTableHeader::Atom(6, dwarf::DW_FORM_data4)};
#endif