Skip to content

Commit 18841c1

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into zcfs
2 parents a1b4a11 + 066221f commit 18841c1

File tree

690 files changed

+38623
-20792
lines changed

Some content is hidden

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

690 files changed

+38623
-20792
lines changed

.ci/generate_test_report_lib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ def plural(num_tests):
9292
]
9393
)
9494
elif failures:
95-
report.extend(["", "## Failed Tests", "(click on a test name to see its output)"])
95+
report.extend(
96+
["", "## Failed Tests", "(click on a test name to see its output)"]
97+
)
9698

9799
for testsuite_name, failures in failures.items():
98100
report.extend(["", f"### {testsuite_name}"])

.ci/metrics/metrics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
# remain small.
6868
BUILDKITE_GRAPHQL_BUILDS_PER_PAGE = 50
6969

70+
7071
@dataclass
7172
class JobMetrics:
7273
job_name: str
@@ -77,6 +78,7 @@ class JobMetrics:
7778
workflow_id: int
7879
workflow_name: str
7980

81+
8082
@dataclass
8183
class GaugeMetric:
8284
name: str
@@ -258,6 +260,7 @@ def buildkite_get_metrics(
258260

259261
return output, incomplete_now
260262

263+
261264
def github_get_metrics(
262265
github_repo: github.Repository, last_workflows_seen_as_completed: set[int]
263266
) -> tuple[list[JobMetrics], int]:

bolt/test/AArch64/check-init-not-moved.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# address. Test checks that _init is not moved.
66

77
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
8-
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static -Wl,--section-start=.data=0x1000 -Wl,--section-start=.init=0x1004
8+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static -Wl,--image-base=0,-Tdata=0x1000,--section-start=.init=0x1004
99
# RUN: llvm-bolt %t.exe -o %t.bolt
1010
# RUN: llvm-nm %t.exe | FileCheck --check-prefix=CHECK-ORIGINAL %s
1111
# RUN: llvm-nm %t.bolt | FileCheck --check-prefix=CHECK-BOLTED %s

bolt/test/AArch64/pad-before-funcs.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
11-
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -Wl,--section-start=.text=0x4000
11+
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -Wl,--image-base=0x3000,--section-start=.text=0x4000
1212
# RUN: llvm-bolt %t.exe -o %t.bolt.0 --pad-funcs-before=_start:0
1313
# RUN: llvm-bolt %t.exe -o %t.bolt.4 --pad-funcs-before=_start:4
1414
# RUN: llvm-bolt %t.exe -o %t.bolt.8 --pad-funcs-before=_start:8

bolt/test/RISCV/reloc-jt.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// NOTE: assign section addresses explicitly to make the symbol difference
22
/// calculation below less fragile.
3-
// RUN: %clang %cflags -Wl,--section-start=.text=0x1000,--section-start=.data=0x2000 -o %t %s
3+
// RUN: %clang %cflags -Wl,--image-base=0,--section-start=.text=0x1000,--section-start=.data=0x2000 -o %t %s
44
// RUN: llvm-bolt -o %t.bolt %t
55
// RUN: llvm-readelf -x .data %t.bolt | FileCheck %s
66

bolt/test/X86/double-rel-scan.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# REQUIRES: system-linux
77

88
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
9-
# RUN: ld.lld %t.o -o %t.exe -q --Ttext=0x80000
9+
# RUN: ld.lld %t.o -o %t.exe -q --image-base=0x80000 --Ttext=0x80000
1010
# RUN: llvm-bolt %t.exe --relocs -o %t.bolt --funcs=foo
1111
# RUN: llvm-objdump -d --print-imm-hex %t.exe \
1212
# RUN: | FileCheck %s

bolt/test/X86/double-rel.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# REQUIRES: system-linux
66

77
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
8-
# RUN: ld.lld %t.o -o %t.exe -q --Tdata=0x80000
8+
# RUN: ld.lld %t.o -o %t.exe -q --image-base=0x70000 --Tdata=0x80000
99
# RUN: llvm-bolt %t.exe --relocs -o %t.null --print-only=_start --print-disasm \
1010
# RUN: | FileCheck %s --check-prefix=CHECK-BOLT
1111
# RUN: llvm-objdump -d --print-imm-hex %t.exe \

clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,9 @@ const HeaderMapCollector::RegexHeaderMap *getSTLPostfixHeaderMap() {
606606
{"sys/xattr.h$", "<sys/xattr.h>"},
607607
{"bits/epoll.h$", "<sys/epoll.h>"},
608608
{"bits/eventfd.h$", "<sys/eventfd.h>"},
609+
{"bits/getopt_core.h$", "<getopt.h>"},
610+
{"bits/getopt_ext.h$", "<getopt.h>"},
611+
{"bits/getopt_posix.h$", "<getopt.h>"},
609612
{"bits/inotify.h$", "<sys/inotify.h>"},
610613
{"bits/ipc.h$", "<sys/ipc.h>"},
611614
{"bits/ipctypes.h$", "<sys/ipc.h>"},

clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name,
5959
: ClangTidyCheck(Name, Context),
6060
IgnoreHeaders(
6161
utils::options::parseStringList(Options.get("IgnoreHeaders", ""))),
62-
DeduplicateFindings(Options.get("DeduplicateFindings", true)) {
62+
DeduplicateFindings(Options.get("DeduplicateFindings", true)),
63+
UnusedIncludes(Options.get("UnusedIncludes", true)),
64+
MissingIncludes(Options.get("MissingIncludes", true)) {
6365
for (const auto &Header : IgnoreHeaders) {
6466
if (!llvm::Regex{Header}.isValid())
6567
configurationDiag("Invalid ignore headers regex '%0'") << Header;
@@ -68,12 +70,19 @@ IncludeCleanerCheck::IncludeCleanerCheck(StringRef Name,
6870
HeaderSuffix += "$";
6971
IgnoreHeadersRegex.emplace_back(HeaderSuffix);
7072
}
73+
74+
if (UnusedIncludes == false && MissingIncludes == false)
75+
this->configurationDiag("The check 'misc-include-cleaner' will not "
76+
"perform any analysis because 'UnusedIncludes' and "
77+
"'MissingIncludes' are both false.");
7178
}
7279

7380
void IncludeCleanerCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
7481
Options.store(Opts, "IgnoreHeaders",
7582
utils::options::serializeStringList(IgnoreHeaders));
7683
Options.store(Opts, "DeduplicateFindings", DeduplicateFindings);
84+
Options.store(Opts, "UnusedIncludes", UnusedIncludes);
85+
Options.store(Opts, "MissingIncludes", MissingIncludes);
7786
}
7887

7988
bool IncludeCleanerCheck::isLanguageVersionSupported(
@@ -200,39 +209,43 @@ void IncludeCleanerCheck::check(const MatchFinder::MatchResult &Result) {
200209
if (!FileStyle)
201210
FileStyle = format::getLLVMStyle();
202211

203-
for (const auto *Inc : Unused) {
204-
diag(Inc->HashLocation, "included header %0 is not used directly")
205-
<< llvm::sys::path::filename(Inc->Spelled,
206-
llvm::sys::path::Style::posix)
207-
<< FixItHint::CreateRemoval(CharSourceRange::getCharRange(
208-
SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1),
209-
SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1)));
212+
if (UnusedIncludes) {
213+
for (const auto *Inc : Unused) {
214+
diag(Inc->HashLocation, "included header %0 is not used directly")
215+
<< llvm::sys::path::filename(Inc->Spelled,
216+
llvm::sys::path::Style::posix)
217+
<< FixItHint::CreateRemoval(CharSourceRange::getCharRange(
218+
SM->translateLineCol(SM->getMainFileID(), Inc->Line, 1),
219+
SM->translateLineCol(SM->getMainFileID(), Inc->Line + 1, 1)));
220+
}
210221
}
211222

212-
tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
213-
FileStyle->IncludeStyle);
214-
// Deduplicate insertions when running in bulk fix mode.
215-
llvm::StringSet<> InsertedHeaders{};
216-
for (const auto &Inc : Missing) {
217-
std::string Spelling = include_cleaner::spellHeader(
218-
{Inc.Missing, PP->getHeaderSearchInfo(), MainFile});
219-
bool Angled = llvm::StringRef{Spelling}.starts_with("<");
220-
// We might suggest insertion of an existing include in edge cases, e.g.,
221-
// include is present in a PP-disabled region, or spelling of the header
222-
// turns out to be the same as one of the unresolved includes in the
223-
// main file.
224-
if (auto Replacement =
225-
HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"),
226-
Angled, tooling::IncludeDirective::Include)) {
227-
DiagnosticBuilder DB =
228-
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
229-
"no header providing \"%0\" is directly included")
230-
<< Inc.SymRef.Target.name();
231-
if (areDiagsSelfContained() ||
232-
InsertedHeaders.insert(Replacement->getReplacementText()).second) {
233-
DB << FixItHint::CreateInsertion(
234-
SM->getComposedLoc(SM->getMainFileID(), Replacement->getOffset()),
235-
Replacement->getReplacementText());
223+
if (MissingIncludes) {
224+
tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
225+
FileStyle->IncludeStyle);
226+
// Deduplicate insertions when running in bulk fix mode.
227+
llvm::StringSet<> InsertedHeaders{};
228+
for (const auto &Inc : Missing) {
229+
std::string Spelling = include_cleaner::spellHeader(
230+
{Inc.Missing, PP->getHeaderSearchInfo(), MainFile});
231+
bool Angled = llvm::StringRef{Spelling}.starts_with("<");
232+
// We might suggest insertion of an existing include in edge cases, e.g.,
233+
// include is present in a PP-disabled region, or spelling of the header
234+
// turns out to be the same as one of the unresolved includes in the
235+
// main file.
236+
if (auto Replacement = HeaderIncludes.insert(
237+
llvm::StringRef{Spelling}.trim("\"<>"), Angled,
238+
tooling::IncludeDirective::Include)) {
239+
DiagnosticBuilder DB =
240+
diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
241+
"no header providing \"%0\" is directly included")
242+
<< Inc.SymRef.Target.name();
243+
if (areDiagsSelfContained() ||
244+
InsertedHeaders.insert(Replacement->getReplacementText()).second) {
245+
DB << FixItHint::CreateInsertion(
246+
SM->getComposedLoc(SM->getMainFileID(), Replacement->getOffset()),
247+
Replacement->getReplacementText());
248+
}
236249
}
237250
}
238251
}

clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class IncludeCleanerCheck : public ClangTidyCheck {
4747
std::vector<StringRef> IgnoreHeaders;
4848
// Whether emit only one finding per usage of a symbol.
4949
const bool DeduplicateFindings;
50+
// Whether to report unused includes.
51+
const bool UnusedIncludes;
52+
// Whether to report missing includes.
53+
const bool MissingIncludes;
5054
llvm::SmallVector<llvm::Regex> IgnoreHeadersRegex;
5155
bool shouldIgnore(const include_cleaner::Header &H);
5256
};

0 commit comments

Comments
 (0)