]> granicus.if.org Git - clang/commitdiff
[clang-format] disable adding extra space after MSVC '__super' keyword
authorMartin Probst <martin@probst.io>
Thu, 16 Mar 2017 10:21:35 +0000 (10:21 +0000)
committerMartin Probst <martin@probst.io>
Thu, 16 Mar 2017 10:21:35 +0000 (10:21 +0000)
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

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index 228425bc4732eb1db87a6f5b126d1f2c39719352..043d83df502e6f778570f0efc702e62ca11b7e45 100644 (file)
@@ -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)) ||
index 674c3b500cffb5126f09e3c2d7a8937168d3c7de..6a250eb8cf76dc0d2088c9e4d300e9e83d05ea73 100644 (file)
@@ -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.