#include "LLParser.h"
#include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/AsmParser/SlotMapping.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/CallingConv.h"
ParseToken(lltok::rbrace, "expected end of struct constant"))
return true;
- ID.ConstantStructElts = make_unique<Constant *[]>(Elts.size());
+ ID.ConstantStructElts = new Constant*[Elts.size()];
ID.UIntVal = Elts.size();
- memcpy(ID.ConstantStructElts.get(), Elts.data(),
- Elts.size() * sizeof(Elts[0]));
+ memcpy(ID.ConstantStructElts, Elts.data(), Elts.size()*sizeof(Elts[0]));
ID.Kind = ValID::t_ConstantStruct;
return false;
}
return true;
if (isPackedStruct) {
- ID.ConstantStructElts = make_unique<Constant *[]>(Elts.size());
- memcpy(ID.ConstantStructElts.get(), Elts.data(),
- Elts.size() * sizeof(Elts[0]));
+ ID.ConstantStructElts = new Constant*[Elts.size()];
+ memcpy(ID.ConstantStructElts, Elts.data(), Elts.size()*sizeof(Elts[0]));
ID.UIntVal = Elts.size();
ID.Kind = ValID::t_PackedConstantStruct;
return false;
return Error(ID.Loc, "element " + Twine(i) +
" of struct initializer doesn't match struct element type");
- V = ConstantStruct::get(
- ST, makeArrayRef(ID.ConstantStructElts.get(), ID.UIntVal));
+ V = ConstantStruct::get(ST, makeArrayRef(ID.ConstantStructElts,
+ ID.UIntVal));
} else
return Error(ID.Loc, "constant expression type mismatch");
return false;
t_InlineAsm, // Value in FTy/StrVal/StrVal2/UIntVal.
t_ConstantStruct, // Value in ConstantStructElts.
t_PackedConstantStruct // Value in ConstantStructElts.
- } Kind = t_LocalID;
+ } Kind;
LLLexer::LocTy Loc;
unsigned UIntVal;
FunctionType *FTy;
std::string StrVal, StrVal2;
APSInt APSIntVal;
- APFloat APFloatVal{0.0};
+ APFloat APFloatVal;
Constant *ConstantVal;
- std::unique_ptr<Constant *[]> ConstantStructElts;
-
- ValID() = default;
- ValID(ValID &&RHS)
- : Kind(RHS.Kind), Loc(RHS.Loc), UIntVal(RHS.UIntVal), FTy(RHS.FTy),
- StrVal(std::move(RHS.StrVal)), StrVal2(std::move(RHS.StrVal2)),
- APSIntVal(std::move(RHS.APSIntVal)),
- APFloatVal(std::move(RHS.APFloatVal)), ConstantVal(RHS.ConstantVal),
- ConstantStructElts(std::move(RHS.ConstantStructElts)) {}
+ 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)