[PATCH] D19666: [ubsan] Add -fubsan-strip-path-components=N

Filipe Cabecinhas via cfe-commits cfe-commits at lists.llvm.org
Fri May 6 00:51:59 PDT 2016


filcab added inline comments.

================
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) {
----------------
rsmith wrote:
> 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.
Ah, right.
My rationale was "if the number of stuff to strip (positive or negative) is greater than the number of path components, keep only the filename", which doesn't really fit with the negative case.
Will change today.

================
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
----------------
rsmith wrote:
> I think this test is incorrect too.
Yep, test update coming.


http://reviews.llvm.org/D19666





More information about the cfe-commits mailing list