@@ -10916,36 +10916,34 @@ static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
1091610916 }
1091710917}
1091810918
10919- static void diagnoseAmbiguousProvenance(Sema &S, ExprResult &LHS,
10920- ExprResult &RHS, SourceLocation Loc,
10921- bool IsCompAssign) {
10919+ void Sema::DiagnoseAmbiguousProvenance(Expr *LHS, Expr *RHS, SourceLocation Loc,
10920+ bool IsCompAssign) {
1092210921 // For compound assignment the provenance source is obvious
1092310922 // TODO: for compound assignment, we should implement a warning that a
1092410923 // capability RHS with a non-cap LHS is potentially inefficient.
1092510924 if (IsCompAssign)
1092610925 return;
1092710926
10928- const QualType LHSType = LHS.get() ->getType();
10929- const QualType RHSType = RHS.get() ->getType();
10930- bool isLHSCap = LHSType->isCHERICapabilityType(S. Context);
10931- bool isRHSCap = RHSType->isCHERICapabilityType(S. Context);
10927+ const QualType LHSType = LHS->getType();
10928+ const QualType RHSType = RHS->getType();
10929+ bool isLHSCap = LHSType->isCHERICapabilityType(Context);
10930+ bool isRHSCap = RHSType->isCHERICapabilityType(Context);
1093210931 // If both sides can carry provenance (i.e. not marked as non-provenance
1093310932 // carrying) we should emit a warning
1093410933 bool LHSProvenance = isLHSCap && !LHSType->hasAttr(attr::CHERINoProvenance);
1093510934 bool RHSProvenance = isRHSCap && !RHSType->hasAttr(attr::CHERINoProvenance);
1093610935
1093710936 if (LHSProvenance && RHSProvenance) {
10938- S.DiagRuntimeBehavior(
10939- Loc, RHS.get(),
10940- S.PDiag(diag::warn_ambiguous_provenance_capability_binop)
10941- << LHSType << RHSType << LHS.get()->getSourceRange()
10942- << RHS.get()->getSourceRange());
10937+ DiagRuntimeBehavior(Loc, RHS,
10938+ PDiag(diag::warn_ambiguous_provenance_capability_binop)
10939+ << LHSType << RHSType << LHS->getSourceRange()
10940+ << RHS->getSourceRange());
1094310941 // In the case of ambiguous provenance we currently default to LHS-derived
1094410942 // values. To achieve this behaviour, flag the RHS as non-provenance
1094510943 // carrying for code-generation.
1094610944 // FIXME: in the future make this an error and require manual annotation.
10947- RHS.get() ->setType(
10948- S. Context.getAttributedType(attr::CHERINoProvenance, RHSType, RHSType));
10945+ RHS->setType(
10946+ Context.getAttributedType(attr::CHERINoProvenance, RHSType, RHSType));
1094910947 }
1095010948}
1095110949
@@ -11000,7 +10998,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
1100010998 DiagnoseBadDivideOrRemainderValues(*this, LHS, RHS, Loc, IsDiv);
1100110999 DiagnoseDivisionSizeofPointerOrArray(*this, LHS.get(), RHS.get(), Loc);
1100211000 } else {
11003- diagnoseAmbiguousProvenance(*this, LHS, RHS, Loc, IsCompAssign);
11001+ DiagnoseAmbiguousProvenance( LHS.get() , RHS.get() , Loc, IsCompAssign);
1100411002 }
1100511003 return compType;
1100611004}
@@ -11418,7 +11416,7 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
1141811416 if (!compType.isNull() && compType->isArithmeticType()) {
1141911417 if (CompLHSTy) *CompLHSTy = compType;
1142011418 assert(Opc == BO_AddAssign || Opc == BO_Add);
11421- diagnoseAmbiguousProvenance(*this, LHS, RHS, Loc, Opc == BO_AddAssign);
11419+ DiagnoseAmbiguousProvenance( LHS.get() , RHS.get() , Loc, Opc == BO_AddAssign);
1142211420 return compType;
1142311421 }
1142411422
@@ -13638,8 +13636,8 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS,
1363813636 diagnoseXorMisusedAsPow(*this, LHS, RHS, Loc);
1363913637
1364013638 if (!compType.isNull() && compType->isIntegralOrUnscopedEnumerationType()) {
13641- const bool UsingUIntCapOffset = getLangOpts().cheriUIntCapUsesOffset();
13642- diagnoseAmbiguousProvenance(*this, LHS, RHS, Loc, IsCompAssign);
13639+ const bool UsingUIntCapOffset = getLangOpts().cheriUIntCapUsesOffset();
13640+ DiagnoseAmbiguousProvenance( LHS.get() , RHS.get() , Loc, IsCompAssign);
1364313641 const bool isLHSCap = LHS.get()->getType()->isCHERICapabilityType(Context);
1364413642 if (isLHSCap && (Opc == BO_And || Opc == BO_AndAssign)) {
1364513643 // Bitwise and can cause checking low pointer bits to be compiled to
0 commit comments