This fix will make us not crash, but ideally we would handle this case
better.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp | ||
---|---|---|
1844–1848 | It's hard to tell what Clang makes of this, I think instead we should test out the root cause of this crash, IIUC, are the legacy C style parameters: @interface Foo - (void)func:(bool)foo, bool bar; @end | |
1853–1856 | We should verify the method name is exactly as expected but comment we mostly care about not crashing. | |
clang/lib/Sema/SemaCodeComplete.cpp | ||
3536 | I think it might be simpler just to check the index: unsigned NumSelectorArgs = Sel.getNumArgs(); P != PEnd && Idx < NumSelectorArgs and note that we need to check this due to legacy use of C-style parameters in Objective-C method declarations which in practice only occurs due to typos |
Looks good but I think for posterity we should add a similar test to clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp for the exact intended code complete behavior (or instead of SymbolCollectorTests.cpp - is there a particular reason you added a test there)?
The crash happens while indexing the file, not during code completion. The code completion tests generally specify a cursor position, but in this case it is not relevant and could confuse the reader. This seemed like a logical place for indexing bug, in the spirit of using minimal repro case (i.e. you don't need to trigger code completion at all)
It's hard to tell what Clang makes of this, I think instead we should test out the root cause of this crash, IIUC, are the legacy C style parameters: