]> granicus.if.org Git - clang/commitdiff
when code completing inside a C-style block comment, don't emit errors about
authorChris Lattner <sabre@nondot.org>
Sun, 16 May 2010 19:54:05 +0000 (19:54 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 16 May 2010 19:54:05 +0000 (19:54 +0000)
a missing */ since we truncated the file.

This fixes rdar://7948776

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103913 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp
test/CodeCompletion/truncation.c

index 74e8d7489e9a8f20da288da4a0a2c67155e61655..83de8c83a95171ca9c1eed15db701ece056f00fc 100644 (file)
@@ -1141,7 +1141,8 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
   unsigned char C = getCharAndSize(CurPtr, CharSize);
   CurPtr += CharSize;
   if (C == 0 && CurPtr == BufferEnd+1) {
-    if (!isLexingRawMode())
+    if (!isLexingRawMode() &&
+        !PP->isCodeCompletionFile(FileLoc))
       Diag(BufferPtr, diag::err_unterminated_block_comment);
     --CurPtr;
 
@@ -1224,7 +1225,7 @@ bool Lexer::SkipBlockComment(Token &Result, const char *CurPtr) {
           Diag(CurPtr-1, diag::warn_nested_block_comment);
       }
     } else if (C == 0 && CurPtr == BufferEnd+1) {
-      if (!isLexingRawMode())
+      if (!isLexingRawMode() && !PP->isCodeCompletionFile(FileLoc))
         Diag(BufferPtr, diag::err_unterminated_block_comment);
       // Note: the user probably forgot a */.  We could continue immediately
       // after the /*, but this would involve lexing a lot of what really is the
index 134139d78bdfba4a7c1109c303f81f65fd000eff..1b446b7d92cad6e09d062831c3ca494973dcc53b 100644 (file)
@@ -2,6 +2,8 @@
 
 struct 
 
+/* foo */
+
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s.h:4:8 -o - %s | FileCheck -check-prefix=CC1 %s
 // CHECK-CC1: X
 // CHECK-CC1-NEXT: Y
@@ -9,3 +11,8 @@ struct
 // CHECK-CC2: X
 // CHECK-CC2: Xa
 // CHECK-CC2: Y
+
+// RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:5:3 -o - %s | FileCheck -check-prefix=CC3 %s
+// CHECK-CC3: X
+// CHECK-CC3: Xa
+// CHECK-CC3: Y