sousajo created this revision. sousajo added a reviewer: MyDeveloperDay. Herald added projects: All, clang, clang-format. Herald added a subscriber: cfe-commits. Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan. sousajo requested review of this revision.
Fixes: https://github.com/llvm/llvm-project/issues/53173 https://reviews.llvm.org/D148437 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -25429,6 +25429,16 @@ verifyFormat("auto x = 5s .count() == 5;"); } +TEST_F(FormatTest, InterfaceAsFieldName) { + FormatStyle Style = getLLVMStyle(); + + constexpr StringRef Code("class Foo {\n" + " int interface;\n" + " Foo::Foo(int iface) : interface{iface} {}\n" + "}\n"); + verifyFormat(Code, Style); +} + } // namespace } // namespace test } // namespace format Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1881,7 +1881,7 @@ } } - if (FormatTok->is(Keywords.kw_interface)) { + if (!Style.isCpp() && FormatTok->is(Keywords.kw_interface)) { if (parseStructLike()) return; break;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -25429,6 +25429,16 @@ verifyFormat("auto x = 5s .count() == 5;"); } +TEST_F(FormatTest, InterfaceAsFieldName) { + FormatStyle Style = getLLVMStyle(); + + constexpr StringRef Code("class Foo {\n" + " int interface;\n" + " Foo::Foo(int iface) : interface{iface} {}\n" + "}\n"); + verifyFormat(Code, Style); +} + } // namespace } // namespace test } // namespace format Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1881,7 +1881,7 @@ } } - if (FormatTok->is(Keywords.kw_interface)) { + if (!Style.isCpp() && FormatTok->is(Keywords.kw_interface)) { if (parseStructLike()) return; break;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits