morehouse updated this revision to Diff 129318. morehouse added a comment. - Enable use-after-dtor instrumentation by default. - Make sanitize-no-dtor-callback.cpp test fail with UAD instrumentation. - Update test cases to reflect new default.
https://reviews.llvm.org/D37860 Files: clang/include/clang/Driver/SanitizerArgs.h clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp clang/test/Driver/fsanitize.c compiler-rt/test/msan/dtor-member.cc compiler-rt/test/msan/use-after-dtor.cc
Index: compiler-rt/test/msan/use-after-dtor.cc =================================================================== --- compiler-rt/test/msan/use-after-dtor.cc +++ compiler-rt/test/msan/use-after-dtor.cc @@ -1,14 +1,17 @@ // RUN: %clangxx_msan %s -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-UAD < %t.out // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-UAD < %t.out // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s < %t.out +// RUN: FileCheck %s --check-prefix=CHECK-UAD < %t.out // RUN: %clangxx_msan %s -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor -fsanitize-memory-track-origins -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t >%t.out 2>&1 -// RUN: FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out +// RUN: FileCheck %s --check-prefixes=CHECK-UAD,CHECK-ORIGINS < %t.out + +// RUN: %clangxx_msan %s -fno-sanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 not %run %t > %t.out 2>&1 +// RUN: FileCheck %s --check-prefix=CHECK-UAD-OFF < %t.out #include <sanitizer/msan_interface.h> #include <assert.h> @@ -32,14 +35,16 @@ Simple *s = new(&buf) Simple(); s->~Simple(); + fprintf(stderr, "\n"); // Need output to parse for CHECK-UAD-OFF case return s->x_; - // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value - // CHECK: {{#0 0x.* in main.*use-after-dtor.cc:}}[[@LINE-3]] + // CHECK-UAD: WARNING: MemorySanitizer: use-of-uninitialized-value + // CHECK-UAD: {{#0 0x.* in main.*use-after-dtor.cc:}}[[@LINE-3]] // CHECK-ORIGINS: Memory was marked as uninitialized // CHECK-ORIGINS: {{#0 0x.* in __sanitizer_dtor_callback}} // CHECK-ORIGINS: {{#1 0x.* in Simple::~Simple}} - // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*main}} + // CHECK-UAD: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*main}} + // CHECK-UAD-OFF-NOT: SUMMARY: MemorySanitizer: use-of-uninitialized-value } Index: compiler-rt/test/msan/dtor-member.cc =================================================================== --- compiler-rt/test/msan/dtor-member.cc +++ compiler-rt/test/msan/dtor-member.cc @@ -7,7 +7,7 @@ // RUN: %clangxx_msan %s -O2 -fsanitize=memory -fsanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 %run %t >%t.out 2>&1 // RUN: FileCheck %s < %t.out -// RUN: %clangxx_msan %s -fsanitize=memory -o %t && MSAN_OPTIONS=poison_in_dtor=1 %run %t >%t.out 2>&1 +// RUN: %clangxx_msan %s -fsanitize=memory -fno-sanitize-memory-use-after-dtor -o %t && MSAN_OPTIONS=poison_in_dtor=1 %run %t >%t.out 2>&1 // RUN: FileCheck %s --check-prefix=CHECK-NO-FLAG < %t.out // RUN: %clangxx_msan -fsanitize=memory -fsanitize-memory-use-after-dtor %s -o %t && MSAN_OPTIONS=poison_in_dtor=0 %run %t >%t.out 2>&1 Index: clang/test/Driver/fsanitize.c =================================================================== --- clang/test/Driver/fsanitize.c +++ clang/test/Driver/fsanitize.c @@ -184,11 +184,11 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-use-after-dtor %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-DTOR // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fno-sanitize-memory-use-after-dtor -fsanitize-memory-use-after-dtor %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-DTOR +// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-DTOR // CHECK-USE-AFTER-DTOR: -cc1{{.*}}-fsanitize-memory-use-after-dtor // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fno-sanitize-memory-use-after-dtor %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-DTOR-OFF // RUN: %clang -target x86_64-linux-gnu -fsanitize=memory -fsanitize-memory-use-after-dtor -fno-sanitize-memory-use-after-dtor %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-DTOR-OFF -// RUN: %clang -target x86_64-linux-gnu -fsanitize=memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-DTOR-OFF // CHECK-USE-AFTER-DTOR-OFF-NOT: -cc1{{.*}}memory-use-after-dtor // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-field-padding=0 %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-FIELD-PADDING-0 Index: clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp =================================================================== --- clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp +++ clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp @@ -1,15 +1,17 @@ -// Test without the flag -fsanitize-memory-use-after-dtor, to ensure that +// Test with the flag -fno-sanitize-memory-use-after-dtor, to ensure that // instrumentation is not erroneously inserted -// RUN: %clang_cc1 -fsanitize=memory -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fsanitize=memory -fno-sanitize-memory-use-after-dtor -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s struct Simple { + int x; ~Simple() {} }; Simple s; // CHECK-LABEL: define {{.*}}SimpleD1Ev // CHECK-NOT: call void @__sanitizer_dtor_callback struct Inlined { + int x; inline ~Inlined() {} }; Inlined i; Index: clang/include/clang/Driver/SanitizerArgs.h =================================================================== --- clang/include/clang/Driver/SanitizerArgs.h +++ clang/include/clang/Driver/SanitizerArgs.h @@ -30,7 +30,7 @@ std::vector<std::string> ExtraDeps; int CoverageFeatures = 0; int MsanTrackOrigins = 0; - bool MsanUseAfterDtor = false; + bool MsanUseAfterDtor = true; bool CfiCrossDso = false; bool CfiICallGeneralizePointers = false; int AsanFieldPadding = 0;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits