From: Martin Probst Date: Thu, 16 Mar 2017 10:21:35 +0000 (+0000) Subject: [clang-format] disable adding extra space after MSVC '__super' keyword X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=976270eae62d60b2e834bcd635fd7a322d0f4d17;p=clang [clang-format] disable adding extra space after MSVC '__super' keyword 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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297936 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 228425bc47..043d83df50 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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)) || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 674c3b500c..6a250eb8cf 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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.