aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-07-18 15:41:43 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-07-18 15:46:26 +0800
commit4983fdfec0443cf388adb87b816b7298a7bdf273 (patch)
tree7d8bedb473adb719277d3b6707c46579247f87c3 /clang/lib
parent11079e8820ab58417365c226d39f2615b0bef685 (diff)
downloadllvm-4983fdfec0443cf388adb87b816b7298a7bdf273.zip
llvm-4983fdfec0443cf388adb87b816b7298a7bdf273.tar.gz
llvm-4983fdfec0443cf388adb87b816b7298a7bdf273.tar.bz2
[C++20] [Modules] Handle reachability for deduction guide
Previously, we forget to handle reachability for deduction guide. The deduction guide is a hint to the compiler. And the deduction guide should be able to use if the corresponding template decl is reachable.
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaLookup.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 47c7a61..aa87a33 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2087,6 +2087,13 @@ bool LookupResult::isAvailableForLookup(Sema &SemaRef, NamedDecl *ND) {
if (isVisible(SemaRef, ND))
return true;
+ // Deduction guide lives in namespace scope generally, but it is just a
+ // hint to the compilers. What we actually lookup for is the generated member
+ // of the corresponding template. So it is sufficient to check the
+ // reachability of the template decl.
+ if (auto *DeductionGuide = ND->getDeclName().getCXXDeductionGuideTemplate())
+ return SemaRef.hasReachableDefinition(DeductionGuide);
+
auto *DC = ND->getDeclContext();
// If ND is not visible and it is at namespace scope, it shouldn't be found
// by name lookup.