summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ItaniumMangle.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-02-14 01:18:37 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-02-14 01:18:37 +0000
commitf4187658fa824f8f24ef578377ff6c174f527021 (patch)
tree63b136d6bc5c88ec27f10ddc87734bd591873d36 /clang/lib/AST/ItaniumMangle.cpp
parentb7444cd11ef1f688d91f0970f2615177af63916f (diff)
downloadbcm5719-llvm-f4187658fa824f8f24ef578377ff6c174f527021.tar.gz
bcm5719-llvm-f4187658fa824f8f24ef578377ff6c174f527021.zip
Add a getLanguageLinkage method to VarDecls and FunctionDecls. Use it to fix
some cases where functions with no language linkage were being treated as having C language linkage. In particular, don't warn in extern "C" { static NonPod foo(); } Since getLanguageLinkage checks the language linkage, the linkage computation cannot use the language linkage. Break the loop by checking just the context in the linkage computation. llvm-svn: 175117
Diffstat (limited to 'clang/lib/AST/ItaniumMangle.cpp')
-rw-r--r--clang/lib/AST/ItaniumMangle.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index dadf9d3cc52..a7fc16aae36 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -356,17 +356,6 @@ private:
}
-static bool isInCLinkageSpecification(const Decl *D) {
- D = D->getCanonicalDecl();
- for (const DeclContext *DC = getEffectiveDeclContext(D);
- !DC->isTranslationUnit(); DC = getEffectiveParentContext(DC)) {
- if (const LinkageSpecDecl *Linkage = dyn_cast<LinkageSpecDecl>(DC))
- return Linkage->getLanguage() == LinkageSpecDecl::lang_c;
- }
-
- return false;
-}
-
bool ItaniumMangleContext::shouldMangleDeclName(const NamedDecl *D) {
// In C, functions with no attributes never need to be mangled. Fastpath them.
if (!getASTContext().getLangOpts().CPlusPlus && !D->hasAttrs())
@@ -405,8 +394,12 @@ bool ItaniumMangleContext::shouldMangleDeclName(const NamedDecl *D) {
return true;
// C functions and "main" are not mangled.
- if ((FD && FD->isMain()) || isInCLinkageSpecification(D))
- return false;
+ if (FD)
+ return !FD->isMain() && !FD->hasCLanguageLinkage();
+
+ // C variables are not mangled.
+ if (const VarDecl *VD = dyn_cast<VarDecl>(D))
+ return !VD->hasCLanguageLinkage();
return true;
}
OpenPOWER on IntegriCloud