Skip to content

Commit b4e6a1a

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents dd9f7b1 + ad5b3e0 commit b4e6a1a

File tree

209 files changed

+8978
-3035
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+8978
-3035
lines changed

clang/docs/InternalsManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Description:
276276
diagnostic instead of having to do things textually. The selected string
277277
does undergo formatting.
278278

279-
**"enum_select format**
279+
**"enum_select" format**
280280

281281
Example:
282282
``unknown frobbling of a %enum_select<FrobbleKind>{%VarDecl{variable declaration}|%FuncDecl{function declaration}}0 when blarging``

clang/docs/LanguageExtensions.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,7 @@ Static assert with user-generated message __cpp_static_assert >= 202306L C
16801680
Pack Indexing __cpp_pack_indexing C++26 C++03
16811681
``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03
16821682
Variadic Friends __cpp_variadic_friend C++26 C++03
1683+
Trivial Relocatability __cpp_trivial_relocatability C++26 C++03
16831684
--------------------------------------------- -------------------------------- ------------- -------------
16841685
Designated initializers (N494) C99 C89
16851686
Array & element qualification (N2607) C23 C89
@@ -1861,8 +1862,15 @@ The following type trait primitives are supported by Clang. Those traits marked
18611862
* ``__is_trivially_relocatable`` (Clang): Returns true if moving an object
18621863
of the given type, and then destroying the source object, is known to be
18631864
functionally equivalent to copying the underlying bytes and then dropping the
1864-
source object on the floor. This is true of trivial types and types which
1865+
source object on the floor. This is true of trivial types,
1866+
C++26 relocatable types, and types which
18651867
were made trivially relocatable via the ``clang::trivial_abi`` attribute.
1868+
* ``__builtin_is_cpp_trivially_relocatable`` (C++): Returns true if an object
1869+
is trivially relocatable, as defined by the C++26 standard [meta.unary.prop].
1870+
Note that when relocating the caller code should ensure that if the object is polymorphic,
1871+
the dynamic type is of the most derived type. Padding bytes should not be copied.
1872+
* ``__builtin_is_replaceable`` (C++): Returns true if an object
1873+
is replaceable, as defined by the C++26 standard [meta.unary.prop].
18661874
* ``__is_trivially_equality_comparable`` (Clang): Returns true if comparing two
18671875
objects of the provided type is known to be equivalent to comparing their
18681876
object representations. Note that types containing padding bytes are never
@@ -3722,6 +3730,21 @@ Query for this feature with ``__has_builtin(__builtin_operator_new)`` or
37223730
replaceable global (de)allocation functions, but do support calling at least
37233731
``::operator new(size_t)`` and ``::operator delete(void*)``.
37243732
3733+
3734+
``__builtin_trivially_relocate``
3735+
-----------------------------------
3736+
3737+
**Syntax**:
3738+
3739+
.. code-block:: c
3740+
3741+
T* __builtin_trivially_relocate(T* dest, T* src, size_t count)
3742+
3743+
Trivially relocates ``count`` objects of relocatable, complete type ``T``
3744+
from ``src`` to ``dest`` and returns ``dest``.
3745+
This builtin is used to implement ``std::trivially_relocate``.
3746+
3747+
37253748
``__builtin_preserve_access_index``
37263749
-----------------------------------
37273750

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ C++2c Feature Support
106106
^^^^^^^^^^^^^^^^^^^^^
107107

108108
- Implemented `P1061R10 Structured Bindings can introduce a Pack <https://wg21.link/P1061R10>`_.
109+
- Implemented `P2786R13 Trivial Relocatability <https://wg21.link/P2786R13>`_.
110+
109111

110112
- Implemented `P0963R3 Structured binding declaration as a condition <https://wg21.link/P0963R3>`_.
111113

