Skip to content

Commit

Permalink
[NFC][sanitizer] Add test for command line flag for enable-noundef-an…
Browse files Browse the repository at this point in the history
…alysis.

A simple unit test to demonstrate the flags working correctly.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D114485
  • Loading branch information
kda committed Dec 3, 2021
1 parent 4748cc6 commit 6c2be30
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 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

0 comments on commit 6c2be30

Please sign in to comment.