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

Add support for SourceLocExpr #598

Closed
Ukilele opened this issue Dec 11, 2023 · 4 comments
Closed

Add support for SourceLocExpr #598

Ukilele opened this issue Dec 11, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@Ukilele
Copy link

Ukilele commented Dec 11, 2023

The following input:

auto X = __builtin_LINE();

generates following output:

unsigned int X = /* INSIGHTS-TODO: CodeGenerator.cpp:3851 stmt: SourceLocExpr */;

According to https://docs.hdoc.io/hdoc/llvm-project/r728584FDD0102CEF.html the class SourceLocExpr represents a function call to one of __builtin_LINE(), __builtin_COLUMN(), __builtin_FUNCTION(), __builtin_FILE(), or __builtin_source_location().
Especially with the C++20 std::source_location it would be neat if cppinsights would support this.

Best regards!

@andreasfertig
Copy link
Owner

Hello @Ukilele,

thanks for bringing this up.

I don't understand what role std::source_location plays here. You're using the internals required to implement source_location; the STD type works fine as far as I know.

I'm a bit reluctant to implement this transformation. Getting the correct information from SourceLocExpr seems difficult, and I'm unsure about the benefit.

Andreas

@Ukilele
Copy link
Author

Ukilele commented Jan 8, 2024

Hi Andreas,
your welcome!

I just brought up std::source_location because this was the class I originally used when I came accross this issue. I guess that since it's standarized since C++20, its usage might be higher than the one of builtin compiler-intrinsics. For a simplification of the code to reproduce the issue, I switched to __builtin_LINE().
When using std::source_location::current() you will get a similar output:

std::source_location::current(/* INSIGHTS-TODO: CodeGenerator.cpp:3851 stmt: SourceLocExpr */)

I agree that it definitely is no urgent or important issue.

@andreasfertig
Copy link
Owner

Hello @Ukilele,

usually I appreciate reduced issue reports, as I did here. Yet, your new std::source_location::current() reminded me of the implementation of source_location. Despite the standard not mentioning it, current takes a parameter of from __builtin_source_location. Looks like I have to act on this one :-)

Andreas

@andreasfertig andreasfertig added the bug Something isn't working label Jan 9, 2024
andreasfertig added a commit that referenced this issue Jan 9, 2024
Fixed #598: Added basic support for `SourceLocExpr`.
@Ukilele
Copy link
Author

Ukilele commented Jan 9, 2024

Awesome, that was quick :) Thanks a lot 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants