summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-03-15 03:13:20 +0000
committerTed Kremenek <kremenek@apple.com>2008-03-15 03:13:20 +0000
commitae5b78615c9211daced23798a6af57e6f9622ba6 (patch)
tree8f0c98a15574a3e3d661600535dbe5f2ba7fb433 /clang
parent5c98d1d6413f6eb0d3317be06603d530d11aa836 (diff)
downloadbcm5719-llvm-ae5b78615c9211daced23798a6af57e6f9622ba6.tar.gz
bcm5719-llvm-ae5b78615c9211daced23798a6af57e6f9622ba6.zip
Implement transfer function logic for alignof operator (types).
llvm-svn: 48386
Diffstat (limited to 'clang')
-rw-r--r--clang/Analysis/GRExprEngine.cpp32
1 files changed, 16 insertions, 16 deletions
diff --git a/clang/Analysis/GRExprEngine.cpp b/clang/Analysis/GRExprEngine.cpp
index a32999eb513..5d6c7122c1b 100644
--- a/clang/Analysis/GRExprEngine.cpp
+++ b/clang/Analysis/GRExprEngine.cpp
@@ -729,27 +729,27 @@ void GRExprEngine::VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr* Ex,
NodeTy* Pred,
NodeSet& Dst) {
- assert (Ex->isSizeOf() && "FIXME: AlignOf(Expr) not yet implemented.");
-
- // 6.5.3.4 sizeof: "The result type is an integer."
-
QualType T = Ex->getArgumentType();
-
-
- // FIXME: Add support for VLAs.
- if (!T.getTypePtr()->isConstantSizeType())
- return;
-
+ uint64_t amt;
- uint64_t size = 1; // Handle sizeof(void)
-
- if (T != getContext().VoidTy)
- size = getContext().getTypeSize(T) / 8;
+ if (Ex->isSizeOf()) {
+
+ // FIXME: Add support for VLAs.
+ if (!T.getTypePtr()->isConstantSizeType())
+ return;
+
+ amt = 1; // Handle sizeof(void)
+
+ if (T != getContext().VoidTy)
+ amt = getContext().getTypeSize(T) / 8;
+
+ }
+ else // Get alignment of the type.
+ amt = getContext().getTypeAlign(T);
Nodify(Dst, Ex, Pred,
SetRVal(GetState(Pred), Ex,
- NonLVal::MakeVal(BasicVals, size, Ex->getType())));
-
+ NonLVal::MakeVal(BasicVals, amt, Ex->getType())));
}
void GRExprEngine::VisitDeref(UnaryOperator* U, NodeTy* Pred,
OpenPOWER on IntegriCloud