[PATCH] D37700: Fix recording preamble's conditional stack in skipped PP branches.

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 12 01:37:27 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313014: Fix recording preamble's conditional stack in skipped PP branches. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D37700

Files:
  cfe/trunk/lib/Lex/PPDirectives.cpp
  cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp
  cfe/trunk/test/Index/preamble-conditionals-inverted.cpp


Index: cfe/trunk/lib/Lex/PPDirectives.cpp
===================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp
+++ cfe/trunk/lib/Lex/PPDirectives.cpp
@@ -383,15 +383,8 @@
 
     // If this is the end of the buffer, we have an error.
     if (Tok.is(tok::eof)) {
-      // Emit errors for each unterminated conditional on the stack, including
-      // the current one.
-      while (!CurPPLexer->ConditionalStack.empty()) {
-        if (CurLexer->getFileLoc() != CodeCompletionFileLoc)
-          Diag(CurPPLexer->ConditionalStack.back().IfLoc,
-               diag::err_pp_unterminated_conditional);
-        CurPPLexer->ConditionalStack.pop_back();
-      }
-
+      // We don't emit errors for unterminated conditionals here,
+      // Lexer::LexEndOfFile can do that propertly.
       // Just return and let the caller lex after this #include.
       break;
     }
Index: cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp
===================================================================
--- cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp
+++ cfe/trunk/test/Index/preamble-conditionals-inverted-with-error.cpp
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \
+// RUN:                                       local -std=c++14 %s 2>&1 \
+// RUN: | FileCheck %s
+#ifdef FOO_H
+
+void foo();
+
+// CHECK: preamble-conditionals-inverted-with-error.cpp:4:2: error: unterminated conditional directive
Index: cfe/trunk/test/Index/preamble-conditionals-inverted.cpp
===================================================================
--- cfe/trunk/test/Index/preamble-conditionals-inverted.cpp
+++ cfe/trunk/test/Index/preamble-conditionals-inverted.cpp
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_EDITING=1 c-index-test -test-load-source-reparse 5 \
+// RUN:                                       local -std=c++14 %s 2>&1 \
+// RUN: | FileCheck %s --implicit-check-not "error:"
+#ifdef FOO_H
+
+void foo();
+
+#endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37700.114779.patch
Type: text/x-patch
Size: 2028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170912/61b107f3/attachment.bin>


More information about the cfe-commits mailing list