Summary:
Frequently, a percent in protos denotes a formatting specifier for string replacement.
Thus it is desirable to keep the percent together with what follows after it.
Reviewers: djasper
Reviewed By: djasper
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D43294
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325159
91177308-0d34-0410-b5e6-
96231b3b80d8
if (Left.MatchingParen && Left.MatchingParen->is(TT_ProtoExtensionLSquare) &&
Right.isOneOf(tok::l_brace, tok::less))
return !Style.Cpp11BracedListStyle;
+ // A percent is probably part of a formatting specification, such as %lld.
+ if (Left.is(tok::percent))
+ return false;
} else if (Style.Language == FormatStyle::LK_JavaScript) {
if (Left.is(TT_JsFatArrow))
return true;
"};");
}
+TEST_F(FormatTestProto, NoSpaceAfterPercent) {
+ verifyFormat("option (MyProto.options) = {\n"
+ " key: %lld\n"
+ "};");
+}
+
} // end namespace tooling
} // end namespace clang
" }\n"
"}");
}
+
+TEST_F(FormatTestTextProto, NoSpaceAfterPercent) {
+ verifyFormat("key: %d");
+}
} // end namespace tooling
} // end namespace clang