[PATCH] D153835: [Sema] Clone VisibilityAttr for functions in template instantiations

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 26 22:43:58 PDT 2023


MaskRay created this revision.
MaskRay added reviewers: clang, aaron.ballman, efriedma, rjmccall, smeenai.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix https://github.com/llvm/llvm-project/issues/31462

Modify the behavior from 7f90b7d4c29d560b57f6026f886adbf4d7ab4382 (2012) to
clone VisibilityAttr for functions. I think that commit fixed a behavior
but made us more difficult to align with GCC.

The new behavior aligns better with GCC. Specifically, an instantiated
FunctionTemplateDecl/CXXMethodDecl now inherits the original visibility
attribute (test71 in visibility.cpp).

The cloned VisibilityAttr is set to implicit. This is important for
`template void HIDDEN zed<&y>();` to override the original VisibilityAttr (test51).

For now, it's important not to clone VisibilityAttr for non-FunctionDecl as that
would break test38 (and change test35 in another way to be incompatible
with GCC).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153835

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/CodeGenCXX/visibility.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153835.534841.patch
Type: text/x-patch
Size: 5200 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230627/d414de04/attachment-0001.bin>


More information about the cfe-commits mailing list