aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-02-14 15:38:59 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-02-14 15:38:59 +0000
commit83dece57e3e3fd84dfd4299a89751e266e87c79d (patch)
tree522cb626996f477ee8c596b91d7bc7eb398109cf
parent9fc56f2636137fcde8acb38865555ed6c7b84dfd (diff)
Mangle extern "C" functions whose names are not simple identifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175166 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/AST/ItaniumMangle.cpp8
-rw-r--r--test/CodeGenCXX/c-linkage.cpp7
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index 1f95a2fee0..d427b082a4 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -373,8 +373,8 @@ bool ItaniumMangleContext::shouldMangleDeclName(const NamedDecl *D) {
if (FD->hasAttr<OverloadableAttr>())
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/test/CodeGenCXX/c-linkage.cpp b/test/CodeGenCXX/c-linkage.cpp
index c31ad43860..cec9e282f6 100644
--- a/test/CodeGenCXX/c-linkage.cpp
+++ b/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) {
+ }
+}