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 | f4187658fa824f8f24ef578377ff6c174f527021 (patch) | |
tree | 63b136d6bc5c88ec27f10ddc87734bd591873d36 /clang/lib/AST/DeclBase.cpp | |
parent | b7444cd11ef1f688d91f0970f2615177af63916f (diff) | |
download | bcm5719-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/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index e1f40356e27..f675436fc5f 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/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); |