[clang] [alpha.webkit.UncountedCallArgsChecker] Allow trivial operator++ (PR #91102)
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Wed May 8 13:18:29 PDT 2024
================
@@ -309,21 +309,8 @@ class TrivialFunctionAnalysisVisitor
bool VisitDefaultStmt(const DefaultStmt *DS) { return VisitChildren(DS); }
bool VisitUnaryOperator(const UnaryOperator *UO) {
- // Operator '*' and '!' are allowed as long as the operand is trivial.
- auto op = UO->getOpcode();
- if (op == UO_Deref || op == UO_AddrOf || op == UO_LNot || op == UO_Not)
- return Visit(UO->getSubExpr());
-
- if (UO->isIncrementOp() || UO->isDecrementOp()) {
- // Allow increment or decrement of a POD type.
- if (auto *RefExpr = dyn_cast<DeclRefExpr>(UO->getSubExpr())) {
- if (auto *Decl = dyn_cast<VarDecl>(RefExpr->getDecl()))
- return Decl->isLocalVarDeclOrParm() &&
- Decl->getType().isPODType(Decl->getASTContext());
- }
- }
- // Other operators are non-trivial.
- return false;
+ // Unary operators are trivial if its operand is trivial.
+ return Visit(UO->getSubExpr());
----------------
haoNoQ wrote:
When blanket-approving all operators, it's probably a good idea to go through the current list to see if any exceptions need to be made. Eg. for unary operators it's https://github.com/llvm/llvm-project/blob/llvmorg-18-init/clang/include/clang/AST/OperationKinds.def#L417 and binary operators are just above that. But I don't immediately see anything problematic in that list. (Is `co_await` blessed?)
https://github.com/llvm/llvm-project/pull/91102
More information about the cfe-commits
mailing list