Author: Chuanqi Xu Date: 2022-01-11T09:54:57+08:00 New Revision: 86c5b870b2e5192a9414204500a53b31524db065
URL: https://github.com/llvm/llvm-project/commit/86c5b870b2e5192a9414204500a53b31524db065 DIFF: https://github.com/llvm/llvm-project/commit/86c5b870b2e5192a9414204500a53b31524db065.diff LOG: [AST] Don't consider 'ExportDecl' when calculating DeclContext 'Encloses' This mimics the style of 90010c2e1 (Don't consider 'LinkageSpec' when calculating DeclContext 'Encloses'). Since ExportDecl and LinkageSpec are transparent DeclContext, they share some similarity. Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D116911 Added: clang/test/SemaCXX/lookup-through-export.cpp Modified: clang/lib/AST/DeclBase.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 064012ba865c8..52b8a45721105 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1212,7 +1212,8 @@ bool DeclContext::Encloses(const DeclContext *DC) const { return getPrimaryContext()->Encloses(DC); for (; DC; DC = DC->getParent()) - if (!isa<LinkageSpecDecl>(DC) && DC->getPrimaryContext() == this) + if (!isa<LinkageSpecDecl>(DC) && !isa<ExportDecl>(DC) && + DC->getPrimaryContext() == this) return true; return false; } diff --git a/clang/test/SemaCXX/lookup-through-export.cpp b/clang/test/SemaCXX/lookup-through-export.cpp new file mode 100644 index 0000000000000..503a694655608 --- /dev/null +++ b/clang/test/SemaCXX/lookup-through-export.cpp @@ -0,0 +1,31 @@ +// RUN: %clang_cc1 -std=c++20 %s -verify + +// expected-no-diagnostics +export module X; +export { + namespace A { + namespace B { + int bar; + } + } // namespace A + namespace C { + void foo() { + using namespace A; + (void)B::bar; + } + } // namespace C +} + +export { + namespace D { + namespace E { + int bar; + } + } // namespace D + namespace F { + void foo() { + using namespace D; + (void)E::bar; + } + } // namespace F +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits