[PATCH] D69546: [SanitizerCommon] Print the current value of options when printing out help.

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 10:54:46 PDT 2019


eugenis added inline comments.


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.cpp:69
+    else
+      Printf("\t%s\n\t\t- %s\n", flags_[i].name, flags_[i].desc);
+  }
----------------
How about printing a truncated value in this case, maybe replacing the last few characters with dots (...)? At least for string flags.



================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h:78
+    str_to_use = reinterpret_cast<const char *>(false_str);
+  }
+  if (size < copy_count)
----------------
const char *str = *t_ ? "true" : "false;
uptr copy_count = internal_strnlen(str, size);



================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h:108
+  int data = *t_;
+  uptr num_symbols_should_write = internal_snprintf(buffer, size, "%d", data);
+  // Not `<=` because `num_symbols_should_write` does not include null
----------------
default integer promotions apply to varargs


================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_flag_parser.h:128
+    return false;
+  bool success = internal_memcpy(buffer, *t_, str_length);
+  CHECK(buffer[str_length - 1] == '\0');
----------------
all of this can be replaced with internal_strncpy


================
Comment at: compiler-rt/test/sanitizer_common/TestCases/options-help-current-values.cpp:2
+// RUN: %clangxx -O0 %s -o %t
+// RUN: %env_tool_opts=help=1 %run %t 2>&1 | FileCheck %s
+
----------------
Remove options-help.cpp test, this new one is strictly better.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69546/new/

https://reviews.llvm.org/D69546





More information about the llvm-commits mailing list