aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-09-15 00:40:32 +0000
committerTed Kremenek <kremenek@apple.com>2009-09-15 00:40:32 +0000
commite2b5744f9a8a08129f1d51e99410a3f3cdda0c91 (patch)
tree89aab72c1ecb285aa5c7a9e55806a9f85e152a11 /lib/Analysis/GRExprEngine.cpp
parent78cf9a26d27349a7b9ae83a0b7d5451571b9b41e (diff)
Add static analyzer transfer function support for __builtin_offsetof.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81820 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r--lib/Analysis/GRExprEngine.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index 8214199f42..0e08cd257b 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -2430,10 +2430,15 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, ExplodedNode* Pred,
return;
}
- // FIXME: Just report "Unknown" for OffsetOf.
- case UnaryOperator::OffsetOf:
- Dst.Add(Pred);
+ case UnaryOperator::OffsetOf: {
+ const APSInt &IV = U->EvaluateAsInt(getContext());
+ assert(IV.getBitWidth() == getContext().getTypeSize(U->getType()));
+ assert(U->getType()->isIntegerType());
+ assert(IV.isSigned() == U->getType()->isSignedIntegerType());
+ SVal X = ValMgr.makeIntVal(IV);
+ MakeNode(Dst, U, Pred, GetState(Pred)->BindExpr(U, X));
return;
+ }
case UnaryOperator::Plus: assert (!asLValue); // FALL-THROUGH.
case UnaryOperator::Extension: {