[clang] [Clang][Sema] Allow access to a public template alias declaration that refers to friend's private nested type (PR #83847)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 11 09:25:10 PDT 2024
================
@@ -4342,10 +4342,17 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
InstantiatingTemplate Inst(*this, TemplateLoc, Template);
if (Inst.isInvalid())
return QualType();
+ if (!AliasTemplate->getDeclContext()->isFileContext()) {
+ ContextRAII SavedContext(*this, AliasTemplate->getDeclContext());
----------------
erichkeane wrote:
> nit: This can be simplified using `std::optional`:
>
> ```c++
> std::optional<ContextRAII> C;
> if (!A.getDeclContext()->isFileContext())
> C.emplace(*this, A->getDeclContext());
> ```
Neat trick, I like it!
https://github.com/llvm/llvm-project/pull/83847
More information about the cfe-commits
mailing list