52 SpecialCaseList::SpecialCaseList() : Entries() {}
60 Error = (
Twine(
"Can't open file '") + Path +
"': " + EC.message()).str();
69 if (!SCL->parse(MB, Error))
86 assert(Entries.empty() &&
87 "parse() should be called on an empty SpecialCaseList");
90 I != E; ++
I, ++LineNo) {
92 if (
I->empty() ||
I->startswith(
"#"))
95 std::pair<StringRef, StringRef> SplitLine =
I->split(
":");
97 if (SplitLine.second.empty()) {
99 Error = (
Twine(
"Malformed line ") +
Twine(LineNo) +
": '" +
100 SplitLine.first +
"'").str();
104 std::pair<StringRef, StringRef> SplitRegexp = SplitLine.second.split(
"=");
105 std::string Regexp = SplitRegexp.first;
106 StringRef Category = SplitRegexp.second;
109 if (Prefix ==
"global-init") {
112 }
else if (Prefix ==
"global-init-type") {
115 }
else if (Prefix ==
"global-init-src") {
122 Entries[
Prefix][Category].Strings.insert(Regexp);
127 for (
size_t pos = 0; (pos = Regexp.find(
"*", pos)) != std::string::npos;
129 Regexp.replace(pos,
strlen(
"*"),
".*");
133 Regex CheckRE(Regexp);
135 if (!CheckRE.isValid(REError)) {
136 Error = (Twine(
"Malformed regex in line ") + Twine(LineNo) +
": '" +
137 SplitLine.second +
"': " + REError).str();
142 if (!Regexps[Prefix][Category].empty())
143 Regexps[Prefix][Category] +=
"|";
144 Regexps[
Prefix][Category] +=
"^" + Regexp +
"$";
148 for (StringMap<StringMap<std::string> >::const_iterator
I = Regexps.begin(),
151 for (StringMap<std::string>::const_iterator II =
I->second.begin(),
152 IE =
I->second.end();
154 Entries[
I->getKey()][II->getKey()].RegEx =
new Regex(II->getValue());
165 IE =
I->second.end();
167 delete II->second.RegEx;
174 inSectionCategory(
"fun", F.
getName(), Category);
181 if (
StructType *SGType = dyn_cast<StructType>(GType)) {
182 if (!SGType->isLiteral())
183 return SGType->getName();
185 return "<unknown type>";
191 inSectionCategory(
"global", G.
getName(), Category) ||
201 return inSectionCategory(
"fun", GA.
getName(), Category);
203 return inSectionCategory(
"global", GA.
getName(), Category) ||
215 if (I == Entries.end())
return false;
217 if (II == I->second.
end())
return false;
const ValueTy & getValue() const
The main container class for the LLVM Intermediate Representation.
iterator find(StringRef Key)
static SpecialCaseList * createOrDie(const StringRef Path)
StringRef getBuffer() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
StringRef getName() const
size_type count(StringRef Key) const
const std::string & getModuleIdentifier() const
static StringRef GetGlobalTypeString(const GlobalValue &G)
bool match(StringRef String, SmallVectorImpl< StringRef > *Matches=0)
Type * getElementType() const
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")
static error_code getFile(Twine Filename, OwningPtr< MemoryBuffer > &result, int64_t FileSize=-1, bool RequiresNullTerminator=true)
size_t strlen(const char *s);
static SpecialCaseList * create(const StringRef Path, std::string &Error)
PointerType * getType() const
getType - Global values are always pointers.
bool isIn(const Function &F, const StringRef Category=StringRef()) const
StringSet - A wrapper for StringMap that provides set-like functionality.
bool empty() const
empty - Check if the string is empty.
bool match(StringRef Query) const