diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-02-14 01:18:37 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-02-14 01:18:37 +0000 |
commit | 950fee2555f7a6bd193e588d6b6a941fd182391a (patch) | |
tree | a0dd9afcad02780d91902e9510ea41187947662d /lib/AST/ItaniumMangle.cpp | |
parent | d3b4f0e27ffa8d73f8c69a717c39c39a4d47ff0c (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ItaniumMangle.cpp')
-rw-r--r-- | lib/AST/ItaniumMangle.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/AST/ItaniumMangle.cpp b/lib/AST/ItaniumMangle.cpp index dadf9d3cc5..a7fc16aae3 100644 --- a/lib/AST/ItaniumMangle.cpp +++ b/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; } |