diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-11-29 00:01:38 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-11-29 00:01:38 +0000 |
commit | 7b09b97bdf575e7d392435f931f767dfa6ab3c9e (patch) | |
tree | 913976991e72d53b299304d09f1320c33b3c7a5c /lib | |
parent | 90e11dc8ada81015becd6f613152131e5c28a29d (diff) | |
download | llvm-7b09b97bdf575e7d392435f931f767dfa6ab3c9e.tar.gz llvm-7b09b97bdf575e7d392435f931f767dfa6ab3c9e.tar.bz2 llvm-7b09b97bdf575e7d392435f931f767dfa6ab3c9e.tar.xz |
Issue a fatal error if the line doesn't have a regular expression.
Also a couple not-user-visible changes; using empty() instead of size(), and
make inSection() not insert NULL Regex*'s into StringMap when doing a lookup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168833 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Instrumentation/BlackList.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/Transforms/Instrumentation/BlackList.cpp b/lib/Transforms/Instrumentation/BlackList.cpp index e02c631f7f..e3ab43e0d7 100644 --- a/lib/Transforms/Instrumentation/BlackList.cpp +++ b/lib/Transforms/Instrumentation/BlackList.cpp @@ -33,7 +33,7 @@ namespace llvm { BlackList::BlackList(const StringRef Path) { // Validate and open blacklist file. - if (!Path.size()) return; + if (Path.empty()) return; OwningPtr<MemoryBuffer> File; if (error_code EC = MemoryBuffer::getFile(Path, File)) { report_fatal_error("Can't open blacklist file: " + Path + ": " + @@ -53,6 +53,10 @@ BlackList::BlackList(const StringRef Path) { std::pair<StringRef, StringRef> SplitLine = I->split(":"); StringRef Prefix = SplitLine.first; std::string Regexp = SplitLine.second; + if (Regexp.empty()) { + // Missing ':' in the line. + report_fatal_error("malformed blacklist line: " + SplitLine.first); + } // Replace * with .* for (size_t pos = 0; (pos = Regexp.find("*", pos)) != std::string::npos; @@ -69,7 +73,7 @@ BlackList::BlackList(const StringRef Path) { } // Add this regexp into the proper group by its prefix. - if (Regexps[Prefix].size()) + if (!Regexps[Prefix].empty()) Regexps[Prefix] += "|"; Regexps[Prefix] += Regexp; } @@ -110,10 +114,12 @@ bool BlackList::isInInit(const GlobalVariable &G) { inSection("global-init-type", GetGVTypeString(G))); } -bool BlackList::inSection(const StringRef Section, - const StringRef Query) { - Regex *FunctionRegex = Entries[Section]; - return FunctionRegex ? FunctionRegex->match(Query) : false; +bool BlackList::inSection(const StringRef Section, const StringRef Query) { + StringMap<Regex*>::iterator I = Entries.find(Section); + if (I == Entries.end()) return false; + + Regex *FunctionRegex = I->getValue(); + return FunctionRegex->match(Query); } } // namespace llvm |