r197184 - [-cxx-abi microsoft] Mangle reference temporaries
Richard Smith
richard at metafoo.co.uk
Thu Dec 12 15:56:02 PST 2013
Using the mangled name of the variable for its lifetime-extended
temporaries doesn't sound right to me. Given:
int n;
int &&r = +n;
Clang generates:
@"\01?r@@3$$QEAHEA" = global i32* null, align 8
@"\01?r@@3$$QEAHEA1" = private global i32 0, align 4
... where the latter is the lifetime-extended temporary, with a suspicious
mangling.
Given:
int &&r = 0;
Clang asserts:
Global variable initializer type does not match global variable type!
i32** @"\01?r@@3$$QEAHEA"
Broken module found, compilation aborted!
On Thu, Dec 12, 2013 at 3:12 PM, David Majnemer <david.majnemer at gmail.com>wrote:
> Author: majnemer
> Date: Thu Dec 12 17:12:01 2013
> New Revision: 197184
>
> URL: http://llvm.org/viewvc/llvm-project?rev=197184&view=rev
> Log:
> [-cxx-abi microsoft] Mangle reference temporaries
>
> They are mangled the same as normal references, nothing special is going
> on here.
>
> Modified:
> cfe/trunk/lib/AST/MicrosoftMangle.cpp
> cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
>
> Modified: cfe/trunk/lib/AST/MicrosoftMangle.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftMangle.cpp?rev=197184&r1=197183&r2=197184&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/AST/MicrosoftMangle.cpp (original)
> +++ cfe/trunk/lib/AST/MicrosoftMangle.cpp Thu Dec 12 17:12:01 2013
> @@ -2040,10 +2040,9 @@ void MicrosoftMangleContextImpl::mangleC
> }
>
> void MicrosoftMangleContextImpl::mangleReferenceTemporary(const VarDecl
> *VD,
> - raw_ostream &) {
> - unsigned DiagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error,
> - "cannot mangle this reference temporary yet");
> - getDiags().Report(VD->getLocation(), DiagID);
> + raw_ostream
> &Out) {
> + MicrosoftCXXNameMangler mangler(*this, Out);
> + mangler.mangle(VD);
> }
>
> void MicrosoftMangleContextImpl::mangleStaticGuardVariable(const VarDecl
> *VD,
>
> Modified: cfe/trunk/test/CodeGenCXX/mangle-ms.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-ms.cpp?rev=197184&r1=197183&r2=197184&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/mangle-ms.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/mangle-ms.cpp Thu Dec 12 17:12:01 2013
> @@ -445,3 +445,10 @@ decltype(a) fun(decltype(a) x, decltype(
> // CHECK-DAG: ?fun at PR18022@@YA?AU<unnamed-type-a>@1 at U21@0 at Z
>
> }
> +
> +// Binding to a bit-field that requires a temporary.
> +struct { int bitfield : 3; } object_with_bitfield = { 3 };
> +const int &reference_to_bitfield = object_with_bitfield.bitfield;
> +// CHECK-DAG: ?object_with_bitfield@
> @3U<unnamed-type-object_with_bitfield>@@A
> +// CHECK-DAG: ?reference_to_bitfield@@3ABHB
> +// CHECK-DAG: ??__Ereference_to_bitfield@@YAXXZ
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131212/7ad51554/attachment.html>
More information about the cfe-commits
mailing list