Skip to content

Commit c294719

Browse files
committed
Merged main:edebbb46b503 into amd-gfx:1ee42a3e1986
Local branch amd-gfx 1ee42a3 Merged main:4fc1e7db273d into amd-gfx:8ff1b908794a Remote branch main edebbb4 [AMDGPU/VOP3P][NFC] - Simplify wmma instruction defs (llvm#70622) Change-Id: Ib689811ed4b7a97a877c6ba8fbb77c1ba6831703
2 parents 1ee42a3 + edebbb4 commit c294719

File tree

554 files changed

+21506
-18787
lines changed

Some content is hidden

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

554 files changed

+21506
-18787
lines changed

.github/workflows/docs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ on:
2121
- 'libcxx/docs/**'
2222
- 'libc/docs/**'
2323
- 'lld/docs/**'
24+
- 'openmp/docs/**'
25+
- 'polly/docs/**'
2426
pull_request:
2527
paths:
2628
- 'llvm/docs/**'
@@ -31,6 +33,8 @@ on:
3133
- 'libcxx/docs/**'
3234
- 'libc/docs/**'
3335
- 'lld/docs/**'
36+
- 'openmp/docs/**'
37+
- 'polly/docs/**'
3438

3539
jobs:
3640
check-docs-build:
@@ -67,6 +71,10 @@ jobs:
6771
- 'libc/docs/**'
6872
lld:
6973
- 'lld/docs/**'
74+
openmp:
75+
- 'openmp/docs/**'
76+
polly:
77+
- 'polly/docs/**'
7078
- name: Fetch LLVM sources (PR)
7179
if: ${{ github.event_name == 'pull_request' }}
7280
uses: actions/checkout@v4
@@ -125,4 +133,14 @@ jobs:
125133
run: |
126134
cmake -B lld-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="lld" -DLLVM_ENABLE_SPHINX=ON ./llvm
127135
TZ=UTC ninja -C lld-build docs-lld-html
136+
- name: Build OpenMP docs
137+
if: steps.docs-changed-subprojects.outputs.openmp_any_changed == 'true'
138+
run: |
139+
cmake -B openmp-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;openmp" -DLLVM_ENABLE_SPHINX=ON ./llvm
140+
TZ=UTC ninja -C openmp-build docs-openmp-html
141+
- name: Build Polly docs
142+
if: steps.docs-changed-subprojects.outputs.polly_any_changed == 'true'
143+
run: |
144+
cmake -B polly-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="polly" -DLLVM_ENABLE_SPHINX=ON ./llvm
145+
TZ=UTC ninja -C polly-build docs-polly-html docs-polly-man
128146

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

Lines changed: 62 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
#include "PreferMemberInitializerCheck.h"
1010
#include "clang/AST/ASTContext.h"
11+
#include "clang/AST/Decl.h"
1112
#include "clang/ASTMatchers/ASTMatchFinder.h"
1213
#include "clang/Lex/Lexer.h"
14+
#include "llvm/ADT/DenseMap.h"
1315

1416
using namespace clang::ast_matchers;
1517

@@ -54,31 +56,66 @@ static bool shouldBeDefaultMemberInitializer(const Expr *Value) {
5456
}
5557

5658
namespace {
59+
5760
AST_MATCHER_P(FieldDecl, indexNotLessThan, unsigned, Index) {
5861
return Node.getFieldIndex() >= Index;
5962
}
63+
64+
enum class AssignedLevel {
65+
// Field is not assigned.
66+
None,
67+
// Field is assigned.
68+
Default,
69+
// Assignment of field has side effect:
70+
// - assign to reference.
71+
// FIXME: support other side effect.
72+
HasSideEffect,
73+
// Assignment of field has data dependence.
74+
HasDependence,
75+
};
76+
6077
} // namespace
6178

79+
static bool canAdvanceAssignment(AssignedLevel Level) {
80+
return Level == AssignedLevel::None || Level == AssignedLevel::Default;
81+
}
82+
6283
// Checks if Field is initialised using a field that will be initialised after
6384
// it.
6485
// TODO: Probably should guard against function calls that could have side
65-
// effects or if they do reference another field that's initialized before this
66-
// field, but is modified before the assignment.
67-
static bool isSafeAssignment(const FieldDecl *Field, const Expr *Init,
68-
const CXXConstructorDecl *Context) {
86+
// effects or if they do reference another field that's initialized before
87+
// this field, but is modified before the assignment.
88+
static void updateAssignmentLevel(
89+
const FieldDecl *Field, const Expr *Init, const CXXConstructorDecl *Ctor,
90+
llvm::DenseMap<const FieldDecl *, AssignedLevel> &AssignedFields) {
91+
auto It = AssignedFields.find(Field);
92+
if (It == AssignedFields.end())
93+
It = AssignedFields.insert({Field, AssignedLevel::None}).first;
94+
95+
if (!canAdvanceAssignment(It->second))
96+
// fast path for already decided field.
97+
return;
98+
99+
if (Field->getType().getCanonicalType()->isReferenceType()) {
100+
// assign to reference type twice cannot be simplified to once.
101+
It->second = AssignedLevel::HasSideEffect;
102+
return;
103+
}
69104

70105
auto MemberMatcher =
71106
memberExpr(hasObjectExpression(cxxThisExpr()),
72107
member(fieldDecl(indexNotLessThan(Field->getFieldIndex()))));
73-
74108
auto DeclMatcher = declRefExpr(
75-
to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Context)))));
76-
77-
return match(expr(anyOf(MemberMatcher, DeclMatcher,
78-
hasDescendant(MemberMatcher),
79-
hasDescendant(DeclMatcher))),
80-
*Init, Field->getASTContext())
81-
.empty();
109+
to(varDecl(unless(parmVarDecl()), hasDeclContext(equalsNode(Ctor)))));
110+
const bool HasDependence = !match(expr(anyOf(MemberMatcher, DeclMatcher,
111+
hasDescendant(MemberMatcher),
112+
hasDescendant(DeclMatcher))),
113+
*Init, Field->getASTContext())
114+
.empty();
115+
if (HasDependence) {
116+
It->second = AssignedLevel::HasDependence;
117+
return;
118+
}
82119
}
83120

