This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGc70e360b355a: [clang-format] Allow trailing return types in macros (authored by rymiel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141811/new/ https://reviews.llvm.org/D141811 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8010,6 +8010,11 @@ "auto aaaaaaaaaaaaaaaaaaaaaa(T t)\n" " -> decltype(eaaaaaaaaaaaaaaa<T>(t.a).aaaaaaaa());"); + FormatStyle Style = getLLVMStyleWithColumns(60); + verifyFormat("#define MAKE_DEF(NAME) \\\n" + " auto NAME() -> int { return 42; }", + Style); + // Not trailing return types. verifyFormat("void f() { auto a = b->c(); }"); verifyFormat("auto a = p->foo();"); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1909,7 +1909,8 @@ } else if (Current.is(tok::arrow) && Style.Language == FormatStyle::LK_Java) { Current.setType(TT_LambdaArrow); - } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration && + } else if (Current.is(tok::arrow) && AutoFound && + (Line.MustBeDeclaration || Line.InPPDirective) && Current.NestingLevel == 0 && !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) { // not auto operator->() -> xxx;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -8010,6 +8010,11 @@ "auto aaaaaaaaaaaaaaaaaaaaaa(T t)\n" " -> decltype(eaaaaaaaaaaaaaaa<T>(t.a).aaaaaaaa());"); + FormatStyle Style = getLLVMStyleWithColumns(60); + verifyFormat("#define MAKE_DEF(NAME) \\\n" + " auto NAME() -> int { return 42; }", + Style); + // Not trailing return types. verifyFormat("void f() { auto a = b->c(); }"); verifyFormat("auto a = p->foo();"); Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -1909,7 +1909,8 @@ } else if (Current.is(tok::arrow) && Style.Language == FormatStyle::LK_Java) { Current.setType(TT_LambdaArrow); - } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration && + } else if (Current.is(tok::arrow) && AutoFound && + (Line.MustBeDeclaration || Line.InPPDirective) && Current.NestingLevel == 0 && !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) { // not auto operator->() -> xxx;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits