Skip to content

Commit 8acf144

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into feat/unknown-attribute-namespaces
2 parents cbbca4d + 650dca5 commit 8acf144

File tree

895 files changed

+24605
-25161
lines changed

Some content is hidden

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

895 files changed

+24605
-25161
lines changed

clang/docs/CommandGuide/clang.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ Language Selection and Mode Options
155155
156156
ISO C 2023 with GNU extensions
157157

158+
| ``c2y``
159+
160+
ISO C 202y
161+
162+
| ``gnu2y``
163+
164+
ISO C 202y with GNU extensions
165+
158166
The default C language standard is ``gnu17``, except on PS4, where it is
159167
``gnu99``.
160168

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: 13 additions & 1 deletion
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

@@ -255,7 +257,10 @@ C23 Feature Support
255257
- Implemented `WG14 N3037 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3037.pdf>`_
256258
which allows tag types to be redefined within the same translation unit so
257259
long as both definitions are structurally equivalent (same tag types, same
258-
tag names, same tag members, etc).
260+
tag names, same tag members, etc). As a result of this paper, ``-Wvisibility``
261+
is no longer diagnosed in C23 if the parameter is a complete tag type (it
262+
does still fire when the parameter is an incomplete tag type as that cannot
263+
be completed).
259264
- Fixed a failed assertion with an invalid parameter to the ``#embed``
260265
directive. Fixes #GH126940.
261266

@@ -284,6 +289,8 @@ Non-comprehensive list of changes in this release
284289
stack space when running on Apple AArch64 based platforms. This means that
285290
stack traces of Clang from debuggers, crashes, and profilers may look
286291
different than before.
292+
- Fixed a crash when a VLA with an invalid size expression was used within a
293+
``sizeof`` or ``typeof`` expression. (#GH138444)
287294

288295
New Compiler Flags
289296
------------------
@@ -591,6 +598,9 @@ Bug Fixes to Attribute Support
591598
``__attribute__((unused))`` are still ignored after the definition, though
592599
this behavior may be relaxed in the future). (#GH135481)
593600

601+
- Clang will warn if a complete type specializes a deprecated partial specialization.
602+
(#GH44496)
603+
594604
Bug Fixes to C++ Support
595605
^^^^^^^^^^^^^^^^^^^^^^^^
596606

@@ -648,6 +658,8 @@ Bug Fixes to C++ Support
648658
(#GH136432), (#GH137014), (#GH138018)
649659
- Fixed an assertion when trying to constant-fold various builtins when the argument
650660
referred to a reference to an incomplete type. (#GH129397)
661+
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
662+
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
651663

652664
Bug Fixes to AST Handling
653665
^^^^^^^^^^^^^^^^^^^^^^^^^

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/ExprCXX.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5124,8 +5124,8 @@ class CXXParenListInitExpr final
51245124

51255125
void updateDependence() { setDependence(computeDependence(this)); }
51265126

5127-
ArrayRef<Expr *> getInitExprs() {
5128-
return ArrayRef(getTrailingObjects<Expr *>(), NumExprs);
5127+
MutableArrayRef<Expr *> getInitExprs() {
5128+
return MutableArrayRef(getTrailingObjects<Expr *>(), NumExprs);
51295129
}
51305130

51315131
const ArrayRef<Expr *> getInitExprs() const {

clang/include/clang/AST/Type.h

Lines changed: 10 additions & 4 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

@@ -3602,6 +3599,9 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36023599
}
36033600

36043601
NestedNameSpecifier *getQualifier() const { return Qualifier; }
3602+
/// Note: this can trigger extra deserialization when external AST sources are
3603+
/// used. Prefer `getCXXRecordDecl()` unless you really need the most recent
3604+
/// decl.
36053605
CXXRecordDecl *getMostRecentCXXRecordDecl() const;
36063606

36073607
bool isSugared() const;
@@ -3610,7 +3610,10 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36103610
}
36113611

36123612
void Profile(llvm::FoldingSetNodeID &ID) {
3613-
Profile(ID, getPointeeType(), getQualifier(), getMostRecentCXXRecordDecl());
3613+
// FIXME: `getMostRecentCXXRecordDecl()` should be possible to use here,
3614+
// however when external AST sources are used it causes nondeterminism
3615+
// issues (see https://github.com/llvm/llvm-project/pull/137910).
3616+
Profile(ID, getPointeeType(), getQualifier(), getCXXRecordDecl());
36143617
}
36153618

36163619
static void Profile(llvm::FoldingSetNodeID &ID, QualType Pointee,
@@ -3620,6 +3623,9 @@ class MemberPointerType : public Type, public llvm::FoldingSetNode {
36203623
static bool classof(const Type *T) {
36213624
return T->getTypeClass() == MemberPointer;
36223625
}
3626+
3627+
private:
3628+
CXXRecordDecl *getCXXRecordDecl() const;
36233629
};
36243630

36253631
/// Capture whether this is a normal array (e.g. int X[4])

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];

0 commit comments

Comments
 (0)