Skip to content

Commit fec4819

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: Ic6b87a60b61985fb9dc6a3c3bb8f99f562fe5bc1
2 parents d18bc8f + 53fecef commit fec4819

File tree

61 files changed

+1907
-506
lines changed

Some content is hidden

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

61 files changed

+1907
-506
lines changed

clang-tools-extra/clang-tidy/bugprone/MultiLevelImplicitPointerConversionCheck.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ AST_MATCHER(ImplicitCastExpr, isMultiLevelPointerConversion) {
4848
return SourcePtrLevel != TargetPtrLevel;
4949
}
5050

51+
AST_MATCHER(QualType, isPointerType) {
52+
const QualType Type =
53+
Node.getCanonicalType().getNonReferenceType().getUnqualifiedType();
54+
55+
return !Type.isNull() && Type->isPointerType();
56+
}
57+
5158
} // namespace
5259

5360
void MultiLevelImplicitPointerConversionCheck::registerMatchers(
5461
MatchFinder *Finder) {
5562
Finder->addMatcher(
56-
implicitCastExpr(hasCastKind(CK_BitCast), isMultiLevelPointerConversion())
63+
implicitCastExpr(hasCastKind(CK_BitCast), isMultiLevelPointerConversion(),
64+
unless(hasParent(explicitCastExpr(
65+
hasDestinationType(isPointerType())))))
5766
.bind("expr"),
5867
this);
5968
}

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ static constexpr bool RestrictToPODTypesDefault = false;
3232
static constexpr char IgnoreMacrosName[] = "IgnoreMacros";
3333
static constexpr bool IgnoreMacrosDefault = true;
3434

35+
static constexpr char StrictCStandardComplianceName[] =
36+
"StrictCStandardCompliance";
37+
static constexpr bool StrictCStandardComplianceDefault = true;
38+
39+
static constexpr char StrictCppStandardComplianceName[] =
40+
"StrictCppStandardCompliance";
41+
static constexpr bool StrictCppStandardComplianceDefault = true;
42+
3543
namespace {
3644

3745
struct Designators {
@@ -97,7 +105,12 @@ UseDesignatedInitializersCheck::UseDesignatedInitializersCheck(
97105
RestrictToPODTypes(
98106
Options.get(RestrictToPODTypesName, RestrictToPODTypesDefault)),
99107
IgnoreMacros(
100-
Options.getLocalOrGlobal(IgnoreMacrosName, IgnoreMacrosDefault)) {}
108+
Options.getLocalOrGlobal(IgnoreMacrosName, IgnoreMacrosDefault)),
109+
StrictCStandardCompliance(Options.get(StrictCStandardComplianceName,
110+
StrictCStandardComplianceDefault)),
111+
StrictCppStandardCompliance(
112+
Options.get(StrictCppStandardComplianceName,
113+
StrictCppStandardComplianceDefault)) {}
101114

102115
void UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
103116
const auto HasBaseWithFields =
@@ -179,6 +192,9 @@ void UseDesignatedInitializersCheck::storeOptions(
179192
IgnoreSingleElementAggregates);
180193
Options.store(Opts, RestrictToPODTypesName, RestrictToPODTypes);
181194
Options.store(Opts, IgnoreMacrosName, IgnoreMacros);
195+
Options.store(Opts, StrictCStandardComplianceName, StrictCStandardCompliance);
196+
Options.store(Opts, StrictCppStandardComplianceName,
197+
StrictCppStandardCompliance);
182198
}
183199

184200
} // namespace clang::tidy::modernize

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,19 @@ class UseDesignatedInitializersCheck : public ClangTidyCheck {
2929
return TK_IgnoreUnlessSpelledInSource;
3030
}
3131

