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

libdrgn: Ensure booleans are treated as primitives in C++ #227

Closed
wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Dec 2, 2022

Booleans in C++ programs were not registering as primitives (i.e. .primitive was None on a boolean type). This has been remedied by treating bool as a keyword in C++, in much the same fashion that #158 added support for classes in C++.

Signed-off-by: Kevin Svetlitski svetlitski@meta.com

@ghost
Copy link
Author

ghost commented Dec 3, 2022

The build error from clang in CI is:

In file included from ../../libdrgn/language_c.c:1655:
./c_keywords.inc:6:19: error: initializer overrides prior initialization of this subobject [-Werror,-Winitializer-overrides]
[C_TOKEN_BOOL] = "bool",
^~~~~~
./c_keywords.inc:4:19: note: previous initialization is here
[C_TOKEN_BOOL] = "_Bool",

This is unfortunate. I would suggest that we just have entirely separate lists of keywords for C and C++ to resolve this, but that won't help address this with regards to C23 support for the same issue (without having to make a new struct drgn_language drgn_language_c23 that differs only in this respect), since it also makes bool a keyword .

Booleans in C++ programs were not registering as primitives (i.e.
`.primitive` was `None` on a boolean type). This has been remedied
by treating `bool` as a keyword in C++, in much the same fashion that
osandov#158 added support for classes in C++.

Signed-off-by: Kevin Svetlitski <svetlitski@meta.com>
@ghost
Copy link
Author

ghost commented Jan 10, 2023

I could just add a separate SPECIFIER_CPP_BOOL and C_TOKEN_CPP_BOOL if that's alright with you.

@ghost
Copy link
Author

ghost commented Jan 11, 2023

Might revisit this later, but for now this is too minor to be worth pursuing.

@ghost ghost closed this Jan 11, 2023
This pull request was closed.
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.

None yet

1 participant