unique_ptrify ValID::ConstantStructElts

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231200 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2015-03-04 01:41:01 +00:00
parent de2cab9eb4
commit cca1f3743d
2 changed files with 9 additions and 11 deletions

View File

@ -2365,9 +2365,10 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
ParseToken(lltok::rbrace, "expected end of struct constant"))
return true;
ID.ConstantStructElts = new Constant*[Elts.size()];
ID.ConstantStructElts.reset(new Constant *[Elts.size()]);
ID.UIntVal = Elts.size();
memcpy(ID.ConstantStructElts, Elts.data(), Elts.size()*sizeof(Elts[0]));
memcpy(ID.ConstantStructElts.get(), Elts.data(),
Elts.size() * sizeof(Elts[0]));
ID.Kind = ValID::t_ConstantStruct;
return false;
}
@ -2386,8 +2387,9 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
return true;
if (isPackedStruct) {
ID.ConstantStructElts = new Constant*[Elts.size()];
memcpy(ID.ConstantStructElts, Elts.data(), Elts.size()*sizeof(Elts[0]));
ID.ConstantStructElts.reset(new Constant *[Elts.size()]);
memcpy(ID.ConstantStructElts.get(), Elts.data(),
Elts.size() * sizeof(Elts[0]));
ID.UIntVal = Elts.size();
ID.Kind = ValID::t_PackedConstantStruct;
return false;
@ -3947,8 +3949,8 @@ bool LLParser::ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
return Error(ID.Loc, "element " + Twine(i) +
" of struct initializer doesn't match struct element type");
V = ConstantStruct::get(ST, makeArrayRef(ID.ConstantStructElts,
ID.UIntVal));
V = ConstantStruct::get(
ST, makeArrayRef(ID.ConstantStructElts.get(), ID.UIntVal));
} else
return Error(ID.Loc, "constant expression type mismatch");
return false;

View File

@ -62,13 +62,9 @@ namespace llvm {
APSInt APSIntVal;
APFloat APFloatVal;
Constant *ConstantVal;
Constant **ConstantStructElts;
std::unique_ptr<Constant*[]> ConstantStructElts;
ValID() : Kind(t_LocalID), APFloatVal(0.0) {}
~ValID() {
if (Kind == t_ConstantStruct || Kind == t_PackedConstantStruct)
delete [] ConstantStructElts;
}
bool operator<(const ValID &RHS) const {
if (Kind == t_LocalID || Kind == t_GlobalID)