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/DeclBase.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/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index e1f40356e2..f675436fc5 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -806,6 +806,17 @@ bool DeclContext::isExternCContext() const { return false; } +bool DeclContext::isExternCXXContext() const { + const DeclContext *DC = this; + while (DC->DeclKind != Decl::TranslationUnit) { + if (DC->DeclKind == Decl::LinkageSpec) + return cast<LinkageSpecDecl>(DC)->getLanguage() + == LinkageSpecDecl::lang_cxx; + DC = DC->getParent(); + } + return false; +} + bool DeclContext::Encloses(const DeclContext *DC) const { if (getPrimaryContext() != this) return getPrimaryContext()->Encloses(DC); |