mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-27 13:57:52 +00:00
[clang-format] Expand the SpacesAroundConditions option to include catch 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
This commit is contained in:
parent
14c044756e
commit
ea2be45254
@ -2597,7 +2597,7 @@ bool TokenAnnotator::spaceRequiredBeforeParens(const FormatToken &Right) const {
|
|||||||
/// otherwise.
|
/// otherwise.
|
||||||
static bool isKeywordWithCondition(const FormatToken &Tok) {
|
static bool isKeywordWithCondition(const FormatToken &Tok) {
|
||||||
return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
|
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,
|
bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
|
||||||
|
@ -14980,6 +14980,7 @@ TEST_F(FormatTest, SpacesInConditionalStatement) {
|
|||||||
verifyFormat("while ( a )\n return;", Spaces);
|
verifyFormat("while ( a )\n return;", Spaces);
|
||||||
verifyFormat("while ( (a && b) )\n return;", Spaces);
|
verifyFormat("while ( (a && b) )\n return;", Spaces);
|
||||||
verifyFormat("do {\n} while ( 1 != 0 );", 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
|
// Check that space on the left of "::" is inserted as expected at beginning
|
||||||
// of condition.
|
// of condition.
|
||||||
verifyFormat("while ( ::func() )\n return;", Spaces);
|
verifyFormat("while ( ::func() )\n return;", Spaces);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user