[PATCH] D40940: [ubsan] Use pass_object_size info in bounds checks
George Burgess IV via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 7 11:53:04 PST 2017
george.burgess.iv added a comment.
Thanks for this!
It's interesting to me that these array-bound checks don't seem to use `@llvm.objectsize` in some form already. I can't find any notes about it grepping through git/source, so I'm happy with it.
================
Comment at: lib/CodeGen/CGExpr.cpp:819
+ QualType EltTy) {
+ auto *DRE = dyn_cast<DeclRefExpr>(E->IgnoreImpCasts());
+ if (!DRE)
----------------
nit: would `IgnoreParenImpCasts` be better?
================
Comment at: lib/CodeGen/CGExpr.cpp:828
+ // Find the implicit size parameter.
+ auto SizeDeclIt = SizeArguments.find(PVD);
+ if (SizeDeclIt == SizeArguments.end())
----------------
We should probably only do this if the argument to `pass_object_size` is `0` or `1`. `2` and `3` give lower-bounds on size (and a default value of 0), which could result in false-positives.
(And please add a test that we don't do this for 2 or 3.)
https://reviews.llvm.org/D40940
More information about the cfe-commits
mailing list