Skip to content

Commit 182c595

Browse files
committed
merge main into amd-staging
2 parents 58c0065 + 18302d0 commit 182c595

File tree

292 files changed

+7366
-5841
lines changed

Some content is hidden

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

292 files changed

+7366
-5841
lines changed

.github/workflows/libc-fullbuild-tests.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,37 +21,37 @@ jobs:
2121
- os: ubuntu-24.04
2222
build_type: Debug
2323
ccache-variant: sccache
24-
c_compiler: clang-21
25-
cpp_compiler: clang++-21
24+
c_compiler: clang-20
25+
cpp_compiler: clang++-20
2626
target: x86_64-unknown-linux-llvm
2727
include_scudo: ON
2828
- os: ubuntu-24.04
2929
build_type: Release
3030
ccache-variant: sccache
31-
c_compiler: clang-21
32-
cpp_compiler: clang++-21
31+
c_compiler: clang-20
32+
cpp_compiler: clang++-20
3333
target: x86_64-unknown-linux-llvm
3434
include_scudo: ON
3535
- os: ubuntu-24.04
3636
build_type: MinSizeRel
3737
ccache-variant: sccache
38-
c_compiler: clang-21
39-
cpp_compiler: clang++-21
38+
c_compiler: clang-20
39+
cpp_compiler: clang++-20
4040
target: x86_64-unknown-linux-llvm
4141
include_scudo: ON
4242
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
4343
- os: ubuntu-24.04-arm
4444
build_type: Debug
4545
ccache-variant: ccache
46-
c_compiler: clang-21
47-
cpp_compiler: clang++-21
46+
c_compiler: clang-20
47+
cpp_compiler: clang++-20
4848
target: aarch64-unknown-linux-llvm
4949
include_scudo: ON
5050
- os: ubuntu-24.04
5151
build_type: Debug
5252
ccache-variant: ccache
53-
c_compiler: clang-21
54-
cpp_compiler: clang++-21
53+
c_compiler: clang-20
54+
cpp_compiler: clang++-20
5555
target: x86_64-unknown-uefi-llvm
5656
include_scudo: OFF
5757
# TODO: add back gcc build when it is fixed
@@ -81,7 +81,7 @@ jobs:
8181
run: |
8282
wget https://apt.llvm.org/llvm.sh
8383
chmod +x llvm.sh
84-
sudo ./llvm.sh 21
84+
sudo ./llvm.sh 20
8585
sudo apt-get update
8686
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
8787
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm

clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,23 @@ EditGenerator rewrite(RangeSelector Call, RangeSelector Builder,
111111
}
112112

113113
RewriteRuleWith<std::string> useNewMlirOpBuilderCheckRule() {
114-
return makeRule(
114+
Stencil message = cat("use 'OpType::create(builder, ...)' instead of "
115+
"'builder.create<OpType>(...)'");
116+
// Match a create call on an OpBuilder.
117+
ast_matchers::internal::Matcher<Stmt> base =
115118
cxxMemberCallExpr(
116119
on(expr(hasType(
117120
cxxRecordDecl(isSameOrDerivedFrom("::mlir::OpBuilder"))))
118121
.bind("builder")),
119122
callee(cxxMethodDecl(hasTemplateArgument(0, templateArgument()))),
120123
callee(cxxMethodDecl(hasName("create"))))
121-
.bind("call"),
122-
rewrite(node("call"), node("builder"), callArgs("call")),
123-
cat("use 'OpType::create(builder, ...)' instead of "
124-
"'builder.create<OpType>(...)'"));
124+
.bind("call");
125+
return applyFirst(
126+
// Attempt rewrite given an lvalue builder, else just warn.
127+
{makeRule(cxxMemberCallExpr(unless(on(cxxTemporaryObjectExpr())), base),
128+
rewrite(node("call"), node("builder"), callArgs("call")),
129+
message),
130+
makeRule(base, noopEdit(node("call")), message)});
125131
}
126132
} // namespace
127133

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

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,14 @@ QualifiedAutoCheck::QualifiedAutoCheck(StringRef Name,
106106
: ClangTidyCheck(Name, Context),
107107
AddConstToQualified(Options.get("AddConstToQualified", true)),
108108
AllowedTypes(
109-
utils::options::parseStringList(Options.get("AllowedTypes", ""))) {}
109+
utils::options::parseStringList(Options.get("AllowedTypes", ""))),
110+
IgnoreAliasing(Options.get("IgnoreAliasing", true)) {}
110111

111112
void QualifiedAutoCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
112113
Options.store(Opts, "AddConstToQualified", AddConstToQualified);
113114
Options.store(Opts, "AllowedTypes",
114115
utils::options::serializeStringList(AllowedTypes));
116+
Options.store(Opts, "IgnoreAliasing", IgnoreAliasing);
115117
}
116118

117119
void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
@@ -134,16 +136,30 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
134136

