-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang][Driver][Test] Created test for unsupported driver options #120900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
PR for issue llvm#78657 Updated clang/docs/LanguageExtensions.rst to detail the return value of __builtin_COLUMN for this implementation.
Created generate_unsupported_in_drivermode.py which generates a Lit regression test file that validates that options are only exposed to intended driver modes. The options and driver modes are parsed from Options.td, whose path should be provided on the command line. See clang/include/clang/Driver/Options.td The path to the TableGen executable can optionally be provided. Otherwise, the script will search for it.
|
✅ With the latest revision this PR passed the Python code formatter. |
|
Hi, Thanks for working on this issue. I wanted to preface this by feel free to ignore this during the holidays, zero pressure. I like to interact with the community in my free time, but that obviously does not need to extend to everyone :). What kind of failures are you seeing in the generated test? There shouldn't be any afaict if the script works correctly, as Options.td IS the source where the parsing code for the various drivers are generated from. Are you perhaps missing the case where there is no visibility specified at all and it should be assumed to be |
|
All of the Visibility fields appear to be not null, but that's a good check to add anyway. Thanks. After adding it though, the same failures occur. Here's an example. Maybe there's a gap in my understanding: The script generates tests for both flang & clang -cc1as when looking at the O_flag option. cc1as outputs the unexpected error message, but flang does not. These are the steps I'm taking for manual validation:
For reference, full list of drivers/visibilities include: |
Changed to a common error message for the various driver modes, and formatted with Python darker.
That looks to be by design, because you are using the Simply you shouldn't be using The other issues is that |
- Added handling for false positives caused by supported options that are prefixes for unsupported ones. - Added a controller to simplify modifying the test commands for each driver. - Generally cleaned things up - A list of exceptions called exceptions_sequence that needs to be fixed - clang-cl & clang-dxc testing remains
|
@Maetveis
Ex:
Ex: |
|
Sorry I was caught up with work, and didn't find the time to look at this until now.
For
These all produce errors for me. Are you sure you're testing everything right? You have an up-to-date clang build for example? The testing tool should give you an output like |
…nsupportedOptions
Additional changes to improve correctness, including preprocessing to
filter automatically added driver options, changed FileCheck strings,
etc.
The script generates two test files, since the flang tests are under the
flang directory.
Driver/unsupported_in_drivermode.c
Driver/flang/unsupported_in_flang.f90
Notably, As per flang.f90, "-fc1 is invoked when in
--driver-mode=flang", so tests were not generated for visibility
FlangOption; only for FC1Option.
|
Ahh, thanks. You're right, I had environment issues. Now that Lit is pointing to an up to date clang, the exceptions I mentioned properly fail. That's a relief. Fyi, I think all that's left before it's ready for review is handling for aliases. I'll try and add that later today or tomorrow. |
More additions: - Redirect stderr to stdout for dxc & cl mode. - Pass/fail RUN line error handling due to unreliable return codes when preprocessing commands.
…nsupportedOptions
…project into 119190-unsupportedOptions
|
Hi @Maetveis . This is ready for review. There are a few things that I came across while making the script that I should highlight :
test/Driver/lit.local.cfg says, '("%clang_cc1", """*** Do not use 'clang -cc1' in Driver tests. ***""")', yet I see various tests in that directory that do so, like linker-wrapper.c. If there's no opposition, I'll leave the cc1 tests in the main Lit test file, Driver/unsupported_in_drivermode.c.
As per clang/test/Driver/flang/flang.f90, "flang -fc1 is invoked when in --driver-mode=flang", so I disabled the plain flang tests since there's no distinction.
I disabled the tests on Windows given the following recursion error that occurs on Windows regression machines. (It has some odd formatting. Pasting in a text editor makes viewing it easier.) |
The same Lit tests are produced as the last commit
Maetveis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is starting to look right. I'm sorry for the long response time, I could not justify spending work time on the review this time, and my weekends have been somewhat busy.
I'll try to get some other reviewers to look at this too, to approve of the proposed workflow when updating Options.td. I would appreciate if you could make a summary of that as a comment, but if not I'll do it later.
- Renamed find_groups() to collect_transitive_groups(), and simplified the function - Introduced additional test file for flang -fc1 tests. unsupported_in_flang_fc1.f90 - Simplified Lit check statement regexes - Created Lit check statements for each option's error messages
|
@Maetveis, referring to the proposed workflow review comment, not sure if you meant to leave a comment in the script, or here in the review. I'll leave it here and in the description for now, but let me know if you mean the script. Proposed workflow
|
Also added _no_warnings to the exception sequence
|
|
Hey @GeorgeKA, there's still some unaddressed comments from my previous review, I thought you were still working on it, so I did not want to post more comments. I realize the latency I'm taking to respond is dragging this out quite a bit. Also it seems like the good first issue label might have been inaccurate, I really didn't expect so much complexity. I'd be happy to help with implementing some of my suggestions if you are okay with that. Github allows to do this by opening a pull request against this branch in your fork of the repository. |
|
Hi @Maetveis.
Oh my mistake. I didn't get a notification, so I didn't see the most recent comments.
Don't sweat it. I appreciate the opportunity.
Fine by me. |
Changed UnsupportedDriverOption to DriverOption, and converted to dataclass. Adjusted argument parsing
Switched to writting each option on its own line for easier git diffs. Added options for Lit test file paths.
No reason to assume file will be named Options.td
Change Options File Dir to Options File Path
|
Ping @Maetveis |
Closes #119190
Created generate_unsupported_in_drivermode.py which generates Lit regression test that validate that options are only exposed to intended driver modes.
The options and driver modes are parsed from Options.td, whose path should be provided on the command line. See
clang/include/clang/Driver/Options.td
The path to the TableGen executable can optionally be provided. Otherwise, the script will search for it.
Proposed workflow
python generate_unsupported_in_drivermode.py --llvm-bin <path>/llvm-project/build/bin --llvm-tblgen llvm-tblgen ../include/clang/Driver/Options.tdllvm-lit -v clang/test/Driver/unsupported_in_drivermode.cllvm-lit -v clang/test/Driver/flang/unsupported_in_drivermode.cllvm-lit -v flang/test/Driver/unsupported_in_flang_fc1.f90