================
@@ -581,6 +581,18 @@ TEST_F(LexerTest, AvoidPastEndOfStringDereference03) {
   EXPECT_TRUE(Lex("#include <\\\\\n").empty());
 }
 
+// Clangd uses single-file-parse mode in preamble scan on a truncated buffer.
+// An unclosed paren after an undefined identifier must not lex past the eod.
+TEST_F(LexerTest, SingleFileUnclosedParenUndefinedId01) {
+  PPOpts.SingleFileParseMode = true;
+  EXPECT_TRUE(Lex("#if (defined(FOO)\n").empty());
+}
+
+TEST_F(LexerTest, SingleFileUnclosedParenUndefinedId02) {
+  PPOpts.SingleFileParseMode = true;
+  EXPECT_TRUE(Lex("#if (FOO\n").empty());
----------------
max-winkler wrote:

This is a great idea. I replaced one of my tests with your one, which has the 
advantage that the line below the PP directive is lexed as well.

https://github.com/llvm/llvm-project/pull/234992
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to