r323218 - clang-format: Support formatting Java 8 interface default methods.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 23 17:48:57 PST 2018


Does 323294 help?

On Tue, Jan 23, 2018 at 4:58 PM, Galina Kistanova via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Hello Nico,
>
> This commit broke one of our builders:
>
> http://lab.llvm.org:8011/builders/ubuntu-gcc7.1-werror/builds/4701
> . . .
> FAILED: /usr/local/gcc-7.1/bin/g++-7.1   -DGTEST_HAS_RTTI=0 -D_DEBUG
> -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
> -D__STDC_LIMIT_MACROS -Itools/clang/lib/Format -I/home/buildslave/am1i-slv2/
> ubuntu-gcc7.1-werror/llvm/tools/clang/lib/Format
> -I/home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/tools/clang/include
> -Itools/clang/include -Iinclude -I/home/buildslave/am1i-slv2/
> ubuntu-gcc7.1-werror/llvm/include -Wno-noexcept-type -fPIC
> -fvisibility-inlines-hidden -Werror -Werror=date-time -std=c++11 -Wall -W
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers
> -pedantic -Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor
> -Wno-comment -ffunction-sections -fdata-sections -fno-common
> -Woverloaded-virtual -fno-strict-aliasing -O3  -fPIC   -UNDEBUG
> -fno-exceptions -fno-rtti -MD -MT tools/clang/lib/Format/
> CMakeFiles/clangFormat.dir/UnwrappedLineParser.cpp.o -MF
> tools/clang/lib/Format/CMakeFiles/clangFormat.dir/UnwrappedLineParser.cpp.o.d
> -o tools/clang/lib/Format/CMakeFiles/clangFormat.dir/UnwrappedLineParser.cpp.o
> -c /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/
> tools/clang/lib/Format/UnwrappedLineParser.cpp
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/
> tools/clang/lib/Format/UnwrappedLineParser.cpp: In member function ‘void
> clang::format::UnwrappedLineParser::parseLevel(bool)’:
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/
> tools/clang/lib/Format/UnwrappedLineParser.cpp:345:7: error: this
> statement may fall through [-Werror=implicit-fallthrough=]
>        }
>        ^
> /home/buildslave/am1i-slv2/ubuntu-gcc7.1-werror/llvm/
> tools/clang/lib/Format/UnwrappedLineParser.cpp:348:5: note: here
>      case tok::kw_case:
>      ^~~~
> cc1plus: all warnings being treated as errors
> ninja: build stopped: subcommand failed.
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Tue, Jan 23, 2018 at 8:30 AM, Nico Weber via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: nico
>> Date: Tue Jan 23 08:30:56 2018
>> New Revision: 323218
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=323218&view=rev
>> Log:
>> clang-format: Support formatting Java 8 interface default methods.
>>
>> Modified:
>>     cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>>     cfe/trunk/unittests/Format/FormatTestJava.cpp
>>
>> Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Unw
>> rappedLineParser.cpp?rev=323218&r1=323217&r2=323218&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Jan 23 08:30:56 2018
>> @@ -333,7 +333,18 @@ void UnwrappedLineParser::parseLevel(boo
>>        nextToken();
>>        addUnwrappedLine();
>>        break;
>> -    case tok::kw_default:
>> +    case tok::kw_default: {
>> +      unsigned StoredPosition = Tokens->getPosition();
>> +      FormatToken *Next = Tokens->getNextToken();
>> +      FormatTok = Tokens->setPosition(StoredPosition);
>> +      if (Next && Next->isNot(tok::colon)) {
>> +        // default not followed by ':' is not a case label; treat it like
>> +        // an identifier.
>> +        parseStructuralElement();
>> +        break;
>> +      }
>> +      // Else, if it is 'default:', fall through to the case handling.
>> +    }
>>      case tok::kw_case:
>>        if (Style.Language == FormatStyle::LK_JavaScript &&
>>            Line->MustBeDeclaration) {
>> @@ -1032,8 +1043,12 @@ void UnwrappedLineParser::parseStructura
>>        // 'default: string' field declaration.
>>        break;
>>      nextToken();
>> -    parseLabel();
>> -    return;
>> +    if (FormatTok->is(tok::colon)) {
>> +      parseLabel();
>> +      return;
>> +    }
>> +    // e.g. "default void f() {}" in a Java interface.
>> +    break;
>>    case tok::kw_case:
>>      if (Style.Language == FormatStyle::LK_JavaScript &&
>> Line->MustBeDeclaration)
>>        // 'case: string' field declaration.
>>
>> Modified: cfe/trunk/unittests/Format/FormatTestJava.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Form
>> at/FormatTestJava.cpp?rev=323218&r1=323217&r2=323218&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/unittests/Format/FormatTestJava.cpp (original)
>> +++ cfe/trunk/unittests/Format/FormatTestJava.cpp Tue Jan 23 08:30:56
>> 2018
>> @@ -144,6 +144,7 @@ TEST_F(FormatTestJava, ClassDeclarations
>>    verifyFormat("public interface SomeInterface {\n"
>>                 "  void doStuff(int theStuff);\n"
>>                 "  void doMoreStuff(int moreStuff);\n"
>> +               "  default void doStuffWithDefault() {}\n"
>>                 "}");
>>    verifyFormat("@interface SomeInterface {\n"
>>                 "  void doStuff(int theStuff);\n"
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180123/f1556dac/attachment.html>


More information about the cfe-commits mailing list