forked from OSchip/llvm-project
[analyzer] pr37204: Take signedness into account in getTruthValue().
It now actually produces a signed APSInt when the QualType passed into it is signed, which is what any caller would expect. Fixes a couple of crashes. Differential Revision: https://reviews.llvm.org/D50363 llvm-svn: 339088
This commit is contained in:
parent
5a5b867422
commit
afdce6684e
|
@ -211,7 +211,8 @@ public:
|
|||
}
|
||||
|
||||
const llvm::APSInt &getTruthValue(bool b, QualType T) {
|
||||
return getValue(b ? 1 : 0, Ctx.getIntWidth(T), true);
|
||||
return getValue(b ? 1 : 0, Ctx.getIntWidth(T),
|
||||
T->isUnsignedIntegerOrEnumerationType());
|
||||
}
|
||||
|
||||
const llvm::APSInt &getTruthValue(bool b) {
|
||||
|
|
|
@ -182,3 +182,9 @@ void testLocNonLocSymbolRemainder(int a, int *b) {
|
|||
c += 1;
|
||||
}
|
||||
}
|
||||
|
||||
void testSwitchWithSizeofs() {
|
||||
switch (sizeof(char) == 1) { // expected-warning{{switch condition has boolean value}}
|
||||
case sizeof(char):; // no-crash
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue