diff options
author | Dmitry Vyukov <dvyukov@google.com> | 2013-07-16 16:44:15 +0000 |
---|---|---|
committer | Dmitry Vyukov <dvyukov@google.com> | 2013-07-16 16:44:15 +0000 |
commit | 55e6f3f4e6b799e0affd13f28137661f8707133f (patch) | |
tree | 29850c1b569336b49872c9a877f0d0951a0710fd /lib/sanitizer_common/sanitizer_suppressions.cc | |
parent | 742c1135a0ae9c5c9c5b0751cd0766c7d9f38d57 (diff) |
tsan: extend suppressions format with ^ and $ symbols
not it's possible to write more precise suppressions,
e.g. "^foo$" won't match "blafoobar"
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@186424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/sanitizer_suppressions.cc')
-rw-r--r-- | lib/sanitizer_common/sanitizer_suppressions.cc | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/sanitizer_common/sanitizer_suppressions.cc b/lib/sanitizer_common/sanitizer_suppressions.cc index f88020fa6..0676c0bd8 100644 --- a/lib/sanitizer_common/sanitizer_suppressions.cc +++ b/lib/sanitizer_common/sanitizer_suppressions.cc @@ -26,25 +26,41 @@ static const char *const kTypeStrings[SuppressionTypeCount] = { bool TemplateMatch(char *templ, const char *str) { if (str == 0 || str[0] == 0) return false; - char *tpos; - const char *spos; + bool start = false; + if (templ && templ[0] == '^') { + start = true; + templ++; + } + bool asterisk = false; while (templ && templ[0]) { if (templ[0] == '*') { templ++; + start = false; + asterisk = true; continue; } + if (templ[0] == '$') + return str[0] == 0 || asterisk; if (str[0] == 0) return false; - tpos = (char*)internal_strchr(templ, '*'); + char *tpos = (char*)internal_strchr(templ, '*'); + char *tpos1 = (char*)internal_strchr(templ, '$'); + if (tpos == 0 || (tpos1 && tpos1 < tpos)) + tpos = tpos1; if (tpos != 0) tpos[0] = 0; - spos = internal_strstr(str, templ); + const char *str0 = str; + const char *spos = internal_strstr(str, templ); str = spos + internal_strlen(templ); templ = tpos; if (tpos) - tpos[0] = '*'; + tpos[0] = tpos == tpos1 ? '$' : '*'; if (spos == 0) return false; + if (start && spos != str0) + return false; + start = false; + asterisk = false; } return true; } |