[cfe-commits] r44369 - /cfe/trunk/AST/Expr.cpp
Chris Lattner
sabre at nondot.org
Tue Nov 27 10:22:04 PST 2007
Author: lattner
Date: Tue Nov 27 12:22:04 2007
New Revision: 44369
URL: http://llvm.org/viewvc/llvm-project?rev=44369&view=rev
Log:
sizeof is defined by bitsin(char) not by units of 8 bits.
Modified:
cfe/trunk/AST/Expr.cpp
Modified: cfe/trunk/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Expr.cpp?rev=44369&r1=44368&r2=44369&view=diff
==============================================================================
--- cfe/trunk/AST/Expr.cpp (original)
+++ cfe/trunk/AST/Expr.cpp Tue Nov 27 12:22:04 2007
@@ -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 @@
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;
More information about the cfe-commits
mailing list