diff options
author | Vedant Kumar <vsk@apple.com> | 2017-06-16 03:27:36 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2017-06-16 03:27:36 +0000 |
commit | c420d14b29e991b234e1ac3ad5f8d00abd0ed1dc (patch) | |
tree | 4ae95871985360ab2176a3098778bec2130d9b04 | |
parent | 10bbc4f99eda44d96df29bba74b6a0d6cc226113 (diff) | |
download | bcm5719-llvm-c420d14b29e991b234e1ac3ad5f8d00abd0ed1dc.tar.gz bcm5719-llvm-c420d14b29e991b234e1ac3ad5f8d00abd0ed1dc.zip |
[ubsan] PR33081: Skip the standard type checks for volatile
Skip checks for null dereference, alignment violation, object size
violation, and dynamic type violation if the pointer points to volatile
data.
Differential Revision: https://reviews.llvm.org/D34262
llvm-svn: 305546
-rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 5 | ||||
-rw-r--r-- | clang/test/CodeGen/ubsan-volatile.c | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 15829888ead..7359006677f 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -549,6 +549,11 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, if (Ptr->getType()->getPointerAddressSpace()) return; + // Don't check pointers to volatile data. The behavior here is implementation- + // defined. + if (Ty.isVolatileQualified()) + return; + SanitizerScope SanScope(this); SmallVector<std::pair<llvm::Value *, SanitizerMask>, 3> Checks; diff --git a/clang/test/CodeGen/ubsan-volatile.c b/clang/test/CodeGen/ubsan-volatile.c new file mode 100644 index 00000000000..ce54aada81f --- /dev/null +++ b/clang/test/CodeGen/ubsan-volatile.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsanitize=null,alignment,object-size,vptr -S -emit-llvm %s -o - | FileCheck %s + +// CHECK: @volatile_null_deref +void volatile_null_deref(volatile int *p) { + // CHECK-NOT: call{{.*}}ubsan + *p; +} |