<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">Thanks!<br><br><div class="gmail_quote">On Wed, Nov 28, 2012 at 4:01 PM, Nick Lewycky <span dir="ltr"><<a href="mailto:nicholas@mxc.ca" target="_blank">nicholas@mxc.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: nicholas<br>
Date: Wed Nov 28 18:01:38 2012<br>
New Revision: <a href="tel:168833" value="+49168833">168833</a><br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=168833&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=168833&view=rev</a><br>
Log:<br>
Issue a fatal error if the line doesn't have a regular expression.<br>
<br>
Also a couple not-user-visible changes; using empty() instead of size(), and<br>
make inSection() not insert NULL Regex*'s into StringMap when doing a lookup.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp?rev=168833&r1=168832&r2=168833&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp?rev=168833&r1=168832&r2=168833&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/Instrumentation/BlackList.cpp Wed Nov 28 18:01:38 2012<br>
@@ -33,7 +33,7 @@<br>
<br>
 BlackList::BlackList(const StringRef Path) {<br>
   // Validate and open blacklist file.<br>
-  if (!Path.size()) return;<br>
+  if (Path.empty()) return;<br>
   OwningPtr<MemoryBuffer> File;<br>
   if (error_code EC = MemoryBuffer::getFile(Path, File)) {<br>
     report_fatal_error("Can't open blacklist file: " + Path + ": " +<br>
@@ -53,6 +53,10 @@<br>
     std::pair<StringRef, StringRef> SplitLine = I->split(":");<br>
     StringRef Prefix = SplitLine.first;<br>
     std::string Regexp = SplitLine.second;<br>
+    if (Regexp.empty()) {<br>
+      // Missing ':' in the line.<br>
+      report_fatal_error("malformed blacklist line: " + SplitLine.first);<br>
+    }<br>
<br>
     // Replace * with .*<br>
     for (size_t pos = 0; (pos = Regexp.find("*", pos)) != std::string::npos;<br>
@@ -69,7 +73,7 @@<br>
     }<br>
<br>
     // Add this regexp into the proper group by its prefix.<br>
-    if (Regexps[Prefix].size())<br>
+    if (!Regexps[Prefix].empty())<br>
       Regexps[Prefix] += "|";<br>
     Regexps[Prefix] += Regexp;<br>
   }<br>
@@ -110,10 +114,12 @@<br>
           inSection("global-init-type", GetGVTypeString(G)));<br>
 }<br>
<br>
-bool BlackList::inSection(const StringRef Section,<br>
-                          const StringRef Query) {<br>
-  Regex *FunctionRegex = Entries[Section];<br>
-  return FunctionRegex ? FunctionRegex->match(Query) : false;<br>
+bool BlackList::inSection(const StringRef Section, const StringRef Query) {<br>
+  StringMap<Regex*>::iterator I = Entries.find(Section);<br>
+  if (I == Entries.end()) return false;<br>
+<br>
+  Regex *FunctionRegex = I->getValue();<br>
+  return FunctionRegex->match(Query);<br>
 }<br>
<br>
 }  // namespace llvm<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div>