diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-13 20:51:45 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-09-13 20:51:45 +0000 |
commit | 17e32460ed016bc2ae168faeba924972b42be9eb (patch) | |
tree | 6902bf7b6f2d2860244033c67598bf548320e9ae /clang/lib/AST | |
parent | 8c9795d9fa94a7478d18e3906dff2408f379e8d9 (diff) | |
download | bcm5719-llvm-17e32460ed016bc2ae168faeba924972b42be9eb.tar.gz bcm5719-llvm-17e32460ed016bc2ae168faeba924972b42be9eb.zip |
Part three of PR15721: if we have an invalid CXXDefaultInitExpr, don't crash if
we try to constant-evaluate it. Patch by Karthik Bhat, test by me.
llvm-svn: 190722
Diffstat (limited to 'clang/lib/AST')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 218ce8101b5..0a2cc7b3d6d 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -3742,8 +3742,12 @@ public: { return StmtVisitorTy::Visit(E->getReplacement()); } RetTy VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *E) { return StmtVisitorTy::Visit(E->getExpr()); } - RetTy VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E) - { return StmtVisitorTy::Visit(E->getExpr()); } + RetTy VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *E) { + // The initializer may not have been parsed yet, or might be erroneous. + if (!E->getExpr()) + return Error(E); + return StmtVisitorTy::Visit(E->getExpr()); + } // We cannot create any objects for which cleanups are required, so there is // nothing to do here; all cleanups must come from unevaluated subexpressions. RetTy VisitExprWithCleanups(const ExprWithCleanups *E) |