This revision was automatically updated to reflect the committed changes. Closed by commit rC344133: [CodeComplete] Fix crash when completing params function declarations. (authored by sammccall, committed by ).
Changed prior to commit: https://reviews.llvm.org/D53070?vs=168967&id=168974#toc Repository: rC Clang https://reviews.llvm.org/D53070 Files: lib/Sema/SemaCodeComplete.cpp test/CodeCompletion/crash-func-decl.cpp Index: test/CodeCompletion/crash-func-decl.cpp =================================================================== --- test/CodeCompletion/crash-func-decl.cpp +++ test/CodeCompletion/crash-func-decl.cpp @@ -0,0 +1,5 @@ +// Important that BB is unknown. +// This triggers completion in PCC_RecoveryInFunction context, with no function. +int AA(BB cc); +// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:12 %s | FileCheck %s +// CHECK: COMPLETION: char Index: lib/Sema/SemaCodeComplete.cpp =================================================================== --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -1881,7 +1881,8 @@ } // Switch-specific statements. - if (!SemaRef.getCurFunction()->SwitchStack.empty()) { + if (SemaRef.getCurFunction() && + !SemaRef.getCurFunction()->SwitchStack.empty()) { // case expression: Builder.AddTypedTextChunk("case"); Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
Index: test/CodeCompletion/crash-func-decl.cpp =================================================================== --- test/CodeCompletion/crash-func-decl.cpp +++ test/CodeCompletion/crash-func-decl.cpp @@ -0,0 +1,5 @@ +// Important that BB is unknown. +// This triggers completion in PCC_RecoveryInFunction context, with no function. +int AA(BB cc); +// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:3:12 %s | FileCheck %s +// CHECK: COMPLETION: char Index: lib/Sema/SemaCodeComplete.cpp =================================================================== --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -1881,7 +1881,8 @@ } // Switch-specific statements. - if (!SemaRef.getCurFunction()->SwitchStack.empty()) { + if (SemaRef.getCurFunction() && + !SemaRef.getCurFunction()->SwitchStack.empty()) { // case expression: Builder.AddTypedTextChunk("case"); Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits