File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1838,6 +1838,20 @@ TEST_F(SymbolCollectorTest, UndefOfModuleMacro) {
1838
1838
EXPECT_THAT (TU.headerSymbols (), Not (Contains (QName (" X" ))));
1839
1839
}
1840
1840
1841
+ TEST_F (SymbolCollectorTest, NoCrashOnObjCMethodCStyleParam) {
1842
+ auto TU = TestTU::withCode (R"objc(
1843
+ @interface Foo
1844
+ - (void)fun:(bool)foo, bool bar;
1845
+ @end
1846
+ )objc" );
1847
+ TU.ExtraArgs .push_back (" -xobjective-c++" );
1848
+
1849
+ TU.build ();
1850
+ // We mostly care about not crashing.
1851
+ EXPECT_THAT (TU.headerSymbols (),
1852
+ UnorderedElementsAre (QName (" Foo" ), QName (" Foo::fun:" )));
1853
+ }
1854
+
1841
1855
} // namespace
1842
1856
} // namespace clangd
1843
1857
} // namespace clang
Original file line number Diff line number Diff line change @@ -3529,9 +3529,11 @@ CodeCompletionString *CodeCompletionResult::createCodeCompletionStringForDecl(
3529
3529
Result.AddTypedTextChunk (" " );
3530
3530
}
3531
3531
unsigned Idx = 0 ;
3532
+ // The extra Idx < Sel.getNumArgs() check is needed due to legacy C-style
3533
+ // method parameters.
3532
3534
for (ObjCMethodDecl::param_const_iterator P = Method->param_begin (),
3533
3535
PEnd = Method->param_end ();
3534
- P != PEnd; (void )++P, ++Idx) {
3536
+ P != PEnd && Idx < Sel. getNumArgs () ; (void )++P, ++Idx) {
3535
3537
if (Idx > 0 ) {
3536
3538
std::string Keyword;
3537
3539
if (Idx > StartParameter)
You can’t perform that action at this time.
0 commit comments