[llvm] r243896 - Recommit r243824: -Wdeprecated-clean: Fix cases of violating the rule of 5 in ways that are deprecated in C++11
David Blaikie
dblaikie at gmail.com
Mon Aug 3 13:08:42 PDT 2015
Author: dblaikie
Date: Mon Aug 3 15:08:41 2015
New Revision: 243896
URL: http://llvm.org/viewvc/llvm-project?rev=243896&view=rev
Log:
Recommit r243824: -Wdeprecated-clean: Fix cases of violating the rule of 5 in ways that are deprecated in C++11
This reverts commit r243888, recommitting r243824.
This broke the Windows build due to a difference in the C++ standard
library implementation. Using emplace/forward_as_tuple should ensure
there's no need to copy ValIDs.
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/AsmParser/LLParser.h
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=243896&r1=243895&r2=243896&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Aug 3 15:08:41 2015
@@ -13,6 +13,7 @@
#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"
@@ -2458,9 +2459,10 @@ bool LLParser::ParseValID(ValID &ID, Per
ParseToken(lltok::rbrace, "expected end of struct constant"))
return true;
- ID.ConstantStructElts = new Constant*[Elts.size()];
+ ID.ConstantStructElts = make_unique<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;
}
@@ -2479,8 +2481,9 @@ bool LLParser::ParseValID(ValID &ID, Per
return true;
if (isPackedStruct) {
- ID.ConstantStructElts = new Constant*[Elts.size()];
- memcpy(ID.ConstantStructElts, Elts.data(), Elts.size()*sizeof(Elts[0]));
+ ID.ConstantStructElts = make_unique<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;
@@ -2606,9 +2609,9 @@ bool LLParser::ParseValID(ValID &ID, Per
if (!F) {
// Make a global variable as a placeholder for this reference.
GlobalValue *&FwdRef =
- ForwardRefBlockAddresses.insert(std::make_pair(
- std::move(Fn),
- std::map<ValID, GlobalValue *>()))
+ ForwardRefBlockAddresses.emplace(std::piecewise_construct,
+ std::forward_as_tuple(std::move(Fn)),
+ std::forward_as_tuple())
.first->second.insert(std::make_pair(std::move(Label), nullptr))
.first->second;
if (!FwdRef)
@@ -4085,8 +4088,8 @@ bool LLParser::ConvertValIDToValue(Type
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;
Modified: llvm/trunk/lib/AsmParser/LLParser.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.h?rev=243896&r1=243895&r2=243896&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.h (original)
+++ llvm/trunk/lib/AsmParser/LLParser.h Mon Aug 3 15:08:41 2015
@@ -55,22 +55,24 @@ namespace llvm {
t_InlineAsm, // Value in FTy/StrVal/StrVal2/UIntVal.
t_ConstantStruct, // Value in ConstantStructElts.
t_PackedConstantStruct // Value in ConstantStructElts.
- } Kind;
+ } Kind = t_LocalID;
LLLexer::LocTy Loc;
unsigned UIntVal;
FunctionType *FTy;
std::string StrVal, StrVal2;
APSInt APSIntVal;
- APFloat APFloatVal;
+ APFloat APFloatVal{0.0};
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;
- }
+ 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)) {}
bool operator<(const ValID &RHS) const {
if (Kind == t_LocalID || Kind == t_GlobalID)
More information about the llvm-commits
mailing list