[PATCH] D122513: [analyzer] Fix "RhsLoc and LhsLoc bitwidth must be same"
Vince Bridgers via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 26 16:28:16 PDT 2022
vabridgers added a comment.
Hi @NoQ, good question :) When I looked into the existing SimpleSValBuilder.cpp code, I found a few places that did width modifications so I concluded this was the correct and accepted way to handle this. A few notes to help decide if my suggestion is correct or is there's a different concrete way to move forward. Looks like we get address space information in the AST, and it's up to the AST client to do the needful (whatever that is). We do get warnings and/or errors in some cases, but it seems this is a case where it's implied that the "void *" cast is same address space as the LHS of the comparison. I'll check the Embedded C Spec to see what it says about this.
The Sample function looks like this:
int fn1() {
int val = 0;
__attribute__((address_space(3))) int *dptr = val;
return dptr == (void *)0;
}
The AST for the return statement "return dptr == (void *)0;" looks like this:
`-ReturnStmt 0x118f2078 <line:21:3, col:26>
`-BinaryOperator 0x118f2058 <col:10, col:26> 'int' '=='
|-ImplicitCastExpr 0x118f2028 <col:10> '__attribute__((address_space(3))) int *' <LValueToRValue>
| `-DeclRefExpr 0x118f1fa8 <col:10> '__attribute__((address_space(3))) int *' lvalue Var 0x118f1af0 'dptr' '__attribute__((address_space(3))) int *'
`-ImplicitCastExpr 0x118f2040 <col:18, col:26> '__attribute__((address_space(3))) int *' <AddressSpaceConversion>
`-CStyleCastExpr 0x118f2000 <col:18, col:26> 'void *' <NullToPointer>
`-IntegerLiteral 0x118f1fc8 <col:26> 'int' 0
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122513/new/
https://reviews.llvm.org/D122513
More information about the cfe-commits
mailing list