diff options
| author | Vedant Kumar <vsk@apple.com> | 2017-12-08 19:51:42 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2017-12-08 19:51:42 +0000 |
| commit | 9174b684b7cd13e26b0eb35e33a67a9b6e971862 (patch) | |
| tree | 617b15dbddfacb8dd9b884c0d86745364b3053ab | |
| parent | d9073510b7c20c8a758c3fbed2519fc4f4a1066d (diff) | |
| download | bcm5719-llvm-9174b684b7cd13e26b0eb35e33a67a9b6e971862.tar.gz bcm5719-llvm-9174b684b7cd13e26b0eb35e33a67a9b6e971862.zip | |
[ubsan] array-bounds: Ignore params with constant size
This is a follow-up to r320128. Eli pointed out that there is some gray
area in the language standard about whether the constant size is exact,
or a lower bound.
https://reviews.llvm.org/D40940
llvm-svn: 320185
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 8 | ||||
| -rw-r--r-- | clang/test/CodeGen/ubsan-pass-object-size.c | 3 |
2 files changed, 1 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 64af2096c98..c61bc0d6422 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -829,14 +829,6 @@ llvm::Value *CodeGenFunction::LoadPassedObjectSize(const Expr *E, if (!ParamDecl) return nullptr; - // Arrays don't have pass_object_size attributes, but if they have a constant - // size modifier it's the array size (C99 6.5.7.2p1). - if (auto *DecayedArrayTy = dyn_cast<DecayedType>(ParamDecl->getType())) - if (auto *ArrayTy = - dyn_cast<ConstantArrayType>(DecayedArrayTy->getOriginalType())) - return llvm::ConstantInt::get(SizeTy, - ArrayTy->getSize().getLimitedValue()); - auto *POSAttr = ParamDecl->getAttr<PassObjectSizeAttr>(); if (!POSAttr) return nullptr; diff --git a/clang/test/CodeGen/ubsan-pass-object-size.c b/clang/test/CodeGen/ubsan-pass-object-size.c index 67970d2918a..d5d4f5a9e42 100644 --- a/clang/test/CodeGen/ubsan-pass-object-size.c +++ b/clang/test/CodeGen/ubsan-pass-object-size.c @@ -55,8 +55,7 @@ int pat(int *const p __attribute__((pass_object_size(3))), int n) { // CHECK-LABEL: define i32 @cat( int cat(int p[static 10], int n) { - // CHECK: icmp ult i64 {{.*}}, 10, !nosanitize - // CHECK: __ubsan_handle_out_of_bounds + // CHECK-NOT: __ubsan_handle_out_of_bounds // CHECK: ret i32 return p[n]; } |