84121
static std::pair<const FieldDecl *, const Expr *>
@@ -99,9 +136,9 @@ isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
99136
if (!isa<CXXThisExpr>(ME->getBase()))
100137
return std::make_pair(nullptr, nullptr);
101138
const Expr *Init = BO->getRHS()->IgnoreParenImpCasts();
102-
if (isSafeAssignment(Field, Init, Ctor))
103-
return std::make_pair(Field, Init);
104-
} else if (const auto *COCE = dyn_cast<CXXOperatorCallExpr>(S)) {
139+
return std::make_pair(Field, Init);
140+
}
141+
if (const auto *COCE = dyn_cast<CXXOperatorCallExpr>(S)) {
105142
if (COCE->getOperator() != OO_Equal)
106143
return std::make_pair(nullptr, nullptr);
107144

@@ -117,10 +154,8 @@ isAssignmentToMemberOf(const CXXRecordDecl *Rec, const Stmt *S,
117154
if (!isa<CXXThisExpr>(ME->getBase()))
118155
return std::make_pair(nullptr, nullptr);
119156
const Expr *Init = COCE->getArg(1)->IgnoreParenImpCasts();
120-
if (isSafeAssignment(Field, Init, Ctor))
121-
return std::make_pair(Field, Init);
157+
return std::make_pair(Field, Init);
122158
}
123-
124159
return std::make_pair(nullptr, nullptr);
125160
}
126161

@@ -156,6 +191,12 @@ void PreferMemberInitializerCheck::check(
156191
const CXXRecordDecl *Class = Ctor->getParent();
157192
bool FirstToCtorInits = true;
158193

194+
llvm::DenseMap<const FieldDecl *, AssignedLevel> AssignedFields{};
195+
196+
for (const CXXCtorInitializer *Init : Ctor->inits())
197+
if (FieldDecl *Field = Init->getMember())
198+
updateAssignmentLevel(Field, Init->getInit(), Ctor, AssignedFields);
199+
159200
for (const Stmt *S : Body->body()) {
160201
if (S->getBeginLoc().isMacroID()) {
161202
StringRef MacroName = Lexer::getImmediateMacroName(
@@ -180,6 +221,9 @@ void PreferMemberInitializerCheck::check(
180221
std::tie(Field, InitValue) = isAssignmentToMemberOf(Class, S, Ctor);
181222
if (!Field)
182223
continue;
224+
updateAssignmentLevel(Field, InitValue, Ctor, AssignedFields);
225+
if (!canAdvanceAssignment(AssignedFields[Field]))
226+
continue;
183227
const bool IsInDefaultMemberInitializer =
184228
IsUseDefaultMemberInitEnabled && getLangOpts().CPlusPlus11 &&
185229
Ctor->isDefaultConstructor() &&

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

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ SourceRange getTypeRange(const ParmVarDecl &Param) {
2121
return {Param.getBeginLoc(), Param.getLocation().getLocWithOffset(-1)};
2222
}
2323

24+
// Finds the location of the qualifying `const` token in the `ParmValDecl`'s
25+
// return type. Returns `std::nullopt` when the parm type is not
26+
// `const`-qualified like when the type is an alias or a macro.
27+
static std::optional<Token>
28+
findConstToRemove(const ParmVarDecl &Param,
29+
const MatchFinder::MatchResult &Result) {
30+
31+
CharSourceRange FileRange = Lexer::makeFileCharRange(
32+
CharSourceRange::getTokenRange(getTypeRange(Param)),
33+
*Result.SourceManager, Result.Context->getLangOpts());
34+
35+
if (FileRange.isInvalid())
36+
return std::nullopt;
37+
38+
return tidy::utils::lexer::getQualifyingToken(
39+
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
40+
}
41+
2442
} // namespace
2543

2644
void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap &Opts) {
@@ -30,11 +48,10 @@ void AvoidConstParamsInDecls::storeOptions(ClangTidyOptions::OptionMap &Opts) {
3048
void AvoidConstParamsInDecls::registerMatchers(MatchFinder *Finder) {
3149
const auto ConstParamDecl =
3250
parmVarDecl(hasType(qualType(isConstQualified()))).bind("param");
33-
Finder->addMatcher(
34-
functionDecl(unless(isDefinition()),
35-
has(typeLoc(forEach(ConstParamDecl))))
36-
.bind("func"),
37-
this);
51+
Finder->addMatcher(functionDecl(unless(isDefinition()),
52+
has(typeLoc(forEach(ConstParamDecl))))
53+
.bind("func"),
54+
this);
3855
}
3956

4057
void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
@@ -50,7 +67,10 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
5067
return;
5168
}
5269

53-
auto Diag = diag(Param->getBeginLoc(),
70+
const auto Tok = findConstToRemove(*Param, Result);
71+
const auto ConstLocation = Tok ? Tok->getLocation() : Param->getBeginLoc();
72+
73+
auto Diag = diag(ConstLocation,
5474
"parameter %0 is const-qualified in the function "
5575
"declaration; const-qualification of parameters only has an "
5676
"effect in function definitions");
@@ -70,18 +90,9 @@ void AvoidConstParamsInDecls::check(const MatchFinder::MatchResult &Result) {
7090
// from a macro.
7191
return;
7292
}
73-
74-
CharSourceRange FileRange = Lexer::makeFileCharRange(
75-
CharSourceRange::getTokenRange(getTypeRange(*Param)),
76-
*Result.SourceManager, getLangOpts());
77-
78-
if (!FileRange.isValid())
79-
return;
80-
81-
auto Tok = tidy::utils::lexer::getQualifyingToken(
82-
tok::kw_const, FileRange, *Result.Context, *Result.SourceManager);
8393
if (!Tok)
8494
return;
95+
8596
Diag << FixItHint::CreateRemoval(
8697
CharSourceRange::getTokenRange(Tok->getLocation(), Tok->getLocation()));
8798
}

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ Changes in existing checks
256256

257257
- Improved :doc:`cppcoreguidelines-prefer-member-initializer
258258
<clang-tidy/checks/cppcoreguidelines/prefer-member-initializer>` check to
259-
ignore delegate constructors.
259+
ignore delegate constructors and ignore re-assignment for reference or when
260+
initialization depend on field that is initialized before.
260261

261262
- Improved :doc:`cppcoreguidelines-pro-bounds-array-to-pointer-decay
262263
<clang-tidy/checks/cppcoreguidelines/pro-bounds-array-to-pointer-decay>` check
@@ -368,6 +369,10 @@ Changes in existing checks
368369
<clang-tidy/checks/readability/braces-around-statements>` check to
369370
ignore false-positive for ``if constexpr`` in lambda expression.
370371

372+
- Improved :doc:`readability-avoid-const-params-in-decls
373+
<clang-tidy/checks/readability/avoid-const-params-in-decls>` diagnositics to
374+
highlight the const location
375+
371376
- Improved :doc:`readability-container-size-empty
372377
<clang-tidy/checks/readability/container-size-empty>` check to
373378
detect comparison between string and empty string literals and support

clang-tools-extra/test/clang-tidy/checkers/bugprone/string-constructor.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ void Test() {
4949
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
5050
std::string q2("test", 200);
5151
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
52+
std::string t1("test", 5);
53+
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
5254
std::string q3(kText, 200);
5355
// CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger than string literal size
5456
std::string q4(kText2, 200);
@@ -97,6 +99,8 @@ void Valid() {
9799
std::string s1("test", 4);
98100
std::string s2("test", 3);
99101
std::string s3("test");
102+
std::string s4("test\000", 5);
103+
std::string s6("te" "st", 4);
100104

101105
std::string_view emptyv();
102106
std::string_view sv1("test", 4);

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,3 +570,19 @@ struct PR52818 {
570570

571571
int bar;
572572
};
573+
574+
struct RefReassignment {
575+
RefReassignment(int &i) : m_i{i} {
576+
m_i = 1;
577+
}
578+
int & m_i;
579+
};
580+
581+
struct ReassignmentAfterUnsafetyAssignment {
582+
ReassignmentAfterUnsafetyAssignment() {
583+
int a = 10;
584+
m_i = a;
585+
m_i = 1;
586+
}
587+
int m_i;
588+
};

clang-tools-extra/test/clang-tidy/checkers/readability/avoid-const-params-in-decls.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ void F1(const int i);
99
// CHECK-FIXES: void F1(int i);
1010

1111
void F2(const int *const i);
12-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
12+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: parameter 'i' is const-qualified
1313
// CHECK-FIXES: void F2(const int *i);
1414

1515
void F3(int const i);
16-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
16+
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is const-qualified
1717
// CHECK-FIXES: void F3(int i);
1818

1919
void F4(alias_type const i);
20-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is const-qualified
20+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: parameter 'i' is const-qualified
2121
// CHECK-FIXES: void F4(alias_type i);
2222

2323
void F5(const int);
2424
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
2525
// CHECK-FIXES: void F5(int);
2626

2727
void F6(const int *const);
28-
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 1 is const-qualified
28+
// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: parameter 1 is const-qualified
2929
// CHECK-FIXES: void F6(const int *);
3030

3131
void F7(int, const int);
@@ -42,7 +42,7 @@ void F9(const int long_name);
4242
// CHECK-FIXES: void F9(int long_name);
4343

4444
void F10(const int *const *const long_name);
45-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'long_name'
45+
// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: parameter 'long_name'
4646
// CHECK-FIXES: void F10(const int *const *long_name);
4747

4848
void F11(const unsigned int /*v*/);
@@ -71,11 +71,11 @@ void F15(const A<const int> Named);
7171
// CHECK-FIXES: void F15(A<const int> Named);
7272

7373
void F16(const A<const int> *const);
74-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 1 is const-qualified
74+
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: parameter 1 is const-qualified
7575
// CHECK-FIXES: void F16(const A<const int> *);
7676

7777
void F17(const A<const int> *const Named);
78-
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: parameter 'Named' is const-qualified
78+
// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: parameter 'Named' is const-qualified
7979
// CHECK-FIXES: void F17(const A<const int> *Named);
8080

8181
struct Foo {

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ Bug Fixes in This Version
529529
``thread_local`` instead of ``_Thread_local``.
530530
Fixes (`#70068 <https://github.com/llvm/llvm-project/issues/70068>`_) and
531531
(`#69167 <https://github.com/llvm/llvm-project/issues/69167>`_)
532+
- Fix crash in evaluating invalid lambda expression which forget capture this.
533+
Fixes (`#67687 <https://github.com/llvm/llvm-project/issues/67687>`_)
532534
- Fix crash from constexpr evaluator evaluating uninitialized arrays as rvalue.
533535
Fixes (`#67317 <https://github.com/llvm/llvm-project/issues/67317>`_)
534536

@@ -818,6 +820,7 @@ clang-format
818820
------------
819821
- Add ``AllowBreakBeforeNoexceptSpecifier`` option.
820822
- Add ``AllowShortCompoundRequirementOnASingleLine`` option.
823+
- Change ``BreakAfterAttributes`` from ``Never`` to ``Leave`` in LLVM style.
821824

822825
libclang
823826
--------

clang/docs/StandardCPlusPlusModules.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,10 @@ the above example could be rewritten into:
365365
366366
$ clang++ -std=c++20 M.cppm --precompile -fmodule-file=M:interface_part=M-interface_part.pcm -fmodule-file=M:impl_part=M-impl_part.pcm -o M.pcm
367367
368+
When there are multiple ``-fmodule-file=<module-name>=`` options for the same
369+
``<module-name>``, the last ``-fmodule-file=<module-name>=`` will override the previous
370+
``-fmodule-file=<module-name>=`` options.
371+
368372
``-fprebuilt-module-path`` is more convenient and ``-fmodule-file`` is faster since
369373
it saves time for file lookup.
370374

0 commit comments

Comments
 (0)