Skip to content

Commit

Permalink
[clang-format] disable adding extra space after MSVC '__super' keyword
Browse files Browse the repository at this point in the history
clang-format treats MSVC `__super` keyword like all other keywords adding
a single space after. This change disables this behavior for `__super`.

Patch originally by jutocz (thanks!).

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

llvm-svn: 297936
  • Loading branch information
mprobst committed Mar 16, 2017
1 parent 6ef42cc commit c9c51c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/Format/TokenAnnotator.cpp
Expand Up @@ -2382,7 +2382,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
return (Left.is(TT_TemplateOpener) &&
Style.Standard == FormatStyle::LS_Cpp03) ||
!(Left.isOneOf(tok::l_paren, tok::r_paren, tok::l_square,
TT_TemplateCloser, TT_TemplateOpener));
tok::kw___super, TT_TemplateCloser, TT_TemplateOpener));
if ((Left.is(TT_TemplateOpener)) != (Right.is(TT_TemplateCloser)))
return Style.SpacesInAngles;
if ((Right.is(TT_BinaryOperator) && !Left.is(tok::l_paren)) ||
Expand Down
4 changes: 4 additions & 0 deletions clang/unittests/Format/FormatTest.cpp
Expand Up @@ -9977,6 +9977,10 @@ TEST_F(FormatTest, ArrayAsTemplateType) {
format("auto a = unique_ptr < Foo < Bar>[10]> ;", Spaces));
}

TEST_F(FormatTest, NoSpaceAfterSuper) {
verifyFormat("__super::FooBar();");
}

TEST(FormatStyle, GetStyleOfFile) {
vfs::InMemoryFileSystem FS;
// Test 1: format file in the same directory.
Expand Down

0 comments on commit c9c51c4

Please sign in to comment.