From 2ae03e178392e0693872e42c947d784b3c02ea60 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Wed, 4 Mar 2015 18:31:10 +0000 Subject: [PATCH] Revert "unique_ptrify ValID::ConstantStructElts" This reverts r231200 and r231204. The second one added an explicit move ctor for MSVC. This change broke the clang-cl self-host due to weirdness in MSVC's implementation of std::map::insert. Somehow we lost our rvalue ref-ness when going through variadic placement new: template void construct(_Objty *_Ptr, _Types &&... _Args) { // construct _Objty(_Types...) at _Ptr ::new ((void *)_Ptr) _Objty(_STD forward<_Types>(_Args)...); } For some reason, Clang decided to call the deleted std::pair copy constructor at this point. Needs further investigation, once I can build. llvm-svn: 231269 --- llvm/lib/AsmParser/LLParser.cpp | 14 ++++++-------- llvm/lib/AsmParser/LLParser.h | 14 +++++--------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index f041da4..a07a109 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2365,10 +2365,9 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { ParseToken(lltok::rbrace, "expected end of struct constant")) return true; - ID.ConstantStructElts.reset(new 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; } @@ -2387,9 +2386,8 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) { return true; if (isPackedStruct) { - ID.ConstantStructElts.reset(new 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; @@ -3949,8 +3947,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.get(), ID.UIntVal)); + V = ConstantStruct::get(ST, makeArrayRef(ID.ConstantStructElts, + ID.UIntVal)); } else return Error(ID.Loc, "constant expression type mismatch"); return false; diff --git a/llvm/lib/AsmParser/LLParser.h b/llvm/lib/AsmParser/LLParser.h index da3d02f..5e92e57 100644 --- a/llvm/lib/AsmParser/LLParser.h +++ b/llvm/lib/AsmParser/LLParser.h @@ -62,17 +62,13 @@ namespace llvm { APSInt APSIntVal; APFloat APFloatVal; Constant *ConstantVal; - std::unique_ptr ConstantStructElts; + Constant **ConstantStructElts; ValID() : Kind(t_LocalID), APFloatVal(0.0) {} - // Workaround for MSVC not synthesizing implicit move members. - ValID(ValID &&RHS) - : Kind(std::move(RHS.Kind)), Loc(std::move(RHS.Loc)), - UIntVal(std::move(RHS.UIntVal)), StrVal(std::move(RHS.StrVal)), - StrVal2(std::move(RHS.StrVal2)), APSIntVal(std::move(RHS.APSIntVal)), - APFloatVal(std::move(RHS.APFloatVal)), - ConstantVal(std::move(RHS.ConstantVal)), - ConstantStructElts(std::move(RHS.ConstantStructElts)) {} + ~ValID() { + if (Kind == t_ConstantStruct || Kind == t_PackedConstantStruct) + delete [] ConstantStructElts; + } bool operator<(const ValID &RHS) const { if (Kind == t_LocalID || Kind == t_GlobalID) -- 2.7.4