[cfe-commits] r59857 - /cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Anders Carlsson
andersca at mac.com
Fri Nov 21 18:34:40 PST 2008
Author: andersca
Date: Fri Nov 21 20:34:39 2008
New Revision: 59857
URL: http://llvm.org/viewvc/llvm-project?rev=59857&view=rev
Log:
Use tryEvaluate for constant exprs.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=59857&r1=59856&r2=59857&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Fri Nov 21 20:34:39 2008
@@ -25,6 +25,8 @@
using namespace clang;
using namespace CodeGen;
+#define USE_TRY_EVALUATE
+
namespace {
class VISIBILITY_HIDDEN ConstExprEmitter :
public StmtVisitor<ConstExprEmitter, llvm::Constant*> {
@@ -49,6 +51,7 @@
return Visit(PE->getSubExpr());
}
+#ifndef USE_TRY_EVALUATE
// Leaves
llvm::Constant *VisitIntegerLiteral(const IntegerLiteral *E) {
return llvm::ConstantInt::get(E->getValue());
@@ -65,13 +68,14 @@
llvm::Constant *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
return llvm::Constant::getNullValue(ConvertType(E->getType()));
}
+#endif
llvm::Constant *VisitObjCStringLiteral(const ObjCStringLiteral *E) {
std::string S(E->getString()->getStrData(),
E->getString()->getByteLength());
llvm::Constant *C = CGM.getObjCRuntime().GenerateConstantString(S);
return llvm::ConstantExpr::getBitCast(C, ConvertType(E->getType()));
}
-
+
llvm::Constant *VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
return Visit(E->getInitializer());
}
@@ -376,6 +380,7 @@
return llvm::ConstantArray::get(CGM.GetStringForStringLiteral(E), false);
}
+#ifndef USE_TRY_EVALUATE
llvm::Constant *VisitDeclRefExpr(DeclRefExpr *E) {
const NamedDecl *Decl = E->getDecl();
if (const EnumConstantDecl *EC = dyn_cast<EnumConstantDecl>(Decl))
@@ -387,7 +392,8 @@
llvm::Constant *VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr *E) {
return EmitSizeAlignOf(E->getTypeOfArgument(), E->getType(), E->isSizeOf());
}
-
+#endif
+
llvm::Constant *VisitAddrLabelExpr(const AddrLabelExpr *E) {
assert(CGF && "Invalid address of label expression outside function.");
llvm::Constant *C =
@@ -396,6 +402,7 @@
return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType()));
}
+#ifndef USE_TRY_EVALUATE
// Unary operators
llvm::Constant *VisitUnaryPlus(const UnaryOperator *E) {
return Visit(E->getSubExpr());
@@ -426,6 +433,8 @@
return llvm::ConstantExpr::getZExt(SubExpr, ConvertType(E->getType()));
}
+#endif
+
llvm::Constant *VisitUnaryAddrOf(const UnaryOperator *E) {
return EmitLValue(E->getSubExpr());
}
@@ -444,6 +453,7 @@
}
// Binary operators
+#ifndef USE_TRY_EVALUATE
llvm::Constant *VisitBinOr(const BinaryOperator *E) {
llvm::Constant *LHS = Visit(E->getLHS());
llvm::Constant *RHS = Visit(E->getRHS());
@@ -607,6 +617,7 @@
return Visit(E->getRHS());
}
+#endif
llvm::Constant *VisitCallExpr(const CallExpr *E) {
APValue Result;
More information about the cfe-commits
mailing list