[clang] [clang-format] Add IndentPPDirectives Leave option (PR #139750)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 12 00:57:17 PDT 2025
================
@@ -5547,22 +5547,62 @@ TEST_F(FormatTest, IndentsPPDirectiveWithPPIndentWidth) {
"#endif",
style);
+ style.IndentPPDirectives = FormatStyle::PPDIS_Leave;
+ style.IndentWidth = 4;
+ verifyNoChange("#ifndef foo\n"
+ "#define foo\n"
+ "if (emacs) {\n"
+ "#ifdef is\n"
+ "#define lit \\\n"
+ " if (af) { \\\n"
+ " return duh(); \\\n"
+ " }\n"
+ "#endif\n"
+ "}\n"
+ "#endif",
+ style);
+ verifyNoChange("#ifndef foo\n"
+ " #define foo\n"
+ "if (emacs) {\n"
+ " #ifdef is\n"
+ "#define lit \\\n"
+ " if (af) { \\\n"
+ " return duh(); \\\n"
+ " }\n"
+ " #endif\n"
+ "}\n"
+ "#endif",
+ style);
+ verifyNoChange(" #ifndef foo\n"
+ "# define foo\n"
+ "if (emacs) {\n"
+ "#ifdef is\n"
+ " # define lit \\\n"
+ " if (af) { \\\n"
+ " return duh(); \\\n"
+ " }\n"
+ "#endif\n"
+ "}\n"
+ " #endif",
+ style);
+ verifyNoChange("#ifdef foo\n"
+ "#else\n"
+ "/* This is a comment */\n"
+ "#ifdef BAR\n"
+ "#endif\n"
+ "#endif",
+ style);
+
style.IndentWidth = 1;
style.PPIndentWidth = 4;
- verifyFormat("#if 1\n"
- "#define X \\\n"
- " { \\\n"
- " x; \\\n"
- " x; \\\n"
- " }\n"
- "#endif",
- style);
- verifyFormat("#define X \\\n"
- " { \\\n"
- " x; \\\n"
- " x; \\\n"
- " }",
- style);
----------------
owenca wrote:
Why did you remove the existing tests?
https://github.com/llvm/llvm-project/pull/139750
More information about the cfe-commits
mailing list