Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,23 @@ Builtin type aliases

Clang provides a few builtin aliases to improve the throughput of certain metaprogramming facilities.

__builtin_common_reference
--------------------------

.. code-block:: c++

template <template <class, class, template <class> class, template <class> class> class BasicCommonReferenceT,
template <class... Args> CommonTypeT,
template <class> HasTypeMember,
class HasNoTypeMember,
class... Ts>
using __builtin_common_reference = ...;

This alias is used for implementing ``std::common_reference``. If ``std::common_reference`` should contain a ``type``
member, it is an alias to ``HasTypeMember<TheCommonReference>``. Otherwse it is an alias to ``HasNoTypeMember``. The
``CommonTypeT`` is usually ``std::common_type_t``. ``BasicCommonReferenceT`` is usually an alias template to
``basic_common_reference<T, U, TX, UX>::type``.

__builtin_common_type
---------------------

Expand Down
30 changes: 28 additions & 2 deletions clang/include/clang/Basic/BuiltinTemplates.td
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class TemplateArg<string name> {
string Name = name;
}

class Template<list<TemplateArg> args, string name> : TemplateArg<name> {
class Template<list<TemplateArg> args, string name = ""> : TemplateArg<name> {
list<TemplateArg> Args = args;
}

class Class<string name, bit is_variadic = 0> : TemplateArg<name> {
class Class<string name = "", bit is_variadic = 0> : TemplateArg<name> {
bit IsVariadic = is_variadic;
}

Expand Down Expand Up @@ -56,6 +56,32 @@ def __builtin_common_type : CPlusPlusBuiltinTemplate<
Class<"HasNoTypeMember">,
Class<"Ts", /*is_variadic=*/1>]>;

// template <template <class,"
// class,"
// template <class> class,"
// template <class> class> class BasicCommonReferenceT,"
// template <class... Args> class CommonTypeT,"
// template <class> class HasTypeMember,"
// class HasNoTypeMember,"
// class... Ts>"
def __builtin_common_reference : CPlusPlusBuiltinTemplate<
[Template<[Class<>,
Class<>,
Template<[Class<>]>,
Template<[Class<>]>], "BasicCommonReferenceT">,
Template<[Class<"Args", /*is_variadic=*/1>], "CommonTypeT">,
Template<[Class<>], "HasTypeMember">,
Class<"HasNoTypeMember">,
Class<"Ts", /*is_variadic=*/1>]>;

foreach Ref = ["", "lvalue", "rvalue"] in {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm being a little dense here... what is going on for the forloop?

foreach Const = ["", "const"] in {
foreach Volatile = ["", "volatile"] in {
def __clang_internal_xref_#Ref#Const#Volatile : CPlusPlusBuiltinTemplate<[Class<>]>;
}
}
}

// template <uint32_t Opcode,
// uint32_t Size,
// uint32_t Alignment,
Expand Down
14 changes: 14 additions & 0 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -15188,6 +15188,17 @@ class Sema final : public SemaBase {
QualType BuiltinDecay(QualType BaseType, SourceLocation Loc);
QualType BuiltinAddReference(QualType BaseType, UTTKind UKind,
SourceLocation Loc);

QualType BuiltinAddRValueReference(QualType BaseType, SourceLocation Loc) {
return BuiltinAddReference(BaseType, UnaryTransformType::AddRvalueReference,
Loc);
}

QualType BuiltinAddLValueReference(QualType BaseType, SourceLocation Loc) {
return BuiltinAddReference(BaseType, UnaryTransformType::AddLvalueReference,
Loc);
}

QualType BuiltinRemoveExtent(QualType BaseType, UTTKind UKind,
SourceLocation Loc);
QualType BuiltinRemoveReference(QualType BaseType, UTTKind UKind,
Expand All @@ -15202,6 +15213,9 @@ class Sema final : public SemaBase {
QualType BuiltinChangeSignedness(QualType BaseType, UTTKind UKind,
SourceLocation Loc);

bool BuiltinIsConvertible(QualType From, QualType To, SourceLocation Loc,
bool CheckNothrow = false);

bool BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT, QualType RhsT);

/// Ensure that the type T is a literal type.
Expand Down
Loading
Loading