diff options
author | John McCall <rjmccall@apple.com> | 2010-11-15 23:31:06 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-11-15 23:31:06 +0000 |
commit | 8d69a2160e48b73a4515c9401e67971fb8c14e07 (patch) | |
tree | 14900bed496fd53f87c2014dc13c3c68ea2fac6a /clang/lib/AST/ExprClassification.cpp | |
parent | 24f6742b345165960ae7cd6a6a838f56d92bc595 (diff) | |
download | bcm5719-llvm-8d69a2160e48b73a4515c9401e67971fb8c14e07.tar.gz bcm5719-llvm-8d69a2160e48b73a4515c9401e67971fb8c14e07.zip |
Add a new expression kind, OpaqueValueExpr, which is useful for
certain internal type-checking procedures as well as for representing
certain implicitly-generated operations. Uses to follow.
llvm-svn: 119289
Diffstat (limited to 'clang/lib/AST/ExprClassification.cpp')
-rw-r--r-- | clang/lib/AST/ExprClassification.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/clang/lib/AST/ExprClassification.cpp b/clang/lib/AST/ExprClassification.cpp index 0ab1402fa83..1daa475b9e3 100644 --- a/clang/lib/AST/ExprClassification.cpp +++ b/clang/lib/AST/ExprClassification.cpp @@ -33,6 +33,22 @@ static Cl::Kinds ClassifyConditional(ASTContext &Ctx, static Cl::ModifiableType IsModifiable(ASTContext &Ctx, const Expr *E, Cl::Kinds Kind, SourceLocation &Loc); +static Cl::Kinds ClassifyExprValueKind(const LangOptions &Lang, + const Expr *E, + ExprValueKind Kind) { + switch (Kind) { + case VK_RValue: + return Lang.CPlusPlus && E->getType()->isRecordType() ? + Cl::CL_ClassTemporary : Cl::CL_PRValue; + case VK_LValue: + return Cl::CL_LValue; + case VK_XValue: + return Cl::CL_XValue; + } + llvm_unreachable("Invalid value category of implicit cast."); + return Cl::CL_PRValue; +} + Cl Expr::ClassifyImpl(ASTContext &Ctx, SourceLocation *Loc) const { assert(!TR->isReferenceType() && "Expressions can't have reference type."); @@ -171,19 +187,15 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { return Cl::CL_PRValue; } + case Expr::OpaqueValueExprClass: + return ClassifyExprValueKind(Lang, E, + cast<OpaqueValueExpr>(E)->getValueKind()); + // Implicit casts are lvalues if they're lvalue casts. Other than that, we // only specifically record class temporaries. case Expr::ImplicitCastExprClass: - switch (cast<ImplicitCastExpr>(E)->getValueKind()) { - case VK_RValue: - return Lang.CPlusPlus && E->getType()->isRecordType() ? - Cl::CL_ClassTemporary : Cl::CL_PRValue; - case VK_LValue: - return Cl::CL_LValue; - case VK_XValue: - return Cl::CL_XValue; - } - llvm_unreachable("Invalid value category of implicit cast."); + return ClassifyExprValueKind(Lang, E, + cast<ImplicitCastExpr>(E)->getValueKind()); // C++ [expr.prim.general]p4: The presence of parentheses does not affect // whether the expression is an lvalue. |