diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp index 80fd48558fe67..c90180b9acb6c 100644 --- a/llvm/lib/Support/SpecialCaseList.cpp +++ b/llvm/lib/Support/SpecialCaseList.cpp @@ -175,7 +175,7 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned FileNo, bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB, std::string &Error) { - unsigned long long Version = 2; + unsigned long long Version = 3; StringRef Header = MB->getBuffer(); if (Header.consume_front("#!special-case-list-v")) @@ -237,6 +237,10 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB, auto [It, _] = CurrentSection->Entries[Prefix].try_emplace( Category, UseGlobs, RemoveDotSlash && llvm::is_contained(PathPrefixes, Prefix)); + if (It->second.RemoveDotSlash) { + // FIXME: On Windows remove_leading_dotslash will break escape sequences. + Pattern = llvm::sys::path::remove_leading_dotslash(Pattern); + } Pattern = Pattern.copy(StrAlloc); if (auto Err = It->second.insert(Pattern, LineNo)) { Error = diff --git a/llvm/unittests/Support/SpecialCaseListTest.cpp b/llvm/unittests/Support/SpecialCaseListTest.cpp index 750fedaf0a436..220a2c2d44de2 100644 --- a/llvm/unittests/Support/SpecialCaseListTest.cpp +++ b/llvm/unittests/Support/SpecialCaseListTest.cpp @@ -313,14 +313,14 @@ TEST_F(SpecialCaseListTest, DotSlash) { "src:./bar\n" "[not]\n" "fun:foo\n" - "src:bar\n"); + "src:bar\n", + /*Version=*/2); std::unique_ptr SCL3 = makeSpecialCaseList("[dot]\n" "fun:./foo\n" "src:./bar\n" "[not]\n" "fun:foo\n" - "src:bar\n", - /*Version=*/3); + "src:bar\n"); EXPECT_TRUE(SCL2->inSection("dot", "fun", "./foo")); EXPECT_TRUE(SCL3->inSection("dot", "fun", "./foo")); @@ -329,10 +329,10 @@ TEST_F(SpecialCaseListTest, DotSlash) { EXPECT_FALSE(SCL3->inSection("dot", "fun", "foo")); EXPECT_TRUE(SCL2->inSection("dot", "src", "./bar")); - EXPECT_FALSE(SCL3->inSection("dot", "src", "./bar")); + EXPECT_TRUE(SCL3->inSection("dot", "src", "./bar")); EXPECT_FALSE(SCL2->inSection("dot", "src", "bar")); - EXPECT_FALSE(SCL3->inSection("dot", "src", "bar")); + EXPECT_TRUE(SCL3->inSection("dot", "src", "bar")); EXPECT_FALSE(SCL2->inSection("not", "fun", "./foo")); EXPECT_FALSE(SCL3->inSection("not", "fun", "./foo"));