[PATCH] D125085: [clang-format] Correctly handle SpaceBeforeParens for builtins.
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon May 9 02:42:49 PDT 2022
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85ec8a9ac141: [clang-format] Correctly handle SpaceBeforeParens for builtins. (authored by curdeius).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125085/new/
https://reviews.llvm.org/D125085
Files:
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -15082,6 +15082,9 @@
// verifyFormat("X A::operator++ (T);", Space);
verifyFormat("auto lambda = [] () { return 0; };", Space);
verifyFormat("int x = int (y);", Space);
+ verifyFormat("#define F(...) __VA_OPT__ (__VA_ARGS__)", Space);
+ verifyFormat("__builtin_LINE ()", Space);
+ verifyFormat("__builtin_UNKNOWN ()", Space);
FormatStyle SomeSpace = getLLVMStyle();
SomeSpace.SpaceBeforeParens = FormatStyle::SBPO_NonEmptyParentheses;
Index: clang/lib/Format/TokenAnnotator.cpp
===================================================================
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3436,9 +3436,9 @@
return (Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
spaceRequiredBeforeParens(Right);
}
+ // Handle builtins like identifiers.
if (Line.Type != LT_PreprocessorDirective &&
- (Left.is(tok::identifier) || Left.isFunctionLikeKeyword() ||
- Left.is(tok::r_paren) || Left.isSimpleTypeSpecifier()))
+ (Left.Tok.getIdentifierInfo() || Left.is(tok::r_paren)))
return spaceRequiredBeforeParens(Right);
return false;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125085.428017.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220509/d84d2562/attachment.bin>
More information about the cfe-commits
mailing list