Skip to content

Commit e61ee7e

Browse files
authored
Merge branch 'main' into Add-inreg-bit-convert-tests
2 parents f7e4a87 + b5c7724 commit e61ee7e

File tree

814 files changed

+19085
-21744
lines changed

Some content is hidden

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

814 files changed

+19085
-21744
lines changed

clang-tools-extra/modularize/ModularizeUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ std::error_code ModularizeUtilities::loadModuleMap(
290290
Target.get(), *HeaderInfo));
291291

292292
// Parse module.modulemap file into module map.
293-
if (ModMap->loadModuleMapFile(ModuleMapEntry, false, Dir)) {
293+
if (ModMap->parseAndLoadModuleMapFile(ModuleMapEntry, false, Dir)) {
294294
return std::error_code(1, std::generic_category());
295295
}
296296

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Regression test for https://github.com/llvm/llvm-project/issues/59819
2+
3+
// RUN: rm -rf %t && mkdir -p %t
4+
// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
5+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS-LINE
6+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.md --check-prefix=MD-MYCLASS
7+
8+
// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
9+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS-LINE
10+
// RUN: FileCheck %s < %t/GlobalNamespace/MyClass.html --check-prefix=HTML-MYCLASS
11+
12+
#define DECLARE_METHODS \
13+
/**
14+
* @brief Declare a method to calculate the sum of two numbers
15+
*/ \
16+
int Add(int a, int b) { \
17+
return a + b; \
18+
}
19+
20+
// MD-MYCLASS: ### Add
21+
// MD-MYCLASS: *public int Add(int a, int b)*
22+
// MD-MYCLASS: **brief** Declare a method to calculate the sum of two numbers
23+
24+
// HTML-MYCLASS: <p>public int Add(int a, int b)</p>
25+
// HTML-MYCLASS: <div>brief</div>
26+
// HTML-MYCLASS: <p> Declare a method to calculate the sum of two numbers</p>
27+
28+
29+
class MyClass {
30+
public:
31+
// MD-MYCLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp#[[@LINE+2]]*
32+
// HTML-MYCLASS-LINE: <p>Defined at line [[@LINE+1]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}comments-in-macros.cpp</p>
33+
DECLARE_METHODS
34+
};
35+

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: 5 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

@@ -655,6 +657,9 @@ Bug Fixes to C++ Support
655657
- Fixed an assertion when trying to constant-fold various builtins when the argument
656658
referred to a reference to an incomplete type. (#GH129397)
657659
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
660+
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
661+
- No longer crashes when instantiating invalid variable template specialization
662+
whose type depends on itself. (#GH51347), (#GH55872)
658663

659664
Bug Fixes to AST Handling
660665
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/ASTContext.h

Lines changed: 19 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

@@ -2956,6 +2970,11 @@ class ASTContext : public RefCountedBase<ASTContext> {
29562970
TemplateTemplateParmDecl *insertCanonicalTemplateTemplateParmDeclInternal(
29572971
TemplateTemplateParmDecl *CanonTTP) const;
29582972

2973+
/// Determine whether the given template arguments \p Arg1 and \p Arg2 are
2974+
/// equivalent.
2975+
bool isSameTemplateArgument(const TemplateArgument &Arg1,
2976+
const TemplateArgument &Arg2) const;
2977+
29592978
/// Type Query functions. If the type is an instance of the specified class,
29602979
/// return the Type pointer for the underlying maximally pretty type. This
29612980
/// is a member of ASTContext because this may need to do some amount of

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

0 commit comments

Comments
 (0)