[clang] 228e9d5 - [clang] Document the type_visibility attribute (#79157)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 9 12:31:13 PST 2024
Author: Louis Dionne
Date: 2024-02-09T15:31:08-05:00
New Revision: 228e9d5bcfcb6411d2a257b560464323d0248c35
URL: https://github.com/llvm/llvm-project/commit/228e9d5bcfcb6411d2a257b560464323d0248c35
DIFF: https://github.com/llvm/llvm-project/commit/228e9d5bcfcb6411d2a257b560464323d0248c35.diff
LOG: [clang] Document the type_visibility attribute (#79157)
I was looking for the documentation of that attribute, and the best I
could find was a Stackoverflow answer or the commit message that
originally introduced the attribute. I figured I might as well document
what I find to save everyone time in the future.
Added:
Modified:
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
Removed:
################################################################################
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index b2d5309e142c1a..45a29e771f2a21 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -3226,8 +3226,8 @@ def TypeVisibility : InheritableAttr {
let Args = [EnumArgument<"Visibility", "VisibilityType",
["default", "hidden", "internal", "protected"],
["Default", "Hidden", "Hidden", "Protected"]>];
-// let Subjects = [Tag, ObjCInterface, Namespace];
- let Documentation = [Undocumented];
+ // let Subjects = SubjectList<[Tag, ObjCInterface, Namespace], ErrorDiag>;
+ let Documentation = [TypeVisibilityDocs];
}
def VecReturn : InheritableAttr {
diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
index 19a98a0ccb9262..8d369091d21590 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5585,6 +5585,25 @@ See :doc:`LTOVisibility`.
}];
}
+def TypeVisibilityDocs : Documentation {
+ let Category = DocCatType;
+ let Content = [{
+The ``type_visibility`` attribute allows the visibility of a type and its vague
+linkage objects (vtable, typeinfo, typeinfo name) to be controlled separately from
+the visibility of functions and data members of the type.
+
+For example, this can be used to give default visibility to the typeinfo and the vtable
+of a type while still keeping hidden visibility on its member functions and static data
+members.
+
+This attribute can only be applied to types and namespaces.
+
+If both ``visibility`` and ``type_visibility`` are applied to a type or a namespace, the
+visibility specified with the ``type_visibility`` attribute overrides the visibility
+provided with the regular ``visibility`` attribute.
+ }];
+}
+
def RenderScriptKernelAttributeDocs : Documentation {
let Category = DocCatFunction;
let Content = [{
More information about the cfe-commits
mailing list