summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-10-22 15:04:37 +0000
committerDouglas Gregor <dgregor@apple.com>2008-10-22 15:04:37 +0000
commit4b62ec63531642429d34bdace180d27708c8db7e (patch)
treeec05faa08b5a0718edb0a3158a439231a9b93ac8 /clang/lib/AST/Expr.cpp
parentda84f683c86ced25361033f9be30ee2db5e89e70 (diff)
downloadbcm5719-llvm-4b62ec63531642429d34bdace180d27708c8db7e.tar.gz
bcm5719-llvm-4b62ec63531642429d34bdace180d27708c8db7e.zip
QualType::isMoreQualifiedThan and isAtLeastAsQualifiedAs assert that we
aren't trying to compare with address-space qualifiers (for now). Clean up handing of DeclRefExprs in Expr::isLvalue and refactor part of the check into a static DeclCanBeLvalue. llvm-svn: 57980
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r--clang/lib/AST/Expr.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 4fd8a24c8ad..5c0e38cf9e7 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -322,6 +322,15 @@ bool Expr::hasLocalSideEffect() const {
}
}
+/// DeclCanBeLvalue - Determine whether the given declaration can be
+/// an lvalue. This is a helper routine for isLvalue.
+static bool DeclCanBeLvalue(const NamedDecl *Decl, ASTContext &Ctx) {
+ return isa<VarDecl>(Decl) ||
+ // C++ 3.10p2: An lvalue refers to an object or function.
+ (Ctx.getLangOptions().CPlusPlus &&
+ (isa<FunctionDecl>(Decl) || isa<OverloadedFunctionDecl>(Decl)));
+}
+
/// isLvalue - C99 6.3.2.1: an lvalue is an expression with an object type or an
/// incomplete type other than void. Nonarray expressions that can be lvalues:
/// - name, where name must be a variable
@@ -359,12 +368,8 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const {
return cast<ArraySubscriptExpr>(this)->getBase()->isLvalue(Ctx);
return LV_Valid;
case DeclRefExprClass: { // C99 6.5.1p2
- const Decl *RefdDecl = cast<DeclRefExpr>(this)->getDecl();
- if (isa<VarDecl>(RefdDecl) ||
- isa<ImplicitParamDecl>(RefdDecl) ||
- // C++ 3.10p2: An lvalue refers to an object or function.
- isa<FunctionDecl>(RefdDecl) ||
- isa<OverloadedFunctionDecl>(RefdDecl))
+ const NamedDecl *RefdDecl = cast<DeclRefExpr>(this)->getDecl();
+ if (DeclCanBeLvalue(RefdDecl, Ctx))
return LV_Valid;
break;
}
OpenPOWER on IntegriCloud