diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2009-03-28 01:22:36 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2009-03-28 01:22:36 +0000 |
commit | ab3a852ae713189444dcbf75e70accf1e8c2b7f2 (patch) | |
tree | 11ea284e9000f600d757c6715283fbc7ba2116f4 /lib/Analysis/GRExprEngine.cpp | |
parent | e5194ff24c224fa8ee83064dff73f62f745a4469 (diff) |
Change compound assignment operators to keep track of both the promoted
LHS type and the computation result type; this encodes information into
the AST which is otherwise non-obvious. Fix Sema to always come up with the
right answer for both of these types. Fix IRGen and the analyzer to
account for these changes. This fixes PR2601. The approach is inspired
by PR2601 comment 2.
Note that this changes real *= complex in CodeGen from a silent
miscompilation to an explicit error.
I'm not really sure that the analyzer changes are correct, or how to
test them... someone more familiar with the analyzer should check those
changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index 2f3f0bf5cc..70e6647c27 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -2810,16 +2810,18 @@ void GRExprEngine::VisitBinaryOperator(BinaryOperator* B, // The RHS is not Unknown. // Get the computation type. - QualType CTy = cast<CompoundAssignOperator>(B)->getComputationType(); + QualType CTy = cast<CompoundAssignOperator>(B)->getComputationResultType(); CTy = getContext().getCanonicalType(CTy); - + + QualType CLHSTy = cast<CompoundAssignOperator>(B)->getComputationLHSType(); + CLHSTy = getContext().getCanonicalType(CTy); + QualType LTy = getContext().getCanonicalType(LHS->getType()); QualType RTy = getContext().getCanonicalType(RHS->getType()); - - // Perform promotions. - if (LTy != CTy) V = EvalCast(V, CTy); - if (RTy != CTy) RightV = EvalCast(RightV, CTy); - + + // Promote LHS. + V = EvalCast(V, CLHSTy); + // Evaluate operands and promote to result type. if (RightV.isUndef()) { // Propagate undefined values (right-side). |