[PATCH] D102730: [clang-format] Support custom If macros
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri May 21 09:04:54 PDT 2021
MyDeveloperDay added inline comments.
================
Comment at: clang/docs/ReleaseNotes.rst:252
+- Option ``IfMacros`` has been added. This lets you define macros that get
+ formatted like conditionals much like ``ForEachMacros`` get stiled like
+ foreach loops.
----------------
stiled? did you mean styled?
================
Comment at: clang/lib/Format/FormatTokenLexer.cpp:1019
FormatTok->setType(it->second);
+ if (it->second == TT_IfMacro) {
+ FormatTok->Tok.setKind(tok::kw_if);
----------------
Is there any chance you could leave a comment here as to why this is needed, I can't work it out?
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:3025
return false;
+ if (Left.is(TT_IfMacro)) {
+ return false;
----------------
I'll let you decide if you think we need another SBPO_XXX style?
================
Comment at: clang/unittests/Format/FormatTest.cpp:19699
verifyFormat("if constexpr ( a )\n return;", Spaces);
+ verifyFormat("MYIF( a )\n return;", Spaces);
+ verifyFormat("MYIF( a )\n return;\nelse MYIF( b )\n return;", Spaces);
----------------
this should support ```MYIF<space>(``` by processing SpacesInConditionalStatement as we do with FOREACH
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102730/new/
https://reviews.llvm.org/D102730
More information about the cfe-commits
mailing list