forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
d: Add `@no_sanitize' attribute to compiler and library.
The `@no_sanitize' attribute disables a particular sanitizer for this function, analogous to `__attribute__((no_sanitize))'. The library also defines `@noSanitize' to be compatible with the LLVM D compiler's `ldc.attributes'. gcc/d/ChangeLog: * d-attribs.cc (d_langhook_attribute_table): Add no_sanitize. (d_handle_no_sanitize_attribute): New function. libphobos/ChangeLog: * libdruntime/gcc/attributes.d (no_sanitize): Define. (noSanitize): Define. gcc/testsuite/ChangeLog: * gdc.dg/asan/attr_no_sanitize1.d: New test. * gdc.dg/ubsan/attr_no_sanitize2.d: New test.
- Loading branch information
Showing
4 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// { dg-options "-fsanitize=address -O3 -fdump-tree-optimized" } | ||
// { dg-do compile } | ||
|
||
import gcc.attributes; | ||
|
||
@no_sanitize("address") | ||
__gshared int globalvar1; // { dg-warning "attribute ignored" } | ||
|
||
pragma(inline, true) | ||
@no_sanitize("address") | ||
void test_no_address() | ||
{ | ||
counter++; | ||
} | ||
|
||
pragma(inline, true) | ||
void test_sanitize()() | ||
{ | ||
counter++; | ||
} | ||
|
||
void func1() | ||
{ | ||
counter++; | ||
test_no_address(); | ||
test_sanitize(); | ||
} | ||
|
||
private int counter; | ||
|
||
// { dg-final { scan-tree-dump-times "Function test_no_address" 1 "optimized" } } | ||
// { dg-final { scan-tree-dump-times "Function test_sanitize" 0 "optimized" } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// { dg-options "-fsanitize=undefined -O3 -fdump-tree-optimized" } | ||
// { dg-do compile } | ||
|
||
import gcc.attributes; | ||
|
||
@no_sanitize("invalid_name") | ||
void func1() { } // { dg-warning "attribute directive ignored" } | ||
|
||
@no_sanitize("address") | ||
@no_sanitize("thread") | ||
@no_sanitize("address,thread") | ||
@no_sanitize("address", "undefined") | ||
@no_sanitize("undefined", "leak", "return,null,bounds") | ||
void func2() { } | ||
|
||
pragma(inline, true) | ||
@no_sanitize("undefined") | ||
void test_no_undefined()() | ||
{ | ||
counter++; | ||
} | ||
|
||
pragma(inline, true) | ||
void test_sanitize()() | ||
{ | ||
counter++; | ||
} | ||
|
||
void func3() | ||
{ | ||
counter++; | ||
test_no_undefined(); | ||
test_sanitize(); | ||
} | ||
|
||
private __gshared int counter; | ||
|
||
// { dg-final { scan-tree-dump-times "Function test_no_undefined" 1 "optimized" } } | ||
// { dg-final { scan-tree-dump-times "Function test_sanitize" 0 "optimized" } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters