[PATCH] Itanium ABI: Properly mangle extern "C" template arguments

Richard Smith richard at metafoo.co.uk
Wed Feb 18 10:46:09 PST 2015


LGTM

On Wed, Feb 18, 2015 at 12:38 AM, David Majnemer <david.majnemer at gmail.com>
wrote:

> Hi rsmith,
>
> extern "C" declarations should be considered like global declarations
> for mangling purposes.
>
> http://reviews.llvm.org/D7718
>
> Files:
>   lib/AST/ItaniumMangle.cpp
>   test/CodeGenCXX/mangle-template.cpp
>
> Index: lib/AST/ItaniumMangle.cpp
> ===================================================================
> --- lib/AST/ItaniumMangle.cpp
> +++ lib/AST/ItaniumMangle.cpp
> @@ -69,6 +69,14 @@
>    if (const CapturedDecl *CD = dyn_cast<CapturedDecl>(DC))
>      return getEffectiveDeclContext(CD);
>
> +  if (const auto *VD = dyn_cast<VarDecl>(D))
> +    if (VD->isExternC())
> +      return VD->getASTContext().getTranslationUnitDecl();
> +
> +  if (const auto *FD = dyn_cast<FunctionDecl>(D))
> +    if (FD->isExternC())
> +      return FD->getASTContext().getTranslationUnitDecl();
> +
>    return DC;
>  }
>
> Index: test/CodeGenCXX/mangle-template.cpp
> ===================================================================
> --- test/CodeGenCXX/mangle-template.cpp
> +++ test/CodeGenCXX/mangle-template.cpp
> @@ -28,16 +28,15 @@
>  // CHECK: void @test3_f0
>  extern "C" void test3_f0(float) {}
>  template<void (&)(float)> struct t1 {};
> -// FIXME: Fails because we tack on a namespace.
> -// CHECK-FIXME: void @_ZN5test32f1ENS_2t1ILZ8test3_f0EEE(
> +// CHECK: void @_ZN5test32f1ENS_2t1IL_Z8test3_f0EEE(
>  void f1(t1<test3_f0> a0) {}
>  }
>
>  namespace test4 {
>  // CHECK: void @test4_f0
>  extern "C" void test4_f0(float) {}
>  template<void (*)(float)> struct t1 {};
> -// CHECK: void @_ZN5test42f1ENS_2t1IXadL_ZNS_8test4_f0EEEEE(
> +// CHECK: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
>  void f1(t1<test4_f0> a0) {}
>  }
>
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150218/d118615e/attachment.html>


More information about the cfe-commits mailing list