diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp --- a/clang/unittests/Format/SortIncludesTest.cpp +++ b/clang/unittests/Format/SortIncludesTest.cpp @@ -458,6 +458,20 @@ "#include \"b.h\"\n")); } +TEST_F(SortIncludesTest, HandlesTrailingCommentsWithAngleBrackets) { + // Regression test from the discussion at https://reviews.llvm.org/D121370. + EXPECT_EQ("#include \n" + "\n" + "#include \"util/bar.h\"\n" + "#include \"util/foo/foo.h\" // foo\n", + sort("#include \n" + "\n" + "#include \"util/bar.h\"\n" + "#include \"util/foo/foo.h\" // foo\n", + /*FileName=*/"input.cc", + /*ExpectedNumRanges=*/0)); +} + TEST_F(SortIncludesTest, LeavesMainHeaderFirst) { Style.IncludeIsMainRegex = "([-_](test|unittest))?$"; EXPECT_EQ("#include \"llvm/a.h\"\n"