[PATCH] D53070: [CodeComplete] Fix crash when completing params function declarations.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 10 03:53:53 PDT 2018


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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53070.168974.patch
Type: text/x-patch
Size: 994 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181010/5839eb6d/attachment.bin>


More information about the cfe-commits mailing list