diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 17 | ||||
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 66 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOverload.cpp | 7 |
8 files changed, 64 insertions, 74 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 6143492ea76..120035c923a 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -191,8 +191,7 @@ Sema::~Sema() { /// If there is already an implicit cast, merge into the existing one. /// The result is of the given category. void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, - CastExpr::CastKind Kind, - ImplicitCastExpr::ResultCategory Category, + CastKind Kind, ExprValueKind VK, const CXXCastPath *BasePath) { QualType ExprTy = Context.getCanonicalType(Expr->getType()); QualType TypeTy = Context.getCanonicalType(Ty); @@ -224,21 +223,18 @@ void Sema::ImpCastExprToType(Expr *&Expr, QualType Ty, if (ImplicitCastExpr *ImpCast = dyn_cast<ImplicitCastExpr>(Expr)) { if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) { ImpCast->setType(Ty); - ImpCast->setCategory(Category); + ImpCast->setValueKind(VK); return; } } - Expr = ImplicitCastExpr::Create(Context, Ty, Kind, Expr, BasePath, Category); + Expr = ImplicitCastExpr::Create(Context, Ty, Kind, Expr, BasePath, VK); } -ImplicitCastExpr::ResultCategory Sema::CastCategory(Expr *E) { +ExprValueKind Sema::CastCategory(Expr *E) { Expr::Classification Classification = E->Classify(Context); - return Classification.isRValue() ? - ImplicitCastExpr::RValue : - (Classification.isLValue() ? - ImplicitCastExpr::LValue : - ImplicitCastExpr::XValue); + return Classification.isRValue() ? VK_RValue : + (Classification.isLValue() ? VK_LValue : VK_XValue); } void Sema::DeleteExpr(ExprTy *E) { diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 7ea96f4014e..271a02dc11b 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -555,7 +555,7 @@ Sema::SemaBuiltinAtomicOverloaded(ExprResult TheCallResult) { // pass in 42. The 42 gets converted to char. This is even more strange // for things like 45.123 -> char, etc. // FIXME: Do this check. - ImpCastExprToType(Arg, ValType, Kind, ImplicitCastExpr::RValue, &BasePath); + ImpCastExprToType(Arg, ValType, Kind, VK_RValue, &BasePath); TheCall->setArg(i+1, Arg); } @@ -1966,7 +1966,7 @@ do { switch (E->getStmtClass()) { case Stmt::ImplicitCastExprClass: { ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E); - if (IE->getCategory() == ImplicitCastExpr::LValue) { + if (IE->getValueKind() == VK_LValue) { E = IE->getSubExpr(); continue; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 659c0d1a92b..9b6680f312d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -7085,7 +7085,7 @@ void Sema::ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, CastExpr::CK_IntegralCast, ECD->getInitExpr(), /*base paths*/ 0, - ImplicitCastExpr::RValue)); + VK_RValue)); if (getLangOptions().CPlusPlus) // C++ [dcl.enum]p4: Following the closing brace of an // enum-specifier, each enumerator has the type of its diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 7761ac910ed..dbf22eba500 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -1540,7 +1540,7 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, BasePath.push_back(BaseSpec); SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy, CastExpr::CK_UncheckedDerivedToBase, - ImplicitCastExpr::LValue, &BasePath); + VK_LValue, &BasePath); InitializationKind InitKind = InitializationKind::CreateDirect(Constructor->getLocation(), @@ -4979,25 +4979,25 @@ void Sema::DefineImplicitCopyAssignment(SourceLocation CurrentLocation, // appropriately-qualified base type. Expr *From = OtherRef->Retain(); ImpCastExprToType(From, Context.getQualifiedType(BaseType, OtherQuals), - CastExpr::CK_UncheckedDerivedToBase, - ImplicitCastExpr::LValue, &BasePath); + CK_UncheckedDerivedToBase, + VK_LValue, &BasePath); // Dereference "this". - ExprResult To = CreateBuiltinUnaryOp(Loc, UnaryOperator::Deref, This); + ExprResult To = CreateBuiltinUnaryOp(Loc, UO_Deref, This); // Implicitly cast "this" to the appropriately-qualified base type. Expr *ToE = To.takeAs<Expr>(); ImpCastExprToType(ToE, Context.getCVRQualifiedType(BaseType, CopyAssignOperator->getTypeQualifiers()), - CastExpr::CK_UncheckedDerivedToBase, - ImplicitCastExpr::LValue, &BasePath); + CK_UncheckedDerivedToBase, + VK_LValue, &BasePath); To = Owned(ToE); // Build the copy. StmtResult Copy = BuildSingleCopyAssign(*this, Loc, BaseType, - To.get(), From, - /*CopyingBaseSubobject=*/true); + To.get(), From, + /*CopyingBaseSubobject=*/true); if (Copy.isInvalid()) { Diag(CurrentLocation, diag::note_member_synthesized_at) << CXXCopyAssignment << Context.getTagDeclType(ClassDecl); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 197c44dfa47..c8e8ecda861 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -1480,7 +1480,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, SourceRange FromRange = From->getSourceRange(); SourceLocation FromLoc = FromRange.getBegin(); - ImplicitCastExpr::ResultCategory Category = CastCategory(From); + ExprValueKind VK = CastCategory(From); // C++ [class.member.lookup]p8: // [...] Ambiguities can often be resolved by qualifying a name with its @@ -1518,8 +1518,8 @@ Sema::PerformObjectMemberConversion(Expr *&From, if (PointerConversions) QType = Context.getPointerType(QType); - ImpCastExprToType(From, QType, CastExpr::CK_UncheckedDerivedToBase, - Category, &BasePath); + ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase, + VK, &BasePath); FromType = QType; FromRecordType = QRecordType; @@ -1556,7 +1556,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, if (PointerConversions) UType = Context.getPointerType(UType); ImpCastExprToType(From, UType, CastExpr::CK_UncheckedDerivedToBase, - Category, &BasePath); + VK, &BasePath); FromType = UType; FromRecordType = URecordType; } @@ -1573,7 +1573,7 @@ Sema::PerformObjectMemberConversion(Expr *&From, return true; ImpCastExprToType(From, DestType, CastExpr::CK_UncheckedDerivedToBase, - Category, &BasePath); + VK, &BasePath); return false; } diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index afca7dc7da8..6b54e2e6718 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -1841,7 +1841,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, CXXCastPath BasePath; if (CheckPointerConversion(From, ToType, Kind, BasePath, IgnoreBaseAccess)) return true; - ImpCastExprToType(From, ToType, Kind, ImplicitCastExpr::RValue, &BasePath); + ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath); break; } @@ -1853,7 +1853,7 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, return true; if (CheckExceptionSpecCompatibility(From, ToType)) return true; - ImpCastExprToType(From, ToType, Kind, ImplicitCastExpr::RValue, &BasePath); + ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath); break; } case ICK_Boolean_Conversion: { @@ -1910,10 +1910,10 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType, case ICK_Qualification: { // The qualification keeps the category of the inner expression, unless the // target type isn't a reference. - ImplicitCastExpr::ResultCategory Category = ToType->isReferenceType() ? - CastCategory(From) : ImplicitCastExpr::RValue; + ExprValueKind VK = ToType->isReferenceType() ? + CastCategory(From) : VK_RValue; ImpCastExprToType(From, ToType.getNonLValueExprType(Context), - CastExpr::CK_NoOp, Category); + CastExpr::CK_NoOp, VK); if (SCS.DeprecatedStringLiteralToCharPtr) Diag(From->getLocStart(), diag::warn_deprecated_string_literal_conversion) @@ -2007,13 +2007,12 @@ QualType Sema::CheckPointerToMemberOperands( } // Cast LHS to type of use. QualType UseType = isIndirect ? Context.getPointerType(Class) : Class; - ImplicitCastExpr::ResultCategory Category = - isIndirect ? ImplicitCastExpr::RValue : CastCategory(lex); + ExprValueKind VK = + isIndirect ? VK_RValue : CastCategory(lex); CXXCastPath BasePath; BuildBasePathArray(Paths, BasePath); - ImpCastExprToType(lex, UseType, CastExpr::CK_DerivedToBase, Category, - &BasePath); + ImpCastExprToType(lex, UseType, CK_DerivedToBase, VK, &BasePath); } if (isa<CXXScalarValueInitExpr>(rex->IgnoreParens())) { diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 034099eac43..57a1874ed47 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -2095,12 +2095,12 @@ void InitializationSequence::AddAddressOverloadResolutionStep( } void InitializationSequence::AddDerivedToBaseCastStep(QualType BaseType, - ImplicitCastExpr::ResultCategory Category) { + ExprValueKind VK) { Step S; - switch (Category) { - case ImplicitCastExpr::RValue: S.Kind = SK_CastDerivedToBaseRValue; break; - case ImplicitCastExpr::XValue: S.Kind = SK_CastDerivedToBaseXValue; break; - case ImplicitCastExpr::LValue: S.Kind = SK_CastDerivedToBaseLValue; break; + switch (VK) { + case VK_RValue: S.Kind = SK_CastDerivedToBaseRValue; break; + case VK_XValue: S.Kind = SK_CastDerivedToBaseXValue; break; + case VK_LValue: S.Kind = SK_CastDerivedToBaseLValue; break; default: llvm_unreachable("No such category"); } S.Type = BaseType; @@ -2134,19 +2134,18 @@ void InitializationSequence::AddUserConversionStep(FunctionDecl *Function, } void InitializationSequence::AddQualificationConversionStep(QualType Ty, - ImplicitCastExpr::ResultCategory Category) { + ExprValueKind VK) { Step S; - switch (Category) { - case ImplicitCastExpr::RValue: + switch (VK) { + case VK_RValue: S.Kind = SK_QualificationConversionRValue; break; - case ImplicitCastExpr::XValue: + case VK_XValue: S.Kind = SK_QualificationConversionXValue; break; - case ImplicitCastExpr::LValue: + case VK_LValue: S.Kind = SK_QualificationConversionLValue; break; - default: llvm_unreachable("No such category"); } S.Type = Ty; Steps.push_back(S); @@ -2409,12 +2408,11 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, // Determine whether we need to perform derived-to-base or // cv-qualification adjustments. - ImplicitCastExpr::ResultCategory Category = ImplicitCastExpr::RValue; + ExprValueKind VK = VK_RValue; if (T2->isLValueReferenceType()) - Category = ImplicitCastExpr::LValue; + VK = VK_LValue; else if (const RValueReferenceType *RRef = T2->getAs<RValueReferenceType>()) - Category = RRef->getPointeeType()->isFunctionType() ? - ImplicitCastExpr::LValue : ImplicitCastExpr::XValue; + VK = RRef->getPointeeType()->isFunctionType() ? VK_LValue : VK_XValue; bool NewDerivedToBase = false; bool NewObjCConversion = false; @@ -2436,14 +2434,14 @@ static OverloadingResult TryRefInitWithConversionFunction(Sema &S, Sequence.AddDerivedToBaseCastStep( S.Context.getQualifiedType(T1, T2.getNonReferenceType().getQualifiers()), - Category); + VK); else if (NewObjCConversion) Sequence.AddObjCObjectConversionStep( S.Context.getQualifiedType(T1, T2.getNonReferenceType().getQualifiers())); if (cv1T1.getQualifiers() != T2.getNonReferenceType().getQualifiers()) - Sequence.AddQualificationConversionStep(cv1T1, Category); + Sequence.AddQualificationConversionStep(cv1T1, VK); Sequence.AddReferenceBindingStep(cv1T1, !T2->isReferenceType()); return OR_Success; @@ -2520,13 +2518,13 @@ static void TryReferenceInitialization(Sema &S, if (DerivedToBase) Sequence.AddDerivedToBaseCastStep( S.Context.getQualifiedType(T1, T2Quals), - ImplicitCastExpr::LValue); + VK_LValue); else if (ObjCConversion) Sequence.AddObjCObjectConversionStep( S.Context.getQualifiedType(T1, T2Quals)); if (T1Quals != T2Quals) - Sequence.AddQualificationConversionStep(cv1T1,ImplicitCastExpr::LValue); + Sequence.AddQualificationConversionStep(cv1T1, VK_LValue); bool BindingTemporary = T1Quals.hasConst() && !T1Quals.hasVolatile() && (Initializer->getBitField() || Initializer->refersToVectorElement()); Sequence.AddReferenceBindingStep(cv1T1, BindingTemporary); @@ -2603,16 +2601,14 @@ static void TryReferenceInitialization(Sema &S, if (DerivedToBase) Sequence.AddDerivedToBaseCastStep( S.Context.getQualifiedType(T1, T2Quals), - isXValue ? ImplicitCastExpr::XValue - : ImplicitCastExpr::RValue); + isXValue ? VK_XValue : VK_RValue); else if (ObjCConversion) Sequence.AddObjCObjectConversionStep( S.Context.getQualifiedType(T1, T2Quals)); if (T1Quals != T2Quals) Sequence.AddQualificationConversionStep(cv1T1, - isXValue ? ImplicitCastExpr::XValue - : ImplicitCastExpr::RValue); + isXValue ? VK_XValue : VK_RValue); Sequence.AddReferenceBindingStep(cv1T1, /*bindingTemporary=*/!isXValue); return; } @@ -3617,17 +3613,17 @@ InitializationSequence::Perform(Sema &S, cast<CXXRecordDecl>(RecordTy->getDecl())); } - ImplicitCastExpr::ResultCategory Category = + ExprValueKind VK = Step->Kind == SK_CastDerivedToBaseLValue ? - ImplicitCastExpr::LValue : + VK_LValue : (Step->Kind == SK_CastDerivedToBaseXValue ? - ImplicitCastExpr::XValue : - ImplicitCastExpr::RValue); + VK_XValue : + VK_RValue); CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, Step->Type, CastExpr::CK_DerivedToBase, - (Expr*)CurInit.release(), - &BasePath, Category)); + CurInit.get(), + &BasePath, VK)); break; } @@ -3765,7 +3761,7 @@ InitializationSequence::Perform(Sema &S, CurInit = S.Owned(ImplicitCastExpr::Create(S.Context, CurInitExpr->getType(), CastKind, CurInitExpr, 0, - IsLvalue ? ImplicitCastExpr::LValue : ImplicitCastExpr::RValue)); + IsLvalue ? VK_LValue : VK_RValue)); if (RequiresCopy) CurInit = CopyObject(S, Entity.getType().getNonReferenceType(), Entity, @@ -3778,13 +3774,13 @@ InitializationSequence::Perform(Sema &S, case SK_QualificationConversionXValue: case SK_QualificationConversionRValue: { // Perform a qualification conversion; these can never go wrong. - ImplicitCastExpr::ResultCategory Category = + ExprValueKind VK = Step->Kind == SK_QualificationConversionLValue ? - ImplicitCastExpr::LValue : + VK_LValue : (Step->Kind == SK_QualificationConversionXValue ? - ImplicitCastExpr::XValue : - ImplicitCastExpr::RValue); - S.ImpCastExprToType(CurInitExpr, Step->Type, CastExpr::CK_NoOp, Category); + VK_XValue : + VK_RValue); + S.ImpCastExprToType(CurInitExpr, Step->Type, CastExpr::CK_NoOp, VK); CurInit.release(); CurInit = S.Owned(CurInitExpr); break; diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index bb291bb4535..0645d97617e 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -3161,8 +3161,7 @@ Sema::PerformObjectArgumentInitialization(Expr *&From, if (!Context.hasSameType(From->getType(), DestType)) ImpCastExprToType(From, DestType, CastExpr::CK_NoOp, - From->getType()->isPointerType() ? - ImplicitCastExpr::RValue : ImplicitCastExpr::LValue); + From->getType()->isPointerType() ? VK_RValue : VK_LValue); return false; } @@ -3848,7 +3847,7 @@ Sema::AddConversionCandidate(CXXConversionDecl *Conversion, ImplicitCastExpr ConversionFn(ImplicitCastExpr::OnStack, Context.getPointerType(Conversion->getType()), CastExpr::CK_FunctionToPointerDecay, - &ConversionRef, ImplicitCastExpr::RValue); + &ConversionRef, VK_RValue); // Note that it is safe to allocate CallExpr on the stack here because // there are 0 arguments (i.e., nothing is allocated using ASTContext's @@ -7790,7 +7789,7 @@ Expr *Sema::FixOverloadedFunctionReference(Expr *E, DeclAccessPair Found, return ImplicitCastExpr::Create(Context, ICE->getType(), ICE->getCastKind(), SubExpr, 0, - ICE->getCategory()); + ICE->getValueKind()); } if (UnaryOperator *UnOp = dyn_cast<UnaryOperator>(E)) { |