135137
auto IsBoundToType = refersToType(equalsBoundNode("type"));
136138
auto UnlessFunctionType = unless(hasUnqualifiedDesugaredType(functionType()));
137-
auto IsAutoDeducedToPointer = [](const std::vector<StringRef> &AllowedTypes,
138-
const auto &...InnerMatchers) {
139-
return autoType(hasDeducedType(
140-
hasUnqualifiedDesugaredType(pointerType(pointee(InnerMatchers...))),
141-
unless(hasUnqualifiedType(
142-
matchers::matchesAnyListedTypeName(AllowedTypes, false))),
143-
unless(pointerType(pointee(hasUnqualifiedType(
144-
matchers::matchesAnyListedTypeName(AllowedTypes, false)))))));
139+
140+
auto IsPointerType = [this](const auto &...InnerMatchers) {
141+
if (this->IgnoreAliasing) {
142+
return qualType(
143+
hasUnqualifiedDesugaredType(pointerType(pointee(InnerMatchers...))));
144+
} else {
145+
return qualType(
146+
anyOf(qualType(pointerType(pointee(InnerMatchers...))),
147+
qualType(substTemplateTypeParmType(hasReplacementType(
148+
pointerType(pointee(InnerMatchers...)))))));
149+
}
145150
};
146151

152+
auto IsAutoDeducedToPointer =
153+
[IsPointerType](const std::vector<StringRef> &AllowedTypes,
154+
const auto &...InnerMatchers) {
155+
return autoType(hasDeducedType(
156+
IsPointerType(InnerMatchers...),
157+
unless(hasUnqualifiedType(
158+
matchers::matchesAnyListedTypeName(AllowedTypes, false))),
159+
unless(pointerType(pointee(hasUnqualifiedType(
160+
matchers::matchesAnyListedTypeName(AllowedTypes, false)))))));
161+
};
162+
147163
Finder->addMatcher(
148164
ExplicitSingleVarDecl(
149165
hasType(IsAutoDeducedToPointer(AllowedTypes, UnlessFunctionType)),

clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class QualifiedAutoCheck : public ClangTidyCheck {
3232
private:
3333
const bool AddConstToQualified;
3434
const std::vector<StringRef> AllowedTypes;
35+
const bool IgnoreAliasing;
3536
};
3637

3738
} // namespace clang::tidy::readability

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ Changes in existing checks
154154
<clang-tidy/checks/portability/template-virtual-member-function>` check to
155155
avoid false positives on pure virtual member functions.
156156

157+
- Improved :doc:`readability-qualified-auto
158+
<clang-tidy/checks/readability/qualified-auto>` check by adding the option
159+
`IgnoreAliasing`, that allows not looking at underlying types of type aliases.
160+
157161
Removed checks
158162
^^^^^^^^^^^^^^
159163

clang-tools-extra/docs/clang-tidy/checks/readability/qualified-auto.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,45 @@ Note in the LLVM alias, the default value is `false`.
9696
matched against only the type name (i.e. ``Type``). E.g. to suppress reports
9797
for ``std::array`` iterators use `std::array<.*>::(const_)?iterator` string.
9898
The default is an empty string.
99+
100+
.. option:: IgnoreAliasing
101+
102+
If set to `true` the check will use the underlying type to determine the type
103+
that ``auto`` is deduced to. If set to `false` the check will not look beyond
104+
the first type alias.
105+
Default value is `true`.
106+
107+
.. code-block:: c++
108+
109+
using IntPtr = int*;
110+
IntPtr foo();
111+
112+
auto bar = foo();
113+
114+
If :option:`IgnoreAliasing` is set to `true`, it will be transformed into:
115+
116+
.. code-block:: c++
117+
118+
auto *bar = foo();
119+
120+
Otherwise no changes will occur.
121+
122+
Limitations
123+
-----------
124+
125+
When :option:`IgnoreAliasing` is set to `false`, there are cases where
126+
Clang has not preserved the type alias and the underlying type will be used so
127+
false positives may occur.
128+
129+
For example:
130+
131+
.. code-block:: c++
132+
133+
using IntPtr = int *;
134+
135+
void loopPtr(const std::vector<IntPtr> &VectorIntPtr) {
136+
137+
// May fail for IgnoreAliasing==false as AST does not have the 'IntPtr'
138+
for (auto Data : VectorIntPtr) {
139+
}
140+
}

clang-tools-extra/test/clang-tidy/checkers/llvm/use-new-mlir-op-builder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ void f() {
6969
// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder]
7070
// CHECK-FIXES: mlir::ModuleOp::create(ib)
7171
ib.create<mlir::ModuleOp>( );
72+
73+
// CHECK-MESSAGES: :[[@LINE+2]]:3: warning: use 'OpType::create(builder, ...)' instead of 'builder.create<OpType>(...)' [llvm-use-new-mlir-op-builder]
74+
// CHECK-FIXES: mlir::OpBuilder().create<mlir::ModuleOp>(builder.getUnknownLoc());
75+
mlir::OpBuilder().create<mlir::ModuleOp>(builder.getUnknownLoc());
7276
}

0 commit comments

Comments
 (0)