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

Michael Spencer via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 3 13:37:17 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"
----------------
Bigcheese wrote:

I'm pretty sure that everything here should be removed except for:
```
#ifndef __TEST
#define __TEST
#endif // #ifndef __TEST
```

But I don't think that matters for this fix.

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


More information about the cfe-commits mailing list