diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-06-19 17:55:38 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-06-19 17:55:38 +0000 |
commit | 46c82ab9940911dc1bc8fd609cc9af28e733a0ec (patch) | |
tree | a2532b5513e24804ef67876e17ae6d34e013b0cc /clang/lib/Analysis/GRExprEngine.cpp | |
parent | d6530872f390e0ec18e144874f704537aef6c362 (diff) | |
download | bcm5719-llvm-46c82ab9940911dc1bc8fd609cc9af28e733a0ec.tar.gz bcm5719-llvm-46c82ab9940911dc1bc8fd609cc9af28e733a0ec.zip |
Introduce initial transfer function support for __imag__ and __real__. We don't
have complex RValues yet, so this logic is only fully implemented when __imag__
and __real__ are used on non-complex types.
llvm-svn: 52501
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index 2580172d530..e8c1ec57a98 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -1596,7 +1596,7 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, default: break; - + case UnaryOperator::Deref: { Expr* Ex = U->getSubExpr()->IgnoreParens(); @@ -1616,10 +1616,57 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, return; } - + case UnaryOperator::Real: { + + Expr* Ex = U->getSubExpr()->IgnoreParens(); + NodeSet Tmp; + Visit(Ex, Pred, Tmp); + + for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { + + // FIXME: We don't have complex RValues yet. + if (Ex->getType()->isAnyComplexType()) { + // Just report "Unknown." + Dst.Add(*I); + continue; + } + + // For all other types, UnaryOperator::Real is an identity operation. + assert (U->getType() == Ex->getType()); + ValueState* St = GetState(*I); + MakeNode(Dst, U, *I, SetRVal(St, U, GetRVal(St, Ex))); + } + + return; + } + + case UnaryOperator::Imag: { + + Expr* Ex = U->getSubExpr()->IgnoreParens(); + NodeSet Tmp; + Visit(Ex, Pred, Tmp); + + for (NodeSet::iterator I=Tmp.begin(), E=Tmp.end(); I!=E; ++I) { + // FIXME: We don't have complex RValues yet. + if (Ex->getType()->isAnyComplexType()) { + // Just report "Unknown." + Dst.Add(*I); + continue; + } + + // For all other types, UnaryOperator::Float returns 0. + assert (Ex->getType()->isIntegerType()); + ValueState* St = GetState(*I); + RVal X = NonLVal::MakeVal(BasicVals, 0, Ex->getType()); + MakeNode(Dst, U, *I, SetRVal(St, U, X)); + } + + return; + } + + // FIXME: Just report "Unknown" for OffsetOf. case UnaryOperator::OffsetOf: - // FIXME: Just report "Unknown" known for OffsetOf. Dst.Add(Pred); return; |