Skip to content

Commit 4d9f2b2

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:7b4b85b75d22a792b2ef80e6af4f0faf18da0a43 into amd-gfx:0d77823cc97e
Local branch amd-gfx 0d77823 Merged main:3082a381f57ef2885c270f41f2955e08c79634c5 into amd-gfx:961ceed5c647 Remote branch main 7b4b85b [clang][bytecode] Reject void InitListExpr differently (llvm#105802)
2 parents 0d77823 + 7b4b85b commit 4d9f2b2

File tree

189 files changed

+9219
-4283
lines changed

Some content is hidden

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

189 files changed

+9219
-4283
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ the configuration (without a prefix: ``Auto``).
16171617
**AllowAllParametersOfDeclarationOnNextLine** (``Boolean``) :versionbadge:`clang-format 3.3` :ref:`<AllowAllParametersOfDeclarationOnNextLine>`
16181618
If the function declaration doesn't fit on a line,
16191619
allow putting all parameters of a function declaration onto
1620-
the next line even if ``BinPackParameters`` is ``false``.
1620+
the next line even if ``BinPackParameters`` is ``OnePerLine``.
16211621

16221622
.. code-block:: c++
16231623

@@ -2067,20 +2067,41 @@ the configuration (without a prefix: ``Auto``).
20672067

20682068
.. _BinPackParameters:
20692069

2070-
**BinPackParameters** (``Boolean``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`
2071-
If ``false``, a function declaration's or function definition's
2072-
parameters will either all be on the same line or will have one line each.
2070+
**BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`
2071+
The bin pack parameters style to use.
20732072

2074-
.. code-block:: c++
2073+
Possible values:
2074+
2075+
* ``BPPS_BinPack`` (in configuration: ``BinPack``)
2076+
Bin-pack parameters.
2077+
2078+
.. code-block:: c++
2079+
2080+
void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
2081+
int ccccccccccccccccccccccccccccccccccccccccccc);
2082+
2083+
* ``BPPS_OnePerLine`` (in configuration: ``OnePerLine``)
2084+
Put all parameters on the current line if they fit.
2085+
Otherwise, put each one on its own line.
2086+
2087+
.. code-block:: c++
2088+
2089+
void f(int a, int b, int c);
2090+
2091+
void f(int a,
2092+
int b,
2093+
int ccccccccccccccccccccccccccccccccccccc);
2094+
2095+
* ``BPPS_AlwaysOnePerLine`` (in configuration: ``AlwaysOnePerLine``)
2096+
Always put each parameter on its own line.
2097+
2098+
.. code-block:: c++
2099+
2100+
void f(int a,
2101+
int b,
2102+
int c);
20752103

2076-
true:
2077-
void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
2078-
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
20792104

2080-
false:
2081-
void f(int aaaaaaaaaaaaaaaaaaaa,
2082-
int aaaaaaaaaaaaaaaaaaaa,
2083-
int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
20842105

20852106
.. _BitFieldColonSpacing:
20862107

@@ -4817,7 +4838,7 @@ the configuration (without a prefix: ``Auto``).
48174838
items into as few lines as possible when they go over ``ColumnLimit``.
48184839

48194840
If ``Auto`` (the default), delegates to the value in
4820-
``BinPackParameters``. If that is ``true``, bin-packs Objective-C
4841+
``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
48214842
protocol conformance list items into as few lines as possible
48224843
whenever they go over ``ColumnLimit``.
48234844

@@ -4831,13 +4852,13 @@ the configuration (without a prefix: ``Auto``).
48314852

48324853
.. code-block:: objc
48334854
4834-
Always (or Auto, if BinPackParameters=true):
4855+
Always (or Auto, if BinPackParameters==BinPack):
48354856
@interface ccccccccccccc () <
48364857
ccccccccccccc, ccccccccccccc,
48374858
ccccccccccccc, ccccccccccccc> {
48384859
}
48394860
4840-
Never (or Auto, if BinPackParameters=false):
4861+
Never (or Auto, if BinPackParameters!=BinPack):
48414862
@interface ddddddddddddd () <
48424863
ddddddddddddd,
48434864
ddddddddddddd,

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,6 @@ C++ Language Changes
107107
constant expression. Supports the `V.xyzw` syntax and other tidbits
108108
as seen in OpenCL. Selecting multiple elements is left as a future work.
109109

110-
C++17 Feature Support
111-
^^^^^^^^^^^^^^^^^^^^^
112-
113-
C++14 Feature Support
114-
^^^^^^^^^^^^^^^^^^^^^
115-
116-
C++20 Feature Support
117-
^^^^^^^^^^^^^^^^^^^^^
118-
119-
C++23 Feature Support
120-
^^^^^^^^^^^^^^^^^^^^^
121-
- Removed the restriction to literal types in constexpr functions in C++23 mode.
122-
123110
C++2c Feature Support
124111
^^^^^^^^^^^^^^^^^^^^^
125112

@@ -131,6 +118,13 @@ C++2c Feature Support
131118

132119
- Implemented `P2893R3 Variadic Friends <https://wg21.link/P2893>`_
133120

121+
C++23 Feature Support
122+
^^^^^^^^^^^^^^^^^^^^^
123+
- Removed the restriction to literal types in constexpr functions in C++23 mode.
124+
125+
C++20 Feature Support
126+
^^^^^^^^^^^^^^^^^^^^^
127+
134128
Resolutions to C++ Defect Reports
135129
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
136130

@@ -239,7 +233,7 @@ Improvements to Clang's diagnostics
239233

240234
- Clang now diagnoses when the result of a [[nodiscard]] function is discarded after being cast in C. Fixes #GH104391.
241235

242-
- Don't emit duplicated dangling diagnostics. (#GH93386).
236+
- Improved diagnostic when trying to befriend a concept. (#GH45182).
243237

244238
Improvements to Clang's time-trace
245239
----------------------------------

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,9 @@ def warn_cxx23_variadic_friends : Warning<
974974
"variadic 'friend' declarations are incompatible with C++ standards before C++2c">,
975975
DefaultIgnore, InGroup<CXXPre26Compat>;
976976

977+
def err_friend_concept : Error<
978+
"friend declaration cannot be a concept">;
979+
977980
// C++11 default member initialization
978981
def ext_nonstatic_member_init : ExtWarn<
979982
"default member initializer for non-static data member is a C++11 "

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def warn_module_system_bit_conflict : Warning<
134134
"as a non-system module; any difference in diagnostic options will be ignored">,
135135
InGroup<ModuleConflict>;
136136

137+
def warn_decls_in_multiple_modules : Warning<
138+
"declaration %0 is detected to be defined in multiple module units, first is from '%1' and second is from '%2'; "
139+
"the compiler may not be good at merging the definitions. ">,
140+
InGroup<DiagGroup<"decls-in-multiple-modules">>,
141+
DefaultIgnore;
142+
137143
def err_failed_to_find_module_file : Error<
138144
"failed to find module file for module '%0'">;
139145
} // let CategoryName

clang/include/clang/Format/Format.h

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ struct FormatStyle {
659659

660660
/// If the function declaration doesn't fit on a line,
661661
/// allow putting all parameters of a function declaration onto
662-
/// the next line even if ``BinPackParameters`` is ``false``.
662+
/// the next line even if ``BinPackParameters`` is ``OnePerLine``.
663663
/// \code
664664
/// true:
665665
/// void myFunction(
@@ -1192,20 +1192,36 @@ struct FormatStyle {
11921192
/// \version 3.7
11931193
bool BinPackArguments;
11941194

1195-
/// If ``false``, a function declaration's or function definition's
1196-
/// parameters will either all be on the same line or will have one line each.
1197-
/// \code
1198-
/// true:
1199-
/// void f(int aaaaaaaaaaaaaaaaaaaa, int aaaaaaaaaaaaaaaaaaaa,
1200-
/// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
1201-
///
1202-
/// false:
1203-
/// void f(int aaaaaaaaaaaaaaaaaaaa,
1204-
/// int aaaaaaaaaaaaaaaaaaaa,
1205-
/// int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}
1206-
/// \endcode
1195+
/// Different way to try to fit all parameters on a line.
1196+
enum BinPackParametersStyle : int8_t {
1197+
/// Bin-pack parameters.
1198+
/// \code
1199+
/// void f(int a, int bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
1200+
/// int ccccccccccccccccccccccccccccccccccccccccccc);
1201+
/// \endcode
1202+
BPPS_BinPack,
1203+
/// Put all parameters on the current line if they fit.
1204+
/// Otherwise, put each one on its own line.
1205+
/// \code
1206+
/// void f(int a, int b, int c);
1207+
///
1208+
/// void f(int a,
1209+
/// int b,
1210+
/// int ccccccccccccccccccccccccccccccccccccc);
1211+
/// \endcode
1212+
BPPS_OnePerLine,
1213+
/// Always put each parameter on its own line.
1214+
/// \code
1215+
/// void f(int a,
1216+
/// int b,
1217+
/// int c);
1218+
/// \endcode
1219+
BPPS_AlwaysOnePerLine,
1220+
};
1221+
1222+
/// The bin pack parameters style to use.
12071223
/// \version 3.7
1208-
bool BinPackParameters;
1224+
BinPackParametersStyle BinPackParameters;
12091225

12101226
/// Styles for adding spacing around ``:`` in bitfield definitions.
12111227
enum BitFieldColonSpacingStyle : int8_t {
@@ -3414,7 +3430,7 @@ struct FormatStyle {
34143430
/// items into as few lines as possible when they go over ``ColumnLimit``.
34153431
///
34163432
/// If ``Auto`` (the default), delegates to the value in
3417-
/// ``BinPackParameters``. If that is ``true``, bin-packs Objective-C
3433+
/// ``BinPackParameters``. If that is ``BinPack``, bin-packs Objective-C
34183434
/// protocol conformance list items into as few lines as possible
34193435
/// whenever they go over ``ColumnLimit``.
34203436
///
@@ -3426,13 +3442,13 @@ struct FormatStyle {
34263442
/// onto individual lines whenever they go over ``ColumnLimit``.
34273443
///
34283444
/// \code{.objc}
3429-
/// Always (or Auto, if BinPackParameters=true):
3445+
/// Always (or Auto, if BinPackParameters==BinPack):
34303446
/// @interface ccccccccccccc () <
34313447
/// ccccccccccccc, ccccccccccccc,
34323448
/// ccccccccccccc, ccccccccccccc> {
34333449
/// }
34343450
///
3435-
/// Never (or Auto, if BinPackParameters=false):
3451+
/// Never (or Auto, if BinPackParameters!=BinPack):
34363452
/// @interface ddddddddddddd () <
34373453
/// ddddddddddddd,
34383454
/// ddddddddddddd,

clang/include/clang/Serialization/ASTReader.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,12 @@ class ASTReader
648648
/// performed deduplication.
649649
llvm::SetVector<NamedDecl *> PendingMergedDefinitionsToDeduplicate;
650650

651+
/// The duplicated definitions in module units which are pending to be warned.
652+
/// We need to delay it to wait for the loading of definitions since we don't
653+
/// want to warn for forward declarations.
654+
llvm::SmallVector<std::pair<Decl *, Decl *>>
655+
PendingWarningForDuplicatedDefsInModuleUnits;
656+
651657
/// Read the record that describes the lexical contents of a DC.
652658
bool ReadLexicalDeclContextStorage(ModuleFile &M,
653659
llvm::BitstreamCursor &Cursor,

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,16 @@ bool Compiler<Emitter>::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
13441344
template <class Emitter>
13451345
bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
13461346
const Expr *ArrayFiller, const Expr *E) {
1347+
QualType QT = E->getType();
1348+
if (const auto *AT = QT->getAs<AtomicType>())
1349+
QT = AT->getValueType();
1350+
1351+
if (QT->isVoidType()) {
1352+
if (Inits.size() == 0)
1353+
return true;
1354+
return this->emitInvalid(E);
1355+
}
1356+
13471357
// Handle discarding first.
13481358
if (DiscardResult) {
13491359
for (const Expr *Init : Inits) {
@@ -1353,13 +1363,6 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
13531363
return true;
13541364
}
13551365

1356-
QualType QT = E->getType();
1357-
if (const auto *AT = QT->getAs<AtomicType>())
1358-
QT = AT->getValueType();
1359-
1360-
if (QT->isVoidType())
1361-
return this->emitInvalid(E);
1362-
13631366
// Primitive values.
13641367
if (std::optional<PrimType> T = classify(QT)) {
13651368
assert(!DiscardResult);
@@ -3262,9 +3265,6 @@ template <class Emitter> bool Compiler<Emitter>::discard(const Expr *E) {
32623265
}
32633266

32643267
template <class Emitter> bool Compiler<Emitter>::delegate(const Expr *E) {
3265-
if (E->containsErrors())
3266-
return this->emitError(E);
3267-
32683268
// We're basically doing:
32693269
// OptionScope<Emitter> Scope(this, DicardResult, Initializing);
32703270
// but that's unnecessary of course.
@@ -3275,9 +3275,12 @@ template <class Emitter> bool Compiler<Emitter>::visit(const Expr *E) {
32753275
if (E->getType().isNull())
32763276
return false;
32773277

3278+
if (E->getType()->isVoidType())
3279+
return this->discard(E);
3280+
32783281
// Create local variable to hold the return value.
3279-
if (!E->getType()->isVoidType() && !E->isGLValue() &&
3280-
!E->getType()->isAnyComplexType() && !classify(E->getType())) {
3282+
if (!E->isGLValue() && !E->getType()->isAnyComplexType() &&
3283+
!classify(E->getType())) {
32813284
std::optional<unsigned> LocalIndex = allocateLocal(E);
32823285
if (!LocalIndex)
32833286
return false;
@@ -5177,7 +5180,7 @@ bool Compiler<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
51775180
// We should already have a pointer when we get here.
51785181
return this->delegate(SubExpr);
51795182
case UO_Deref: // *x
5180-
if (DiscardResult || E->getType()->isVoidType())
5183+
if (DiscardResult)
51815184
return this->discard(SubExpr);
51825185
return this->visit(SubExpr);
51835186
case UO_Not: // ~x

clang/lib/AST/ByteCode/Descriptor.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
3131
}
3232

3333
template <typename T>
34-
static void moveTy(Block *, const std::byte *Src, std::byte *Dst,
34+
static void moveTy(Block *, std::byte *Src, std::byte *Dst,
3535
const Descriptor *) {
36-
// FIXME: Get rid of the const_cast.
37-
auto *SrcPtr = reinterpret_cast<T *>(const_cast<std::byte *>(Src));
36+
auto *SrcPtr = reinterpret_cast<T *>(Src);
3837
auto *DstPtr = reinterpret_cast<T *>(Dst);
3938
new (DstPtr) T(std::move(*SrcPtr));
4039
}
@@ -63,11 +62,9 @@ static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
6362
}
6463

6564
template <typename T>
66-
static void moveArrayTy(Block *, const std::byte *Src, std::byte *Dst,
65+
static void moveArrayTy(Block *, std::byte *Src, std::byte *Dst,
6766
const Descriptor *D) {
68-
// FIXME: Get rid of the const_cast.
69-
InitMapPtr &SrcIMP =
70-
*reinterpret_cast<InitMapPtr *>(const_cast<std::byte *>(Src));
67+
InitMapPtr &SrcIMP = *reinterpret_cast<InitMapPtr *>(Src);
7168
if (SrcIMP) {
7269
// We only ever invoke the moveFunc when moving block contents to a
7370
// DeadBlock. DeadBlocks don't need InitMaps, so we destroy them here.
@@ -76,7 +73,7 @@ static void moveArrayTy(Block *, const std::byte *Src, std::byte *Dst,
7673
Src += sizeof(InitMapPtr);
7774
Dst += sizeof(InitMapPtr);
7875
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {
79-
auto *SrcPtr = &reinterpret_cast<T *>(const_cast<std::byte *>(Src))[I];
76+
auto *SrcPtr = &reinterpret_cast<T *>(Src)[I];
8077
auto *DstPtr = &reinterpret_cast<T *>(Dst)[I];
8178
new (DstPtr) T(std::move(*SrcPtr));
8279
}
@@ -126,19 +123,19 @@ static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D) {
126123
}
127124
}
128125

129-
static void moveArrayDesc(Block *B, const std::byte *Src, std::byte *Dst,
126+
static void moveArrayDesc(Block *B, std::byte *Src, std::byte *Dst,
130127
const Descriptor *D) {
131128
const unsigned NumElems = D->getNumElems();
132129
const unsigned ElemSize =
133130
D->ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
134131

135132
unsigned ElemOffset = 0;
136133
for (unsigned I = 0; I < NumElems; ++I, ElemOffset += ElemSize) {
137-
const auto *SrcPtr = Src + ElemOffset;
134+
auto *SrcPtr = Src + ElemOffset;
138135
auto *DstPtr = Dst + ElemOffset;
139136

140-
const auto *SrcDesc = reinterpret_cast<const InlineDescriptor *>(SrcPtr);
141-
const auto *SrcElemLoc = reinterpret_cast<const std::byte *>(SrcDesc + 1);
137+
auto *SrcDesc = reinterpret_cast<InlineDescriptor *>(SrcPtr);
138+
auto *SrcElemLoc = reinterpret_cast<std::byte *>(SrcDesc + 1);
142139
auto *DstDesc = reinterpret_cast<InlineDescriptor *>(DstPtr);
143140
auto *DstElemLoc = reinterpret_cast<std::byte *>(DstDesc + 1);
144141

@@ -233,7 +230,7 @@ static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
233230
destroyBase(B, Ptr, F.Desc, F.Offset);
234231
}
235232

236-
static void moveRecord(Block *B, const std::byte *Src, std::byte *Dst,
233+
static void moveRecord(Block *B, std::byte *Src, std::byte *Dst,
237234
const Descriptor *D) {
238235
assert(D);
239236
assert(D->ElemRecord);

clang/lib/AST/ByteCode/Descriptor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ using BlockDtorFn = void (*)(Block *Storage, std::byte *FieldPtr,
4444
/// blocks are persisted: the move function copies all inline descriptors and
4545
/// non-trivial fields, as existing pointers might need to reference those
4646
/// descriptors. Data is not copied since it cannot be legally read.
47-
using BlockMoveFn = void (*)(Block *Storage, const std::byte *SrcFieldPtr,
47+
using BlockMoveFn = void (*)(Block *Storage, std::byte *SrcFieldPtr,
4848
std::byte *DstFieldPtr,
4949
const Descriptor *FieldDesc);
5050

0 commit comments

Comments
 (0)