Skip to content

Commit 228e9d5

Browse files
authored
[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.
1 parent 2cbe5a3 commit 228e9d5

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,8 +3226,8 @@ def TypeVisibility : InheritableAttr {
32263226
let Args = [EnumArgument<"Visibility", "VisibilityType",
32273227
["default", "hidden", "internal", "protected"],
32283228
["Default", "Hidden", "Hidden", "Protected"]>];
3229-
// let Subjects = [Tag, ObjCInterface, Namespace];
3230-
let Documentation = [Undocumented];
3229+
// let Subjects = SubjectList<[Tag, ObjCInterface, Namespace], ErrorDiag>;
3230+
let Documentation = [TypeVisibilityDocs];
32313231
}
32323232

32333233
def VecReturn : InheritableAttr {

clang/include/clang/Basic/AttrDocs.td

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5585,6 +5585,25 @@ See :doc:`LTOVisibility`.
55855585
}];
55865586
}
55875587

5588+
def TypeVisibilityDocs : Documentation {
5589+
let Category = DocCatType;
5590+
let Content = [{
5591+
The ``type_visibility`` attribute allows the visibility of a type and its vague
5592+
linkage objects (vtable, typeinfo, typeinfo name) to be controlled separately from
5593+
the visibility of functions and data members of the type.
5594+
5595+
For example, this can be used to give default visibility to the typeinfo and the vtable
5596+
of a type while still keeping hidden visibility on its member functions and static data
5597+
members.
5598+
5599+
This attribute can only be applied to types and namespaces.
5600+
5601+
If both ``visibility`` and ``type_visibility`` are applied to a type or a namespace, the
5602+
visibility specified with the ``type_visibility`` attribute overrides the visibility
5603+
provided with the regular ``visibility`` attribute.
5604+
}];
5605+
}
5606+
55885607
def RenderScriptKernelAttributeDocs : Documentation {
55895608
let Category = DocCatFunction;
55905609
let Content = [{

0 commit comments

Comments
 (0)