From 3e0e33d7e5e6cafa2ef8403fe2822f9f6e51eb78 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 14 Feb 2013 15:38:59 +0000 Subject: [PATCH] Mangle extern "C" functions whose names are not simple identifiers. llvm-svn: 175166 --- clang/lib/AST/ItaniumMangle.cpp | 8 ++++++-- clang/test/CodeGenCXX/c-linkage.cpp | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index 1f95a2f..d427b08 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -373,8 +373,8 @@ bool ItaniumMangleContext::shouldMangleDeclName(const NamedDecl *D) { if (FD->hasAttr()) return true; - // C functions and "main" are not mangled. - if (FD->isMain() || L == CLanguageLinkage) + // "main" is not mangled. + if (FD->isMain()) return false; // C++ functions and those whose names are not a simple identifier need @@ -382,6 +382,10 @@ bool ItaniumMangleContext::shouldMangleDeclName(const NamedDecl *D) { if (!FD->getDeclName().isIdentifier() || L == CXXLanguageLinkage) return true; + // C functions are not mangled. + if (L == CLanguageLinkage) + return false; + // FIXME: Users assume they know the mangling of static functions // declared in extern "C" contexts, so we cannot always mangle them. // As an improvement, maybe we could mangle them only if they are actually diff --git a/clang/test/CodeGenCXX/c-linkage.cpp b/clang/test/CodeGenCXX/c-linkage.cpp index c31ad43..cec9e28 100644 --- a/clang/test/CodeGenCXX/c-linkage.cpp +++ b/clang/test/CodeGenCXX/c-linkage.cpp @@ -22,3 +22,10 @@ extern "C" { test2_f(); } } + +extern "C" { + struct test3_s { + }; + bool operator==(const int& a, const test3_s& b) { + } +} -- 2.7.4