Skip to content

Commit a6f6365

Browse files
Merge branch 'llvm:main' into cfi-show
2 parents cafca68 + 313b52f commit a6f6365

File tree

453 files changed

+37404
-3722
lines changed

Some content is hidden

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

453 files changed

+37404
-3722
lines changed

.ci/cache_lit_timing_files.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,21 @@
1414
import logging
1515
import multiprocessing.pool
1616
import pathlib
17+
import platform
1718
import glob
1819

1920
from google.cloud import storage
2021

2122
GCS_PARALLELISM = 100
2223

2324

25+
def _get_blob_prefix():
26+
return f"lit_timing_{platform.system().lower()}"
27+
28+
2429
def _maybe_upload_timing_file(bucket, timing_file_path):
2530
if os.path.exists(timing_file_path):
26-
timing_file_blob = bucket.blob("lit_timing/" + timing_file_path)
31+
timing_file_blob = bucket.blob(_get_blob_prefix() + "/" + timing_file_path)
2732
timing_file_blob.upload_from_filename(timing_file_path)
2833

2934

@@ -43,14 +48,14 @@ def upload_timing_files(storage_client, bucket_name: str):
4348

4449

4550
def _maybe_download_timing_file(blob):
46-
file_name = blob.name.removeprefix("lit_timing/")
51+
file_name = blob.name.removeprefix(_get_blob_prefix() + "/")
4752
pathlib.Path(os.path.dirname(file_name)).mkdir(parents=True, exist_ok=True)
4853
blob.download_to_filename(file_name)
4954

5055

5156
def download_timing_files(storage_client, bucket_name: str):
5257
bucket = storage_client.bucket(bucket_name)
53-
blobs = bucket.list_blobs(prefix="lit_timing")
58+
blobs = bucket.list_blobs(prefix=_get_blob_prefix())
5459
with multiprocessing.pool.ThreadPool(GCS_PARALLELISM) as thread_pool:
5560
futures = []
5661
for timing_file_blob in blobs:

.ci/generate_test_report_lib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ def _parse_ninja_log(ninja_log: list[str]) -> list[tuple[str, str]]:
2727
# We hit the end of the log without finding a build failure, go to
2828
# the next log.
2929
return failures
30+
# If we are doing a build with LLVM_ENABLE_RUNTIMES, we can have nested
31+
# ninja invocations. The sub-ninja will print that a subcommand failed,
32+
# and then the outer ninja will list the command that failed. We should
33+
# ignore the outer failure.
34+
if ninja_log[index - 1].startswith("ninja: build stopped:"):
35+
index += 1
36+
continue
3037
# We are trying to parse cases like the following:
3138
#
3239
# [4/5] test/4.stamp

.ci/generate_test_report_lib_test.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,39 @@ def test_ninja_log_multiple_failures(self):
126126
),
127127
)
128128

