[compiler-rt] 6c2be30 - [NFC][sanitizer] Add test for command line flag for enable-noundef-analysis.

Kevin Athey via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 3 15:44:40 PST 2021


Author: Kevin Athey
Date: 2021-12-03T15:44:36-08:00
New Revision: 6c2be3015e07f25912b8cd5b75214c532f568638

URL: https://github.com/llvm/llvm-project/commit/6c2be3015e07f25912b8cd5b75214c532f568638
DIFF: https://github.com/llvm/llvm-project/commit/6c2be3015e07f25912b8cd5b75214c532f568638.diff

LOG: [NFC][sanitizer] Add test for command line flag for enable-noundef-analysis.

A simple unit test to demonstrate the flags working correctly.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114485

Added: 
    compiler-rt/test/msan/noundef_analysis.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/msan/noundef_analysis.cpp b/compiler-rt/test/msan/noundef_analysis.cpp
new file mode 100644
index 000000000000..d0008648e9f6
--- /dev/null
+++ b/compiler-rt/test/msan/noundef_analysis.cpp
@@ -0,0 +1,22 @@
+// RUN: %clangxx_msan %s -o %t && %run %t >%t.out 2>&1
+// RUN: FileCheck %s --check-prefix=MISSED --allow-empty < %t.out
+// RUN: %clangxx_msan %s -Xclang -enable-noundef-analysis -mllvm -msan-eager-checks=1 -o %t && not %run %t >%t.out 2>&1
+// RUN: FileCheck %s < %t.out
+
+struct SimpleStruct {
+  int md1;
+};
+
+static int sink;
+
+static void examineValue(int x) { sink = x; }
+
+int main(int argc, char *argv[]) {
+  auto ss = new SimpleStruct;
+  examineValue(ss->md1);
+
+  return 0;
+}
+
+// CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
+// MISSED-NOT: use-of-uninitialized-value


        


More information about the llvm-commits mailing list