diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/AST/ExprClassification.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/AST/ExprClassification.cpp | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/contrib/llvm-project/clang/lib/AST/ExprClassification.cpp b/contrib/llvm-project/clang/lib/AST/ExprClassification.cpp index 6998e28fd2ea..6482cb6d39ac 100644 --- a/contrib/llvm-project/clang/lib/AST/ExprClassification.cpp +++ b/contrib/llvm-project/clang/lib/AST/ExprClassification.cpp @@ -145,7 +145,7 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::FunctionParmPackExprClass: case Expr::MSPropertyRefExprClass: case Expr::MSPropertySubscriptExprClass: - case Expr::OMPArraySectionExprClass: + case Expr::ArraySectionExprClass: case Expr::OMPArrayShapingExprClass: case Expr::OMPIteratorExprClass: return Cl::CL_LValue; @@ -160,7 +160,6 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::CXXPseudoDestructorExprClass: case Expr::UnaryExprOrTypeTraitExprClass: case Expr::CXXNewExprClass: - case Expr::CXXThisExprClass: case Expr::CXXNullPtrLiteralExprClass: case Expr::ImaginaryLiteralClass: case Expr::GNUNullExprClass: @@ -205,6 +204,15 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::RequiresExprClass: return Cl::CL_PRValue; + case Expr::EmbedExprClass: + // Nominally, this just goes through as a PRValue until we actually expand + // it and check it. + return Cl::CL_PRValue; + + // Make HLSL this reference-like + case Expr::CXXThisExprClass: + return Lang.HLSL ? Cl::CL_LValue : Cl::CL_PRValue; + case Expr::ConstantExprClass: return ClassifyInternal(Ctx, cast<ConstantExpr>(E)->getSubExpr()); @@ -213,6 +221,14 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { return ClassifyInternal(Ctx, cast<SubstNonTypeTemplateParmExpr>(E)->getReplacement()); + case Expr::PackIndexingExprClass: { + // A pack-index-expression always expands to an id-expression. + // Consider it as an LValue expression. + if (cast<PackIndexingExpr>(E)->isInstantiationDependent()) + return Cl::CL_LValue; + return ClassifyInternal(Ctx, cast<PackIndexingExpr>(E)->getSelectedExpr()); + } + // C, C++98 [expr.sub]p1: The result is an lvalue of type "T". // C++11 (DR1213): in the case of an array operand, the result is an lvalue // if that operand is an lvalue and an xvalue otherwise. @@ -442,6 +458,11 @@ static Cl::Kinds ClassifyInternal(ASTContext &Ctx, const Expr *E) { case Expr::SYCLUniqueStableNameExprClass: return Cl::CL_PRValue; break; + + case Expr::CXXParenListInitExprClass: + if (isa<ArrayType>(E->getType())) + return Cl::CL_ArrayTemporary; + return Cl::CL_ClassTemporary; } llvm_unreachable("unhandled expression kind in classification"); @@ -457,22 +478,24 @@ static Cl::Kinds ClassifyDecl(ASTContext &Ctx, const Decl *D) { // lvalue unless it's a reference type (C++ [temp.param]p6), so we need to // special-case this. - if (isa<CXXMethodDecl>(D) && cast<CXXMethodDecl>(D)->isInstance()) - return Cl::CL_MemberFunction; + if (const auto *M = dyn_cast<CXXMethodDecl>(D)) { + if (M->isImplicitObjectMemberFunction()) + return Cl::CL_MemberFunction; + if (M->isStatic()) + return Cl::CL_LValue; + return Cl::CL_PRValue; + } bool islvalue; if (const auto *NTTParm = dyn_cast<NonTypeTemplateParmDecl>(D)) islvalue = NTTParm->getType()->isReferenceType() || NTTParm->getType()->isRecordType(); else - islvalue = isa<VarDecl>(D) || isa<FieldDecl>(D) || - isa<IndirectFieldDecl>(D) || - isa<BindingDecl>(D) || - isa<MSGuidDecl>(D) || - isa<TemplateParamObjectDecl>(D) || - (Ctx.getLangOpts().CPlusPlus && - (isa<FunctionDecl>(D) || isa<MSPropertyDecl>(D) || - isa<FunctionTemplateDecl>(D))); + islvalue = + isa<VarDecl, FieldDecl, IndirectFieldDecl, BindingDecl, MSGuidDecl, + UnnamedGlobalConstantDecl, TemplateParamObjectDecl>(D) || + (Ctx.getLangOpts().CPlusPlus && + (isa<FunctionDecl, MSPropertyDecl, FunctionTemplateDecl>(D))); return islvalue ? Cl::CL_LValue : Cl::CL_PRValue; } @@ -546,8 +569,13 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) { // -- If it refers to a static member function [...], then E1.E2 is an // lvalue; [...] // -- Otherwise [...] E1.E2 is a prvalue. - if (const auto *Method = dyn_cast<CXXMethodDecl>(Member)) - return Method->isStatic() ? Cl::CL_LValue : Cl::CL_MemberFunction; + if (const auto *Method = dyn_cast<CXXMethodDecl>(Member)) { + if (Method->isStatic()) + return Cl::CL_LValue; + if (Method->isImplicitObjectMemberFunction()) + return Cl::CL_MemberFunction; + return Cl::CL_PRValue; + } // -- If E2 is a member enumerator [...], the expression E1.E2 is a prvalue. // So is everything else we haven't handled yet. |