<div dir="ltr">Hi Ryan,<div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 5, 2015 at 4:47 PM, Ryan Govostes <span dir="ltr"><<a href="mailto:rzg@apple.com" target="_blank">rzg@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The documentation for the sanitizer special case list format[0] says,<br>
<br>
> The meanining of * in regular expression for entity names is different - it is treated as in shell wildcarding.<br>
<br>
<br>
In SpecialCaseList::parse, we see that this is just replacing * with .*:<br>
<br>
    // Replace * with .*<br>
    for (size_t pos = 0; (pos = Regexp.find("*", pos)) != std::string::npos;<br>
         pos += strlen(".*")) {<br>
      Regexp.replace(pos, strlen("*"), ".*");<br>
    }<br>
<br>
This seems to introduce more problems than it solves, since (i) this doesn’t really behave like a shell globbing wildcard as advertised, and (ii) if the user tries to use * as a regex quantifier, this will match incorrectly: A* matches the empty string and any number of As, while A.* matches all strings that start with at least one A.<br>
<br>
If it’s forgivable to break compatibility here, we should do regular expressions _or_ shell globbing, and not a hybrid format.<br></blockquote><div><br></div><div>I agree that the current format description is misleading, e.g. "foo*bar" will also match "fooxxx/yyy/zzzbar", which might be unexpected for user expecting a shell globbing. For now we should at least change documentation to reflect that. In retrospective, replacing "*" with ".*" doesn't look like a good idea at all, and for simplicity I'd prefer to just use regular expressions. Adding special case for "file paths" isn't nice:</div><div>1) as you mention, we have to do careful escaping</div><div>2) at the moment special case list format is generic and is not tied to "src" or "fun" entities, it's specific sanitizers that introduce logic on top of it. I'd prefer to treat all special case list entries in a similar way.</div><div><br></div><div>However, I'm really afraid of breaking compatibility :( I know several users of blacklist that already use "*" meaning ".*", and it would be challenging to migrate them - e.g. you have to keep two different blacklist files for older and newer Clang...</div><div><br></div><div>The only option I see is to introduce versioning to special case list format. That's unfortunate and extra complexity, but can be useful if we decide to make further changes.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I’d prefer shell globbing for paths in src entities, but that isn’t as useful for function names. Most filenames will contain periods, which also need to be escaped properly as regular expressions. (This also limits the usefulness of treating literals separately.)<br>
<br>
(Just a note: the way that regular expressions are concatenated in ::parse appears to have a bug if a pattern contains a pipe.)<br></blockquote><div><br></div><div>Patches welcome :) You can also open a bug against me, but I can't guarantee I will get to this (or the suggestion above) in the nearest future.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Ryan<br>
<br>
<br>
0: <a href="http://clang.llvm.org/docs/SanitizerSpecialCaseList.html" target="_blank">http://clang.llvm.org/docs/SanitizerSpecialCaseList.html</a><br>
<br>
<br>
diff --git a/lib/Support/SpecialCaseList.cpp b/lib/Support/SpecialCaseList.cpp<br>
index c312cc1..2972cb1 100644<br>
--- a/lib/Support/SpecialCaseList.cpp<br>
+++ b/lib/Support/SpecialCaseList.cpp<br>
@@ -133,7 +133,7 @@ bool SpecialCaseList::parse(const MemoryBuffer *MB, std::string &Error) {<br>
     // Add this regexp into the proper group by its prefix.<br>
     if (!Regexps[Prefix][Category].empty())<br>
       Regexps[Prefix][Category] += "|";<br>
-    Regexps[Prefix][Category] += "^" + Regexp + "$";<br>
+    Regexps[Prefix][Category] += "^(" + Regexp + ")$)";<br>
   }<br>
   return true;<br>
 }<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div></div>