r320185 - [ubsan] array-bounds: Ignore params with constant size
Vedant Kumar via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 8 11:51:42 PST 2017
Author: vedantk
Date: Fri Dec 8 11:51:42 2017
New Revision: 320185
URL: http://llvm.org/viewvc/llvm-project?rev=320185&view=rev
Log:
[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
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGen/ubsan-pass-object-size.c
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=320185&r1=320184&r2=320185&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Fri Dec 8 11:51:42 2017
@@ -829,14 +829,6 @@ llvm::Value *CodeGenFunction::LoadPassed
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;
Modified: cfe/trunk/test/CodeGen/ubsan-pass-object-size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ubsan-pass-object-size.c?rev=320185&r1=320184&r2=320185&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/ubsan-pass-object-size.c (original)
+++ cfe/trunk/test/CodeGen/ubsan-pass-object-size.c Fri Dec 8 11:51:42 2017
@@ -55,8 +55,7 @@ int pat(int *const p __attribute__((pass
// 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];
}
More information about the cfe-commits
mailing list