[clang] [clang-format] Option to ignore PP directives (PR #70338)

via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 11 12:32:01 PST 2023


================
@@ -24153,6 +24153,23 @@ TEST_F(FormatTest, WhitespaceSensitiveMacros) {
   verifyNoChange("FOO(String-ized&Messy+But: :Still=Intentional);", Style);
 }
 
+TEST_F(FormatTest, IgnorePPDefinitions) {
+  FormatStyle Style = getLLVMStyle();
+  Style.IgnorePPDefinitions = true;
+
+  verifyNoChange("#define  A", Style);
+  verifyNoChange("#define A   b", Style);
+  verifyNoChange("#define A  (  args   )", Style);
+  verifyNoChange("#define A  (  args   )  =  func  (  args  )", Style);
+  verifyNoChange("#define TEXT \\\nLine  number  one .  \\\nNumber  two .",
+                 Style);
+  verifyNoChange("#define A x:", Style);
+  verifyNoChange("#define A a. b", Style);
+
+  // TODO
----------------
tomekpaszek wrote:

The code path for when the statement is preceded by a comment seems different. It's not 100% unclear to me where to look to support that. Any hints would be appriciated

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


More information about the cfe-commits mailing list