From 600ee1726b3e57c2827965e025457a65ad801555 Mon Sep 17 00:00:00 2001 From: Alex Lorenz Date: Thu, 27 Oct 2016 13:51:30 +0000 Subject: [PATCH] Add documentation for the transparent_union attribute Differential Revision: https://reviews.llvm.org/D25995 llvm-svn: 285292 --- clang/include/clang/Basic/Attr.td | 2 +- clang/include/clang/Basic/AttrDocs.td | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 2855207b4b6e..3376f640a127 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1542,7 +1542,7 @@ def Target : InheritableAttr { def TransparentUnion : InheritableAttr { let Spellings = [GCC<"transparent_union">]; // let Subjects = SubjectList<[Record, TypedefName]>; - let Documentation = [Undocumented]; + let Documentation = [TransparentUnionDocs]; let LangOpts = [COnly]; } diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index b62ac7cf2a2a..44e0a8e400c4 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -2649,3 +2649,21 @@ Conversely, ``__attribute__((xray_never_instrument))`` or ``[[clang::xray_never_ If a function has neither of these attributes, they become subject to the XRay heuristics used to determine whether a function should be instrumented or otherwise. }]; } + +def TransparentUnionDocs : Documentation { + let Category = DocCatType; + let Content = [{ +This attribute can be applied to a union to change the behaviour of calls to +functions that have an argument with a transparent union type. The compiler +behaviour is changed in the following manner: + +- A value whose type is any member of the transparent union can be passed as an +argument without the need to cast that value. + +- The argument is passed to the function using the calling convention of the +first member of the transparent union. Consequently, all the members of the +transparent union should have the same calling convention as its first member. + +Transparent unions are not supported in C++. + }]; +}