[clang] ff04c5b - [NFC][Sema] Move `Sema::AssignmentAction` into its own scoped enum (#106453)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 29 12:00:33 PDT 2024
Author: Dan Liew
Date: 2024-08-29T12:00:28-07:00
New Revision: ff04c5b2e69481fc3b828bfcf32e05ff7a2c4b05
URL: https://github.com/llvm/llvm-project/commit/ff04c5b2e69481fc3b828bfcf32e05ff7a2c4b05
DIFF: https://github.com/llvm/llvm-project/commit/ff04c5b2e69481fc3b828bfcf32e05ff7a2c4b05.diff
LOG: [NFC][Sema] Move `Sema::AssignmentAction` into its own scoped enum (#106453)
The primary motivation behind this is to allow the enum type to be
referred to earlier in the Sema.h file which is needed for #106321.
It was requested in #106321 that a scoped enum be used (rather than
moving the enum declaration earlier in the Sema class declaration).
Unfortunately doing this creates a lot of churn as all use sites of the
enum constants had to be changed. Appologies to all downstream forks in
advanced.
Note the AA_ prefix has been dropped from the enum value names as they
are now redundant.
Added:
Modified:
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaARM.cpp
clang/lib/Sema/SemaCast.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaPseudoObject.cpp
clang/lib/Sema/SemaStmt.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 821182e8356428..0358259945c796 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -204,6 +204,24 @@ class SemaPPCallbacks;
class TemplateDeductionInfo;
} // namespace sema
+// AssignmentAction - This is used by all the assignment diagnostic functions
+// to represent what is actually causing the operation
+enum class AssignmentAction {
+ Assigning,
+ Passing,
+ Returning,
+ Converting,
+ Initializing,
+ Sending,
+ Casting,
+ Passing_CFAudited
+};
+inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &DB,
+ const AssignmentAction &AA) {
+ DB << llvm::to_underlying(AA);
+ return DB;
+}
+
namespace threadSafety {
class BeforeSet;
void threadSafetyCleanup(BeforeSet *Cache);
@@ -6493,19 +6511,6 @@ class Sema final : public SemaBase {
/// cleanup that are created by the current full expression.
SmallVector<ExprWithCleanups::CleanupObject, 8> ExprCleanupObjects;
- // AssignmentAction - This is used by all the assignment diagnostic functions
- // to represent what is actually causing the operation
- enum AssignmentAction {
- AA_Assigning,
- AA_Passing,
- AA_Returning,
- AA_Converting,
- AA_Initializing,
- AA_Sending,
- AA_Casting,
- AA_Passing_CFAudited
- };
-
/// Determine whether the use of this declaration is valid, without
/// emitting diagnostics.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid);
diff --git a/clang/lib/Sema/SemaARM.cpp b/clang/lib/Sema/SemaARM.cpp
index e18872f0dc551e..185e0427d5c995 100644
--- a/clang/lib/Sema/SemaARM.cpp
+++ b/clang/lib/Sema/SemaARM.cpp
@@ -795,7 +795,8 @@ bool SemaARM::CheckNeonBuiltinFunctionCall(const TargetInfo &TI,
if (RHS.isInvalid())
return true;
if (SemaRef.DiagnoseAssignmentResult(ConvTy, Arg->getBeginLoc(), LHSTy,
- RHSTy, RHS.get(), Sema::AA_Assigning))
+ RHSTy, RHS.get(),
+ AssignmentAction::Assigning))
return true;
}
@@ -921,7 +922,7 @@ bool SemaARM::CheckARMBuiltinExclusiveCall(unsigned BuiltinID,
CastNeeded = CK_BitCast;
Diag(DRE->getBeginLoc(), diag::ext_typecheck_convert_discards_qualifiers)
<< PointerArg->getType() << Context.getPointerType(AddrType)
- << Sema::AA_Passing << PointerArg->getSourceRange();
+ << AssignmentAction::Passing << PointerArg->getSourceRange();
}
// Finally, do the cast and replace the argument with the corrected version.
diff --git a/clang/lib/Sema/SemaCast.cpp b/clang/lib/Sema/SemaCast.cpp
index eca8363ee9605c..f01b22a72915c8 100644
--- a/clang/lib/Sema/SemaCast.cpp
+++ b/clang/lib/Sema/SemaCast.cpp
@@ -2673,7 +2673,7 @@ void CastOperation::checkAddressSpaceCast(QualType SrcType, QualType DestType) {
? DestPPointee.getAddressSpace() != SrcPPointee.getAddressSpace()
: !DestPPointee.isAddressSpaceOverlapping(SrcPPointee)) {
Self.Diag(OpRange.getBegin(), DiagID)
- << SrcType << DestType << Sema::AA_Casting
+ << SrcType << DestType << AssignmentAction::Casting
<< SrcExpr.get()->getSourceRange();
if (!Nested)
SrcExpr = ExprError();
@@ -3213,7 +3213,7 @@ void CastOperation::CheckCStyleCast() {
!CastQuals.compatiblyIncludesObjCLifetime(ExprQuals)) {
Self.Diag(SrcExpr.get()->getBeginLoc(),
diag::err_typecheck_incompatible_ownership)
- << SrcType << DestType << Sema::AA_Casting
+ << SrcType << DestType << AssignmentAction::Casting
<< SrcExpr.get()->getSourceRange();
return;
}
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ee143381cf4f79..b021e27209cf1b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4880,7 +4880,8 @@ bool Sema::BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
if (Arg->isTypeDependent())
return false;
- ExprResult Res = PerformImplicitConversion(Arg, Context.IntTy, AA_Passing);
+ ExprResult Res = PerformImplicitConversion(Arg, Context.IntTy,
+ AssignmentAction::Passing);
if (Res.isInvalid())
return true;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index d89a47f3e6226a..3044f1218f5b23 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -10871,7 +10871,8 @@ bool Sema::CheckDestructor(CXXDestructorDecl *Destructor) {
ExprResult This =
ActOnCXXThis(OperatorDelete->getParamDecl(0)->getLocation());
assert(!This.isInvalid() && "couldn't form 'this' expr in dtor?");
- This = PerformImplicitConversion(This.get(), ParamType, AA_Passing);
+ This = PerformImplicitConversion(This.get(), ParamType,
+ AssignmentAction::Passing);
if (This.isInvalid()) {
// FIXME: Register this as a context note so that it comes out
// in the right order.
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index de316f30e9523d..dcb08790911e74 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9586,7 +9586,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
QualType RHSType = RHS.get()->getType();
if (Diagnose) {
RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
- AA_Assigning);
+ AssignmentAction::Assigning);
} else {
ImplicitConversionSequence ICS =
TryImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
@@ -9598,7 +9598,7 @@ Sema::CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &CallerRHS,
if (ICS.isFailure())
return Incompatible;
RHS = PerformImplicitConversion(RHS.get(), LHSType.getUnqualifiedType(),
- ICS, AA_Assigning);
+ ICS, AssignmentAction::Assigning);
}
if (RHS.isInvalid())
return Incompatible;
@@ -13660,8 +13660,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS,
ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
}
- if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
- RHS.get(), AA_Assigning))
+ if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType, RHS.get(),
+ AssignmentAction::Assigning))
return QualType();
CheckForNullPointerDereference(*this, LHSExpr);
@@ -16669,7 +16669,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
MayHaveConvFixit = true;
break;
case IncompatiblePointer:
- if (Action == AA_Passing_CFAudited) {
+ if (Action == AssignmentAction::Passing_CFAudited) {
DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
} else if (getLangOpts().CPlusPlus) {
DiagKind = diag::err_typecheck_convert_incompatible_pointer;
@@ -16823,19 +16823,19 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
QualType FirstType, SecondType;
switch (Action) {
- case AA_Assigning:
- case AA_Initializing:
+ case AssignmentAction::Assigning:
+ case AssignmentAction::Initializing:
// The destination type comes first.
FirstType = DstType;
SecondType = SrcType;
break;
- case AA_Returning:
- case AA_Passing:
- case AA_Passing_CFAudited:
- case AA_Converting:
- case AA_Sending:
- case AA_Casting:
+ case AssignmentAction::Returning:
+ case AssignmentAction::Passing:
+ case AssignmentAction::Passing_CFAudited:
+ case AssignmentAction::Converting:
+ case AssignmentAction::Sending:
+ case AssignmentAction::Casting:
// The source type comes first.
FirstType = SrcType;
SecondType = DstType;
@@ -16844,8 +16844,8 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
PartialDiagnostic FDiag = PDiag(DiagKind);
AssignmentAction ActionForDiag = Action;
- if (Action == AA_Passing_CFAudited)
- ActionForDiag = AA_Passing;
+ if (Action == AssignmentAction::Passing_CFAudited)
+ ActionForDiag = AssignmentAction::Passing;
FDiag << FirstType << SecondType << ActionForDiag
<< SrcExpr->getSourceRange();
@@ -16885,7 +16885,7 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy,
if (CheckInferredResultType)
ObjC().EmitRelatedResultTypeNote(SrcExpr);
- if (Action == AA_Returning && ConvTy == IncompatiblePointer)
+ if (Action == AssignmentAction::Returning && ConvTy == IncompatiblePointer)
ObjC().EmitRelatedResultTypeNoteForReturn(DstType);
if (Complained)
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index d8719ab26cc83f..b7531581d37ff0 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2199,8 +2199,8 @@ ExprResult Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
if (getLangOpts().CPlusPlus14) {
assert(Context.getTargetInfo().getIntWidth() && "Builtin type of size 0?");
- ConvertedSize = PerformImplicitConversion(*ArraySize, Context.getSizeType(),
- AA_Converting);
+ ConvertedSize = PerformImplicitConversion(
+ *ArraySize, Context.getSizeType(), AssignmentAction::Converting);
if (!ConvertedSize.isInvalid() &&
(*ArraySize)->getType()->getAs<RecordType>())
@@ -3851,7 +3851,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
Context.getQualifiedType(Pointee.getUnqualifiedType(), Qs));
Ex = ImpCastExprToType(Ex.get(), Unqual, CK_NoOp);
}
- Ex = PerformImplicitConversion(Ex.get(), ParamType, AA_Passing);
+ Ex = PerformImplicitConversion(Ex.get(), ParamType,
+ AssignmentAction::Passing);
if (Ex.isInvalid())
return ExprError();
}
@@ -4256,10 +4257,9 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
}
// Watch out for ellipsis conversion.
if (!ICS.UserDefined.EllipsisConversion) {
- ExprResult Res =
- PerformImplicitConversion(From, BeforeToType,
- ICS.UserDefined.Before, AA_Converting,
- CCK);
+ ExprResult Res = PerformImplicitConversion(
+ From, BeforeToType, ICS.UserDefined.Before,
+ AssignmentAction::Converting, CCK);
if (Res.isInvalid())
return ExprError();
From = Res.get();
@@ -4282,7 +4282,7 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
return From;
return PerformImplicitConversion(From, ToType, ICS.UserDefined.After,
- AA_Converting, CCK);
+ AssignmentAction::Converting, CCK);
}
case ImplicitConversionSequence::AmbiguousConversion:
@@ -4451,19 +4451,19 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
// target entity shall allow at least the exceptions allowed by the
// source value in the assignment or initialization.
switch (Action) {
- case AA_Assigning:
- case AA_Initializing:
+ case AssignmentAction::Assigning:
+ case AssignmentAction::Initializing:
// Note, function argument passing and returning are initialization.
- case AA_Passing:
- case AA_Returning:
- case AA_Sending:
- case AA_Passing_CFAudited:
+ case AssignmentAction::Passing:
+ case AssignmentAction::Returning:
+ case AssignmentAction::Sending:
+ case AssignmentAction::Passing_CFAudited:
if (CheckExceptionSpecCompatibility(From, ToType))
return ExprError();
break;
- case AA_Casting:
- case AA_Converting:
+ case AssignmentAction::Casting:
+ case AssignmentAction::Converting:
// Casts and implicit conversions are not initialization, so are not
// checked for exception specification mismatches.
break;
@@ -4577,9 +4577,10 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
case ICK_Writeback_Conversion:
case ICK_Pointer_Conversion: {
- if (SCS.IncompatibleObjC && Action != AA_Casting) {
+ if (SCS.IncompatibleObjC && Action != AssignmentAction::Casting) {
// Diagnose incompatible Objective-C conversions
- if (Action == AA_Initializing || Action == AA_Assigning)
+ if (Action == AssignmentAction::Initializing ||
+ Action == AssignmentAction::Assigning)
Diag(From->getBeginLoc(),
diag::ext_typecheck_convert_incompatible_pointer)
<< ToType << From->getType() << Action << From->getSourceRange()
@@ -4596,12 +4597,12 @@ Sema::PerformImplicitConversion(Expr *From, QualType ToType,
} else if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
!ObjC().CheckObjCARCUnavailableWeakConversion(ToType,
From->getType())) {
- if (Action == AA_Initializing)
+ if (Action == AssignmentAction::Initializing)
Diag(From->getBeginLoc(), diag::err_arc_weak_unavailable_assign);
else
Diag(From->getBeginLoc(), diag::err_arc_convesion_of_weak_unavailable)
- << (Action == AA_Casting) << From->getType() << ToType
- << From->getSourceRange();
+ << (Action == AssignmentAction::Casting) << From->getType()
+ << ToType << From->getSourceRange();
}
// Defer address space conversion to the third conversion.
@@ -6666,14 +6667,14 @@ static bool FindConditionalOverload(Sema &Self, ExprResult &LHS, ExprResult &RHS
// We found a match. Perform the conversions on the arguments and move on.
ExprResult LHSRes = Self.PerformImplicitConversion(
LHS.get(), Best->BuiltinParamTypes[0], Best->Conversions[0],
- Sema::AA_Converting);
+ AssignmentAction::Converting);
if (LHSRes.isInvalid())
break;
LHS = LHSRes;
ExprResult RHSRes = Self.PerformImplicitConversion(
RHS.get(), Best->BuiltinParamTypes[1], Best->Conversions[1],
- Sema::AA_Converting);
+ AssignmentAction::Converting);
if (RHSRes.isInvalid())
break;
RHS = RHSRes;
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 5a19a3505454ca..7dc17187524621 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6799,43 +6799,44 @@ InitializationSequence::~InitializationSequence() {
//===----------------------------------------------------------------------===//
// Perform initialization
//===----------------------------------------------------------------------===//
-static Sema::AssignmentAction
-getAssignmentAction(const InitializedEntity &Entity, bool Diagnose = false) {
+static AssignmentAction getAssignmentAction(const InitializedEntity &Entity,
+ bool Diagnose = false) {
switch(Entity.getKind()) {
case InitializedEntity::EK_Variable:
case InitializedEntity::EK_New:
case InitializedEntity::EK_Exception:
case InitializedEntity::EK_Base:
case InitializedEntity::EK_Delegating:
- return Sema::AA_Initializing;
+ return AssignmentAction::Initializing;
case InitializedEntity::EK_Parameter:
if (Entity.getDecl() &&
isa<ObjCMethodDecl>(Entity.getDecl()->getDeclContext()))
- return Sema::AA_Sending;
+ return AssignmentAction::Sending;
- return Sema::AA_Passing;
+ return AssignmentAction::Passing;
case InitializedEntity::EK_Parameter_CF_Audited:
if (Entity.getDecl() &&
isa<ObjCMethodDecl>(Entity.getDecl()->getDeclContext()))
- return Sema::AA_Sending;
+ return AssignmentAction::Sending;
- return !Diagnose ? Sema::AA_Passing : Sema::AA_Passing_CFAudited;
+ return !Diagnose ? AssignmentAction::Passing
+ : AssignmentAction::Passing_CFAudited;
case InitializedEntity::EK_Result:
case InitializedEntity::EK_StmtExprResult: // FIXME: Not quite right.
- return Sema::AA_Returning;
+ return AssignmentAction::Returning;
case InitializedEntity::EK_Temporary:
case InitializedEntity::EK_RelatedResult:
// FIXME: Can we tell apart casting vs. converting?
- return Sema::AA_Casting;
+ return AssignmentAction::Casting;
case InitializedEntity::EK_TemplateParameter:
// This is really initialization, but refer to it as conversion for
// consistency with CheckConvertedConstantExpression.
- return Sema::AA_Converting;
+ return AssignmentAction::Converting;
case InitializedEntity::EK_Member:
case InitializedEntity::EK_ParenAggInitMember:
@@ -6847,7 +6848,7 @@ getAssignmentAction(const InitializedEntity &Entity, bool Diagnose = false) {
case InitializedEntity::EK_LambdaToBlockConversionBlockElement:
case InitializedEntity::EK_LambdaCapture:
case InitializedEntity::EK_CompoundLiteralInit:
- return Sema::AA_Initializing;
+ return AssignmentAction::Initializing;
}
llvm_unreachable("Invalid EntityKind!");
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 74c646f64b42f2..23c4903ec15855 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7395,7 +7395,8 @@ SemaOpenMP::checkOpenMPDeclareVariantFunction(SemaOpenMP::DeclGroupPtrTy DG,
return std::nullopt;
}
VariantRefCast = SemaRef.PerformImplicitConversion(
- VariantRef, FnPtrType.getUnqualifiedType(), Sema::AA_Converting);
+ VariantRef, FnPtrType.getUnqualifiedType(),
+ AssignmentAction::Converting);
if (!VariantRefCast.isUsable())
return std::nullopt;
}
@@ -8415,9 +8416,10 @@ tryBuildCapture(Sema &SemaRef, Expr *Capture,
if (SemaRef.CurContext->isDependentContext() || Capture->containsErrors())
return Capture;
if (Capture->isEvaluatable(SemaRef.Context, Expr::SE_AllowSideEffects))
- return SemaRef.PerformImplicitConversion(
- Capture->IgnoreImpCasts(), Capture->getType(), Sema::AA_Converting,
- /*AllowExplicit=*/true);
+ return SemaRef.PerformImplicitConversion(Capture->IgnoreImpCasts(),
+ Capture->getType(),
+ AssignmentAction::Converting,
+ /*AllowExplicit=*/true);
auto I = Captures.find(Capture);
if (I != Captures.end())
return buildCapture(SemaRef, Capture, I->second, Name);
@@ -8517,7 +8519,7 @@ calculateNumIters(Sema &SemaRef, Scope *S, SourceLocation DefaultLoc,
SemaRef
.PerformImplicitConversion(
SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Upper).get(),
- CastType, Sema::AA_Converting)
+ CastType, AssignmentAction::Converting)
.get();
Lower = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, Lower).get();
NewStep = SemaRef.ActOnParenExpr(DefaultLoc, DefaultLoc, NewStep.get());
@@ -8801,8 +8803,9 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
: Type->hasSignedIntegerRepresentation();
Type = C.getIntTypeForBitwidth(NewSize, IsSigned);
if (!SemaRef.Context.hasSameType(Diff.get()->getType(), Type)) {
- Diff = SemaRef.PerformImplicitConversion(
- Diff.get(), Type, Sema::AA_Converting, /*AllowExplicit=*/true);
+ Diff = SemaRef.PerformImplicitConversion(Diff.get(), Type,
+ AssignmentAction::Converting,
+ /*AllowExplicit=*/true);
if (!Diff.isUsable())
return nullptr;
}
@@ -8820,7 +8823,8 @@ Expr *OpenMPIterationSpaceChecker::buildNumIterations(
C.getTypeSize(Type) < NewSize);
if (!SemaRef.Context.hasSameType(Diff.get()->getType(), NewType)) {
Diff = SemaRef.PerformImplicitConversion(Diff.get(), NewType,
- Sema::AA_Converting, true);
+ AssignmentAction::Converting,
+ /*AllowExplicit=*/true);
if (!Diff.isUsable())
return nullptr;
}
@@ -8892,7 +8896,7 @@ std::pair<Expr *, Expr *> OpenMPIterationSpaceChecker::buildMinMaxValues(
SemaRef.Context.getUnsignedPointerDiffType())) {
Diff = SemaRef.PerformImplicitConversion(
Diff.get(), SemaRef.Context.getUnsignedPointerDiffType(),
- Sema::AA_Converting, /*AllowExplicit=*/true);
+ AssignmentAction::Converting, /*AllowExplicit=*/true);
}
if (!Diff.isUsable())
return std::make_pair(nullptr, nullptr);
@@ -8920,7 +8924,7 @@ std::pair<Expr *, Expr *> OpenMPIterationSpaceChecker::buildMinMaxValues(
// Convert to the original type.
if (SemaRef.Context.hasSameType(Diff.get()->getType(), VarType))
Diff = SemaRef.PerformImplicitConversion(Diff.get(), VarType,
- Sema::AA_Converting,
+ AssignmentAction::Converting,
/*AllowExplicit=*/true);
if (!Diff.isUsable())
return std::make_pair(nullptr, nullptr);
@@ -8955,7 +8959,7 @@ Expr *OpenMPIterationSpaceChecker::buildPreCond(
return SemaRef
.PerformImplicitConversion(
SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get(),
- SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
+ SemaRef.Context.BoolTy, /*Action=*/AssignmentAction::Casting,
/*AllowExplicit=*/true)
.get();
@@ -8976,7 +8980,8 @@ Expr *OpenMPIterationSpaceChecker::buildPreCond(
if (!SemaRef.Context.hasSameUnqualifiedType(CondExpr.get()->getType(),
SemaRef.Context.BoolTy))
CondExpr = SemaRef.PerformImplicitConversion(
- CondExpr.get(), SemaRef.Context.BoolTy, /*Action=*/Sema::AA_Casting,
+ CondExpr.get(), SemaRef.Context.BoolTy,
+ /*Action=*/AssignmentAction::Casting,
/*AllowExplicit=*/true);
}
@@ -9393,7 +9398,7 @@ buildCounterInit(Sema &SemaRef, Scope *S, SourceLocation Loc, ExprResult VarRef,
if (!SemaRef.Context.hasSameType(NewStart.get()->getType(),
VarRef.get()->getType())) {
NewStart = SemaRef.PerformImplicitConversion(
- NewStart.get(), VarRef.get()->getType(), Sema::AA_Converting,
+ NewStart.get(), VarRef.get()->getType(), AssignmentAction::Converting,
/*AllowExplicit=*/true);
if (!NewStart.isUsable())
return ExprError();
@@ -9469,7 +9474,8 @@ static ExprResult buildCounterUpdate(
if (!SemaRef.Context.hasSameType(Update.get()->getType(),
VarRef.get()->getType())) {
Update = SemaRef.PerformImplicitConversion(
- Update.get(), VarRef.get()->getType(), Sema::AA_Converting, true);
+ Update.get(), VarRef.get()->getType(), AssignmentAction::Converting,
+ /*AllowExplicit=*/true);
if (!Update.isUsable())
return ExprError();
}
@@ -9491,8 +9497,8 @@ static ExprResult widenIterationCount(unsigned Bits, Expr *E, Sema &SemaRef) {
return ExprResult(E);
// OK to convert to signed, because new type has more bits than old.
QualType NewType = C.getIntTypeForBitwidth(Bits, /*Signed=*/true);
- return SemaRef.PerformImplicitConversion(E, NewType, Sema::AA_Converting,
- true);
+ return SemaRef.PerformImplicitConversion(
+ E, NewType, AssignmentAction::Converting, /*AllowExplicit=*/true);
}
/// Check if the given expression \a E is a constant integer that fits
@@ -9752,19 +9758,19 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
// true).
auto PreCond = ExprResult(IterSpaces[0].PreCond);
Expr *N0 = IterSpaces[0].NumIterations;
- ExprResult LastIteration32 =
- widenIterationCount(/*Bits=*/32,
- SemaRef
- .PerformImplicitConversion(
- N0->IgnoreImpCasts(), N0->getType(),
- Sema::AA_Converting, /*AllowExplicit=*/true)
- .get(),
- SemaRef);
+ ExprResult LastIteration32 = widenIterationCount(
+ /*Bits=*/32,
+ SemaRef
+ .PerformImplicitConversion(N0->IgnoreImpCasts(), N0->getType(),
+ AssignmentAction::Converting,
+ /*AllowExplicit=*/true)
+ .get(),
+ SemaRef);
ExprResult LastIteration64 = widenIterationCount(
/*Bits=*/64,
SemaRef
.PerformImplicitConversion(N0->IgnoreImpCasts(), N0->getType(),
- Sema::AA_Converting,
+ AssignmentAction::Converting,
/*AllowExplicit=*/true)
.get(),
SemaRef);
@@ -9790,7 +9796,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
CurScope, Loc, BO_Mul, LastIteration32.get(),
SemaRef
.PerformImplicitConversion(N->IgnoreImpCasts(), N->getType(),
- Sema::AA_Converting,
+ AssignmentAction::Converting,
/*AllowExplicit=*/true)
.get());
if (LastIteration64.isUsable())
@@ -9798,7 +9804,7 @@ checkOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
CurScope, Loc, BO_Mul, LastIteration64.get(),
SemaRef
.PerformImplicitConversion(N->IgnoreImpCasts(), N->getType(),
- Sema::AA_Converting,
+ AssignmentAction::Converting,
/*AllowExplicit=*/true)
.get());
}
@@ -11538,7 +11544,7 @@ bool OpenMPAtomicUpdateChecker::checkStatement(Stmt *S, unsigned DiagId,
if (Update.isInvalid())
return true;
Update = SemaRef.PerformImplicitConversion(Update.get(), X->getType(),
- Sema::AA_Casting);
+ AssignmentAction::Casting);
if (Update.isInvalid())
return true;
UpdateExpr = Update.get();
@@ -15655,7 +15661,7 @@ static bool findOMPAllocatorHandleT(Sema &S, SourceLocation Loc,
break;
}
Res = S.PerformImplicitConversion(Res.get(), AllocatorHandleEnumTy,
- Sema::AA_Initializing,
+ AssignmentAction::Initializing,
/*AllowExplicit=*/true);
if (!Res.isUsable()) {
ErrorFound = true;
@@ -15686,7 +15692,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPAllocatorClause(Expr *A,
return nullptr;
Allocator = SemaRef.PerformImplicitConversion(
Allocator.get(), DSAStack->getOMPAllocatorHandleT(),
- Sema::AA_Initializing,
+ AssignmentAction::Initializing,
/*AllowExplicit=*/true);
if (Allocator.isInvalid())
return nullptr;
@@ -23096,7 +23102,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPAllocateClause(
return nullptr;
AllocatorRes = SemaRef.PerformImplicitConversion(
AllocatorRes.get(), DSAStack->getOMPAllocatorHandleT(),
- Sema::AA_Initializing,
+ AssignmentAction::Initializing,
/*AllowExplicit=*/true);
if (AllocatorRes.isInvalid())
return nullptr;
@@ -23939,14 +23945,14 @@ ExprResult SemaOpenMP::ActOnOMPIteratorExpr(Scope *S,
Expr *Begin = D.Range.Begin;
if (!IsDeclTyDependent && Begin && !Begin->isTypeDependent()) {
- ExprResult BeginRes =
- SemaRef.PerformImplicitConversion(Begin, DeclTy, Sema::AA_Converting);
+ ExprResult BeginRes = SemaRef.PerformImplicitConversion(
+ Begin, DeclTy, AssignmentAction::Converting);
Begin = BeginRes.get();
}
Expr *End = D.Range.End;
if (!IsDeclTyDependent && End && !End->isTypeDependent()) {
- ExprResult EndRes =
- SemaRef.PerformImplicitConversion(End, DeclTy, Sema::AA_Converting);
+ ExprResult EndRes = SemaRef.PerformImplicitConversion(
+ End, DeclTy, AssignmentAction::Converting);
End = EndRes.get();
}
Expr *Step = D.Range.Step;
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 1ce0fa091938d7..a3c13e21c709cb 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1811,9 +1811,9 @@ ExprResult Sema::PerformImplicitConversion(Expr *From, QualType ToType,
return ExprError();
// Objective-C ARC: Determine whether we will allow the writeback conversion.
- bool AllowObjCWritebackConversion
- = getLangOpts().ObjCAutoRefCount &&
- (Action == AA_Passing || Action == AA_Sending);
+ bool AllowObjCWritebackConversion =
+ getLangOpts().ObjCAutoRefCount && (Action == AssignmentAction::Passing ||
+ Action == AssignmentAction::Sending);
if (getLangOpts().ObjC)
ObjC().CheckObjCBridgeRelatedConversions(From->getBeginLoc(), ToType,
From->getType(), From);
@@ -5983,7 +5983,8 @@ ExprResult Sema::PerformContextuallyConvertToBool(Expr *From) {
ImplicitConversionSequence ICS = TryContextuallyConvertToBool(*this, From);
if (!ICS.isBad())
- return PerformImplicitConversion(From, Context.BoolTy, ICS, AA_Converting);
+ return PerformImplicitConversion(From, Context.BoolTy, ICS,
+ AssignmentAction::Converting);
if (!DiagnoseMultipleUserDefinedConversion(From, Context.BoolTy))
return Diag(From->getBeginLoc(), diag::err_typecheck_bool_condition)
@@ -6149,7 +6150,8 @@ static ExprResult BuildConvertedConstantExpression(Sema &S, Expr *From,
T, cast<NonTypeTemplateParmDecl>(Dest)),
SourceLocation(), From);
} else {
- Result = S.PerformImplicitConversion(From, T, ICS, Sema::AA_Converting);
+ Result =
+ S.PerformImplicitConversion(From, T, ICS, AssignmentAction::Converting);
}
if (Result.isInvalid())
return Result;
@@ -6370,7 +6372,8 @@ ExprResult Sema::PerformContextuallyConvertToObjCPointer(Expr *From) {
ImplicitConversionSequence ICS =
TryContextuallyConvertToObjCPointer(*this, From);
if (!ICS.isBad())
- return PerformImplicitConversion(From, Ty, ICS, AA_Converting);
+ return PerformImplicitConversion(From, Ty, ICS,
+ AssignmentAction::Converting);
return ExprResult();
}
@@ -14363,7 +14366,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
// break out so that we will build the appropriate built-in
// operator node.
ExprResult InputRes = PerformImplicitConversion(
- Input, Best->BuiltinParamTypes[0], Best->Conversions[0], AA_Passing,
+ Input, Best->BuiltinParamTypes[0], Best->Conversions[0],
+ AssignmentAction::Passing,
CheckedConversionKind::ForBuiltinOverloadedOp);
if (InputRes.isInvalid())
return ExprError();
@@ -14825,14 +14829,16 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
// operator node.
ExprResult ArgsRes0 = PerformImplicitConversion(
Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
- AA_Passing, CheckedConversionKind::ForBuiltinOverloadedOp);
+ AssignmentAction::Passing,
+ CheckedConversionKind::ForBuiltinOverloadedOp);
if (ArgsRes0.isInvalid())
return ExprError();
Args[0] = ArgsRes0.get();
ExprResult ArgsRes1 = PerformImplicitConversion(
Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
- AA_Passing, CheckedConversionKind::ForBuiltinOverloadedOp);
+ AssignmentAction::Passing,
+ CheckedConversionKind::ForBuiltinOverloadedOp);
if (ArgsRes1.isInvalid())
return ExprError();
Args[1] = ArgsRes1.get();
@@ -15203,14 +15209,16 @@ ExprResult Sema::CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
// operator node.
ExprResult ArgsRes0 = PerformImplicitConversion(
Args[0], Best->BuiltinParamTypes[0], Best->Conversions[0],
- AA_Passing, CheckedConversionKind::ForBuiltinOverloadedOp);
+ AssignmentAction::Passing,
+ CheckedConversionKind::ForBuiltinOverloadedOp);
if (ArgsRes0.isInvalid())
return ExprError();
Args[0] = ArgsRes0.get();
ExprResult ArgsRes1 = PerformImplicitConversion(
Args[1], Best->BuiltinParamTypes[1], Best->Conversions[1],
- AA_Passing, CheckedConversionKind::ForBuiltinOverloadedOp);
+ AssignmentAction::Passing,
+ CheckedConversionKind::ForBuiltinOverloadedOp);
if (ArgsRes1.isInvalid())
return ExprError();
Args[1] = ArgsRes1.get();
diff --git a/clang/lib/Sema/SemaPseudoObject.cpp b/clang/lib/Sema/SemaPseudoObject.cpp
index fdb584ceb81059..30ed47e6e56ec9 100644
--- a/clang/lib/Sema/SemaPseudoObject.cpp
+++ b/clang/lib/Sema/SemaPseudoObject.cpp
@@ -787,7 +787,7 @@ ExprResult ObjCPropertyOpBuilder::buildSet(Expr *op, SourceLocation opcLoc,
if (opResult.isInvalid() ||
S.DiagnoseAssignmentResult(assignResult, opcLoc, paramType,
op->getType(), opResult.get(),
- Sema::AA_Assigning))
+ AssignmentAction::Assigning))
return ExprError();
op = opResult.get();
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index ba681671eb3290..9664287b9a3fe9 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3151,7 +3151,8 @@ Sema::ActOnIndirectGotoStmt(SourceLocation GotoLoc, SourceLocation StarLoc,
if (ExprRes.isInvalid())
return StmtError();
E = ExprRes.get();
- if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E, AA_Passing))
+ if (DiagnoseAssignmentResult(ConvTy, StarLoc, DestTy, ETy, E,
+ AssignmentAction::Passing))
return StmtError();
}
More information about the cfe-commits
mailing list