Skip to content

Commit 050d1cb

Browse files
committed
merge main into amd-staging
2 parents 486faec + 4d6ca11 commit 050d1cb

File tree

422 files changed

+20270
-19506
lines changed

Some content is hidden

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

422 files changed

+20270
-19506
lines changed

.ci/metrics/metrics.py

Lines changed: 164 additions & 154 deletions
Large diffs are not rendered by default.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@ void UseDefaultMemberInitCheck::storeOptions(
194194
}
195195

196196
void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
197+
auto ConstExpRef = varDecl(anyOf(isConstexpr(), isStaticStorageClass()));
198+
197199
auto InitBase =
198200
anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
199201
unaryOperator(hasAnyOperatorName("+", "-"),
@@ -202,7 +204,7 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
202204
unaryOperator(hasAnyOperatorName("+", "-"),
203205
hasUnaryOperand(floatLiteral())),
204206
cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
205-
declRefExpr(to(enumConstantDecl())));
207+
declRefExpr(to(anyOf(enumConstantDecl(), ConstExpRef))));
206208

207209
auto Init =
208210
anyOf(initListExpr(anyOf(allOf(initCountIs(1), hasInit(0, InitBase)),

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,11 @@ struct MatchBuilder {
9191

9292
auto matchMathCall(const StringRef FunctionName,
9393
const Matcher<clang::Expr> ArgumentMatcher) const {
94+
auto HasAnyPrecisionName = hasAnyName(
95+
FunctionName, (FunctionName + "l").str(),
96+
(FunctionName + "f").str()); // Support long double(l) and float(f).
9497
return expr(ignoreParenAndFloatingCasting(
95-
callExpr(callee(functionDecl(hasName(FunctionName),
98+
callExpr(callee(functionDecl(HasAnyPrecisionName,
9699
hasParameter(0, hasType(isArithmetic())))),
97100
hasArgument(0, ArgumentMatcher))));
98101
}

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,6 @@ buildPreamble(PathRef FileName, CompilerInvocation CI,
673673
// Reset references to ref-counted-ptrs before executing the callbacks, to
674674
// prevent resetting them concurrently.
675675
PreambleDiagsEngine.reset();
676-
CI.DiagnosticOpts.reset();
677676

678677
// When building the AST for the main file, we do want the function
679678
// bodies.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,18 @@ Changes in existing checks
142142
<clang-tidy/checks/modernize/use-ranges>` check by updating suppress
143143
warnings logic for ``nullptr`` in ``std::find``.
144144

145+
- Improved :doc:`modernize-use-std-numbers
146+
<clang-tidy/checks/modernize/use-std-numbers>` check to support math
147+
functions of different precisions.
148+
145149
- Improved :doc:`misc-use-internal-linkage
146150
<clang-tidy/checks/misc/use-internal-linkage>` check by fix false positives
147151
for function or variable in header file which contains macro expansion.
148152

153+
- Improved :doc:`modernize-use-default-member-init
154+
<clang-tidy/checks/modernize/use-default-member-init>` check by matching
155+
``constexpr`` and ``static`` values on member initialization.
156+
149157
- Improved :doc:`performance/unnecessary-value-param
150158
<clang-tidy/checks/performance/unnecessary-value-param>` check performance by
151159
tolerating fix-it breaking compilation when functions is used as pointers

clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,22 @@ class ArrayBraceInitMultipleValues {
518518
};
519519

520520
} // namespace PR63285
521+
522+
namespace PR122480 {
523+
524+
static int STATIC_VAL = 23;
525+
constexpr const char* CONSTEXPR_REF = "Const";
526+
527+
class StaticConstExprInit {
528+
529+
StaticConstExprInit() : a{CONSTEXPR_REF}, b{STATIC_VAL}{}
530+
// CHECK-FIXES: StaticConstExprInit() {}
531+
const char* a;
532+
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use default member initializer for 'a' [modernize-use-default-member-init]
533+
// CHECK-FIXES: const char* a{CONSTEXPR_REF};
534+
int b;
535+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'b' [modernize-use-default-member-init]
536+
// CHECK-FIXES: int b{STATIC_VAL};
537+
};
538+
539+
} //namespace PR122480

clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-numbers.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ namespace bar {
99
template <typename T>
1010
auto sqrt(T val) { return sqrt(static_cast<double>(val)); }
1111

12+
float sqrtf(float Arg);
13+
long double sqrtl(long double Arg);
14+
1215
static constexpr double e = 2.718281828459045235360287471352662497757247093;
1316
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:33: warning: prefer 'std::numbers::e' to this literal, differs by '0.00e+00' [modernize-use-std-numbers]
1417
// CHECK-FIXES-ALL: static constexpr double e = std::numbers::e;
1518
}
1619

20+
float expf(float Arg);
1721
double exp(double Arg);
22+
long double expl(long double Arg);
1823
double log(double Arg);
1924

2025
double log2(double Arg);
@@ -110,6 +115,14 @@ void foo(){
110115
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::sqrt2_v<float>' to this formula [modernize-use-std-numbers]
111116
// CHECK-FIXES-ALL: std::numbers::sqrt2_v<float>;
112117

118+
bar::sqrtf(2.0F);
119+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::sqrt2_v<float>' to this formula [modernize-use-std-numbers]
120+
// CHECK-FIXES-ALL: std::numbers::sqrt2_v<float>;
121+
122+
bar::sqrtl(2.0);
123+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::sqrt2_v<long double>' to this formula [modernize-use-std-numbers]
124+
// CHECK-FIXES-ALL: std::numbers::sqrt2_v<long double>;
125+
113126
sink(MY_PI);
114127
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:10: warning: prefer 'std::numbers::pi' to this macro, differs by '5.36e-08' [modernize-use-std-numbers]
115128
// CHECK-FIXES-ALL: sink(std::numbers::pi);
@@ -155,6 +168,14 @@ void foo(){
155168
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::e' to this formula [modernize-use-std-numbers]
156169
// CHECK-FIXES-ALL: std::numbers::e;
157170

171+
expf(1);
172+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::e_v<float>' to this formula [modernize-use-std-numbers]
173+
// CHECK-FIXES-ALL: std::numbers::e_v<float>;
174+
175+
expl(1);
176+
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::e_v<long double>' to this formula [modernize-use-std-numbers]
177+
// CHECK-FIXES-ALL: std::numbers::e_v<long double>;
178+
158179
log2(exp(1));
159180
// CHECK-MESSAGES-ALL: :[[@LINE-1]]:5: warning: prefer 'std::numbers::log2e' to this formula [modernize-use-std-numbers]
160181
// CHECK-MESSAGES-ALL: :[[@LINE-2]]:10: warning: prefer 'std::numbers::e' to this formula [modernize-use-std-numbers]

clang/docs/LanguageExtensions.rst

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,53 +1604,54 @@ More information could be found `here <https://clang.llvm.org/docs/Modules.html>
16041604
Language Extensions Back-ported to Previous Standards
16051605
=====================================================
16061606

1607-
============================================ ================================ ============= =============
1608-
Feature Feature Test Macro Introduced In Backported To
1609-
============================================ ================================ ============= =============
1610-
variadic templates __cpp_variadic_templates C++11 C++03
1611-
Alias templates __cpp_alias_templates C++11 C++03
1612-
Non-static data member initializers __cpp_nsdmi C++11 C++03
1613-
Range-based ``for`` loop __cpp_range_based_for C++11 C++03
1614-
RValue references __cpp_rvalue_references C++11 C++03
1615-
Attributes __cpp_attributes C++11 C++03
1616-
Lambdas __cpp_lambdas C++11 C++03
1617-
Generalized lambda captures __cpp_init_captures C++14 C++03
1618-
Generic lambda expressions __cpp_generic_lambdas C++14 C++03
1619-
variable templates __cpp_variable_templates C++14 C++03
1620-
Binary literals __cpp_binary_literals C++14 C++03
1621-
Relaxed constexpr __cpp_constexpr C++14 C++11
1622-
Static assert with no message __cpp_static_assert >= 201411L C++17 C++11
1623-
Pack expansion in generalized lambda-capture __cpp_init_captures C++17 C++03
1624-
``if constexpr`` __cpp_if_constexpr C++17 C++11
1625-
fold expressions __cpp_fold_expressions C++17 C++03
1626-
Lambda capture of \*this by value __cpp_capture_star_this C++17 C++03
1627-
Attributes on enums __cpp_enumerator_attributes C++17 C++03
1628-
Guaranteed copy elision __cpp_guaranteed_copy_elision C++17 C++03
1629-
Hexadecimal floating literals __cpp_hex_float C++17 C++03
1630-
``inline`` variables __cpp_inline_variables C++17 C++03
1631-
Attributes on namespaces __cpp_namespace_attributes C++17 C++11
1632-
Structured bindings __cpp_structured_bindings C++17 C++03
1633-
template template arguments __cpp_template_template_args C++17 C++03
1634-
Familiar template syntax for generic lambdas __cpp_generic_lambdas C++20 C++03
1635-
``static operator[]`` __cpp_multidimensional_subscript C++20 C++03
1636-
Designated initializers __cpp_designated_initializers C++20 C++03
1637-
Conditional ``explicit`` __cpp_conditional_explicit C++20 C++03
1638-
``using enum`` __cpp_using_enum C++20 C++03
1639-
``if consteval`` __cpp_if_consteval C++23 C++20
1640-
``static operator()`` __cpp_static_call_operator C++23 C++03
1641-
Attributes on Lambda-Expressions C++23 C++11
1642-
Attributes on Structured Bindings __cpp_structured_bindings C++26 C++03
1643-
Packs in Structured Bindings __cpp_structured_bindings C++26 C++03
1644-
Static assert with user-generated message __cpp_static_assert >= 202306L C++26 C++11
1645-
Pack Indexing __cpp_pack_indexing C++26 C++03
1646-
``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03
1647-
Variadic Friends __cpp_variadic_friend C++26 C++03
1648-
-------------------------------------------- -------------------------------- ------------- -------------
1649-
Designated initializers (N494) C99 C89
1650-
Array & element qualification (N2607) C23 C89
1651-
Attributes (N2335) C23 C89
1652-
``#embed`` (N3017) C23 C89, C++
1653-
============================================ ================================ ============= =============
1607+
============================================= ================================ ============= =============
1608+
Feature Feature Test Macro Introduced In Backported To
1609+
============================================= ================================ ============= =============
1610+
variadic templates __cpp_variadic_templates C++11 C++03
1611+
Alias templates __cpp_alias_templates C++11 C++03
1612+
Non-static data member initializers __cpp_nsdmi C++11 C++03
1613+
Range-based ``for`` loop __cpp_range_based_for C++11 C++03
1614+
RValue references __cpp_rvalue_references C++11 C++03
1615+
Attributes __cpp_attributes C++11 C++03
1616+
Lambdas __cpp_lambdas C++11 C++03
1617+
Generalized lambda captures __cpp_init_captures C++14 C++03
1618+
Generic lambda expressions __cpp_generic_lambdas C++14 C++03
1619+
variable templates __cpp_variable_templates C++14 C++03
1620+
Binary literals __cpp_binary_literals C++14 C++03
1621+
Relaxed constexpr __cpp_constexpr C++14 C++11
1622+
Static assert with no message __cpp_static_assert >= 201411L C++17 C++11
1623+
Pack expansion in generalized lambda-capture __cpp_init_captures C++17 C++03
1624+
``if constexpr`` __cpp_if_constexpr C++17 C++11
1625+
fold expressions __cpp_fold_expressions C++17 C++03
1626+
Lambda capture of \*this by value __cpp_capture_star_this C++17 C++03
1627+
Attributes on enums __cpp_enumerator_attributes C++17 C++03
1628+
Guaranteed copy elision __cpp_guaranteed_copy_elision C++17 C++03
1629+
Hexadecimal floating literals __cpp_hex_float C++17 C++03
1630+
``inline`` variables __cpp_inline_variables C++17 C++03
1631+
Attributes on namespaces __cpp_namespace_attributes C++17 C++11
1632+
Structured bindings __cpp_structured_bindings C++17 C++03
1633+
template template arguments __cpp_template_template_args C++17 C++03
1634+
Familiar template syntax for generic lambdas __cpp_generic_lambdas C++20 C++03
1635+
``static operator[]`` __cpp_multidimensional_subscript C++20 C++03
1636+
Designated initializers __cpp_designated_initializers C++20 C++03
1637+
Conditional ``explicit`` __cpp_conditional_explicit C++20 C++03
1638+
``using enum`` __cpp_using_enum C++20 C++03
1639+
``if consteval`` __cpp_if_consteval C++23 C++20
1640+
``static operator()`` __cpp_static_call_operator C++23 C++03
1641+
Attributes on Lambda-Expressions C++23 C++11
1642+
Attributes on Structured Bindings __cpp_structured_bindings C++26 C++03
1643+
Packs in Structured Bindings __cpp_structured_bindings C++26 C++03
1644+
Structured binding declaration as a condition __cpp_structured_bindings C++26 C++98
1645+
Static assert with user-generated message __cpp_static_assert >= 202306L C++26 C++11
1646+
Pack Indexing __cpp_pack_indexing C++26 C++03
1647+
``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03
1648+
Variadic Friends __cpp_variadic_friend C++26 C++03
1649+
--------------------------------------------- -------------------------------- ------------- -------------
1650+
Designated initializers (N494) C99 C89
1651+
Array & element qualification (N2607) C23 C89
1652+
Attributes (N2335) C23 C89
1653+
``#embed`` (N3017) C23 C89, C++
1654+
============================================= ================================ ============= =============
16541655

16551656
Builtin type aliases
16561657
====================

0 commit comments

Comments
 (0)