[PATCH] D41688: [Lex] Fix crash on code completion in comment in included file.

Volodymyr Sapsai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 19 15:43:50 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rC323008: [Lex] Fix crash on code completion in comment in included file. (authored by vsapsai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D41688?vs=128480&id=130710#toc

Repository:
  rC Clang

https://reviews.llvm.org/D41688

Files:
  lib/Lex/PPCaching.cpp
  lib/Lex/PPLexerChange.cpp
  test/CodeCompletion/Inputs/comments.h
  test/CodeCompletion/comments.cpp


Index: test/CodeCompletion/comments.cpp
===================================================================
--- test/CodeCompletion/comments.cpp
+++ test/CodeCompletion/comments.cpp
@@ -0,0 +1,13 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+#include "comments.h"
+
+struct A {
+  // <- code completion
+  /* <- code completion */
+};
+
+// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:7:6 %s
+// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%s:8:6 %s
+// RUN: %clang_cc1 -I %S/Inputs -fsyntax-only -code-completion-at=%S/Inputs/comments.h:3:6 %s
Index: test/CodeCompletion/Inputs/comments.h
===================================================================
--- test/CodeCompletion/Inputs/comments.h
+++ test/CodeCompletion/Inputs/comments.h
@@ -0,0 +1,4 @@
+// PR32732
+struct B {
+  // <- code completion
+};
Index: lib/Lex/PPCaching.cpp
===================================================================
--- lib/Lex/PPCaching.cpp
+++ lib/Lex/PPCaching.cpp
@@ -105,8 +105,10 @@
 }
 
 void Preprocessor::EnterCachingLexMode() {
-  if (InCachingLexMode())
+  if (InCachingLexMode()) {
+    assert(CurLexerKind == CLK_CachingLexer && "Unexpected lexer kind");
     return;
+  }
 
   PushIncludeMacroStack();
   CurLexerKind = CLK_CachingLexer;
Index: lib/Lex/PPLexerChange.cpp
===================================================================
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -444,6 +444,7 @@
       }
 
       CurPPLexer = nullptr;
+      recomputeCurLexerKind();
       return true;
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41688.130710.patch
Type: text/x-patch
Size: 1625 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180119/7cc27603/attachment.bin>


More information about the cfe-commits mailing list