summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-02-01 20:16:42 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-02-01 20:16:42 +0000
commit5ca7984bb4fe32623d40a7f1cd9691eb21eb3560 (patch)
tree4d37fae6578972f9b67ea61d617bffc1c0a1c317 /clang/lib/AST/Expr.cpp
parentb18093e4675655be85226f03aeaba2081c09ddf5 (diff)
downloadbcm5719-llvm-5ca7984bb4fe32623d40a7f1cd9691eb21eb3560.tar.gz
bcm5719-llvm-5ca7984bb4fe32623d40a7f1cd9691eb21eb3560.zip
In C++, an initializer on a variable doesn't necessarily mean it's the definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function.
llvm-svn: 94999
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index b76048a2b8d..cf78c66a8d3 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -99,8 +99,7 @@ void DeclRefExpr::computeDependence() {
else if (VarDecl *Var = dyn_cast<VarDecl>(D)) {
if (Var->getType()->isIntegralType() &&
Var->getType().getCVRQualifiers() == Qualifiers::Const) {
- const VarDecl *Def = 0;
- if (const Expr *Init = Var->getDefinition(Def))
+ if (const Expr *Init = Var->getAnyInitializer())
if (Init->isValueDependent())
ValueDependent = true;
}
@@ -1654,15 +1653,14 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
if (Quals.hasVolatile() || !Quals.hasConst())
return ICEDiag(2, cast<DeclRefExpr>(E)->getLocation());
- // Look for the definition of this variable, which will actually have
- // an initializer.
- const VarDecl *Def = 0;
- const Expr *Init = Dcl->getDefinition(Def);
+ // Look for a declaration of this variable that has an initializer.
+ const VarDecl *ID = 0;
+ const Expr *Init = Dcl->getAnyInitializer(ID);
if (Init) {
- if (Def->isInitKnownICE()) {
+ if (ID->isInitKnownICE()) {
// We have already checked whether this subexpression is an
// integral constant expression.
- if (Def->isInitICE())
+ if (ID->isInitICE())
return NoDiag();
else
return ICEDiag(2, cast<DeclRefExpr>(E)->getLocation());
@@ -1674,7 +1672,7 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) {
// specify a constant-initializer which shall be an integral
// constant expression (5.19). In that case, the member can appear
// in integral constant expressions.
- if (Def->isOutOfLine()) {
+ if (ID->isOutOfLine()) {
Dcl->setInitKnownICE(false);
return ICEDiag(2, cast<DeclRefExpr>(E)->getLocation());
}
OpenPOWER on IntegriCloud