Skip to content
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

Unify -x<language> option usage #213

Merged
merged 3 commits into from
Nov 9, 2023
Merged

Unify -x<language> option usage #213

merged 3 commits into from
Nov 9, 2023

Conversation

jnikula
Copy link
Owner

@jnikula jnikula commented Nov 9, 2023

Move the clang language selection at a lower level, do it unconditionally, and add -header too. This unifies -x option across the extension, tests ,and cli.

Fixes #208

Currently the domain is handled indirectly via -x<language> option in
clang_args, but prepare for moving the option at a lower level.
Currently the domain is handled indirectly via -x<language> option in
clang_args, but prepare for moving the option at a lower level.
Have a single point of truth for setting the clang -x<language> option,
to unify parsing across the extension, tests, and cli.

Choose the language primarily based on the domain, and secondarily based
on the filename extension to differentiate headers. Using "-header" is
necessary for some cases such as "#pragma once", where plain "-xc" or
"-xc++" would interpret the file as a main file.

This unconditionally bypasses libclang automatic detection. The user and
tests can still override the parser selected language, as the user
provided clang_args are appended.

Fixes: #208
@BrunoMSantos
Copy link
Collaborator

Looks great!

@jnikula
Copy link
Owner Author

jnikula commented Nov 9, 2023

Looks great!

Thanks; I additionally pushed some tests that would fail without the fixes in the series. Would you mind eyeballing them too, please?

test/c/pragma-once.h Outdated Show resolved Hide resolved
@jnikula jnikula force-pushed the clang-language-option branch from c29ec87 to 15147ad Compare November 9, 2023 21:46
@jnikula jnikula merged commit cfdd547 into master Nov 9, 2023
10 checks passed
@jnikula jnikula deleted the clang-language-option branch November 9, 2023 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

C++: hawkmoth warns about #pragma once in main file
2 participants