forked from OSchip/llvm-project
clang-format: Add space in function pointers with SpaceBeforeParens=Always
"void (*my_function)(void)" should become "void (*my_function) (void)" when SpaceBeforeParens is set to 'Always' Differential Revision: http://reviews.llvm.org/D9835 llvm-svn: 237704
This commit is contained in:
parent
285fe84edd
commit
b09075a240
|
@ -1827,7 +1827,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
|
|||
tok::kw_new, tok::kw_delete) &&
|
||||
(!Left.Previous || Left.Previous->isNot(tok::period))))) ||
|
||||
(Style.SpaceBeforeParens == FormatStyle::SBPO_Always &&
|
||||
(Left.is(tok::identifier) || Left.isFunctionLikeKeyword()) &&
|
||||
(Left.is(tok::identifier) || Left.isFunctionLikeKeyword() || Left.is(tok::r_paren)) &&
|
||||
Line.Type != LT_PreprocessorDirective);
|
||||
}
|
||||
if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)
|
||||
|
|
|
@ -8454,6 +8454,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
|
|||
verifyFormat("size_t x = alignof(MyType);", NoSpace);
|
||||
verifyFormat("static_assert(sizeof(char) == 1, \"Impossible!\");", NoSpace);
|
||||
verifyFormat("int f() throw(Deprecated);", NoSpace);
|
||||
verifyFormat("typedef void (*cb)(int);", NoSpace);
|
||||
|
||||
FormatStyle Space = getLLVMStyle();
|
||||
Space.SpaceBeforeParens = FormatStyle::SBPO_Always;
|
||||
|
@ -8498,6 +8499,7 @@ TEST_F(FormatTest, ConfigurableSpaceBeforeParens) {
|
|||
verifyFormat("size_t x = alignof (MyType);", Space);
|
||||
verifyFormat("static_assert (sizeof (char) == 1, \"Impossible!\");", Space);
|
||||
verifyFormat("int f () throw (Deprecated);", Space);
|
||||
verifyFormat("typedef void (*cb) (int);", Space);
|
||||
}
|
||||
|
||||
TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
|
||||
|
|
Loading…
Reference in New Issue