[cfe-commits] r62951 - in /cfe/trunk: include/clang/AST/Expr.h lib/AST/Expr.cpp lib/Analysis/CheckDeadStores.cpp lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprAgg.cpp
Eli Friedman
eli.friedman at gmail.com
Sat Jan 24 18:32:41 PST 2009
Author: efriedma
Date: Sat Jan 24 20:32:41 2009
New Revision: 62951
URL: http://llvm.org/viewvc/llvm-project?rev=62951&view=rev
Log:
Rename Expr::isConstantExpr to Expr::isConstantInitializer; this more
accurately states what the function is trying to do and how it is
different from Expr::isEvaluatable. Also get rid of a parameter that is both
unused and inaccurate.
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/lib/Analysis/CheckDeadStores.cpp
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
Modified: cfe/trunk/include/clang/AST/Expr.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=62951&r1=62950&r2=62951&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Sat Jan 24 20:32:41 2009
@@ -181,8 +181,9 @@
llvm::APSInt X;
return isIntegerConstantExpr(X, Ctx, Loc);
}
- /// isConstantExpr - Return true if this expression is a valid constant expr.
- bool isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const;
+ /// isConstantInitializer - Returns true if this expression is a constant
+ /// initializer, which can be emitted at compile-time.
+ bool isConstantInitializer(ASTContext &Ctx) const;
/// EvalResult is a struct with detailed info about an evaluated expression.
struct EvalResult {
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=62951&r1=62950&r2=62951&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Jan 24 20:32:41 2009
@@ -692,11 +692,10 @@
return false;
}
-bool Expr::isConstantExpr(ASTContext &Ctx, SourceLocation *Loc) const {
+bool Expr::isConstantInitializer(ASTContext &Ctx) const {
switch (getStmtClass()) {
default:
if (!isEvaluatable(Ctx)) {
- if (Loc) *Loc = getLocStart();
return false;
}
break;
@@ -704,13 +703,13 @@
return true;
case CompoundLiteralExprClass: {
const Expr *Exp = cast<CompoundLiteralExpr>(this)->getInitializer();
- return Exp->isConstantExpr(Ctx, Loc);
+ return Exp->isConstantInitializer(Ctx);
}
case InitListExprClass: {
const InitListExpr *Exp = cast<InitListExpr>(this);
unsigned numInits = Exp->getNumInits();
for (unsigned i = 0; i < numInits; i++) {
- if (!Exp->getInit(i)->isConstantExpr(Ctx, Loc))
+ if (!Exp->getInit(i)->isConstantInitializer(Ctx))
return false;
}
}
Modified: cfe/trunk/lib/Analysis/CheckDeadStores.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckDeadStores.cpp?rev=62951&r1=62950&r2=62951&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CheckDeadStores.cpp (original)
+++ cfe/trunk/lib/Analysis/CheckDeadStores.cpp Sat Jan 24 20:32:41 2009
@@ -195,7 +195,7 @@
// If x is EVER assigned a new value later, don't issue
// a warning. This is because such initialization can be
// due to defensive programming.
- if (!E->isConstantExpr(Ctx,NULL))
+ if (!E->isConstantInitializer(Ctx))
Report(V, DeadInit, V->getLocation(), E->getSourceRange());
}
}
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=62951&r1=62950&r2=62951&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Sat Jan 24 20:32:41 2009
@@ -86,7 +86,7 @@
if ((D.getInit() == 0) || NoInit) {
Init = llvm::Constant::getNullValue(LTy);
} else {
- if (D.getInit()->isConstantExpr(getContext(), 0))
+ if (D.getInit()->isConstantInitializer(getContext()))
Init = CGM.EmitConstantExpr(D.getInit(), this);
else {
assert(getContext().getLangOptions().CPlusPlus &&
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=62951&r1=62950&r2=62951&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Sat Jan 24 20:32:41 2009
@@ -394,7 +394,7 @@
// FIXME: Should we really be doing this? Should we try to avoid
// cases where we emit a global with a lot of zeros? Should
// we try to avoid short globals?
- if (E->isConstantExpr(CGF.getContext(), 0)) {
+ if (E->isConstantInitializer(CGF.getContext(), 0)) {
llvm::Constant* C = CGF.CGM.EmitConstantExpr(E, &CGF);
llvm::GlobalVariable* GV =
new llvm::GlobalVariable(C->getType(), true,
More information about the cfe-commits
mailing list