|
86 | 86 | from enum import Enum |
87 | 87 | from functools import reduce |
88 | 88 | from pathlib import Path |
89 | | -from subprocess import run |
90 | 89 | from sys import exit |
91 | | -from tempfile import TemporaryDirectory |
92 | | -from typing import Optional |
93 | 90 |
|
94 | 91 | statistics = defaultdict(int) |
95 | 92 |
|
@@ -425,64 +422,6 @@ def get_with_lang_spec(args: CompileArgs) -> list: |
425 | 422 | """ |
426 | 423 |
|
427 | 424 |
|
428 | | -def can_code_compile( |
429 | | - code: str, |
430 | | - headers: list, |
431 | | - compile_commands, |
432 | | -) -> bool: |
433 | | - """Check if the code can compile using the provided arguments. |
434 | | - This is used to determine if a code snippet could actually compile in |
435 | | - one of the specified language versions. Provides an earlier warning |
436 | | - than after building and executing the test suite. |
437 | | -
|
438 | | - Args: |
439 | | - code: The code to test |
440 | | - headers: Headers, if any |
441 | | - compile_commands: The compile arguments, if any |
442 | | -
|
443 | | - Returns: |
444 | | - If the code compiled with the specified compile arguments. |
445 | | - """ |
446 | | - tmp_dir = TemporaryDirectory() |
447 | | - tmp_path = Path(tmp_dir.name) |
448 | | - |
449 | | - is_cuda = compile_commands and compile_commands.is_cuda() |
450 | | - if is_cuda: |
451 | | - return True |
452 | | - |
453 | | - code_file_name = "code.cpp" |
454 | | - if compile_commands and compile_commands.lang_spec.cxx == "": |
455 | | - code_file_name = "code.c" |
456 | | - if compile_commands and "cuda" in compile_commands.lang_spec.raw: |
457 | | - code_file_name = "code.cu" |
458 | | - |
459 | | - (tmp_path / code_file_name).write_text(code) |
460 | | - |
461 | | - for header_name, header_content in headers: |
462 | | - file_path = tmp_path / header_name |
463 | | - file_path.parent.mkdir(parents=True, exist_ok=True) |
464 | | - file_path.write_text(header_content) |
465 | | - |
466 | | - args: list[str] = [] |
467 | | - if compile_commands: |
468 | | - args = get_with_lang_spec(compile_commands) |
469 | | - |
470 | | - invocation = [ |
471 | | - "clang", |
472 | | - *args, |
473 | | - "-c", |
474 | | - "-Wno-everything", |
475 | | - code_file_name, |
476 | | - ] |
477 | | - res = run(invocation, cwd=tmp_path, check=False) |
478 | | - if res.returncode == 0: |
479 | | - return True |
480 | | - |
481 | | - print(f"args: {res.args}") |
482 | | - print(f"code: \n{code}") |
483 | | - return False |
484 | | - |
485 | | - |
486 | 425 | class MatchType(Enum): |
487 | 426 | """Available types of a match, specified by using the lowercase version in |
488 | 427 | doxygen: '\\match{type=typestr}'. |
@@ -617,11 +556,6 @@ def build_test_case(self): |
617 | 556 | statistics["skipped_objc"] += 1 |
618 | 557 | return "" |
619 | 558 |
|
620 | | - if not can_code_compile(self.code, self.headers, self.compile_args): |
621 | | - self.diag("failed to compile") |
622 | | - statistics["compile_failures"] += 1 |
623 | | - return "" |
624 | | - |
625 | 559 | statistics["code_snippets"] += 1 |
626 | 560 |
|
627 | 561 | statistics["matches"] += reduce( |
|
0 commit comments