Skip to content

Commit 732fa1e

Browse files
author
git apple-llvm automerger
committed
Merge commit '88f04bdbd861' from llvm.org/main into experimental/cas/main
2 parents 9824455 + 88f04bd commit 732fa1e

File tree

244 files changed

+8768
-5008
lines changed

Some content is hidden

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

244 files changed

+8768
-5008
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,10 @@ Improvements to Clang's diagnostics
210210
- ``-Wenum-conversion`` now warns on converting a signed enum of one type to an
211211
unsigned enum of a different type (or vice versa) rather than
212212
``-Wsign-conversion``.
213+
- Added the ``-Wunreachable-code-generic-assoc`` diagnostic flag (grouped under
214+
the ``-Wunreachable-code`` flag) which is enabled by default and warns the
215+
user about ``_Generic`` selection associations which are unreachable because
216+
the type specified is an array type or a qualified type.
213217

214218
Non-comprehensive list of changes in this release
215219
-------------------------------------------------

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,11 @@ def ReservedIdentifier : DiagGroup<"reserved-identifier",
843843
//
844844
def UnreachableCodeLoopIncrement : DiagGroup<"unreachable-code-loop-increment">;
845845
def UnreachableCodeFallthrough : DiagGroup<"unreachable-code-fallthrough">;
846+
def UnreachableCodeGenericAssoc : DiagGroup<"unreachable-code-generic-assoc">;
846847
def UnreachableCode : DiagGroup<"unreachable-code",
847848
[UnreachableCodeLoopIncrement,
848-
UnreachableCodeFallthrough]>;
849+
UnreachableCodeFallthrough,
850+
UnreachableCodeGenericAssoc]>;
849851
def UnreachableCodeBreak : DiagGroup<"unreachable-code-break">;
850852
def UnreachableCodeReturn : DiagGroup<"unreachable-code-return">;
851853
def UnreachableCodeAggressive : DiagGroup<"unreachable-code-aggressive",

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,10 @@ def warn_unreachable_fallthrough_attr : Warning<
693693
InGroup<UnreachableCodeFallthrough>, DefaultIgnore;
694694
def note_unreachable_silence : Note<
695695
"silence by adding parentheses to mark code as explicitly dead">;
696+
def warn_unreachable_association : Warning<
697+
"due to lvalue conversion of the controlling expression, association of type "
698+
"%0 will never be selected because it is %select{of array type|qualified}1">,
699+
InGroup<UnreachableCodeGenericAssoc>;
696700

697701
/// Built-in functions.
698702
def ext_implicit_lib_function_decl : ExtWarn<

