summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2018-11-21 20:44:18 +0000
committerBill Wendling <isanbard@gmail.com>2018-11-21 20:44:18 +0000
commit4e64d31bc5f3acbb9dd104dd4ae7ef492d4fe031 (patch)
treedd55b3cf11351ddce77e676435622743879ad499 /lib/Analysis
parentcb1a557450468b15cb27dffafcaeba1a0a715e0d (diff)
downloadclang-4e64d31bc5f3acbb9dd104dd4ae7ef492d4fe031.tar.gz
Re-Reinstate 347294 with a fix for the failures.
Don't try to emit a scalar expression for a non-scalar argument to __builtin_constant_p(). Third time's a charm! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347417 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/CFG.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index cfda27dd37..96130c25be 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -1039,12 +1039,14 @@ private:
if (!areExprTypesCompatible(Expr1, Expr2))
return {};
- llvm::APSInt L1, L2;
-
- if (!Expr1->EvaluateAsInt(L1, *Context) ||
- !Expr2->EvaluateAsInt(L2, *Context))
+ Expr::EvalResult L1Result, L2Result;
+ if (!Expr1->EvaluateAsInt(L1Result, *Context) ||
+ !Expr2->EvaluateAsInt(L2Result, *Context))
return {};
+ llvm::APSInt L1 = L1Result.Val.getInt();
+ llvm::APSInt L2 = L2Result.Val.getInt();
+
// Can't compare signed with unsigned or with different bit width.
if (L1.isSigned() != L2.isSigned() || L1.getBitWidth() != L2.getBitWidth())
return {};
@@ -1134,13 +1136,16 @@ private:
case BO_And: {
// If either operand is zero, we know the value
// must be false.
- llvm::APSInt IntVal;
- if (Bop->getLHS()->EvaluateAsInt(IntVal, *Context)) {
+ Expr::EvalResult LHSResult;
+ if (Bop->getLHS()->EvaluateAsInt(LHSResult, *Context)) {
+ llvm::APSInt IntVal = LHSResult.Val.getInt();
if (!IntVal.getBoolValue()) {
return TryResult(false);
}
}
- if (Bop->getRHS()->EvaluateAsInt(IntVal, *Context)) {
+ Expr::EvalResult RHSResult;
+ if (Bop->getRHS()->EvaluateAsInt(RHSResult, *Context)) {
+ llvm::APSInt IntVal = RHSResult.Val.getInt();
if (!IntVal.getBoolValue()) {
return TryResult(false);
}