diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-05-15 18:33:32 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-05-15 18:33:32 +0000 |
commit | 915df9968b6524d1858884ae5694812b6831a1ac (patch) | |
tree | b7e541fa454fbea85db502afff25cb5d2533bd43 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 25e2500ac866365beaf747e2b0c926b9db4f721b (diff) | |
download | bcm5719-llvm-915df9968b6524d1858884ae5694812b6831a1ac.tar.gz bcm5719-llvm-915df9968b6524d1858884ae5694812b6831a1ac.zip |
Implement no_sanitize attribute.
Differential Revision: http://reviews.llvm.org/D9631
llvm-svn: 237463
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index aae2ae0b41b..3c5bc1c9d9c 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -608,6 +608,20 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, if (CGM.isInSanitizerBlacklist(Fn, Loc)) SanOpts.clear(); + if (D) { + // Apply the no_sanitize* attributes to SanOpts. + for (auto Attr : D->specific_attrs<NoSanitizeAttr>()) + SanOpts.Mask &= ~Attr->getMask(); + } + + // Apply sanitizer attributes to the function. + if (SanOpts.has(SanitizerKind::Address)) + Fn->addFnAttr(llvm::Attribute::SanitizeAddress); + if (SanOpts.has(SanitizerKind::Thread)) + Fn->addFnAttr(llvm::Attribute::SanitizeThread); + if (SanOpts.has(SanitizerKind::Memory)) + Fn->addFnAttr(llvm::Attribute::SanitizeMemory); + // Pass inline keyword to optimizer if it appears explicitly on any // declaration. Also, in the case of -fno-inline attach NoInline // attribute to all function that are not marked AlwaysInline. |