[PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu May 5 14:38:45 PDT 2016
rsmith added inline comments.
================
Comment at: docs/UndefinedBehaviorSanitizer.rst:235
@@ +234,3 @@
+UndefinedBehaviorSanitizer adds static check data for each check unless it is
+in trap mode. This check data includes the full file name. option
+``-fsanitize-undefined-strip-path-components=N`` can be used to trim this
----------------
"option" -> "Option" or "The option"
================
Comment at: lib/CodeGen/CGExpr.cpp:2385-2386
@@ +2384,4 @@
+ FilenameString = FilenameString.substr(I - E);
+ else
+ FilenameString = llvm::sys::path::filename(FilenameString);
+ } else if (PathComponentsToStrip > 0) {
----------------
This doesn't look right: if `I == E`, we were asked to keep at least as many components as there were, so we should keep the entire string. I think the `substr(I - E)` codepath is appropriate in either case here.
================
Comment at: test/CodeGen/ubsan-strip-path-components.cpp:6
@@ +5,3 @@
+// Try to strip too much:
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=-99999 | FileCheck %s -check-prefix=LAST-ONLY
+// RUN: %clang_cc1 %s -emit-llvm -fsanitize=unreachable -o - -fsanitize-undefined-strip-path-components=99999 | FileCheck %s -check-prefix=LAST-ONLY
----------------
I think this test is incorrect too.
http://reviews.llvm.org/D19666
More information about the cfe-commits
mailing list