129+
# Test that we can correctly handle the runtimes build. the LLVM runtimes
130+
# build will involve ninja invoking more ninja processes within the
131+
# runtimes directory. This means that we see two failures for a failure in
132+
# the runtimes build: one from the inner ninja containing the actual action
133+
# that failed, and one for the sub ninja invocation that failed.
134+
def test_ninja_log_runtimes_failure(self):
135+
failures = generate_test_report_lib.find_failure_in_ninja_logs(
136+
[
137+
[
138+
"[1/5] test/1.stamp",
139+
"[2/5] test/2.stamp",
140+
"FAILED: touch test/2.stamp",
141+
"Wow! This system is really broken!",
142+
"ninja: build stopped: subcommand failed.",
143+
"FAILED: running check-runtime failed.",
144+
"<some random command>",
145+
"ninja: build stopped: subcommand failed.",
146+
]
147+
]
148+
)
149+
self.assertEqual(len(failures), 1)
150+
self.assertEqual(
151+
failures[0],
152+
(
153+
"test/2.stamp",
154+
dedent(
155+
"""\
156+
FAILED: touch test/2.stamp
157+
Wow! This system is really broken!"""
158+
),
159+
),
160+
)
161+
129162
def test_title_only(self):
130163
self.assertEqual(
131164
generate_test_report_lib.generate_report("Foo", 0, [], []),

.github/workflows/libcxx-build-containers.yml

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
3434

35+
# The default Docker storage location for GitHub Actions doesn't have
36+
# enough disk space, so change it to /mnt, which has more disk space.
37+
- name: Change Docker storage location
38+
run: |
39+
sudo mkdir /mnt/docker
40+
echo '{ "data-root": "/mnt/docker" }' | sudo tee /etc/docker/daemon.json
41+
sudo systemctl restart docker
42+
3543
- name: Build the Linux builder image
3644
working-directory: libcxx/utils/ci
3745
run: |
@@ -40,11 +48,11 @@ jobs:
4048
env:
4149
TAG: ${{ github.sha }}
4250

43-
# - name: Build the Android builder image
44-
# working-directory: libcxx/utils/ci
45-
# run: docker compose build android-buildkite-builder
46-
# env:
47-
# TAG: ${{ github.sha }}
51+
- name: Build the Android builder image
52+
working-directory: libcxx/utils/ci
53+
run: docker compose build android-buildkite-builder
54+
env:
55+
TAG: ${{ github.sha }}
4856

4957
- name: Log in to GitHub Container Registry
5058
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
@@ -62,10 +70,10 @@ jobs:
6270
env:
6371
TAG: ${{ github.sha }}
6472

65-
# - name: Push the Android builder image
66-
# if: github.event_name == 'push'
67-
# working-directory: libcxx/utils/ci
68-
# run: |
69-
# docker compose push android-buildkite-builder
70-
# env:
71-
# TAG: ${{ github.sha }}
73+
- name: Push the Android builder image
74+
if: github.event_name == 'push'
75+
working-directory: libcxx/utils/ci
76+
run: |
77+
docker compose push android-buildkite-builder
78+
env:
79+
TAG: ${{ github.sha }}

.github/workflows/pr-code-format.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,13 @@ jobs:
5252
echo "Formatting files:"
5353
echo "$CHANGED_FILES"
5454
55+
# The clang format version should always be upgraded to the first version
56+
# of a release cycle (x.1.0) or the last version of a release cycle, or
57+
# if there have been relevant clang-format backports.
5558
- name: Install clang-format
5659
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
5760
with:
58-
clangformat: 20.1.8
61+
clangformat: 21.1.0
5962

6063
- name: Setup Python env
6164
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0

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

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ AST_MATCHER_P(UserDefinedLiteral, hasLiteral,
110110
return false;
111111
}
112112

113+
AST_MATCHER_P(CXXMethodDecl, hasCanonicalDecl,
114+
clang::ast_matchers::internal::Matcher<CXXMethodDecl>,
115+
InnerMatcher) {
116+
return InnerMatcher.matches(*Node.getCanonicalDecl(), Finder, Builder);
117+
}
118+
119+
AST_POLYMORPHIC_MATCHER_P(
120+
matchMemberName,
121+
AST_POLYMORPHIC_SUPPORTED_TYPES(MemberExpr, CXXDependentScopeMemberExpr),
122+
std::string, MemberName) {
123+
if (const auto *E = dyn_cast<MemberExpr>(&Node))
124+
return E->getMemberDecl()->getName() == MemberName;
125+
126+
if (const auto *E = dyn_cast<CXXDependentScopeMemberExpr>(&Node))
127+
return E->getMember().getAsString() == MemberName;
128+
129+
return false;
130+
}
131+
113132
} // namespace
114133

115134
using utils::isBinaryOrTernary;
@@ -140,9 +159,10 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
140159
const auto ValidContainerNonTemplateType =
141160
qualType(hasUnqualifiedDesugaredType(
142161
recordType(hasDeclaration(ValidContainerRecord))));
143-
const auto ValidContainerTemplateType =
144-
qualType(hasUnqualifiedDesugaredType(templateSpecializationType(
145-
hasDeclaration(classTemplateDecl(has(ValidContainerRecord))))));
162+
const auto ValidContainerTemplateType = qualType(hasUnqualifiedDesugaredType(
163+
anyOf(templateSpecializationType(
164+
hasDeclaration(classTemplateDecl(has(ValidContainerRecord)))),
165+
injectedClassNameType(hasDeclaration(ValidContainerRecord)))));
146166

147167
const auto ValidContainer = qualType(
148168
anyOf(ValidContainerNonTemplateType, ValidContainerTemplateType));
@@ -155,6 +175,9 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
155175
.bind("SizeBinaryOp")),
156176
usedInBooleanContext());
157177

178+
const auto NotInEmptyMethodOfContainer = unless(
179+
forCallable(cxxMethodDecl(hasCanonicalDecl(equalsBoundNode("empty")))));
180+
158181
Finder->addMatcher(
159182
cxxMemberCallExpr(
160183
argumentCountIs(0),
@@ -164,25 +187,23 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
164187
.bind("MemberCallObject")),
165188
callee(
166189
cxxMethodDecl(hasAnyName("size", "length")).bind("SizeMethod")),
167-
WrongUse,
168-
unless(hasAncestor(
169-
cxxMethodDecl(ofClass(equalsBoundNode("container"))))))
190+
WrongUse, NotInEmptyMethodOfContainer)
170191
.bind("SizeCallExpr"),
171192
this);
172193

