From d96ae867351ece78d2aa2fe0fb463a626fbb3029 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 24 Feb 2017 19:10:12 +0000 Subject: clang-format: Fix many Objective-C formatting regressions from r289428 r289428 added a separate language kind for Objective-C, but kept many "Language == LK_Cpp" checks untouched. This introduced a "IsCpp()" method that returns true for both C++ and Objective-C++, and replaces all comparisons of Language with LK_Cpp with calls to this new method. Also add a lot more test coverge for formatting things in LK_ObjC mode, by having FormatTest's verifyFormat() test for LK_ObjC everything that's being tested for LK_Cpp at the moment. Fixes PR32060 and many other things. llvm-svn: 296160 --- clang/lib/Format/UnwrappedLineParser.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'clang/lib/Format/UnwrappedLineParser.cpp') diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 1211c8ffec5..ab343d8bbed 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -946,7 +946,7 @@ void UnwrappedLineParser::parseStructuralElement() { if (!parseEnum()) break; // This only applies for C++. - if (Style.Language != FormatStyle::LK_Cpp) { + if (!Style.IsCpp()) { addUnwrappedLine(); return; } @@ -1127,7 +1127,7 @@ void UnwrappedLineParser::parseStructuralElement() { } bool UnwrappedLineParser::tryToParseLambda() { - if (Style.Language != FormatStyle::LK_Cpp) { + if (!Style.IsCpp()) { nextToken(); return false; } @@ -1737,8 +1737,7 @@ bool UnwrappedLineParser::parseEnum() { nextToken(); // If there are two identifiers in a row, this is likely an elaborate // return type. In Java, this can be "implements", etc. - if (Style.Language == FormatStyle::LK_Cpp && - FormatTok->is(tok::identifier)) + if (Style.IsCpp() && FormatTok->is(tok::identifier)) return false; } } -- cgit v1.2.3