[clang] [Clang] Add wraps attribute (for granular integer overflow handling) (PR #86618)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 10 07:01:08 PDT 2024
================
@@ -2237,6 +2237,21 @@ bool BinaryOperator::isNullPointerArithmeticExtension(ASTContext &Ctx,
return true;
}
+bool BinaryOperator::oneOfWraps(const ASTContext &Ctx) const {
+ llvm::SmallVector<Expr *, 2> Both = {getLHS(), getRHS()};
----------------
erichkeane wrote:
Suggest instead:
```
return children().end() != llvm::find_if(children(), [](const Expr *E) {
return E && !E->IgnoreParenImpCasts()->getType().isNull() && E->IgnoreParenImpCasts()->getType()->hasAttr(attr::Wraps);
});
```
Alternatively, you could make that significantly easier by implementing `hasWrapAttr` on `QualType` which could just do `return !isNull() && getTypePtr()->hasAttr(attr::Wraps);`.
https://github.com/llvm/llvm-project/pull/86618
More information about the cfe-commits
mailing list