173194
Finder->addMatcher(
174-
callExpr(argumentCountIs(0),
175-
has(cxxDependentScopeMemberExpr(
176-
hasObjectExpression(
177-
expr(anyOf(hasType(ValidContainer),
178-
hasType(pointsTo(ValidContainer)),
179-
hasType(references(ValidContainer))))
180-
.bind("MemberCallObject")),
181-
anyOf(hasMemberName("size"), hasMemberName("length")))
182-
.bind("DependentExpr")),
183-
WrongUse,
184-
unless(hasAncestor(
185-
cxxMethodDecl(ofClass(equalsBoundNode("container"))))))
195+
callExpr(
196+
argumentCountIs(0),
197+
has(mapAnyOf(memberExpr, cxxDependentScopeMemberExpr)
198+
.with(
199+
hasObjectExpression(
200+
expr(anyOf(hasType(ValidContainer),
201+
hasType(pointsTo(ValidContainer)),
202+
hasType(references(ValidContainer))))
203+
.bind("MemberCallObject")),
204+
anyOf(matchMemberName("size"), matchMemberName("length")))
205+
.bind("MemberExpr")),
206+
WrongUse, NotInEmptyMethodOfContainer)
186207
.bind("SizeCallExpr"),
187208
this);
188209

@@ -217,8 +238,7 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
217238
hasAnyOperatorName("==", "!="), hasOperands(WrongComparend, STLArg),
218239
unless(allOf(hasLHS(hasType(ExcludedComparisonTypesMatcher)),
219240
hasRHS(hasType(SameExcludedComparisonTypesMatcher)))),
220-
unless(hasAncestor(
221-
cxxMethodDecl(ofClass(equalsBoundNode("container"))))))
241+
NotInEmptyMethodOfContainer)
222242
.bind("BinCmp"),
223243
this);
224244
}
@@ -382,9 +402,12 @@ void ContainerSizeEmptyCheck::check(const MatchFinder::MatchResult &Result) {
382402
Diag << SizeMethod;
383403
else if (const auto *DependentExpr =
384404
Result.Nodes.getNodeAs<CXXDependentScopeMemberExpr>(
385-
"DependentExpr"))
405+
"MemberExpr"))
386406
Diag << DependentExpr->getMember();
387-
else
407+
else if (const auto *ME =
408+
Result.Nodes.getNodeAs<MemberExpr>("MemberExpr")) {
409+
Diag << ME->getMemberNameInfo().getName();
410+
} else
388411
Diag << "unknown method";
389412
Diag << Hint;
390413
} else {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ Changes in existing checks
232232

233233
- Improved :doc:`readability-container-size-empty
234234
<clang-tidy/checks/readability/container-size-empty>` check by correctly
235-
generating fix-it hints when size method is called from implicit ``this``.
235+
generating fix-it hints when size method is called from implicit ``this``
236+
and adding detection in container's method except ``empty``.
236237

237238
- Improved :doc:`readability-identifier-naming
238239
<clang-tidy/checks/readability/identifier-naming>` check by ignoring

clang-tools-extra/test/clang-tidy/checkers/readability/container-size-empty.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,3 +908,46 @@ class foo : public std::string{
908908
};
909909

910910
}
911+
912+
class ReportInContainerNonEmptyMethod {
913+
public:
914+
int size() const;
915+
bool empty() const;
916+
917+
void doit() {
918+
if (!size()) {
919+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used to check for emptiness instead of 'size'
920+
// CHECK-FIXES: if (empty())
921+
}
922+
}
923+
};
924+
925+
template <typename T>
926+
class ReportInTemplateContainerNonEmptyMethod {
927+
public:
928+
int size() const;
929+
bool empty() const;
930+
931+
void doit() {
932+
if (!size()) {
933+
// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used to check for emptiness instead of 'size'
934+
// CHECK-FIXES: if (empty()) {
935+
}
936+
}
937+
};
938+
939+
940+
941+
class ReportInContainerNonEmptyMethodCompare {
942+
public:
943+
bool operator==(const ReportInContainerNonEmptyMethodCompare& other) const;
944+
int size() const;
945+
bool empty() const;
946+
947+
void doit() {
948+
if (*this == ReportInContainerNonEmptyMethodCompare()) {
949+
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: the 'empty' method should be used to check for emptiness instead of comparing to an empty object
950+
// CHECK-FIXES: if (this->empty()) {
951+
}
952+
}
953+
};

clang/docs/AddressSanitizer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ Instrumentation code outlining
297297

298298
By default AddressSanitizer inlines the instrumentation code to improve the
299299
run-time performance, which leads to increased binary size. Using the
300-
(clang flag ``-fsanitize-address-outline-instrumentation` default: ``false``)
300+
(clang flag ``-fsanitize-address-outline-instrumentation`` default: ``false``)
301301
flag forces all code instrumentation to be outlined, which reduces the size
302302
of the generated code, but also reduces the run-time performance.
303303

clang/docs/InternalsManual.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ Class:
343343
Description:
344344
This is a formatter which represents the argument number in a human-readable
345345
format: the value ``123`` stays ``123``, ``12345`` becomes ``12.34k``,
346-
``6666666` becomes ``6.67M``, and so on for 'G' and 'T'.
346+
``6666666`` becomes ``6.67M``, and so on for 'G' and 'T'.
347347

348348
**"objcclass" format**
349349

0 commit comments

Comments
 (0)