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

clangd sometimes crashes parsing a spliced expand statement #104

Open
fzuuzf opened this issue Oct 19, 2024 · 3 comments
Open

clangd sometimes crashes parsing a spliced expand statement #104

fzuuzf opened this issue Oct 19, 2024 · 3 comments

Comments

@fzuuzf
Copy link

fzuuzf commented Oct 19, 2024

The crash seams to only happen, if the spliced expand statement is located in an included file.

To Reproduce
See https://github.com/fzuuzf/crash_clang-p2996-clangd

I also ran clangd with this applied:

--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7585,6 +7585,7 @@ ASTRecordReader::readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
   case TemplateArgument::NullPtr:
   case TemplateArgument::StructuralValue:
   case TemplateArgument::Pack:
+  case TemplateArgument::SpliceSpecifier:
     // FIXME: Is this right?
     return TemplateArgumentLocInfo();
   }

While I don't know if it is correct, it helps avoid another crash. It doesn't help the $title issue.

@Yaraslaut
Copy link

Yaraslaut commented Oct 20, 2024

I suppose that the issue is in wrong usage of expand statement,
here is a godbolt example https://godbolt.org/z/o54vrdvdr of what is happening

Edit: and here is example on godbolt with cmake and header file from the repo
https://godbolt.org/z/cfhbcT5h5

@fzuuzf
Copy link
Author

fzuuzf commented Oct 21, 2024

I think the repo's code is not wrong, the expand statement is just unused.

https://godbolt.org/z/bqGa1xaMv
has your example except the expand statement is used.
It lets Clangd here crash just the same.

EDIT: https://github.com/fzuuzf/crash_clang-p2996-clangd now shows the build setups, I used.

@fzuuzf
Copy link
Author

fzuuzf commented Oct 21, 2024

The culprit likely is:
clang::Stmt::CXXSpliceExprBitfields::HasTemplateKWAndArgsInfo
not being default initialized.

By the way, what does the KW in HasTemplateKWAndArgsInfo stand for?

EDIT: See pull request #106

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

No branches or pull requests

2 participants