22#include <system_error>
30 std::string &REError) {
32 REError =
"Supplied regexp was blank";
37 Strings[Regexp] = LineNumber;
43 for (
size_t pos = 0; (pos = Regexp.find(
'*', pos)) != std::string::npos;
44 pos += strlen(
".*")) {
45 Regexp.replace(pos, strlen(
"*"),
".*");
51 Regex CheckRE(Regexp);
56 std::make_pair(std::make_unique<Regex>(std::move(CheckRE)), LineNumber));
61 auto It = Strings.find(Query);
62 if (It != Strings.end())
64 if (Trigrams.isDefinitelyOut(Query))
66 for (
const auto &RegExKV : RegExes)
67 if (RegExKV.first->match(Query))
68 return RegExKV.second;
72std::unique_ptr<SpecialCaseList>
84 if (SCL->createInternal(MB,
Error))
89std::unique_ptr<SpecialCaseList>
101 for (
const auto &Path :
Paths) {
104 if (std::error_code EC = FileOrErr.
getError()) {
105 Error = (
Twine(
"can't open file '") + Path +
"': " + EC.message()).str();
108 std::string ParseError;
110 Error = (
Twine(
"error parsing file '") + Path +
"': " + ParseError).str();
118 std::string &
Error) {
127 std::string &
Error) {
135 for (
auto I = Lines.begin(),
E = Lines.end();
I !=
E; ++
I, ++LineNo) {
138 if (
I->empty() ||
I->startswith(
"#"))
142 if (
I->startswith(
"[")) {
143 if (!
I->endswith(
"]")) {
153 if (!CheckRE.
isValid(REError)) {
155 (
Twine(
"malformed regex for section ") +
Section +
": '" + REError)
164 std::pair<StringRef, StringRef> SplitLine =
I->split(
":");
166 if (SplitLine.second.empty()) {
169 SplitLine.first +
"'").str();
173 std::pair<StringRef, StringRef> SplitRegexp = SplitLine.second.split(
"=");
174 std::string Regexp = std::string(SplitRegexp.first);
179 std::unique_ptr<Matcher> M = std::make_unique<Matcher>();
181 if (!M->insert(std::string(
Section), LineNo, REError)) {
187 Sections.emplace_back(std::move(M));
190 auto &Entry =
Sections[SectionsMap[
Section]].Entries[Prefix][Category];
192 if (!Entry.insert(std::move(Regexp), LineNo, REError)) {
194 SplitLine.second +
"': " + REError).str();
211 for (
const auto &SectionIter :
Sections)
212 if (SectionIter.SectionMatcher->match(
Section)) {
225 if (
I == Entries.end())
return 0;
227 if (II ==
I->second.end())
return 0;
229 return II->getValue().match(Query);
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the SmallVector class.
Defines the virtual file system interface vfs::FileSystem.
Represents either an error or a value T.
std::error_code getError() const
Lightweight error class with error context and mandatory checking.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
StringRef getBuffer() const
static bool isLiteralERE(StringRef Str)
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str.
bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, if any.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool insert(std::string Regexp, unsigned LineNumber, std::string &REError)
unsigned match(StringRef Query) const
std::vector< Section > Sections
bool parse(const MemoryBuffer *MB, StringMap< size_t > &SectionsMap, std::string &Error)
Parses just-constructed SpecialCaseList entries from a memory buffer.
bool createInternal(const std::vector< std::string > &Paths, vfs::FileSystem &VFS, std::string &Error)
static std::unique_ptr< SpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS)
Parses the special case list entries from files.
static std::unique_ptr< SpecialCaseList > create(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS, std::string &Error)
Parses the special case list entries from files.
SpecialCaseList()=default
unsigned inSectionBlame(StringRef Section, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const
Returns the line number corresponding to the special case list entry if the special case list contain...
bool inSection(StringRef Section, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const
Returns true, if special case list contains a line.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
bool contains(StringRef Key) const
contains - Return true if the element is in the map, false otherwise.
StringRef - Represent a constant reference to a string, i.e.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
void insert(const std::string &Regex)
Inserts a new Regex into the index.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The virtual file system interface.
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const Twine &Name, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatile=false)
This is a convenience method that opens a file, gets its content and then closes the file.
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.