Go to the documentation of this file.
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;
72 std::unique_ptr<SpecialCaseList>
76 if (SCL->createInternal(Paths,
FS,
Error))
84 if (SCL->createInternal(MB,
Error))
89 std::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)) {
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);
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
bool inSection(StringRef Section, StringRef Prefix, StringRef Query, StringRef Category=StringRef()) const
Returns true, if special case list contains a line.
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.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool createInternal(const std::vector< std::string > &Paths, vfs::FileSystem &VFS, std::string &Error)
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...
iterator find(StringRef Key)
This interface provides simple read-only access to a block of memory, and provides simple methods for...
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.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
std::error_code getError() const
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool parse(const MemoryBuffer *MB, StringMap< size_t > &SectionsMap, std::string &Error)
Parses just-constructed SpecialCaseList entries from a memory buffer.
StringRef getBuffer() const
std::vector< Section > Sections
bool insert(std::string Regexp, unsigned LineNumber, std::string &REError)
void insert(const std::string &Regex)
Inserts a new Regex into the index.
static bool isLiteralERE(StringRef Str)
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str.
SpecialCaseList()=default
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
static std::unique_ptr< SpecialCaseList > createOrDie(const std::vector< std::string > &Paths, llvm::vfs::FileSystem &FS)
Parses the special case list entries from files.
bool isValid(std::string &Error) const
isValid - returns the error encountered during regex compilation, if any.
unsigned match(StringRef Query) const
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The virtual file system interface.
Lightweight error class with error context and mandatory checking.
Represents either an error or a value T.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.