aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/ItaniumMangle.cpp9
-rw-r--r--lib/Sema/SemaOverload.cpp8
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp
index e9a3b03483..1f95a2fee0 100644
--- a/lib/AST/ItaniumMangle.cpp
+++ b/lib/AST/ItaniumMangle.cpp
@@ -381,6 +381,15 @@ bool ItaniumMangleContext::shouldMangleDeclName(const NamedDecl *D) {
// mangling.
if (!FD->getDeclName().isIdentifier() || L == CXXLanguageLinkage)
return true;
+
+ // 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
+ // overloaded.
+ const DeclContext *DC = FD->getDeclContext();
+ if (!DC->isRecord() &&
+ FD->getFirstDeclaration()->getDeclContext()->isExternCContext())
+ return false;
}
// Otherwise, no mangling is done outside C++ mode.
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 9bba5f6c78..20fb7a768b 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -974,6 +974,14 @@ static bool canBeOverloaded(const FunctionDecl &D) {
if (D.isMain())
return false;
+ // FIXME: Users assume they know the mangling of static functions
+ // declared in extern "C" contexts. For now just disallow overloading these
+ // functions so that we can avoid mangling them.
+ const DeclContext *DC = D.getDeclContext();
+ if (!DC->isRecord() &&
+ D.getFirstDeclaration()->getDeclContext()->isExternCContext())
+ return false;
+
return true;
}