diff options
| author | Fangrui Song <maskray@google.com> | 2018-11-30 23:41:18 +0000 |
|---|---|---|
| committer | Fangrui Song <maskray@google.com> | 2018-11-30 23:41:18 +0000 |
| commit | 407659ab0a1048027b3419b163c245036469ec35 (patch) | |
| tree | 52e6ecfa03743811c8c88293f77a520618561b15 /clang/lib/AST/Expr.cpp | |
| parent | cada498038e320b175130210c7bf2386e3e50a91 (diff) | |
| download | bcm5719-llvm-407659ab0a1048027b3419b163c245036469ec35.tar.gz bcm5719-llvm-407659ab0a1048027b3419b163c245036469ec35.zip | |
Revert "Revert r347417 "Re-Reinstate 347294 with a fix for the failures.""
It seems the two failing tests can be simply fixed after r348037
Fix 3 cases in Analysis/builtin-functions.cpp
Delete the bad CodeGen/builtin-constant-p.c for now
llvm-svn: 348053
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index d8df83def4b..4de1342c77f 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2594,8 +2594,8 @@ Expr *Expr::IgnoreParenCasts() { E = NTTP->getReplacement(); continue; } - if (ConstantExpr *CE = dyn_cast<ConstantExpr>(E)) { - E = CE->getSubExpr(); + if (FullExpr *FE = dyn_cast<FullExpr>(E)) { + E = FE->getSubExpr(); continue; } return E; @@ -2619,8 +2619,8 @@ Expr *Expr::IgnoreCasts() { E = NTTP->getReplacement(); continue; } - if (ConstantExpr *CE = dyn_cast<ConstantExpr>(E)) { - E = CE->getSubExpr(); + if (FullExpr *FE = dyn_cast<FullExpr>(E)) { + E = FE->getSubExpr(); continue; } return E; @@ -2648,8 +2648,8 @@ Expr *Expr::IgnoreParenLValueCasts() { = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) { E = NTTP->getReplacement(); continue; - } else if (ConstantExpr *CE = dyn_cast<ConstantExpr>(E)) { - E = CE->getSubExpr(); + } else if (FullExpr *FE = dyn_cast<FullExpr>(E)) { + E = FE->getSubExpr(); continue; } break; @@ -2920,6 +2920,12 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef, break; } + case ConstantExprClass: { + // FIXME: We should be able to return "true" here, but it can lead to extra + // error messages. E.g. in Sema/array-init.c. + const Expr *Exp = cast<ConstantExpr>(this)->getSubExpr(); + return Exp->isConstantInitializer(Ctx, false, Culprit); + } case CompoundLiteralExprClass: { // This handles gcc's extension that allows global initializers like // "struct x {int x;} x = (struct x) {};". @@ -2959,8 +2965,8 @@ bool Expr::isConstantInitializer(ASTContext &Ctx, bool IsForRef, const Expr *Elt = ILE->getInit(ElementNo++); if (Field->isBitField()) { // Bitfields have to evaluate to an integer. - llvm::APSInt ResultTmp; - if (!Elt->EvaluateAsInt(ResultTmp, Ctx)) { + EvalResult Result; + if (!Elt->EvaluateAsInt(Result, Ctx)) { if (Culprit) *Culprit = Elt; return false; |

