Skip to content

Commit

Permalink
[clang-format] Expand the SpacesAroundConditions option to include ca…
Browse files Browse the repository at this point in the history
…tch statements

Summary: This diff expands the SpacesAroundConditions option added in D68346 to include adding spaces to catch statements.

Reviewed By: MyDeveloperDay

Patch by: timwoj

Differential Revision: https://reviews.llvm.org/D72793

(cherry picked from commit ea2be45)
  • Loading branch information
mydeveloperday authored and zmodem committed Jan 21, 2020
1 parent de4b2a7 commit 587b3b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Expand Up @@ -2596,7 +2596,7 @@ bool TokenAnnotator::spaceRequiredBeforeParens(const FormatToken &Right) const {
/// otherwise.
static bool isKeywordWithCondition(const FormatToken &Tok) {
return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
tok::kw_constexpr);
tok::kw_constexpr, tok::kw_catch);
}

bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
Expand Down
1 change: 1 addition & 0 deletions clang/unittests/Format/FormatTest.cpp
Expand Up @@ -14927,6 +14927,7 @@ TEST_F(FormatTest, SpacesInConditionalStatement) {
verifyFormat("while ( a )\n return;", Spaces);
verifyFormat("while ( (a && b) )\n return;", Spaces);
verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
verifyFormat("try {\n} catch ( const std::exception & ) {\n}", Spaces);
// Check that space on the left of "::" is inserted as expected at beginning
// of condition.
verifyFormat("while ( ::func() )\n return;", Spaces);
Expand Down

0 comments on commit 587b3b2

Please sign in to comment.