clang/include/clang/AST/ASTContext.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,20 @@ class ASTContext : public RefCountedBase<ASTContext> {
617617
using ParameterIndexTable = llvm::DenseMap<const VarDecl *, unsigned>;
618618
ParameterIndexTable ParamIndices;
619619

620+
public:
621+
struct CXXRecordDeclRelocationInfo {
622+
unsigned IsRelocatable;
623+
unsigned IsReplaceable;
624+
};
625+
std::optional<CXXRecordDeclRelocationInfo>
626+
getRelocationInfoForCXXRecord(const CXXRecordDecl *) const;
627+
void setRelocationInfoForCXXRecord(const CXXRecordDecl *,
628+
CXXRecordDeclRelocationInfo);
629+
630+
private:
631+
llvm::DenseMap<const CXXRecordDecl *, CXXRecordDeclRelocationInfo>
632+
RelocatableClasses;
633+
620634
ImportDecl *FirstLocalImport = nullptr;
621635
ImportDecl *LastLocalImport = nullptr;
622636

clang/include/clang/AST/DeclCXX.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,9 @@ class CXXRecordDecl : public RecordDecl {
15501550
/// Returns the destructor decl for this class.
15511551
CXXDestructorDecl *getDestructor() const;
15521552

1553+
/// Returns the destructor decl for this class.
1554+
bool hasDeletedDestructor() const;
1555+
15531556
/// Returns true if the class destructor, or any implicitly invoked
15541557
/// destructors are marked noreturn.
15551558
bool isAnyDestructorNoReturn() const { return data().IsAnyDestructorNoReturn; }

clang/include/clang/AST/Type.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,6 @@ class QualType {
11331133
/// Return true if this is a trivially copyable type
11341134
bool isTriviallyCopyConstructibleType(const ASTContext &Context) const;
11351135

1136-
/// Return true if this is a trivially relocatable type.
1137-
bool isTriviallyRelocatableType(const ASTContext &Context) const;
1138-
11391136
/// Returns true if it is a class and it might be dynamic.
11401137
bool mayBeDynamicClass() const;
11411138

clang/include/clang/Basic/Attr.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,6 +1819,22 @@ def Final : InheritableAttr {
18191819
let Documentation = [InternalOnly];
18201820
}
18211821

1822+
def TriviallyRelocatable : InheritableAttr {
1823+
let Spellings = [CustomKeyword<"trivially_relocatable_if_eligible">];
1824+
let SemaHandler = 0;
1825+
// Omitted from docs, since this is language syntax, not an attribute, as far
1826+
// as users are concerned.
1827+
let Documentation = [InternalOnly];
1828+
}
1829+
1830+
def Replaceable : InheritableAttr {
1831+
let Spellings = [CustomKeyword<"replaceable_if_eligible">];
1832+
let SemaHandler = 0;
1833+
// Omitted from docs, since this is language syntax, not an attribute, as far
1834+
// as users are concerned.
1835+
let Documentation = [InternalOnly];
1836+
}
1837+
18221838
def MinSize : InheritableAttr {
18231839
let Spellings = [Clang<"minsize">];
18241840
let Subjects = SubjectList<[Function, ObjCMethod], ErrorDiag>;

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,6 +2853,12 @@ def MemMove : LibBuiltin<"string.h"> {
28532853
let AddBuiltinPrefixedAlias = 1;
28542854
}
28552855

2856+
def BuiltinTriviallyRelocate : Builtin {
2857+
let Spellings = ["__builtin_trivially_relocate"];
2858+
let Attributes = [FunctionWithBuiltinPrefix, CustomTypeChecking, NoThrow];
2859+
let Prototype = "void*(void*, void*, size_t)";
2860+
}
2861+
28562862
def StrCpy : LibBuiltin<"string.h"> {
28572863
let Spellings = ["strcpy"];
28582864
let Attributes = [NoThrow];

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,12 +1065,24 @@ def ext_ms_abstract_keyword : ExtWarn<
10651065
"'abstract' keyword is a Microsoft extension">,
10661066
InGroup<MicrosoftAbstract>;
10671067

1068+
def ext_relocatable_keyword : ExtWarn<
1069+
"'%select{trivially_relocatable_if_eligible|replaceable_if_eligible}0' "
1070+
"keyword is a C++2c extension">,
1071+
InGroup<CXX26>;
1072+
def warn_relocatable_keyword : Warning<
1073+
"'%select{trivially_relocatable|replaceable}0_if_eligible' "
1074+
"keyword is incompatible with standards before C++2c">,
1075+
DefaultIgnore, InGroup<CXXPre26Compat>;
1076+
10681077
def err_access_specifier_interface : Error<
10691078
"interface types cannot specify '%select{private|protected}0' access">;
10701079

10711080
def err_duplicate_class_virt_specifier : Error<
10721081
"class already marked '%0'">;
10731082

1083+
def err_duplicate_class_relocation_specifier : Error<
1084+
"class already marked '%select{trivially_relocatable_if_eligible|replaceable_if_eligible}0'">;
1085+
10741086
def err_duplicate_virt_specifier : Error<
10751087
"class member already marked '%0'">;
10761088

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12668,6 +12668,11 @@ def err_builtin_invalid_arg_type: Error<
1266812668
"%plural{0:|: }3"
1266912669
"%plural{[0,3]:type|:types}1 (was %4)">;
1267012670

12671+
def err_builtin_trivially_relocate_invalid_arg_type: Error <
12672+
"first%select{||| and second}0 argument%select{|||s}0 to "
12673+
"'__builtin_trivially_relocate' must be"
12674+
" %select{a pointer|non-const|relocatable|of the same type}0">;
12675+
1267112676
def err_builtin_matrix_disabled: Error<
1267212677
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;
1267312678
def err_matrix_index_not_integer: Error<

0 commit comments

Comments
 (0)