diff options
author | Kostya Serebryany <kcc@google.com> | 2014-10-31 19:01:02 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2014-10-31 19:01:02 +0000 |
commit | 5f1b4e8f58cdad859568f7bf213fd6ad62dbb072 (patch) | |
tree | 79f00ed903539a528a7bc6a21a6318d879889cbd /clang/test/CodeGen/sanitize-address-field-padding.cpp | |
parent | ea48bdc702035c369af37ff462cd0dd0925b2d8d (diff) | |
download | bcm5719-llvm-5f1b4e8f58cdad859568f7bf213fd6ad62dbb072.tar.gz bcm5719-llvm-5f1b4e8f58cdad859568f7bf213fd6ad62dbb072.zip |
ignore -mconstructor-aliases when adding field paddings for asan
Summary:
When we are adding field paddings for asan even an empty dtor has to remain in the code,
so we ignore -mconstructor-aliases if the paddings are going to be added.
Test Plan: added a test
Reviewers: rsmith, rnk, rafael
Reviewed By: rafael
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6038
llvm-svn: 220986
Diffstat (limited to 'clang/test/CodeGen/sanitize-address-field-padding.cpp')
-rw-r--r-- | clang/test/CodeGen/sanitize-address-field-padding.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/CodeGen/sanitize-address-field-padding.cpp b/clang/test/CodeGen/sanitize-address-field-padding.cpp index 5f049bb0058..0d09a133d43 100644 --- a/clang/test/CodeGen/sanitize-address-field-padding.cpp +++ b/clang/test/CodeGen/sanitize-address-field-padding.cpp @@ -2,6 +2,7 @@ // RUN: echo 'type:SomeNamespace::BlacklistedByName=field-padding' > %t.type.blacklist // RUN: echo 'src:*sanitize-address-field-padding.cpp=field-padding' > %t.file.blacklist // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.type.blacklist -Rsanitize-address -emit-llvm -o - %s -O1 -mconstructor-aliases 2>&1 | FileCheck %s --check-prefix=WITH_CTOR_ALIASES // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsanitize=address -fsanitize-address-field-padding=1 -fsanitize-blacklist=%t.file.blacklist -Rsanitize-address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=FILE_BLACKLIST // RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=NO_PADDING // REQUIRES: shell @@ -193,3 +194,27 @@ ExternCStruct extern_C_struct; // CHECK-NOT: __asan_poison_intra_object_redzone // CHECK: ret void // + +struct WithVirtualDtor { + virtual ~WithVirtualDtor(); + int x, y; +}; +struct InheritsFrom_WithVirtualDtor: WithVirtualDtor { + int a, b; + InheritsFrom_WithVirtualDtor() {} + ~InheritsFrom_WithVirtualDtor() {} +}; + +void Create_InheritsFrom_WithVirtualDtor() { + InheritsFrom_WithVirtualDtor x; +} + + +// Make sure the dtor of InheritsFrom_WithVirtualDtor remains in the code, +// i.e. we ignore -mconstructor-aliases when field paddings are added +// because the paddings in InheritsFrom_WithVirtualDtor needs to be unpoisoned +// in the dtor. +// WITH_CTOR_ALIASES-LABEL: define void @_Z35Create_InheritsFrom_WithVirtualDtor +// WITH_CTOR_ALIASES-NOT: call void @_ZN15WithVirtualDtorD2Ev +// WITH_CTOR_ALIASES: call void @_ZN28InheritsFrom_WithVirtualDtorD2Ev +// WITH_CTOR_ALIASES: ret void |