[clang] [clang-scan-deps] Fix "unterminated conditional directive" bug (PR #146645)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 2 01:07:56 PDT 2025


================
@@ -880,6 +880,37 @@ TEST(MinimizeSourceToDependencyDirectivesTest,
   EXPECT_EQ(pp_eof, Directives[22].Kind);
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest,
+     TestFixedBugThatReportUnterminatedDirectiveFalsely) {
+  SmallVector<char, 512> Out;
+  SmallVector<dependency_directives_scan::Token, 16> Tokens;
+  SmallVector<Directive, 16> Directives;
+
+  StringRef Input = "#ifndef __TEST \n"
+                    "#define __TEST \n"
+                    "#if defined(__TEST_DUMMY) \n"
+                    "#if defined(__TEST_DUMMY2) \n"
+                    "#pragma GCC warning        \\ \n"
+                    "\"hello!\"\n"
+                    "#else\n"
----------------
ziqingluo-90 wrote:

### The `#else` directive was and is still missing but I think it is irrelevant to this fix.

https://github.com/llvm/llvm-project/pull/146645


More information about the cfe-commits mailing list