[PATCH] D35955: clang-format: Add preprocessor directive indentation

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 23 07:10:07 PDT 2017


djasper added inline comments.


================
Comment at: unittests/Format/FormatTest.cpp:2297
+               "#include <someheader.h>\n"
+               "#define MACRO                                                  "
+               "                \\\n"
----------------
Please just set Style.ColumnLimit to 60 or so in order not to have to wrap the test cases. Makes then much easier to understand.


================
Comment at: unittests/Format/FormatTest.cpp:2314
+               "#    define MACRO                                              "
+               "            \\\n"
+               "      some_very_long_func_aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
----------------
It's hard to tell with the line wrap, but this does look wrong, the escaped newline does not seem to be in column 80.


================
Comment at: unittests/Format/FormatTest.cpp:2427
+                   Style));
+  // Defect: The comment indent corrector in TokenAnnotator gets thrown off by
+  // preprocessor indentation.
----------------
Write "FIXME" instead of "Defect"


================
Comment at: unittests/Format/FormatTestUtils.h:34
       InComment = true;
-    } else if (MessedUp[i] == '#' && (JustReplacedNewline || i == 0)) {
+    } else if (MessedUp[i] == '#' && (JustPassedNewline || i == 0)) {
       if (i != 0)
----------------
Could we just do:

  } else if (MessedUp[i] == '#' && (JustReplacedNewline || i == 0 || MessedUp[i - 1] == '\n') {

?


https://reviews.llvm.org/D35955





More information about the cfe-commits mailing list