Skip to content

[clangd] Avoid clangd crash with -fsycl flag #11795

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

Merged
merged 2 commits into from
Dec 22, 2023
Merged

Conversation

rafbiels
Copy link
Contributor

@rafbiels rafbiels commented Nov 6, 2023

Add four extra option resets in disableUnsupportedOptions when parsing SYCL code. All four are needed to make clangd happily parse code when -fsycl is specified in compile commands. Without each of them, the following happens:

  • without SYCLIsDevice=false: crash on !nullptr assert
  • without DeclareSPIRVBuiltins=false: crash on !nullptr assert
  • without SYCLUnnamedLambda=false: ref_non_value error, 'T' does not refer to a value
  • without Triple=HostTriple: pp_file_not_found error, 'gnu/stubs-32.h' file not found

Fixes #11088 and clangd/clangd#1097

Also add a LIT test which parses the following code:

#include <sycl/sycl.hpp>
sycl::queue q{};

and checks symbolInfo for the symbol q against a reference.

@rafbiels rafbiels requested a review from a team as a code owner November 6, 2023 17:19
@premanandrao
Copy link
Contributor

Not sure who the reviewers for this should be.

@elizabethandrews
Copy link
Contributor

Not sure who the reviewers for this should be.

Yea me neither. @bader the FE team does not have experience with clangd. Who should the code owners be for this PR?

@bader
Copy link
Contributor

bader commented Nov 13, 2023

Not sure who the reviewers for this should be.

Yea me neither. @bader the FE team does not have experience with clangd. Who should the code owners be for this PR?

I don't know anyone who works with clangd on this project. Considering that this is a clang tool @intel/dpcpp-cfe-reviewers is the best option we have. Based on the changes I guess @intel/dpcpp-clang-driver-reviewers team might be able to help, but I don't know if clangd shares any logic with the clang driver.

Add four extra option resets in disableUnsupportedOptions
when parsing SYCL code. All four are needed to make clangd
happily parse code when -fsycl is specified in compile
commands. Without each of them, the following happens:
* without SYCLIsDevice=false: crash on !nullptr assert
* without DeclareSPIRVBuiltins=false: crash on !nullptr
  assert
* without SYCLUnnamedLambda=false: ref_non_value error,
  'T' does not refer to a value
* without Triple=HostTriple: pp_file_not_found error,
  'gnu/stubs-32.h' file not found

Fixes intel#11088 and clangd/clangd#1097
@rafbiels
Copy link
Contributor Author

@intel/dpcpp-cfe-reviewers I would appreciate any further review comments or launching the tests if this version looks OK.

Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

clangd fails on basic code examples
5 participants