diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/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; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/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;