Skip to content

Commit

Permalink
Itanium ABI: Properly mangle extern "C" template arguments
Browse files Browse the repository at this point in the history
extern "C" declarations should be considered like global declarations
for mangling purposes.

Differential Revision: http://reviews.llvm.org/D7718

llvm-svn: 229724
  • Loading branch information
majnemer committed Feb 18, 2015
1 parent 11ae778 commit f8c02e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 8 additions & 0 deletions clang/lib/AST/ItaniumMangle.cpp
Expand Up @@ -69,6 +69,14 @@ static const DeclContext *getEffectiveDeclContext(const Decl *D) {
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;
}

Expand Down
6 changes: 2 additions & 4 deletions clang/test/CodeGenCXX/mangle-template.cpp
Expand Up @@ -29,17 +29,15 @@ namespace test3 {
// 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 {};
// FIXME: Fails because we don't treat as an expression.
// CHECK-FIXME: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
// CHECK: void @_ZN5test42f1ENS_2t1IXadL_Z8test4_f0EEEE(
void f1(t1<test4_f0> a0) {}
}

Expand Down

0 comments on commit f8c02e6

Please sign in to comment.