32+
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
33+
return LangOpts.CPlusPlus20 || LangOpts.C99 ||
34+
(LangOpts.CPlusPlus && !StrictCppStandardCompliance) ||
35+
(!LangOpts.CPlusPlus && !LangOpts.ObjC &&
36+
!StrictCStandardCompliance);
37+
}
38+
3239
private:
3340
bool IgnoreSingleElementAggregates;
3441
bool RestrictToPODTypes;
3542
bool IgnoreMacros;
43+
bool StrictCStandardCompliance;
44+
bool StrictCppStandardCompliance;
3645
};
3746

3847
} // namespace clang::tidy::modernize

clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
279279
hasParent(callExpr()),
280280
hasSourceExpression(binaryOperator(hasAnyOperatorName("==", "!="))));
281281

282+
auto IsInCompilerGeneratedFunction = hasAncestor(namedDecl(anyOf(
283+
isImplicit(), functionDecl(isDefaulted()), functionTemplateDecl())));
284+
282285
Finder->addMatcher(
283286
traverse(TK_AsIs,
284287
implicitCastExpr(
@@ -299,7 +302,7 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
299302
// additional parens in replacement.
300303
optionally(hasParent(stmt().bind("parentStmt"))),
301304
unless(isInTemplateInstantiation()),
302-
unless(hasAncestor(functionTemplateDecl())))
305+
unless(IsInCompilerGeneratedFunction))
303306
.bind("implicitCastToBool")),
304307
this);
305308

@@ -331,7 +334,7 @@ void ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
331334
anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
332335
anything()),
333336
unless(isInTemplateInstantiation()),
334-
unless(hasAncestor(functionTemplateDecl())))),
337+
unless(IsInCompilerGeneratedFunction))),
335338
this);
336339
}
337340

clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ static void addParantheses(const BinaryOperator *BinOp,
5757
int Precedence1 = getPrecedence(BinOp);
5858
int Precedence2 = getPrecedence(ParentBinOp);
5959

60-
if (ParentBinOp != nullptr && Precedence1 != Precedence2) {
60+
if (ParentBinOp != nullptr && Precedence1 != Precedence2 && Precedence1 > 0 &&
61+
Precedence2 > 0) {
6162
const clang::SourceLocation StartLoc = BinOp->getBeginLoc();
6263
const clang::SourceLocation EndLoc =
6364
clang::Lexer::getLocForEndOfToken(BinOp->getEndLoc(), 0, SM, LangOpts);

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,10 @@ Changes in existing checks
224224
check by ignoring ``__func__`` macro in lambda captures, initializers of
225225
default parameters and nested function declarations.
226226

227+
- Improved :doc:`bugprone-multi-level-implicit-pointer-conversion
228+
<clang-tidy/checks/bugprone/multi-level-implicit-pointer-conversion>` check
229+
by ignoring implicit pointer conversions that are part of a cast expression.
230+
227231
- Improved :doc:`bugprone-non-zero-enum-to-bool-conversion
228232
<clang-tidy/checks/bugprone/non-zero-enum-to-bool-conversion>` check by
229233
eliminating false positives resulting from direct usage of bitwise operators
@@ -408,7 +412,8 @@ Changes in existing checks
408412
valid fix suggestions for ``static_cast`` without a preceding space and
409413
fixed problem with duplicate parentheses in double implicit casts. Corrected
410414
the fix suggestions for C23 and later by using C-style casts instead of
411-
``static_cast``.
415+
``static_cast``. Fixed false positives in C++20 spaceship operator by ignoring
416+
casts in implicit and defaulted functions.
412417

413418
- Improved :doc:`readability-redundant-inline-specifier
414419
<clang-tidy/checks/readability/redundant-inline-specifier>` check to properly

clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declaration of ``S``.
3737

3838
Even when compiling in a language version older than C++20, depending on your
3939
compiler, designated initializers are potentially supported. Therefore, the
40-
check is not restricted to C++20 and newer versions. Check out the options
40+
check is by default restricted to C99/C++20 and above. Check out the options
4141
``-Wc99-designator`` to get support for mixed designators in initializer list in
4242
C and ``-Wc++20-designator`` for support of designated initializers in older C++
4343
language modes.
@@ -60,3 +60,13 @@ Options
6060
The value `true` specifies that only Plain Old Data (POD) types shall be
6161
checked. This makes the check applicable to even older C++ standards. The
6262
default value is `false`.
63+
64+
.. option:: StrictCStandardCompliance
65+
66+
When set to `false`, the check will not restrict itself to C99 and above.
67+
The default value is `true`.
68+
69+
.. option:: StrictCppStandardCompliance
70+
71+
When set to `false`, the check will not restrict itself to C++20 and above.
72+
The default value is `true`.

clang-tools-extra/test/clang-tidy/checkers/bugprone/multi-level-implicit-pointer-conversion.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,15 @@ void test()
6363

6464
takeSecondLevelVoidPtr(getSecondLevelVoidPtr());
6565
}
66+
67+
namespace PR93959 {
68+
void free(void*);
69+
70+
void test() {
71+
char **p = nullptr;
72+
free(p);
73+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: multilevel pointer conversion from 'char **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion]
74+
free((void *)p);
75+
free(static_cast<void *>(p));
76+
}
77+
}

clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// RUN: %check_clang_tidy -std=c++17 %s modernize-use-designated-initializers %t \
1+
// RUN: %check_clang_tidy -std=c++20 %s modernize-use-designated-initializers %t \
22
// RUN: -- \
33
// RUN: -- -fno-delayed-template-parsing
4-
// RUN: %check_clang_tidy -check-suffixes=,SINGLE-ELEMENT -std=c++17 %s modernize-use-designated-initializers %t \
4+
// RUN: %check_clang_tidy -check-suffixes=,SINGLE-ELEMENT -std=c++20 %s modernize-use-designated-initializers %t \
55
// RUN: -- -config="{CheckOptions: {modernize-use-designated-initializers.IgnoreSingleElementAggregates: false}}" \
66
// RUN: -- -fno-delayed-template-parsing
7-
// RUN: %check_clang_tidy -check-suffixes=POD -std=c++17 %s modernize-use-designated-initializers %t \
7+
// RUN: %check_clang_tidy -check-suffixes=POD -std=c++20 %s modernize-use-designated-initializers %t \
88
// RUN: -- -config="{CheckOptions: {modernize-use-designated-initializers.RestrictToPODTypes: true}}" \
99
// RUN: -- -fno-delayed-template-parsing
10-
// RUN: %check_clang_tidy -check-suffixes=,MACROS -std=c++17 %s modernize-use-designated-initializers %t \
10+
// RUN: %check_clang_tidy -check-suffixes=,MACROS -std=c++20 %s modernize-use-designated-initializers %t \
1111
// RUN: -- -config="{CheckOptions: {modernize-use-designated-initializers.IgnoreMacros: false}}" \
1212
// RUN: -- -fno-delayed-template-parsing
1313

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %check_clang_tidy -std=c++20 %s readability-implicit-bool-conversion %t
2+
3+
namespace std {
4+
struct strong_ordering {
5+
int n;
6+
constexpr operator int() const { return n; }
7+
static const strong_ordering equal, greater, less;
8+
};
9+
constexpr strong_ordering strong_ordering::equal = {0};
10+
constexpr strong_ordering strong_ordering::greater = {1};
11+
constexpr strong_ordering strong_ordering::less = {-1};
12+
} // namespace std
13+
14+
namespace PR93409 {
15+
struct X
16+
{
17+
auto operator<=>(const X&) const = default;
18+
bool m_b;
19+
};
20+
21+
struct Y
22+
{
23+
auto operator<=>(const Y&) const = default;
24+
X m_x;
25+
};
26+
27+
bool compare(const Y& y1, const Y& y2)
28+
{
29+
return y1 == y2 || y1 < y2 || y1 > y2;
30+
}
31+
}

clang-tools-extra/test/clang-tidy/checkers/readability/math-missing-parentheses.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,20 @@ void f(){
140140
//CHECK-MESSAGES: :[[@LINE+1]]:13: warning: '*' has higher precedence than '+'; add parentheses to explicitly specify the order of operations [readability-math-missing-parentheses]
141141
int v = FUN5(0 + 1);
142142
}
143+
144+
namespace PR92516 {
145+
void f(int i) {
146+
int j, k;
147+
for (j = i + 1, k = 0; j < 1; ++j) {}
148+
}
149+
150+
void f2(int i) {
151+
int j;
152+
for (j = i + 1; j < 1; ++j) {}
153+
}
154+
155+
void f3(int i) {
156+
int j;
157+
for (j = i + 1, 2; j < 1; ++j) {}
158+
}
159+
}

clang/lib/AST/Interp/EvalEmitter.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ void EvalEmitter::cleanup() { S.cleanup(); }
4040
EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
4141
bool ConvertResultToRValue) {
4242
S.setEvalLocation(E->getExprLoc());
43-
this->ConvertResultToRValue = ConvertResultToRValue;
43+
this->ConvertResultToRValue = ConvertResultToRValue && !isa<ConstantExpr>(E);
4444
this->CheckFullyInitialized = isa<ConstantExpr>(E);
4545
EvalResult.setSource(E);
4646

@@ -56,10 +56,14 @@ EvaluationResult EvalEmitter::interpretExpr(const Expr *E,
5656
EvaluationResult EvalEmitter::interpretDecl(const VarDecl *VD,
5757
bool CheckFullyInitialized) {
5858
this->CheckFullyInitialized = CheckFullyInitialized;
59-
this->ConvertResultToRValue =
60-
VD->getAnyInitializer() &&
61-
(VD->getAnyInitializer()->getType()->isAnyComplexType() ||
62-
VD->getAnyInitializer()->getType()->isVectorType());
59+
60+
if (const Expr *Init = VD->getAnyInitializer()) {
61+
QualType T = VD->getType();
62+
this->ConvertResultToRValue = !Init->isGLValue() && !T->isPointerType() &&
63+
!T->isObjCObjectPointerType();
64+
} else
65+
this->ConvertResultToRValue = false;
66+
6367
EvalResult.setSource(VD);
6468

6569
if (!this->visitDecl(VD) && EvalResult.empty())
@@ -138,6 +142,10 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
138142
return true;
139143

140144
const Pointer &Ptr = S.Stk.pop<Pointer>();
145+
146+
if (CheckFullyInitialized && !EvalResult.checkFullyInitialized(S, Ptr))
147+
return false;
148+
141149
// Implicitly convert lvalue to rvalue, if requested.
142150
if (ConvertResultToRValue) {
143151
if (std::optional<APValue> V = Ptr.toRValue(Ctx)) {
@@ -146,17 +154,7 @@ template <> bool EvalEmitter::emitRet<PT_Ptr>(const SourceInfo &Info) {
146154
return false;
147155
}
148156
} else {
149-
if (CheckFullyInitialized) {
150-
if (!EvalResult.checkFullyInitialized(S, Ptr))
151-
return false;
152-
153-
std::optional<APValue> RValueResult = Ptr.toRValue(Ctx);
154-
if (!RValueResult)
155-
return false;
156-
EvalResult.setValue(*RValueResult);
157-
} else {
158-
EvalResult.setValue(Ptr.toAPValue());
159-
}
157+
EvalResult.setValue(Ptr.toAPValue());
160158
}
161159

162160
return true;

clang/lib/AST/Interp/EvaluationResult.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,12 @@ bool EvaluationResult::checkFullyInitialized(InterpState &S,
151151

152152
if (const Record *R = Ptr.getRecord())
153153
return CheckFieldsInitialized(S, InitLoc, Ptr, R);
154-
const auto *CAT =
155-
cast<ConstantArrayType>(Ptr.getType()->getAsArrayTypeUnsafe());
156-
return CheckArrayInitialized(S, InitLoc, Ptr, CAT);
154+
155+
if (const auto *CAT = dyn_cast_if_present<ConstantArrayType>(
156+
Ptr.getType()->getAsArrayTypeUnsafe()))
157+
return CheckArrayInitialized(S, InitLoc, Ptr, CAT);
158+
159+
return true;
157160
}
158161

159162
} // namespace interp

clang/www/cxx_dr_status.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17186,6 +17186,18 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1718617186
<td>open</td>
1718717187
<td>Template argument deduction involving exception specifications</td>
1718817188
<td align="center">Not resolved</td>
17189+
</tr>
17190+
<tr class="open" id="2897">
17191+
<td><a href="https://cplusplus.github.io/CWG/issues/2897.html">2897</a></td>
17192+
<td>open</td>
17193+
<td>Copying potentially-overlapping union subobjects</td>
17194+
<td align="center">Not resolved</td>
17195+
</tr>
17196+
<tr class="open" id="2898">
17197+
<td><a href="https://cplusplus.github.io/CWG/issues/2898.html">2898</a></td>
17198+
<td>open</td>
17199+
<td>Clarify implicit conversion sequence from <I>cv</I> <TT>T</TT> to <TT>T</TT></td>
17200+
<td align="center">Not resolved</td>
1718917201
</tr></table>
1719017202

1719117203
</div>

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ set(TARGET_LIBM_ENTRYPOINTS
394394
libc.src.math.fminimum_mag_num
395395
libc.src.math.fminimum_mag_numf
396396
libc.src.math.fminimum_mag_numl
397+
libc.src.math.fmul
397398
libc.src.math.fmod
398399
libc.src.math.fmodf
399400
libc.src.math.fmodl
@@ -574,6 +575,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
574575
libc.src.math.nextafterf128
575576
libc.src.math.nextdownf128
576577
libc.src.math.nextupf128
578+
libc.src.math.remquof128
577579
libc.src.math.rintf128
578580
libc.src.math.roundf128
579581
libc.src.math.scalbnf128

libc/config/linux/arm/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ set(TARGET_LIBM_ENTRYPOINTS
261261
libc.src.math.fminimum_mag_num
262262
libc.src.math.fminimum_mag_numf
263263
libc.src.math.fminimum_mag_numl
264+
libc.src.math.fmul
264265
libc.src.math.fmod
265266
libc.src.math.fmodf
266267
libc.src.math.frexp

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ set(TARGET_LIBM_ENTRYPOINTS
402402
libc.src.math.fminimum_mag_num
403403
libc.src.math.fminimum_mag_numf
404404
libc.src.math.fminimum_mag_numl
405+
libc.src.math.fmul
405406
libc.src.math.fmod
406407
libc.src.math.fmodf
407408
libc.src.math.fmodl

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ set(TARGET_LIBM_ENTRYPOINTS
421421
libc.src.math.fminimum_mag_num
422422
libc.src.math.fminimum_mag_numf
423423
libc.src.math.fminimum_mag_numl
424+
libc.src.math.fmul
424425
libc.src.math.fmod
425426
libc.src.math.fmodf
426427
libc.src.math.fmodl
@@ -605,6 +606,7 @@ if(LIBC_TYPES_HAS_FLOAT128)
605606
libc.src.math.nextafterf128
606607
libc.src.math.nextdownf128
607608
libc.src.math.nextupf128
609+
libc.src.math.remquof128
608610
libc.src.math.rintf128
609611
libc.src.math.roundevenf128
610612
libc.src.math.roundf128

libc/config/windows/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ set(TARGET_LIBM_ENTRYPOINTS
180180
libc.src.math.fminimum_mag_num
181181
libc.src.math.fminimum_mag_numf
182182
libc.src.math.fminimum_mag_numl
183+
libc.src.math.fmul
183184
libc.src.math.fmod
184185
libc.src.math.fmodf
185186
libc.src.math.fmodl

0 commit comments

Comments
 (0)