clang/include/clang/Frontend/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct CreateInvocationOptions {
206206
/// This is used to replace -include with -include-pch in the cc1 args.
207207
/// FIXME: ProbePrecompiled=true is a poor, historical default.
208208
/// It misbehaves if the PCH file is from GCC, has the wrong version, etc.
209-
bool ProbePrecompiled = true;
209+
bool ProbePrecompiled = false;
210210
/// If set, the target is populated with the cc1 args produced by the driver.
211211
/// This may be populated even if createInvocation returns nullptr.
212212
std::vector<std::string> *CC1Args = nullptr;

clang/lib/CodeGen/CGExprCXX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1573,7 +1573,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
15731573
llvm::Value *allocSize =
15741574
EmitCXXNewAllocSize(*this, E, minElements, numElements,
15751575
allocSizeWithoutCookie);
1576-
CharUnits allocAlign = getContext().getPreferredTypeAlignInChars(allocType);
1576+
CharUnits allocAlign = getContext().getTypeAlignInChars(allocType);
15771577

15781578
// Emit the allocation call. If the allocator is a global placement
15791579
// operator, just "inline" it directly.

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,6 +1732,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
17321732
CreateInvocationOptions CIOpts;
17331733
CIOpts.VFS = VFS;
17341734
CIOpts.Diags = Diags;
1735+
CIOpts.ProbePrecompiled = true; // FIXME: historical default. Needed?
17351736
CI = createInvocation(llvm::makeArrayRef(ArgBegin, ArgEnd),
17361737
std::move(CIOpts));
17371738
if (!CI)

clang/lib/Sema/SemaExpr.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,25 @@ Sema::CreateGenericSelectionExpr(SourceLocation KeyLoc,
16851685
D = diag::err_assoc_type_nonobject;
16861686
else if (Types[i]->getType()->isVariablyModifiedType())
16871687
D = diag::err_assoc_type_variably_modified;
1688+
else {
1689+
// Because the controlling expression undergoes lvalue conversion,
1690+
// array conversion, and function conversion, an association which is
1691+
// of array type, function type, or is qualified can never be
1692+
// reached. We will warn about this so users are less surprised by
1693+
// the unreachable association. However, we don't have to handle
1694+
// function types; that's not an object type, so it's handled above.
1695+
unsigned Reason = 0;
1696+
QualType QT = Types[i]->getType();
1697+
if (QT->isArrayType())
1698+
Reason = 1;
1699+
else if (QT.hasQualifiers())
1700+
Reason = 2;
1701+
1702+
if (Reason)
1703+
Diag(Types[i]->getTypeLoc().getBeginLoc(),
1704+
diag::warn_unreachable_association)
1705+
<< QT << (Reason - 1);
1706+
}
16881707

16891708
if (D != 0) {
16901709
Diag(Types[i]->getTypeLoc().getBeginLoc(), D)

clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_aba.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
66
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
77
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s -check-prefix=CPP-CHECK
8-
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -Wno-error=implicit-function-declaration -verify -verify-ignore-unexpected=error %s
9-
// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -Wno-error=implicit-function-declaration -verify=overload -verify-ignore-unexpected=error %s
108

119
#include <arm_sve.h>
1210

@@ -29,8 +27,6 @@
2927
//
3028
svint8_t test_svaba_s8(svint8_t op1, svint8_t op2, svint8_t op3)
3129
{
32-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
33-
// expected-warning@+1 {{call to undeclared function 'svaba_s8'; ISO C99 and later do not support implicit function declarations}}
3430
return SVE_ACLE_FUNC(svaba,_s8,,)(op1, op2, op3);
3531
}
3632

@@ -46,8 +42,6 @@ svint8_t test_svaba_s8(svint8_t op1, svint8_t op2, svint8_t op3)
4642
//
4743
svint16_t test_svaba_s16(svint16_t op1, svint16_t op2, svint16_t op3)
4844
{
49-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
50-
// expected-warning@+1 {{call to undeclared function 'svaba_s16'; ISO C99 and later do not support implicit function declarations}}
5145
return SVE_ACLE_FUNC(svaba,_s16,,)(op1, op2, op3);
5246
}
5347

@@ -63,8 +57,6 @@ svint16_t test_svaba_s16(svint16_t op1, svint16_t op2, svint16_t op3)
6357
//
6458
svint32_t test_svaba_s32(svint32_t op1, svint32_t op2, svint32_t op3)
6559
{
66-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
67-
// expected-warning@+1 {{call to undeclared function 'svaba_s32'; ISO C99 and later do not support implicit function declarations}}
6860
return SVE_ACLE_FUNC(svaba,_s32,,)(op1, op2, op3);
6961
}
7062

@@ -80,8 +72,6 @@ svint32_t test_svaba_s32(svint32_t op1, svint32_t op2, svint32_t op3)
8072
//
8173
svint64_t test_svaba_s64(svint64_t op1, svint64_t op2, svint64_t op3)
8274
{
83-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
84-
// expected-warning@+1 {{call to undeclared function 'svaba_s64'; ISO C99 and later do not support implicit function declarations}}
8575
return SVE_ACLE_FUNC(svaba,_s64,,)(op1, op2, op3);
8676
}
8777

@@ -97,8 +87,6 @@ svint64_t test_svaba_s64(svint64_t op1, svint64_t op2, svint64_t op3)
9787
//
9888
svuint8_t test_svaba_u8(svuint8_t op1, svuint8_t op2, svuint8_t op3)
9989
{
100-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
101-
// expected-warning@+1 {{call to undeclared function 'svaba_u8'; ISO C99 and later do not support implicit function declarations}}
10290
return SVE_ACLE_FUNC(svaba,_u8,,)(op1, op2, op3);
10391
}
10492

@@ -114,8 +102,6 @@ svuint8_t test_svaba_u8(svuint8_t op1, svuint8_t op2, svuint8_t op3)
114102
//
115103
svuint16_t test_svaba_u16(svuint16_t op1, svuint16_t op2, svuint16_t op3)
116104
{
117-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
118-
// expected-warning@+1 {{call to undeclared function 'svaba_u16'; ISO C99 and later do not support implicit function declarations}}
119105
return SVE_ACLE_FUNC(svaba,_u16,,)(op1, op2, op3);
120106
}
121107

@@ -131,8 +117,6 @@ svuint16_t test_svaba_u16(svuint16_t op1, svuint16_t op2, svuint16_t op3)
131117
//
132118
svuint32_t test_svaba_u32(svuint32_t op1, svuint32_t op2, svuint32_t op3)
133119
{
134-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
135-
// expected-warning@+1 {{call to undeclared function 'svaba_u32'; ISO C99 and later do not support implicit function declarations}}
136120
return SVE_ACLE_FUNC(svaba,_u32,,)(op1, op2, op3);
137121
}
138122

@@ -148,8 +132,6 @@ svuint32_t test_svaba_u32(svuint32_t op1, svuint32_t op2, svuint32_t op3)
148132
//
149133
svuint64_t test_svaba_u64(svuint64_t op1, svuint64_t op2, svuint64_t op3)
150134
{
151-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
152-
// expected-warning@+1 {{call to undeclared function 'svaba_u64'; ISO C99 and later do not support implicit function declarations}}
153135
return SVE_ACLE_FUNC(svaba,_u64,,)(op1, op2, op3);
154136
}
155137

@@ -169,8 +151,6 @@ svuint64_t test_svaba_u64(svuint64_t op1, svuint64_t op2, svuint64_t op3)
169151
//
170152
svint8_t test_svaba_n_s8(svint8_t op1, svint8_t op2, int8_t op3)
171153
{
172-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
173-
// expected-warning@+1 {{call to undeclared function 'svaba_n_s8'; ISO C99 and later do not support implicit function declarations}}
174154
return SVE_ACLE_FUNC(svaba,_n_s8,,)(op1, op2, op3);
175155
}
176156

@@ -190,8 +170,6 @@ svint8_t test_svaba_n_s8(svint8_t op1, svint8_t op2, int8_t op3)
190170
//
191171
svint16_t test_svaba_n_s16(svint16_t op1, svint16_t op2, int16_t op3)
192172
{
193-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
194-
// expected-warning@+1 {{call to undeclared function 'svaba_n_s16'; ISO C99 and later do not support implicit function declarations}}
195173
return SVE_ACLE_FUNC(svaba,_n_s16,,)(op1, op2, op3);
196174
}
197175

@@ -211,8 +189,6 @@ svint16_t test_svaba_n_s16(svint16_t op1, svint16_t op2, int16_t op3)
211189
//
212190
svint32_t test_svaba_n_s32(svint32_t op1, svint32_t op2, int32_t op3)
213191
{
214-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
215-
// expected-warning@+1 {{call to undeclared function 'svaba_n_s32'; ISO C99 and later do not support implicit function declarations}}
216192
return SVE_ACLE_FUNC(svaba,_n_s32,,)(op1, op2, op3);
217193
}
218194

@@ -232,8 +208,6 @@ svint32_t test_svaba_n_s32(svint32_t op1, svint32_t op2, int32_t op3)
232208
//
233209
svint64_t test_svaba_n_s64(svint64_t op1, svint64_t op2, int64_t op3)
234210
{
235-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
236-
// expected-warning@+1 {{call to undeclared function 'svaba_n_s64'; ISO C99 and later do not support implicit function declarations}}
237211
return SVE_ACLE_FUNC(svaba,_n_s64,,)(op1, op2, op3);
238212
}
239213

@@ -253,8 +227,6 @@ svint64_t test_svaba_n_s64(svint64_t op1, svint64_t op2, int64_t op3)
253227
//
254228
svuint8_t test_svaba_n_u8(svuint8_t op1, svuint8_t op2, uint8_t op3)
255229
{
256-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
257-
// expected-warning@+1 {{call to undeclared function 'svaba_n_u8'; ISO C99 and later do not support implicit function declarations}}
258230
return SVE_ACLE_FUNC(svaba,_n_u8,,)(op1, op2, op3);
259231
}
260232

@@ -274,8 +246,6 @@ svuint8_t test_svaba_n_u8(svuint8_t op1, svuint8_t op2, uint8_t op3)
274246
//
275247
svuint16_t test_svaba_n_u16(svuint16_t op1, svuint16_t op2, uint16_t op3)
276248
{
277-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
278-
// expected-warning@+1 {{call to undeclared function 'svaba_n_u16'; ISO C99 and later do not support implicit function declarations}}
279249
return SVE_ACLE_FUNC(svaba,_n_u16,,)(op1, op2, op3);
280250
}
281251

@@ -295,8 +265,6 @@ svuint16_t test_svaba_n_u16(svuint16_t op1, svuint16_t op2, uint16_t op3)
295265
//
296266
svuint32_t test_svaba_n_u32(svuint32_t op1, svuint32_t op2, uint32_t op3)
297267
{
298-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
299-
// expected-warning@+1 {{call to undeclared function 'svaba_n_u32'; ISO C99 and later do not support implicit function declarations}}
300268
return SVE_ACLE_FUNC(svaba,_n_u32,,)(op1, op2, op3);
301269
}
302270

@@ -316,7 +284,5 @@ svuint32_t test_svaba_n_u32(svuint32_t op1, svuint32_t op2, uint32_t op3)
316284
//
317285
svuint64_t test_svaba_n_u64(svuint64_t op1, svuint64_t op2, uint64_t op3)
318286
{
319-
// overload-warning@+2 {{call to undeclared function 'svaba'; ISO C99 and later do not support implicit function declarations}}
320-
// expected-warning@+1 {{call to undeclared function 'svaba_n_u64'; ISO C99 and later do not support implicit function declarations}}
321287
return SVE_ACLE_FUNC(svaba,_n_u64,,)(op1, op2, op3);
322288
}

0 commit comments

Comments
 (0)