@@ -11472,36 +11472,34 @@ static void DiagnoseDivisionSizeofPointerOrArray(Sema &S, Expr *LHS, Expr *RHS,
1147211472 }
1147311473}
1147411474
11475- static void diagnoseAmbiguousProvenance(Sema &S, ExprResult &LHS,
11476- ExprResult &RHS, SourceLocation Loc,
11477- bool IsCompAssign) {
11475+ void Sema::DiagnoseAmbiguousProvenance(Expr *LHS, Expr *RHS, SourceLocation Loc,
11476+ bool IsCompAssign) {
1147811477 // For compound assignment the provenance source is obvious
1147911478 // TODO: for compound assignment, we should implement a warning that a
1148011479 // capability RHS with a non-cap LHS is potentially inefficient.
1148111480 if (IsCompAssign)
1148211481 return;
1148311482
11484- const QualType LHSType = LHS.get() ->getType();
11485- const QualType RHSType = RHS.get() ->getType();
11486- bool isLHSCap = LHSType->isCHERICapabilityType(S. Context);
11487- bool isRHSCap = RHSType->isCHERICapabilityType(S. Context);
11483+ const QualType LHSType = LHS->getType();
11484+ const QualType RHSType = RHS->getType();
11485+ bool isLHSCap = LHSType->isCHERICapabilityType(Context);
11486+ bool isRHSCap = RHSType->isCHERICapabilityType(Context);
1148811487 // If both sides can carry provenance (i.e. not marked as non-provenance
1148911488 // carrying) we should emit a warning
1149011489 bool LHSProvenance = isLHSCap && !LHSType->hasAttr(attr::CHERINoProvenance);
1149111490 bool RHSProvenance = isRHSCap && !RHSType->hasAttr(attr::CHERINoProvenance);
1149211491
1149311492 if (LHSProvenance && RHSProvenance) {
11494- S.DiagRuntimeBehavior(
11495- Loc, RHS.get(),
11496- S.PDiag(diag::warn_ambiguous_provenance_capability_binop)
11497- << LHSType << RHSType << LHS.get()->getSourceRange()
11498- << RHS.get()->getSourceRange());
11493+ DiagRuntimeBehavior(Loc, RHS,
11494+ PDiag(diag::warn_ambiguous_provenance_capability_binop)
11495+ << LHSType << RHSType << LHS->getSourceRange()
11496+ << RHS->getSourceRange());
1149911497 // In the case of ambiguous provenance we currently default to LHS-derived
1150011498 // values. To achieve this behaviour, flag the RHS as non-provenance
1150111499 // carrying for code-generation.
1150211500 // FIXME: in the future make this an error and require manual annotation.
11503- RHS.get() ->setType(
11504- S. Context.getAttributedType(attr::CHERINoProvenance, RHSType, RHSType));
11501+ RHS->setType(
11502+ Context.getAttributedType(attr::CHERINoProvenance, RHSType, RHSType));
1150511503 }
1150611504}
1150711505
@@ -11554,7 +11552,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
1155411552 DiagnoseBadDivideOrRemainderValues(*this, LHS, RHS, Loc, IsDiv);
1155511553 DiagnoseDivisionSizeofPointerOrArray(*this, LHS.get(), RHS.get(), Loc);
1155611554 } else {
11557- diagnoseAmbiguousProvenance(*this, LHS, RHS, Loc, IsCompAssign);
11555+ DiagnoseAmbiguousProvenance( LHS.get() , RHS.get() , Loc, IsCompAssign);
1155811556 }
1155911557 return compType;
1156011558}
@@ -11947,7 +11945,7 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
1194711945 if (!compType.isNull() && compType->isArithmeticType()) {
1194811946 if (CompLHSTy) *CompLHSTy = compType;
1194911947 assert(Opc == BO_AddAssign || Opc == BO_Add);
11950- diagnoseAmbiguousProvenance(*this, LHS, RHS, Loc, Opc == BO_AddAssign);
11948+ DiagnoseAmbiguousProvenance( LHS.get() , RHS.get() , Loc, Opc == BO_AddAssign);
1195111949 return compType;
1195211950 }
1195311951
@@ -14100,7 +14098,7 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS,
1410014098
1410114099 if (!compType.isNull() && compType->isIntegralOrUnscopedEnumerationType()) {
1410214100 const bool UsingUIntCapOffset = getLangOpts().cheriUIntCapUsesOffset();
14103- diagnoseAmbiguousProvenance(*this, LHS, RHS, Loc, IsCompAssign);
14101+ DiagnoseAmbiguousProvenance( LHS.get() , RHS.get() , Loc, IsCompAssign);
1410414102 const bool isLHSCap = LHS.get()->getType()->isCHERICapabilityType(Context);
1410514103 if (isLHSCap && (Opc == BO_And || Opc == BO_AndAssign)) {
1410614104 // Bitwise and can cause checking low pointer bits to be compiled to
0 commit comments