Skip to content

Commit 38a437b

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into feat/28334_tests
2 parents ae6e763 + 7573ee1 commit 38a437b

File tree

131 files changed

+5195
-5605
lines changed

Some content is hidden

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

131 files changed

+5195
-5605
lines changed

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/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2883,7 +2883,7 @@ https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Function-Attributes.html
28832883
https://riscv.org/specifications/privileged-isa/
28842884
The RISC-V Instruction Set Manual Volume II: Privileged Architecture
28852885
Version 1.10.
2886-
https://github.com/quic/riscv-unified-db/releases/tag/Xqci-0.6
2886+
https://github.com/quic/riscv-unified-db/releases/tag/Xqci-0.7
28872887
}];
28882888
}
28892889

clang/include/clang/Basic/DiagnosticOptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ inline DiagnosticLevelMask operator&(DiagnosticLevelMask LHS,
6767
raw_ostream& operator<<(raw_ostream& Out, DiagnosticLevelMask M);
6868

6969
/// Options for controlling the compiler diagnostics engine.
70-
class DiagnosticOptions : public RefCountedBase<DiagnosticOptions>{
70+
class DiagnosticOptions
71+
: public llvm::ThreadSafeRefCountedBase<DiagnosticOptions> {
7172
friend bool ParseDiagnosticArgs(DiagnosticOptions &, llvm::opt::ArgList &,
7273
clang::DiagnosticsEngine *, bool);
7374

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class CompilerInvocation : public CompilerInvocationBase {
269269
/// @{
270270
using CompilerInvocationBase::LangOpts;
271271
using CompilerInvocationBase::TargetOpts;
272-
using CompilerInvocationBase::DiagnosticOpts;
273272
std::shared_ptr<HeaderSearchOptions> getHeaderSearchOptsPtr() {
274273
return HSOpts;
275274
}

clang/include/clang/Serialization/ASTWriter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ class ASTWriter : public ASTDeserializationListener,
571571
std::pair<ASTFileSignature, ASTFileSignature> createSignature() const;
572572
ASTFileSignature createSignatureForNamedModule() const;
573573

574-
void WriteInputFiles(SourceManager &SourceMgr, HeaderSearchOptions &HSOpts);
574+
void WriteInputFiles(SourceManager &SourceMgr);
575575
void WriteSourceManagerBlock(SourceManager &SourceMgr);
576576
void WritePreprocessor(const Preprocessor &PP, bool IsModule);
577577
void WriteHeaderSearch(const HeaderSearch &HS);

0 commit comments

Comments
 (0)