[llvm] r243824 - -Wdeprecated-clean: Fix cases of violating the rule of 5 in ways that are deprecated in C++11

Reid Kleckner rnk at google.com
Mon Aug 3 10:37:22 PDT 2015


Reverted in r243888.

On Sat, Aug 1, 2015 at 12:23 PM, Yaron Keren <yaron.keren at gmail.com> wrote:

> Hi,
>
> ValID move contructor may be causing a compilation failure:
>
>
> http://lab.llvm.org:8011/builders/clang-x86-win2008-selfhost/builds/2195/steps/build%20stage%202/logs/stdio
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lab.llvm.org-3A8011_builders_clang-2Dx86-2Dwin2008-2Dselfhost_builds_2195_steps_build-2520stage-25202_logs_stdio&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=4J10aigkxdAi9hxhWEo1NVVu16QrCspBzJ_Ex41wYIw&s=IvQkVSBDca1aPEQf9CXXQx9UTOAWUg2v2YbtDts973M&e=>
>
> C:\buildbot\slave-config\clang-x86-win2008-selfhost\llvm\lib\AsmParser/LLParser.h(70,5) :  note: copy constructor is implicitly deleted because 'ValID' has a user-declared move constructor
>     ValID(ValID &&RHS)
>     ^
>
> Yaron
>
>
>
> 2015-08-01 8:10 GMT+03:00 David Blaikie <dblaikie at gmail.com>:
>
>> Author: dblaikie
>> Date: Sat Aug  1 00:10:40 2015
>> New Revision: 243824
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=243824&view=rev
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D243824-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=4J10aigkxdAi9hxhWEo1NVVu16QrCspBzJ_Ex41wYIw&s=HlEgmAomodYXc_3vu1TFy5qA1cxdA1XKI00o0CHT_MA&e=>
>> Log:
>> -Wdeprecated-clean: Fix cases of violating the rule of 5 in ways that are
>> deprecated in C++11
>>
>> 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=243824&r1=243823&r2=243824&view=diff
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_AsmParser_LLParser.cpp-3Frev-3D243824-26r1-3D243823-26r2-3D243824-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=4J10aigkxdAi9hxhWEo1NVVu16QrCspBzJ_Ex41wYIw&s=obprrmTcZ8ztrM0E9qkv61K_GiFpZU7cAtC0bF1lj1Q&e=>
>>
>> ==============================================================================
>> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
>> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Sat Aug  1 00:10:40 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"
>> @@ -2441,9 +2442,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;
>>    }
>> @@ -2462,8 +2464,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;
>> @@ -4067,8 +4070,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=243824&r1=243823&r2=243824&view=diff
>> <https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_AsmParser_LLParser.h-3Frev-3D243824-26r1-3D243823-26r2-3D243824-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=4J10aigkxdAi9hxhWEo1NVVu16QrCspBzJ_Ex41wYIw&s=L9k847iW1SwHw7AmQzqHEz8enXdmVK7IQS-cqgMSQuo&e=>
>>
>> ==============================================================================
>> --- llvm/trunk/lib/AsmParser/LLParser.h (original)
>> +++ llvm/trunk/lib/AsmParser/LLParser.h Sat Aug  1 00:10:40 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)
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150803/1efe28b9/attachment.html>


More information about the llvm-commits mailing list