https://github.com/qinkunbao updated https://github.com/llvm/llvm-project/pull/140821
>From bb0e2f0bb26a47602978d1ac6f3d73a770075900 Mon Sep 17 00:00:00 2001 From: Qinkun Bao <qin...@google.com> Date: Wed, 21 May 2025 00:28:47 +0000 Subject: [PATCH 1/2] Remove lineno. Created using spr 1.3.6 --- llvm/include/llvm/Support/SpecialCaseList.h | 1 - llvm/lib/Support/SpecialCaseList.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h index baa5c917220e3..fc6dc93651f38 100644 --- a/llvm/include/llvm/Support/SpecialCaseList.h +++ b/llvm/include/llvm/Support/SpecialCaseList.h @@ -138,7 +138,6 @@ class SpecialCaseList { std::unique_ptr<Matcher> SectionMatcher; SectionEntries Entries; std::string SectionStr; - unsigned LineNo; }; std::vector<Section> Sections; diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp index e8dac4680f96f..2d84f7f22cd7b 100644 --- a/llvm/lib/Support/SpecialCaseList.cpp +++ b/llvm/lib/Support/SpecialCaseList.cpp @@ -139,13 +139,12 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned LineNo, bool UseGlobs) { auto it = std::find_if(Sections.begin(), Sections.end(), [&](const Section &s) { - return s.SectionStr == SectionStr && s.LineNo == LineNo; + return s.SectionStr == SectionStr; }); if (it == Sections.end()) { Sections.emplace_back(); auto &sec = Sections.back(); sec.SectionStr = SectionStr; - sec.LineNo = LineNo; it = std::prev(Sections.end()); } if (auto Err = it->SectionMatcher->insert(SectionStr, LineNo, UseGlobs)) { >From 6c30ad8f079fe2fccc8fe194daaa0cf087577710 Mon Sep 17 00:00:00 2001 From: Qinkun Bao <qin...@google.com> Date: Wed, 21 May 2025 01:30:49 +0000 Subject: [PATCH 2/2] Add unit tests. Created using spr 1.3.6 --- .../unittests/Support/SpecialCaseListTest.cpp | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/llvm/unittests/Support/SpecialCaseListTest.cpp b/llvm/unittests/Support/SpecialCaseListTest.cpp index d6d5621116d72..16da11e2d7835 100644 --- a/llvm/unittests/Support/SpecialCaseListTest.cpp +++ b/llvm/unittests/Support/SpecialCaseListTest.cpp @@ -216,8 +216,9 @@ TEST_F(SpecialCaseListTest, NoTrigramsInARule) { } TEST_F(SpecialCaseListTest, RepetitiveRule) { - std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList("fun:*bar*bar*bar*bar*\n" - "fun:bar*\n"); + std::unique_ptr<SpecialCaseList> SCL = + makeSpecialCaseList("fun:*bar*bar*bar*bar*\n" + "fun:bar*\n"); EXPECT_TRUE(SCL->inSection("", "fun", "bara")); EXPECT_FALSE(SCL->inSection("", "fun", "abara")); EXPECT_TRUE(SCL->inSection("", "fun", "barbarbarbar")); @@ -226,7 +227,8 @@ TEST_F(SpecialCaseListTest, RepetitiveRule) { } TEST_F(SpecialCaseListTest, SpecialSymbolRule) { - std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList("src:*c\\+\\+abi*\n"); + std::unique_ptr<SpecialCaseList> SCL = + makeSpecialCaseList("src:*c\\+\\+abi*\n"); EXPECT_TRUE(SCL->inSection("", "src", "c++abi")); EXPECT_FALSE(SCL->inSection("", "src", "c\\+\\+abi")); } @@ -242,8 +244,9 @@ TEST_F(SpecialCaseListTest, PopularTrigram) { } TEST_F(SpecialCaseListTest, EscapedSymbols) { - std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList("src:*c\\+\\+abi*\n" - "src:*hello\\\\world*\n"); + std::unique_ptr<SpecialCaseList> SCL = + makeSpecialCaseList("src:*c\\+\\+abi*\n" + "src:*hello\\\\world*\n"); EXPECT_TRUE(SCL->inSection("", "src", "dir/c++abi")); EXPECT_FALSE(SCL->inSection("", "src", "dir/c\\+\\+abi")); EXPECT_FALSE(SCL->inSection("", "src", "c\\+\\+abi")); @@ -315,7 +318,9 @@ TEST_F(SpecialCaseListTest, Version3) { "src:def\n" "[sect2]\n" "src:def\n" - "src:def\n"); + "src:def\n" + "[sect1]\n" + "src:foo*\n"); EXPECT_TRUE(SCL->inSection("sect1", "src", "fooz")); EXPECT_TRUE(SCL->inSection("sect1", "src", "barz")); EXPECT_FALSE(SCL->inSection("sect2", "src", "fooz")); @@ -323,9 +328,9 @@ TEST_F(SpecialCaseListTest, Version3) { EXPECT_TRUE(SCL->inSection("sect2", "src", "def")); EXPECT_TRUE(SCL->inSection("sect1", "src", "def")); - EXPECT_EQ(2u, SCL->inSectionBlame("sect1", "src", "fooz")); EXPECT_EQ(4u, SCL->inSectionBlame("sect1", "src", "barz")); EXPECT_EQ(5u, SCL->inSectionBlame("sect1", "src", "def")); EXPECT_EQ(8u, SCL->inSectionBlame("sect2", "src", "def")); + EXPECT_EQ(10u, SCL->inSectionBlame("sect1", "src", "fooz")); } -} +} // namespace _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits