diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-09-03 21:41:29 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-09-03 21:41:29 +0000 |
commit | 53b715b5ba3f838ab20de8d3f34297c6555c7981 (patch) | |
tree | 264810938cd5b02b228fb2193588d88398d58d83 /contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc | |
parent | c22165b4f1f5d38b681921797a44b3ba8c13b7e0 (diff) | |
parent | b58b5b4a2eef87f528c56a9e91d9bfeba74ac210 (diff) |
Update compiler-rt to 3.9.0 release, and update the build glue for
libcompiler_rt and libclang_rt.
Notes
Notes:
svn path=/projects/clang390-import/; revision=305364
Diffstat (limited to 'contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc')
-rw-r--r-- | contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc b/contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc index 18b9ea3df9e1..c2f19d425bdb 100644 --- a/contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc +++ b/contrib/compiler-rt/lib/sanitizer_common/sanitizer_flags.cc @@ -45,17 +45,44 @@ void CommonFlags::CopyFrom(const CommonFlags &other) { internal_memcpy(this, &other, sizeof(*this)); } -// Copy the string from "s" to "out", replacing "%b" with the binary basename. -static void SubstituteBinaryName(const char *s, char *out, uptr out_size) { +// Copy the string from "s" to "out", making the following substitutions: +// %b = binary basename +// %p = pid +void SubstituteForFlagValue(const char *s, char *out, uptr out_size) { char *out_end = out + out_size; while (*s && out < out_end - 1) { - if (s[0] != '%' || s[1] != 'b') { *out++ = *s++; continue; } - const char *base = GetProcessName(); - CHECK(base); - while (*base && out < out_end - 1) - *out++ = *base++; - s += 2; // skip "%b" + if (s[0] != '%') { + *out++ = *s++; + continue; + } + switch (s[1]) { + case 'b': { + const char *base = GetProcessName(); + CHECK(base); + while (*base && out < out_end - 1) + *out++ = *base++; + s += 2; // skip "%b" + break; + } + case 'p': { + int pid = internal_getpid(); + char buf[32]; + char *buf_pos = buf + 32; + do { + *--buf_pos = (pid % 10) + '0'; + pid /= 10; + } while (pid); + while (buf_pos < buf + 32 && out < out_end - 1) + *out++ = *buf_pos++; + s += 2; // skip "%p" + break; + } + default: + *out++ = *s++; + break; + } } + CHECK(out < out_end - 1); *out = '\0'; } @@ -69,7 +96,7 @@ class FlagHandlerInclude : public FlagHandlerBase { bool Parse(const char *value) final { if (internal_strchr(value, '%')) { char *buf = (char *)MmapOrDie(kMaxPathLength, "FlagHandlerInclude"); - SubstituteBinaryName(value, buf, kMaxPathLength); + SubstituteForFlagValue(value, buf, kMaxPathLength); bool res = parser_->ParseFile(buf, ignore_missing_); UnmapOrDie(buf, kMaxPathLength); return res; @@ -99,4 +126,10 @@ void RegisterCommonFlags(FlagParser *parser, CommonFlags *cf) { RegisterIncludeFlags(parser, cf); } +void InitializeCommonFlags(CommonFlags *cf) { + // need to record coverage to generate coverage report. + cf->coverage |= cf->html_cov_report; + SetVerbosity(cf->verbosity); +} + } // namespace __sanitizer |