summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-11-27 18:22:04 +0000
committerChris Lattner <sabre@nondot.org>2007-11-27 18:22:04 +0000
commita7944d86de509d668e9ab2f641baf0a5f104b114 (patch)
tree71b9dc5cde4ca08ce933e705580ed35eefb3426e
parent75445ae2c35d3f6779931d625108873f08afafce (diff)
downloadbcm5719-llvm-a7944d86de509d668e9ab2f641baf0a5f104b114.tar.gz
bcm5719-llvm-a7944d86de509d668e9ab2f641baf0a5f104b114.zip
sizeof is defined by bitsin(char) not by units of 8 bits.
llvm-svn: 44369
-rw-r--r--clang/AST/Expr.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/AST/Expr.cpp b/clang/AST/Expr.cpp
index 77221392f23..9bc6b903adb 100644
--- a/clang/AST/Expr.cpp
+++ b/clang/AST/Expr.cpp
@@ -15,6 +15,7 @@
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtVisitor.h"
#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/TargetInfo.h"
using namespace clang;
//===----------------------------------------------------------------------===//
@@ -587,12 +588,14 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
Exp->getOperatorLoc())));
// Get information about the size or align.
- if (Exp->getOpcode() == UnaryOperator::SizeOf)
- Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(),
- Exp->getOperatorLoc()) / 8;
- else
+ if (Exp->getOpcode() == UnaryOperator::AlignOf) {
Result = Ctx.getTypeAlign(Exp->getSubExpr()->getType(),
Exp->getOperatorLoc());
+ } else {
+ unsigned CharSize = Ctx.Target.getCharWidth(Exp->getOperatorLoc());
+ Result = Ctx.getTypeSize(Exp->getSubExpr()->getType(),
+ Exp->getOperatorLoc()) / CharSize;
+ }
break;
case UnaryOperator::LNot: {
bool Val = Result != 0;
OpenPOWER on IntegriCloud