This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGcd2b050fa499: [clang-format] spacesRequiredBetween is not honouring clang-format off/on (authored by MyDeveloperDay).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116494/new/ https://reviews.llvm.org/D116494 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 @@ -21156,6 +21156,16 @@ verifyFormat("A< A< int > >();", Spaces); verifyFormat("A<A<int > >();", Spaces); verifyFormat("A< A< int>>();", Spaces); + + Spaces.SpacesInAngles = FormatStyle::SIAS_Always; + verifyFormat("// clang-format off\n" + "foo<<<1, 1>>>();\n" + "// clang-format on\n", + Spaces); + verifyFormat("// clang-format off\n" + "foo< < <1, 1> > >();\n" + "// clang-format on\n", + Spaces); } TEST_F(FormatTest, SpaceAfterTemplateKeyword) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3294,6 +3294,11 @@ return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd(); }; + // If the token is finalized don't touch it (as it could be in a + // clang-format-off section). + if (Left.Finalized) + return HasExistingWhitespace(); + if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo()) return true; // Never ever merge two identifiers.
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -21156,6 +21156,16 @@ verifyFormat("A< A< int > >();", Spaces); verifyFormat("A<A<int > >();", Spaces); verifyFormat("A< A< int>>();", Spaces); + + Spaces.SpacesInAngles = FormatStyle::SIAS_Always; + verifyFormat("// clang-format off\n" + "foo<<<1, 1>>>();\n" + "// clang-format on\n", + Spaces); + verifyFormat("// clang-format off\n" + "foo< < <1, 1> > >();\n" + "// clang-format on\n", + Spaces); } TEST_F(FormatTest, SpaceAfterTemplateKeyword) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -3294,6 +3294,11 @@ return Right.WhitespaceRange.getBegin() != Right.WhitespaceRange.getEnd(); }; + // If the token is finalized don't touch it (as it could be in a + // clang-format-off section). + if (Left.Finalized) + return HasExistingWhitespace(); + if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo()) return true; // Never ever merge two identifiers.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits