diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-05 18:03:03 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2009-11-05 18:03:03 +0000 |
commit | 4127b8ef97e5d361fddf9142af61cee106348522 (patch) | |
tree | a9f1d4e8aa5f4dca04d8357867a0e73d7712fe00 /clang/lib/AST/ExprConstant.cpp | |
parent | a117dd23e9eb9ac77eca31de963dc8ba51aef204 (diff) | |
download | bcm5719-llvm-4127b8ef97e5d361fddf9142af61cee106348522.tar.gz bcm5719-llvm-4127b8ef97e5d361fddf9142af61cee106348522.zip |
Added support for static variables which require
initialization before main. Fixes pr5396.
llvm-svn: 86145
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 7862c57c2d4..c036640b711 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -204,13 +204,6 @@ public: bool VisitUnaryOperator(UnaryOperator *E) { return Visit(E->getSubExpr()); } }; -bool HasSideEffects(const Expr* E, ASTContext &Ctx) { - Expr::EvalResult Result; - EvalInfo Info(Ctx, Result); - - return HasSideEffect(Info).Visit(const_cast<Expr*>(E)); -} - } // end anonymous namespace //===----------------------------------------------------------------------===// @@ -964,7 +957,7 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { } } - if (HasSideEffects(E->getArg(0), Info.Ctx)) { + if (E->getArg(0)->HasSideEffects(Info.Ctx)) { if (E->getArg(1)->EvaluateAsInt(Info.Ctx).getZExtValue() < 2) return Success(-1ULL, E); return Success(0, E); @@ -1947,6 +1940,12 @@ bool Expr::isEvaluatable(ASTContext &Ctx) const { return Evaluate(Result, Ctx) && !Result.HasSideEffects; } +bool Expr::HasSideEffects(ASTContext &Ctx) const { + Expr::EvalResult Result; + EvalInfo Info(Ctx, Result); + return HasSideEffect(Info).Visit(const_cast<Expr*>(this)); +} + APSInt Expr::EvaluateAsInt(ASTContext &Ctx) const { EvalResult EvalResult; bool Result = Evaluate(EvalResult, Ctx); |