mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-24 08:24:33 +00:00
Reapply "IR: Simplify DIBuilder's HeaderBuilder API, NFC"
This reverts commit r226542, effectively reapplying r226540. This time, initialize `IsEmpty` in the copy and move constructors as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226545 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -25,15 +25,24 @@ using namespace llvm::dwarf;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class HeaderBuilder {
|
class HeaderBuilder {
|
||||||
|
/// \brief Whether there are any fields yet.
|
||||||
|
///
|
||||||
|
/// Note that this is not equivalent to \c Chars.empty(), since \a concat()
|
||||||
|
/// may have been called already with an empty string.
|
||||||
|
bool IsEmpty;
|
||||||
SmallVector<char, 256> Chars;
|
SmallVector<char, 256> Chars;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit HeaderBuilder(Twine T) { T.toVector(Chars); }
|
HeaderBuilder() : IsEmpty(true) {}
|
||||||
HeaderBuilder(const HeaderBuilder &X) : Chars(X.Chars) {}
|
HeaderBuilder(const HeaderBuilder &X) : IsEmpty(X.IsEmpty), Chars(X.Chars) {}
|
||||||
HeaderBuilder(HeaderBuilder &&X) : Chars(std::move(X.Chars)) {}
|
HeaderBuilder(HeaderBuilder &&X)
|
||||||
|
: IsEmpty(X.IsEmpty), Chars(std::move(X.Chars)) {}
|
||||||
|
|
||||||
template <class Twineable> HeaderBuilder &concat(Twineable &&X) {
|
template <class Twineable> HeaderBuilder &concat(Twineable &&X) {
|
||||||
Chars.push_back(0);
|
if (IsEmpty)
|
||||||
|
IsEmpty = false;
|
||||||
|
else
|
||||||
|
Chars.push_back(0);
|
||||||
Twine(X).toVector(Chars);
|
Twine(X).toVector(Chars);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -43,7 +52,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static HeaderBuilder get(unsigned Tag) {
|
static HeaderBuilder get(unsigned Tag) {
|
||||||
return HeaderBuilder("0x" + Twine::utohexstr(Tag));
|
return HeaderBuilder().concat("0x" + Twine::utohexstr(Tag));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -739,8 +748,10 @@ static HeaderBuilder setTypeFlagsInHeader(StringRef Header,
|
|||||||
Flags = 0;
|
Flags = 0;
|
||||||
Flags |= FlagsToSet;
|
Flags |= FlagsToSet;
|
||||||
|
|
||||||
return HeaderBuilder(Twine(I.getPrefix())).concat(Flags).concat(
|
return HeaderBuilder()
|
||||||
I.getSuffix());
|
.concat(I.getPrefix())
|
||||||
|
.concat(Flags)
|
||||||
|
.concat(I.getSuffix());
|
||||||
}
|
}
|
||||||
|
|
||||||
static DIType createTypeWithFlags(LLVMContext &Context, DIType Ty,
|
static DIType createTypeWithFlags(LLVMContext &Context, DIType Ty,
|
||||||
|
Reference in New Issue
Block a user