diff options
author | Muhammad Usman Shahid <codesbyusman@gmail.com> | 2022-07-28 07:45:28 -0400 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2022-07-28 07:45:28 -0400 |
commit | 0cc3c184c784d5f0d55de8ad0a9eeee876acd149 (patch) | |
tree | 2205eddeba010f8dd0aedf70f192f7a860733c9e /lldb/source/Plugins/ScriptInterpreter/Python | |
parent | 955cc56af448301e2d353df90ca1f0c6a74118f2 (diff) | |
download | llvm-0cc3c184c784d5f0d55de8ad0a9eeee876acd149.zip llvm-0cc3c184c784d5f0d55de8ad0a9eeee876acd149.tar.gz llvm-0cc3c184c784d5f0d55de8ad0a9eeee876acd149.tar.bz2 |
Missing tautological compare warnings due to unary operators
The patch mainly focuses on the lack of warnings for
-Wtautological-compare. It works fine for positive numbers but doesn't
for negative numbers. This is because the warning explicitly checks for
an IntegerLiteral AST node, but -1 is represented by a UnaryOperator
with an IntegerLiteral sub-Expr.
For the below code we have warnings:
if (0 == (5 | x)) {}
but not for
if (0 == (-5 | x)) {}
This patch changes the analysis to not look at the AST node directly to
see if it is an IntegerLiteral, but instead attempts to evaluate the
expression to see if it is an integer constant expression. This handles
unary negation signs, but also handles all the other possible operators
as well.
Fixes #42918
Differential Revision: https://reviews.llvm.org/D130510
Diffstat (limited to 'lldb/source/Plugins/ScriptInterpreter/Python')
0 files changed, 0 insertions, 0 deletions