[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread John McCall via cfe-commits
rjmccall wrote: Can we just ignore template parameters selectively when we have a visibility attribute, the way I suggested in https://reviews.llvm.org/D154774? To quote: > A visibility attribute on an explicit specialization or instantiation should > definitely override everything else. A v

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread Fangrui Song via cfe-commits
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/72092 >From 401af7b4eabe92c8264c722a3f1181875da18438 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Sun, 12 Nov 2023 23:22:50 -0800 Subject: [PATCH 1/2] Ignore template parameter visibility When computing the visib

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread Fangrui Song via cfe-commits
MaskRay wrote: Thanks for the comment. Frankly, I am at a loss in deriving a criterion (for shouldConsiderTemplateVisibility) to select one of the following rules. (1) factor in both template arguments and template parameters (2) factor in only template arguments (3) factor in nothing. Could y

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread John McCall via cfe-commits
rjmccall wrote: > I cannot figure out a test case for `TemplateArgument::Expression`. I wonder > whether it applies to `X<&s.s> x5;` (address of static member), which Clang > doesn't support. It's primarily used as a dependent template argument. I'm not sure off-hand that it's *never* canoni

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread Fangrui Song via cfe-commits
MaskRay wrote: > > After the change, does it seem more feasible to ignore template parameters? > > Hmm. You're right that considering the type of a non-type template argument > would be enough to give the right visibility to my example. It would not be > enough if the template was used as a te

[clang] Ignore template parameter visibility (PR #72092)

2023-11-14 Thread John McCall via cfe-commits
rjmccall wrote: The basic design idea behind Clang's visibility model is to treat hidden visibility as essentially a second grade of external linkage, external to the translation unit but internal to the linkage unit (i.e. image). So what you pointed out about using an anonymous namespace is

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread Fangrui Song via cfe-commits
https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/72092 When computing the visibility of a template specialization/instantiation, GCC considers template arguments and ignores type template parameters. We currently consider non-type template parameters, which adds a lo

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Fangrui Song (MaskRay) Changes When computing the visibility of a template specialization/instantiation, GCC considers template arguments and ignores type template parameters. We currently consider non-type template parameters, which adds

[clang] Ignore template parameter visibility (PR #72092)

2023-11-13 Thread via cfe-commits
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff e734bc53de8173a1b54493f3e0c8f70575341a9e 401af7b4eabe92c8264c722a3f1181875da18438 --