[llvm] r231199 - LLParser: Avoid copying ValIDs, the copy ctor is deprecated in C++11 due to the presence of a user-declared dtor

David Blaikie dblaikie at gmail.com
Tue Mar 3 17:45:23 PST 2015


On Tue, Mar 3, 2015 at 5:40 PM, David Blaikie <dblaikie at gmail.com> wrote:

> Author: dblaikie
> Date: Tue Mar  3 19:40:07 2015
> New Revision: 231199
>
> URL: http://llvm.org/viewvc/llvm-project?rev=231199&view=rev
> Log:
> LLParser: Avoid copying ValIDs, the copy ctor is deprecated in C++11 due
> to the presence of a user-declared dtor
>

Oh, as a bonus - ValID's dtor actually delete memory pointed to by a member
of ValID, the only reason this code didn't cause double-delete due to the
copy, is that the instances copied in this codepath never had a non-null
pointer in this member... subtle to say the least.


>
> Modified:
>     llvm/trunk/lib/AsmParser/LLParser.cpp
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=231199&r1=231198&r2=231199&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Mar  3 19:40:07 2015
> @@ -2512,7 +2512,12 @@ bool LLParser::ParseValID(ValID &ID, Per
>
>      if (!F) {
>        // Make a global variable as a placeholder for this reference.
> -      GlobalValue *&FwdRef = ForwardRefBlockAddresses[Fn][Label];
> +      GlobalValue *&FwdRef =
> +          ForwardRefBlockAddresses.insert(std::make_pair(
> +                                              std::move(Fn),
> +                                              std::map<ValID, GlobalValue
> *>()))
> +              .first->second.insert(std::make_pair(std::move(Label),
> nullptr))
> +              .first->second;
>        if (!FwdRef)
>          FwdRef = new GlobalVariable(*M, Type::getInt8Ty(Context), false,
>                                      GlobalValue::InternalLinkage,
> nullptr, "");
>
>
> _______________________________________________
> 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/20150303/cea5cb97/attachment.html>


More information about the llvm-commits mailing list