Skip to content

Commit 801e12e

Browse files
committed
Merge from 'main' to 'sycl-web' (226 commits)
CONFLICT (content): Merge conflict in llvm/utils/git/requirements.txt
2 parents 3a66fd7 + f14fd32 commit 801e12e

File tree

1,305 files changed

+37651
-14706
lines changed

Some content is hidden

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

1,305 files changed

+37651
-14706
lines changed

.github/workflows/commit-access-review.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,10 @@ def main():
358358
gh = github.Github(login_or_token=token)
359359
org = gh.get_organization("llvm")
360360
repo = org.get_repo("llvm-project")
361-
team = org.get_team_by_slug("llvm-committers")
362361
one_year_ago = datetime.datetime.now() - datetime.timedelta(days=365)
363362
triage_list = {}
364-
for member in team.get_members():
365-
triage_list[member.login] = User(member.login, triage_list)
363+
for collaborator in repo.get_collaborators(permission="push"):
364+
triage_list[collaborator.login] = User(collaborator.login, triage_list)
366365

367366
print("Start:", len(triage_list), "triagers")
368367
# Step 0 Check if users have requested commit access in the last year.

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5959
// Don't relax adr if it points to the same function and it is not split
6060
// and BF initial size is < 1MB.
6161
const unsigned OneMB = 0x100000;
62-
if (!BF.isSplit() && BF.getSize() < OneMB) {
62+
if (BF.getSize() < OneMB) {
6363
BinaryFunction *TargetBF = BC.getFunctionForSymbol(Symbol);
64-
if (TargetBF && TargetBF == &BF)
64+
if (TargetBF == &BF && !BF.isSplit())
6565
continue;
66+
// No relaxation needed if ADR references a basic block in the same
67+
// fragment.
68+
if (BinaryBasicBlock *TargetBB = BF.getBasicBlockForLabel(Symbol))
69+
if (BB.getFragmentNum() == TargetBB->getFragmentNum())
70+
continue;
6671
}
6772

6873
MCPhysReg Reg;

clang-tools-extra/clang-tidy/cert/FloatLoopCounter.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,38 @@
99
#include "FloatLoopCounter.h"
1010
#include "clang/AST/ASTContext.h"
1111
#include "clang/ASTMatchers/ASTMatchFinder.h"
12+
#include "clang/ASTMatchers/ASTMatchers.h"
1213

1314
using namespace clang::ast_matchers;
1415

1516
namespace clang::tidy::cert {
1617

1718
void FloatLoopCounter::registerMatchers(MatchFinder *Finder) {
1819
Finder->addMatcher(
19-
forStmt(hasIncrement(expr(hasType(realFloatingPointType())))).bind("for"),
20+
forStmt(hasIncrement(forEachDescendant(
21+
declRefExpr(hasType(realFloatingPointType()),
22+
to(varDecl().bind("var")))
23+
.bind("inc"))),
24+
hasCondition(forEachDescendant(
25+
declRefExpr(hasType(realFloatingPointType()),
26+
to(varDecl(equalsBoundNode("var"))))
27+
.bind("cond"))))
28+
.bind("for"),
2029
this);
2130
}
2231

2332
void FloatLoopCounter::check(const MatchFinder::MatchResult &Result) {
2433
const auto *FS = Result.Nodes.getNodeAs<ForStmt>("for");
2534

26-
diag(FS->getInc()->getExprLoc(), "loop induction expression should not have "
27-
"floating-point type");
35+
diag(FS->getInc()->getBeginLoc(), "loop induction expression should not have "
36+
"floating-point type")
37+
<< Result.Nodes.getNodeAs<DeclRefExpr>("inc")->getSourceRange()
38+
<< Result.Nodes.getNodeAs<DeclRefExpr>("cond")->getSourceRange();
39+
40+
if (!FS->getInc()->getType()->isRealFloatingType())
41+
if (const auto *V = Result.Nodes.getNodeAs<VarDecl>("var"))
42+
diag(V->getBeginLoc(), "floating-point type loop induction variable",
43+
DiagnosticIDs::Note);
2844
}
2945

3046
} // namespace clang::tidy::cert

clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void updateAssignmentLevel(
8383
memberExpr(hasObjectExpression(cxxThisExpr()),
8484
member(fieldDecl(indexNotLessThan(Field->getFieldIndex()))));
8585
auto DeclMatcher = declRefExpr(
86-
to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Ctor)))));
86+
to(valueDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Ctor)))));
8787
const bool HasDependence = !match(expr(anyOf(MemberMatcher, DeclMatcher,
8888
hasDescendant(MemberMatcher),
8989
hasDescendant(DeclMatcher))),

clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,38 +46,41 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) {
4646
// Handle the more common streaming '... << std::endl' case
4747
const CharSourceRange TokenRange =
4848
CharSourceRange::getTokenRange(Expression->getSourceRange());
49-
const StringRef SourceText = Lexer::getSourceText(
49+
StringRef SourceText = Lexer::getSourceText(
5050
TokenRange, *Result.SourceManager, Result.Context->getLangOpts());
51-
51+
if (SourceText.empty())
52+
SourceText = "std::endl";
5253
auto Diag = diag(Expression->getBeginLoc(),
5354
"do not use '%0' with streams; use '\\n' instead")
5455
<< SourceText;
55-
56-
Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'");
56+
if (TokenRange.isValid())
57+
Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'");
5758
} else {
5859
// Handle the less common function call 'std::endl(...)' case
5960
const auto *CallExpression = llvm::cast<CallExpr>(Expression);
6061
assert(CallExpression->getNumArgs() == 1);
6162

62-
const StringRef SourceText = Lexer::getSourceText(
63+
StringRef SourceText = Lexer::getSourceText(
6364
CharSourceRange::getTokenRange(
6465
CallExpression->getCallee()->getSourceRange()),
6566
*Result.SourceManager, Result.Context->getLangOpts());
67+
if (SourceText.empty())
68+
SourceText = "std::endl";
69+
auto Diag = diag(CallExpression->getBeginLoc(),
70+
"do not use '%0' with streams; use '\\n' instead")
71+
<< SourceText;
6672

6773
const CharSourceRange ArgTokenRange = CharSourceRange::getTokenRange(
6874
CallExpression->getArg(0)->getSourceRange());
6975
const StringRef ArgSourceText = Lexer::getSourceText(
7076
ArgTokenRange, *Result.SourceManager, Result.Context->getLangOpts());
71-
72-
const std::string ReplacementString =
73-
std::string(ArgSourceText) + " << '\\n'";
74-
75-
diag(CallExpression->getBeginLoc(),
76-
"do not use '%0' with streams; use '\\n' instead")
77-
<< SourceText
78-
<< FixItHint::CreateReplacement(
79-
CharSourceRange::getTokenRange(CallExpression->getSourceRange()),
80-
ReplacementString);
77+
const CharSourceRange ReplacementRange =
78+
CharSourceRange::getTokenRange(CallExpression->getSourceRange());
79+
if (!ArgSourceText.empty() && ReplacementRange.isValid()) {
80+
const std::string ReplacementString =
81+
std::string(ArgSourceText) + " << '\\n'";
82+
Diag << FixItHint::CreateReplacement(ReplacementRange, ReplacementString);
83+
}
8184
}
8285
}
8386

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ struct AvoidUnconditionalPreprocessorIfPPCallbacks : public PPCallbacks {
8484
return (Tok.getRawIdentifier() == "true" ||
8585
Tok.getRawIdentifier() == "false");
8686
default:
87-
return Tok.getKind() >= tok::l_square && Tok.getKind() <= tok::caretcaret;
87+
return Tok.getKind() >= tok::l_square &&
88+
Tok.getKind() <= tok::greatergreatergreater;
8889
}
8990
}
9091

clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ TEST_F(ConfigCompileTests, DiagnosticSuppression) {
298298
"unreachable-code", "unused-variable",
299299
"typecheck_bool_condition",
300300
"unexpected_friend", "warn_alloca"));
301-
clang::DiagnosticsEngine DiagEngine(nullptr, nullptr,
301+
clang::DiagnosticsEngine DiagEngine(new DiagnosticIDs, nullptr,
302302
new clang::IgnoringDiagConsumer);
303303

304304
using Diag = clang::Diagnostic;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ Changes in existing checks
111111
<clang-tidy/checks/bugprone/casting-through-void>` check to suggest replacing
112112
the offending code with ``reinterpret_cast``, to more clearly express intent.
113113

114+
- Improved :doc:`cert-flp30-c<clang-tidy/checks/cert/flp30-c>` check to
115+
fix false positive that floating point variable is only used in increment
116+
expression.
117+
118+
- Improved :doc:`cppcoreguidelines-prefer-member-initializer
119+
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to avoid
120+
false positive when member initialization depends on a structured binging
121+
variable.
122+
114123
- Improved :doc:`modernize-use-std-format
115124
<clang-tidy/checks/modernize/use-std-format>` check to support replacing
116125
member function calls too.
@@ -123,6 +132,10 @@ Changes in existing checks
123132
<clang-tidy/checks/modernize/use-std-print>` check to support replacing
124133
member function calls too.
125134

135+
- Improved :doc:`performance-avoid-endl
136+
<clang-tidy/checks/performance/avoid-endl>` check to use ``std::endl`` as
137+
placeholder when lexer cannot get source text.
138+
126139
- Improved :doc:`readability-implicit-bool-conversion
127140
<clang-tidy/checks/readability/implicit-bool-conversion>` check
128141
by adding the option `UseUpperCaseLiteralSuffix` to select the

clang-tools-extra/pseudo/lib/cxx/cxx.bnf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ operator-name := >
639639
operator-name := <=
640640
operator-name := >=
641641
operator-name := <=>
642-
operator-name := ^^
643642
operator-name := ||
644643
operator-name := <<
645644
operator-name := greatergreater
Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
// RUN: %check_clang_tidy %s cert-flp30-c %t
22

33
float g(void);
4+
int c(float);
5+
float f = 1.0f;
6+
7+
void match(void) {
48

5-
void func(void) {
69
for (float x = 0.1f; x <= 1.0f; x += 0.1f) {}
7-
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: loop induction expression should not have floating-point type [cert-flp30-c]
10+
// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: loop induction expression should not have floating-point type [cert-flp30-c]
811

9-
float f = 1.0f;
1012
for (; f > 0; --f) {}
11-
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: loop induction expression
13+
// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: loop induction expression should not have floating-point type [cert-flp30-c]
1214

13-
for (;;g()) {}
14-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: loop induction expression
15+
for (float x = 0.0f; c(x); x = g()) {}
16+
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: loop induction expression should not have floating-point type [cert-flp30-c]
1517

16-
for (int i = 0; i < 10; i += 1.0f) {}
18+
for (int i=0; i < 10 && f < 2.0f; f++, i++) {}
19+
// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: loop induction expression should not have floating-point type [cert-flp30-c]
20+
// CHECK-MESSAGES: :5:1: note: floating-point type loop induction variable
21+
}
1722

23+
void not_match(void) {
24+
for (int i = 0; i < 10; i += 1.0f) {}
1825
for (int i = 0; i < 10; ++i) {}
26+
for (int i = 0; i < 10; ++i, f++) {}
27+
for (int i = 0; f < 10.f; ++i) {}
1928
}

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,3 +639,14 @@ struct S3 {
639639
T M;
640640
};
641641
}
642+
643+
namespace GH82970 {
644+
struct InitFromBingingDecl {
645+
int m;
646+
InitFromBingingDecl() {
647+
struct { int i; } a;
648+
auto [n] = a;
649+
m = n;
650+
}
651+
};
652+
} // namespace GH82970

clang-tools-extra/test/clang-tidy/checkers/performance/avoid-endl.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,3 +225,14 @@ void bad_custom_stream() {
225225
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
226226
// CHECK-FIXES: logger << '\n';
227227
}
228+
229+
namespace gh107859 {
230+
231+
#define ENDL std::endl;
232+
233+
void bad_macro() {
234+
std::cout << ENDL;
235+
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use 'std::endl' with streams; use '\n' instead [performance-avoid-endl]
236+
}
237+
238+
} // namespace gh107859

clang/docs/ReleaseNotes.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ Improvements to Clang's diagnostics
303303

304304
- Clang now warns for u8 character literals used in C23 with ``-Wpre-c23-compat`` instead of ``-Wpre-c++17-compat``.
305305

306+
- Clang now diagnose when importing module implementation partition units in module interface units.
307+
308+
- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272).
309+
306310
Improvements to Clang's time-trace
307311
----------------------------------
308312

@@ -386,7 +390,7 @@ Bug Fixes to C++ Support
386390
- Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
387391
- Fixed a crash when clang tries to subtitute parameter pack while retaining the parameter
388392
pack. #GH63819, #GH107560
389-
393+
- Fix a crash when a static assert declaration has an invalid close location. (#GH108687)
390394

391395
Bug Fixes to AST Handling
392396
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -499,7 +503,7 @@ AST Matchers
499503
- Fixed an issue with the `hasName` and `hasAnyName` matcher when matching
500504
inline namespaces with an enclosing namespace of the same name.
501505

502-
- Fixed an ordering issue with the `hasOperands` matcher occuring when setting a
506+
- Fixed an ordering issue with the `hasOperands` matcher occurring when setting a
503507
binding in the first matcher and using it in the second matcher.
504508

505509
clang-format

clang/docs/UsersManual.rst

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,6 +2410,39 @@ are listed below.
24102410
link-time optimizations like whole program inter-procedural basic block
24112411
reordering.
24122412

2413+
.. option:: -fcodegen-data-generate[=<path>]
2414+
2415+
Emit the raw codegen (CG) data into custom sections in the object file.
2416+
Currently, this option also combines the raw CG data from the object files
2417+
into an indexed CG data file specified by the <path>, for LLD MachO only.
2418+
When the <path> is not specified, `default.cgdata` is created.
2419+
The CG data file combines all the outlining instances that occurred locally
2420+
in each object file.
2421+
2422+
.. code-block:: console
2423+
2424+
$ clang -fuse-ld=lld -Oz -fcodegen-data-generate code.cc
2425+
2426+
For linkers that do not yet support this feature, `llvm-cgdata` can be used
2427+
manually to merge this CG data in object files.
2428+
2429+
.. code-block:: console
2430+
2431+
$ clang -c -fuse-ld=lld -Oz -fcodegen-data-generate code.cc
2432+
$ llvm-cgdata --merge -o default.cgdata code.o
2433+
2434+
.. option:: -fcodegen-data-use[=<path>]
2435+
2436+
Read the codegen data from the specified path to more effectively outline
2437+
functions across compilation units. When the <path> is not specified,
2438+
`default.cgdata` is used. This option can create many identically outlined
2439+
functions that can be optimized by the conventional linker’s identical code
2440+
folding (ICF).
2441+
2442+
.. code-block:: console
2443+
2444+
$ clang -fuse-ld=lld -Oz -Wl,--icf=safe -fcodegen-data-use code.cc
2445+
24132446
Profile Guided Optimization
24142447
---------------------------
24152448

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,11 @@ bool RecursiveASTVisitor<Derived>::PostVisitStmt(Stmt *S) {
652652

653653
#undef DISPATCH_STMT
654654

655+
// Inlining this method can lead to large code size and compile-time increases
656+
// without any benefit to runtime performance.
655657
template <typename Derived>
656-
bool RecursiveASTVisitor<Derived>::TraverseStmt(Stmt *S,
657-
DataRecursionQueue *Queue) {
658+
LLVM_ATTRIBUTE_NOINLINE bool
659+
RecursiveASTVisitor<Derived>::TraverseStmt(Stmt *S, DataRecursionQueue *Queue) {
658660
if (!S)
659661
return true;
660662

clang/include/clang/Analysis/Analyses/ExprMutationAnalyzer.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,10 @@ class FunctionParmMutationAnalyzer {
118118
static FunctionParmMutationAnalyzer *
119119
getFunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context,
120120
ExprMutationAnalyzer::Memoized &Memorized) {
121-
auto it = Memorized.FuncParmAnalyzer.find(&Func);
122-
if (it == Memorized.FuncParmAnalyzer.end())
123-
it =
124-
Memorized.FuncParmAnalyzer
125-
.try_emplace(&Func, std::unique_ptr<FunctionParmMutationAnalyzer>(
126-
new FunctionParmMutationAnalyzer(
127-
Func, Context, Memorized)))
128-
.first;
121+
auto [it, Inserted] = Memorized.FuncParmAnalyzer.try_emplace(&Func);
122+
if (Inserted)
123+
it->second = std::unique_ptr<FunctionParmMutationAnalyzer>(
124+
new FunctionParmMutationAnalyzer(Func, Context, Memorized));
129125
return it->getSecond().get();
130126
}
131127

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8560,7 +8560,7 @@ def UnsafeBufferUsageDocs : Documentation {
85608560
The attribute ``[[clang::unsafe_buffer_usage]]`` should be placed on functions
85618561
that need to be avoided as they are prone to buffer overflows or unsafe buffer
85628562
struct fields. It is designed to work together with the off-by-default compiler
8563-
warning ``-Wunsafe-buffer-usage``to help codebases transition away from raw pointer
8563+
warning ``-Wunsafe-buffer-usage`` to help codebases transition away from raw pointer
85648564
based buffer management, in favor of safer abstractions such as C++20 ``std::span``.
85658565
The attribute causes ``-Wunsafe-buffer-usage`` to warn on every use of the function or
85668566
the field it is attached to, and it may also lead to emission of automatic fix-it

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,10 @@ def PedanticMacros : DiagGroup<"pedantic-macros",
15601560
def BranchProtection : DiagGroup<"branch-protection">;
15611561

15621562
// HLSL diagnostic groups
1563+
def HLSL202y : DiagGroup<"hlsl-202y-extensions">;
1564+
15631565
// Warnings for HLSL Clang extensions
1564-
def HLSLExtension : DiagGroup<"hlsl-extensions">;
1566+
def HLSLExtension : DiagGroup<"hlsl-extensions", [HLSL202y]>;
15651567

15661568
// Warning for mix packoffset and non-packoffset.
15671569
def HLSLMixPackOffset : DiagGroup<"mix-packoffset">;

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,8 @@ def note_macro_expansion_here : Note<"expansion of macro %0 requested here">;
508508

509509
def ext_pp_opencl_variadic_macros : Extension<
510510
"variadic macros are a Clang extension in OpenCL">;
511+
def err_opencl_logical_exclusive_or : Error<
512+
"^^ is a reserved operator in OpenCL">;
511513

512514
def ext_pp_gnu_line_directive : Extension<
513515
"this style of line directive is a GNU extension">,

0 commit comments

Comments
 (0)