Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions llvm/lib/Support/SpecialCaseList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/Support/SpecialCaseList.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
Expand Down Expand Up @@ -66,10 +67,10 @@ Error SpecialCaseList::Matcher::insert(StringRef Pattern, unsigned LineNumber,
}

unsigned SpecialCaseList::Matcher::match(StringRef Query) const {
for (const auto &Glob : Globs)
for (const auto &Glob : reverse(Globs))
if (Glob->Pattern.match(Query))
return Glob->LineNo;
for (const auto &[Regex, LineNumber] : RegExes)
for (const auto &[Regex, LineNumber] : reverse(RegExes))
if (Regex->match(Query))
return LineNumber;
return 0;
Expand Down Expand Up @@ -213,7 +214,7 @@ bool SpecialCaseList::inSection(StringRef Section, StringRef Prefix,
unsigned SpecialCaseList::inSectionBlame(StringRef Section, StringRef Prefix,
StringRef Query,
StringRef Category) const {
for (const auto &S : Sections) {
for (const auto &S : reverse(Sections)) {
if (S.SectionMatcher->match(Section)) {
unsigned Blame = inSectionBlame(S.Entries, Prefix, Query, Category);
if (Blame)
Expand Down
8 changes: 3 additions & 5 deletions llvm/unittests/Support/SpecialCaseListTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ TEST_F(SpecialCaseListTest, LinesInSection) {
std::unique_ptr<SpecialCaseList> SCL = makeSpecialCaseList("fun:foo\n"
"fun:bar\n"
"fun:foo\n");
// FIXME: Get the last one for #139128.
EXPECT_EQ(1u, SCL->inSectionBlame("sect1", "fun", "foo"));
EXPECT_EQ(3u, SCL->inSectionBlame("sect1", "fun", "foo"));
EXPECT_EQ(2u, SCL->inSectionBlame("sect1", "fun", "bar"));
}

Expand All @@ -322,8 +321,7 @@ TEST_F(SpecialCaseListTest, LinesCrossSection) {
"fun:foo\n"
"[sect1]\n"
"fun:bar\n");
// FIXME: Get the last one for #139128.
EXPECT_EQ(1u, SCL->inSectionBlame("sect1", "fun", "foo"));
EXPECT_EQ(2u, SCL->inSectionBlame("sect1", "fun", "bar"));
EXPECT_EQ(3u, SCL->inSectionBlame("sect1", "fun", "foo"));
EXPECT_EQ(5u, SCL->inSectionBlame("sect1", "fun", "bar"));
}
}
Loading