mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
unique_ptrify ValID::ConstantStructElts
llvm-svn: 231200
This commit is contained in:
parent
e3c56b2d84
commit
731e1ed968
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user