aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2018-11-12 20:11:57 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2018-11-12 20:11:57 +0000
commitbd844e0de7aca247ec0a1a6ecd2742d99a86d15d (patch)
tree52be3d6035113a40dc3b16167fe9954fefc0f1d0 /clang/lib/AST/ExprConstant.cpp
parentb8d8db30ea54a9394e5387410d98fcaae6cd7336 (diff)
downloadllvm-bd844e0de7aca247ec0a1a6ecd2742d99a86d15d.zip
llvm-bd844e0de7aca247ec0a1a6ecd2742d99a86d15d.tar.gz
llvm-bd844e0de7aca247ec0a1a6ecd2742d99a86d15d.tar.bz2
PR39628 Treat all non-zero values as 'true' in bool compound-assignment
in constant evaluation, not just odd values. llvm-svn: 346699
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3080056..b0dc7d4 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2074,11 +2074,12 @@ static APSInt HandleIntToIntCast(EvalInfo &Info, const Expr *E,
QualType DestType, QualType SrcType,
const APSInt &Value) {
unsigned DestWidth = Info.Ctx.getIntWidth(DestType);
- APSInt Result = Value;
// Figure out if this is a truncate, extend or noop cast.
// If the input is signed, do a sign extend, noop, or truncate.
- Result = Result.extOrTrunc(DestWidth);
+ APSInt Result = Value.extOrTrunc(DestWidth);
Result.setIsUnsigned(DestType->isUnsignedIntegerOrEnumerationType());
+ if (DestType->isBooleanType())
+ Result = Value.getBoolValue();
return Result;
}