diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2010-05-16 09:32:51 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2010-05-16 09:32:51 +0000 |
| commit | e299ba66f5f8e270f7a0f2f44f90e72ad67ad8a3 (patch) | |
| tree | c2902b678c618550891be2c6d2f69fb7dde785e7 /clang/lib/AST/ExprConstant.cpp | |
| parent | 497d83196684ad2b0a6dbe21878e789bdfcef2aa (diff) | |
| download | bcm5719-llvm-e299ba66f5f8e270f7a0f2f44f90e72ad67ad8a3.tar.gz bcm5719-llvm-e299ba66f5f8e270f7a0f2f44f90e72ad67ad8a3.zip | |
When constant folding reference variables with an initializer to the
initializer, don't fold paramters. Their initializers are just default
arguments which can be overridden. This fixes some spectacular regressions due
to more things making it into the constant folding.
llvm-svn: 103904
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index f903035d220..dc614018ec2 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -355,6 +355,10 @@ bool LValueExprEvaluator::VisitDeclRefExpr(DeclRefExpr *E) { } else if (VarDecl* VD = dyn_cast<VarDecl>(E->getDecl())) { if (!VD->getType()->isReferenceType()) return Success(E); + // Reference parameters can refer to anything even if they have an + // "initializer" in the form of a default argument. + if (isa<ParmVarDecl>(VD)) + return false; // FIXME: Check whether VD might be overridden! if (const Expr *Init = VD->getAnyInitializer()) return Visit(const_cast<Expr *>(Init)); |

