25 #include <system_error>
49 SpecialCaseList::SpecialCaseList() : Entries(), Regexps(), IsCompiled(
false) {}
51 std::unique_ptr<SpecialCaseList>
55 for (
const auto &Path : Paths) {
58 if (std::error_code EC = FileOrErr.
getError()) {
59 Error = (
Twine(
"can't open file '") + Path +
"': " + EC.message()).str();
62 std::string ParseError;
63 if (!SCL->parse(FileOrErr.
get().get(), ParseError)) {
64 Error = (
Twine(
"error parsing file '") + Path +
"': " + ParseError).str();
75 if (!SCL->parse(MB, Error))
81 std::unique_ptr<SpecialCaseList>
84 if (
auto SCL =
create(Paths, Error))
94 for (
auto I = Lines.
begin(),
E = Lines.
end();
I !=
E; ++
I, ++LineNo) {
96 if (
I->empty() ||
I->startswith(
"#"))
99 std::pair<StringRef, StringRef> SplitLine =
I->split(
":");
101 if (SplitLine.second.empty()) {
103 Error = (
Twine(
"malformed line ") +
Twine(LineNo) +
": '" +
104 SplitLine.first +
"'").str();
108 std::pair<StringRef, StringRef> SplitRegexp = SplitLine.second.split(
"=");
109 std::string Regexp = SplitRegexp.first;
110 StringRef
Category = SplitRegexp.second;
115 Entry.Strings.insert(Regexp);
118 Entry.Trigrams.insert(Regexp);
121 for (
size_t pos = 0; (pos = Regexp.find(
'*', pos)) != std::string::npos;
122 pos += strlen(
".*")) {
123 Regexp.replace(pos, strlen(
"*"),
".*");
127 Regex CheckRE(Regexp);
129 if (!CheckRE.isValid(REError)) {
130 Error = (Twine(
"malformed regex in line ") + Twine(LineNo) +
": '" +
131 SplitLine.second +
"': " + REError).str();
136 if (!Regexps[Prefix][Category].empty())
137 Regexps[Prefix][Category] +=
"|";
143 void SpecialCaseList::compile() {
144 assert(!IsCompiled &&
"compile() should only be called once");
146 for (StringMap<StringMap<std::string>>::const_iterator
I = Regexps.begin(),
149 for (StringMap<std::string>::const_iterator II =
I->second.begin(),
150 IE =
I->second.end();
152 Entries[
I->getKey()][II->getKey()].RegEx.reset(
new Regex(II->getValue()));
163 assert(IsCompiled &&
"SpecialCaseList::compile() was not called!");
165 if (I == Entries.end())
return false;
167 if (II == I->second.
end())
return false;
std::error_code getError() const
Represents either an error or a value T.
const ValueTy & getValue() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
iterator find(StringRef Key)
StringRef getBuffer() const
static std::unique_ptr< SpecialCaseList > createOrDie(const std::vector< std::string > &Paths)
Parses the special case list entries from files.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Function Alias Analysis false
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
static bool isLiteralERE(StringRef Str)
If this function returns true, ^Str$ is an extended regular expression that matches Str and only Str...
void SplitString(StringRef Source, SmallVectorImpl< StringRef > &OutFragments, StringRef Delimiters=" \t\n\v\f\r")
SplitString - Split up the specified string according to the specified delimiters, appending the result fragments to the output list.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static ManagedStatic< CodeViewErrorCategory > Category
This interface provides simple read-only access to a block of memory, and provides simple methods for...
std::unique_ptr< Regex > RegEx
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Represents a set of regular expressions.
bool inSection(StringRef Section, StringRef Query, StringRef Category=StringRef()) const
Returns true, if special case list contains a line.
bool isDefinitelyOut(StringRef Query) const
Returns true, if special case list definitely does not have a line that matches the query...
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFile(const Twine &Filename, int64_t FileSize=-1, bool RequiresNullTerminator=true, bool IsVolatileSize=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
static void Query(const MachineInstr &MI, AliasAnalysis &AA, bool &Read, bool &Write, bool &Effects, bool &StackPointer)
static std::unique_ptr< SpecialCaseList > create(const std::vector< std::string > &Paths, std::string &Error)
Parses the special case list entries from files.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
StringSet - A wrapper for StringMap that provides set-like functionality.
StringRef - Represent a constant reference to a string, i.e.
bool match(StringRef Query) const