Skip to content

Commit c4738fc

Browse files
committed
Merge remote-tracking branch 'origin/main' into ActOnEnumConstantCheckDiagnoseClassNameShadow
2 parents 66990b5 + 52c9489 commit c4738fc

File tree

22,714 files changed

+1524930
-683577
lines changed

Some content is hidden

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

22,714 files changed

+1524930
-683577
lines changed

.ci/compute_projects.py

Lines changed: 87 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
PROJECT_DEPENDENCIES = {
2020
"llvm": set(),
2121
"clang": {"llvm"},
22+
"CIR": {"clang", "mlir"},
2223
"bolt": {"clang", "lld", "llvm"},
2324
"clang-tools-extra": {"clang", "llvm"},
2425
"compiler-rt": {"clang", "lld"},
@@ -52,8 +53,20 @@
5253
"clang": {"clang-tools-extra", "cross-project-tests"},
5354
"mlir": {"flang"},
5455
# Test everything if ci scripts are changed.
55-
# FIXME: Figure out what is missing and add here.
56-
".ci": {"llvm", "clang", "lld", "lldb"},
56+
".ci": {
57+
"llvm",
58+
"clang",
59+
"CIR",
60+
"lld",
61+
"lldb",
62+
"bolt",
63+
"clang-tools-extra",
64+
"mlir",
65+
"polly",
66+
"flang",
67+
"libclc",
68+
"openmp",
69+
},
5770
}
5871

5972
# This mapping describes runtimes that should be enabled for a specific project,
@@ -66,6 +79,9 @@
6679
DEPENDENT_RUNTIMES_TO_TEST = {
6780
"clang": {"compiler-rt"},
6881
"clang-tools-extra": {"libc"},
82+
"libc": {"libc"},
83+
"compiler-rt": {"compiler-rt"},
84+
".ci": {"compiler-rt", "libc"},
6985
}
7086
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG = {
7187
"llvm": {"libcxx", "libcxxabi", "libunwind"},
@@ -85,6 +101,9 @@
85101
"libc", # No Windows Support.
86102
"lldb", # TODO(issues/132800): Needs environment setup.
87103
"bolt", # No Windows Support.
104+
"libcxx",
105+
"libcxxabi",
106+
"libunwind",
88107
}
89108

90109
# These are projects that we should test if the project itself is changed but
@@ -103,6 +122,9 @@
103122
"lldb",
104123
"openmp",
105124
"polly",
125+
"libcxx",
126+
"libcxxabi",
127+
"libunwind",
106128
}
107129

108130
PROJECT_CHECK_TARGETS = {
@@ -115,6 +137,7 @@
115137
"lldb": "check-lldb",
116138
"llvm": "check-llvm",
117139
"clang": "check-clang",
140+
"CIR": "check-clang-cir",
118141
"bolt": "check-bolt",
119142
"lld": "check-lld",
120143
"flang": "check-flang",
@@ -128,20 +151,35 @@
128151

129152
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
130153

154+
# Meta projects are projects that need explicit handling but do not reside
155+
# in their own top level folder. To add a meta project, the start of the path
156+
# for the metaproject should be mapped to the name of the project below.
157+
# Multiple paths can map to the same metaproject.
158+
META_PROJECTS = {
159+
("clang", "lib", "CIR"): "CIR",
160+
("clang", "test", "CIR"): "CIR",
161+
("clang", "include", "clang", "CIR"): "CIR",
162+
("*", "docs"): "docs",
163+
("llvm", "utils", "gn"): "gn",
164+
(".github", "workflows", "premerge.yaml"): ".ci",
165+
("third-party",): ".ci",
166+
}
167+
168+
# Projects that should not run any tests. These need to be metaprojects.
169+
SKIP_PROJECTS = ["docs", "gn"]
170+
131171

132172
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
133173
projects_with_dependents = set(projects)
134174
current_projects_count = 0
135175
while current_projects_count != len(projects_with_dependents):
136176
current_projects_count = len(projects_with_dependents)
137177
for project in list(projects_with_dependents):
138-
if project not in PROJECT_DEPENDENCIES:
139-
continue
140-
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
178+
if project in PROJECT_DEPENDENCIES:
179+
projects_with_dependents.update(PROJECT_DEPENDENCIES[project])
141180
for runtime in runtimes:
142-
if runtime not in PROJECT_DEPENDENCIES:
143-
continue
144-
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
181+
if runtime in PROJECT_DEPENDENCIES:
182+
projects_with_dependents.update(PROJECT_DEPENDENCIES[runtime])
145183
return projects_with_dependents
146184

147185

@@ -187,18 +225,16 @@ def _compute_projects_to_build(
187225
def _compute_project_check_targets(projects_to_test: Set[str]) -> Set[str]:
188226
check_targets = set()
189227
for project_to_test in projects_to_test:
190-
if project_to_test not in PROJECT_CHECK_TARGETS:
191-
continue
192-
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
228+
if project_to_test in PROJECT_CHECK_TARGETS:
229+
check_targets.add(PROJECT_CHECK_TARGETS[project_to_test])
193230
return check_targets
194231

195232

196233
def _compute_runtimes_to_test(modified_projects: Set[str], platform: str) -> Set[str]:
197234
runtimes_to_test = set()
198235
for modified_project in modified_projects:
199-
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST:
200-
continue
201-
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
236+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST:
237+
runtimes_to_test.update(DEPENDENT_RUNTIMES_TO_TEST[modified_project])
202238
return _exclude_projects(runtimes_to_test, platform)
203239

204240

@@ -207,11 +243,10 @@ def _compute_runtimes_to_test_needs_reconfig(
207243
) -> Set[str]:
208244
runtimes_to_test = set()
209245
for modified_project in modified_projects:
210-
if modified_project not in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
211-
continue
212-
runtimes_to_test.update(
213-
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
214-
)
246+
if modified_project in DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG:
247+
runtimes_to_test.update(
248+
DEPENDENT_RUNTIMES_TO_TEST_NEEDS_RECONFIG[modified_project]
249+
)
215250
return _exclude_projects(runtimes_to_test, platform)
216251

217252

@@ -225,21 +260,34 @@ def _compute_runtimes_to_build(
225260
return _exclude_projects(runtimes_to_build, platform)
226261

227262

263+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
264+
if len(file_path) < len(matcher):
265+
return False
266+
for match_part, file_part in zip(matcher, file_path):
267+
if match_part == "*" or file_part == "*":
268+
continue
269+
if match_part != file_part:
270+
return False
271+
return True
272+
273+
274+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
275+
modified_projects = set()
276+
path_parts = pathlib.Path(modified_file).parts
277+
for meta_project_files in META_PROJECTS.keys():
278+
if _path_matches(meta_project_files, path_parts):
279+
meta_project = META_PROJECTS[meta_project_files]
280+
if meta_project in SKIP_PROJECTS:
281+
return set()
282+
modified_projects.add(meta_project)
283+
modified_projects.add(pathlib.Path(modified_file).parts[0])
284+
return modified_projects
285+
286+
228287
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
229288
modified_projects = set()
230289
for modified_file in modified_files:
231-
path_parts = pathlib.Path(modified_file).parts
232-
# Exclude files in the docs directory. They do not impact an test
233-
# targets and there is a separate workflow used for ensuring the
234-
# documentation builds.
235-
if len(path_parts) > 2 and path_parts[1] == "docs":
236-
continue
237-
# Exclude files for the gn build. We do not test it within premerge
238-
# and changes occur often enough that they otherwise take up
239-
# capacity.
240-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
241-
continue
242-
modified_projects.add(pathlib.Path(modified_file).parts[0])
290+
modified_projects.update(_get_modified_projects_for_file(modified_file))
243291
return modified_projects
244292

245293

@@ -259,6 +307,13 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
259307
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
260308
runtimes_to_test_needs_reconfig
261309
)
310+
311+
# CIR is used as a pseudo-project in this script. It is built as part of the
312+
# clang build, but it requires an explicit option to enable. We set that
313+
# option here, and remove it from the projects_to_build list.
314+
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
315+
projects_to_build.discard("CIR")
316+
262317
# We use a semicolon to separate the projects/runtimes as they get passed
263318
# to the CMake invocation and thus we need to use the CMake list separator
264319
# (;). We use spaces to separate the check targets as they end up getting
@@ -271,6 +326,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
271326
"runtimes_check_targets_needs_reconfig": " ".join(
272327
sorted(runtimes_check_targets_needs_reconfig)
273328
),
329+
"enable_cir": enable_cir,
274330
}
275331

276332

0 commit comments

Comments
 (0)