aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-01-24 10:22:33 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-01-24 10:25:25 +0800
commit3a3af2bbc97e7db045eccb8683e93b9aa7ef562b (patch)
tree25c9b3e52b6017cf9ec0a6d8195c095b063f32e2 /clang/lib/AST/DeclBase.cpp
parent2e58a18910867ba6795066e044293e6daf89edf5 (diff)
downloadllvm-3a3af2bbc97e7db045eccb8683e93b9aa7ef562b.zip
llvm-3a3af2bbc97e7db045eccb8683e93b9aa7ef562b.tar.gz
llvm-3a3af2bbc97e7db045eccb8683e93b9aa7ef562b.tar.bz2
[C++20] [Module] fix bug 47716 and implement [module.interface]/p6
This fixes bug 47716. According to [module.interface]p2, it is meaningless to export an entity which is not in namespace scope. The reason why the compiler crashes is that the compiler missed ExportDecl when the compiler traverse the subclass of DeclContext. So here is the crash. Also, the patch implements [module.interface]p6 in Sema::CheckRedeclaration* functions. Reviewed By: aaron.ballman, urnathan Differential Revision: https://reviews.llvm.org/D112903
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 98a5c6b..9ee1cc0 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -995,6 +995,15 @@ bool Decl::AccessDeclContextCheck() const {
return true;
}
+bool Decl::isInExportDeclContext() const {
+ const DeclContext *DC = getLexicalDeclContext();
+
+ while (DC && !isa<ExportDecl>(DC))
+ DC = DC->getLexicalParent();
+
+ return DC && isa<ExportDecl>(DC);
+}
+
static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }