[PATCH] D20131: Fixed crash during code completion in file included within declaration

Cameron via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 13:42:17 PDT 2016


cameron314 created this revision.
cameron314 added a reviewer: rsmith.
cameron314 added a subscriber: cfe-commits.

When triggering code completion within a file that is included in the middle of a declaration in another file, clang would crash while parsing the code.

This occurred with real-world code; there was an enum declaration that included a header in the middle of its declaration to specify the enum members.

http://reviews.llvm.org/D20131

Files:
  lib/Lex/PPLexerChange.cpp

Index: lib/Lex/PPLexerChange.cpp
===================================================================
--- lib/Lex/PPLexerChange.cpp
+++ lib/Lex/PPLexerChange.cpp
@@ -378,6 +378,8 @@
         Result.startToken();
         CurLexer->FormTokenWithChars(Result, CurLexer->BufferEnd, tok::eof);
         CurLexer.reset();
+        if (CurLexerKind == CLK_Lexer)
+          CurLexerKind = CLK_CachingLexer;
       } else {
         assert(CurPTHLexer && "Got EOF but no current lexer set!");
         CurPTHLexer->getEOF(Result);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20131.56799.patch
Type: text/x-patch
Size: 523 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160510/b068dc44/attachment.bin>


More information about the cfe-commits mailing list