[PATCH] D130510: Missing tautological compare warnings due to unary operators
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 16 10:26:40 PDT 2022
aaron.ballman added a comment.
Nice! Just a few more small nits to fix that I can see.
================
Comment at: clang/lib/Analysis/CFG.cpp:1016-1021
+ Optional<llvm::APInt> getIntegerLiteralSubexpressionValue(const Expr *E) {
+
+ const auto *UnOp = dyn_cast<UnaryOperator>(E->IgnoreParens());
+
+ // If unary.
+ if (UnOp) {
----------------
Oops, I realized we could simplify this further and keep `UnOp` scoped more tightly to where it's used.
================
Comment at: clang/lib/Analysis/CFG.cpp:1026-1032
+ if (const auto *IntLiteral = dyn_cast<IntegerLiteral>(SubExpr)) {
+
+ llvm::APInt Value = IntLiteral->getValue();
+ UnaryOperatorKind OpCode = UnOp->getOpcode();
+
+ // Perform the operation manually.
+ switch (OpCode) {
----------------
Another simplification to scope things more tightly.
================
Comment at: clang/lib/Analysis/CFG.cpp:1045-1047
+ }
+
+ } else if (const auto *IntLiteral =
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130510/new/
https://reviews.llvm.org/D130510
More information about the cfe-commits
mailing list