Author: mydeveloperday Date: 2020-01-19T15:56:04Z New Revision: ea2be452542c81b04621e26c0d5e83be565f07e2
URL: https://github.com/llvm/llvm-project/commit/ea2be452542c81b04621e26c0d5e83be565f07e2 DIFF: https://github.com/llvm/llvm-project/commit/ea2be452542c81b04621e26c0d5e83be565f07e2.diff LOG: [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 Added: Modified: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Removed: ################################################################################ diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index a8f33e62f994..7dbde9a8d6a8 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2597,7 +2597,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, diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 43e75dde6806..53d543728fb9 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -14980,6 +14980,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); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits