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
}
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) {
c += 1;
}
}
+
+void testSwitchWithSizeofs() {
+ switch (sizeof(char) == 1) { // expected-warning{{switch condition has boolean value}}
+ case sizeof(char):; // no-crash
+ }
+}