diff options
author | Alex Lorenz <arphaman@gmail.com> | 2016-11-02 15:46:34 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2016-11-02 15:46:34 +0000 |
commit | 560ae565e9fa981ce2a49282b71c1e716ff347d1 (patch) | |
tree | e84aeceba2a821f6f863609ac9dd5307da27cb57 /clang/lib/AST/DeclBase.cpp | |
parent | 93f2f7fb6c323083ec39abc0b67a9b51dc416684 (diff) | |
download | bcm5719-llvm-560ae565e9fa981ce2a49282b71c1e716ff347d1.tar.gz bcm5719-llvm-560ae565e9fa981ce2a49282b71c1e716ff347d1.zip |
Add a note that points to the linkage specifier for the C++ linkage errors
This commit improves the "must have C++ linkage" error diagnostics that are
emitted for C++ declarations like templates and literal operators by adding an
additional note that points to the appropriate extern "C" linkage specifier.
rdar://19021120
Differential Revision: https://reviews.llvm.org/D26189
llvm-svn: 285823
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 7e790cec68a..5d130acfbed 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -992,6 +992,18 @@ bool DeclContext::isExternCContext() const { return isLinkageSpecContext(this, clang::LinkageSpecDecl::lang_c); } +const LinkageSpecDecl *DeclContext::getExternCContext() const { + const DeclContext *DC = this; + while (DC->getDeclKind() != Decl::TranslationUnit) { + if (DC->getDeclKind() == Decl::LinkageSpec && + cast<LinkageSpecDecl>(DC)->getLanguage() == + clang::LinkageSpecDecl::lang_c) + return cast<LinkageSpecDecl>(DC); + DC = DC->getLexicalParent(); + } + return nullptr; +} + bool DeclContext::isExternCXXContext() const { return isLinkageSpecContext(this, clang::LinkageSpecDecl::lang_cxx); } |