@@ -8808,40 +8808,25 @@ static bool MustDelayAttributeArguments(const ParsedAttr &AL) {
8808
8808
8809
8809
static bool checkArmNewAttrMutualExclusion (Sema &S, const ParsedAttr &AL,
8810
8810
const FunctionProtoType *FPT,
8811
- FunctionType::ArmStateValue State ,
8811
+ FunctionType::ArmStateValue CurrentState ,
8812
8812
StringRef StateName) {
8813
- std::string ArmNewStr =
8814
- std::string (" '__arm_new(\" " ) + StateName.str () + " \" )'" ;
8815
-
8816
- if (State == FunctionType::ARM_In) {
8817
- S.Diag (AL.getLoc (), diag::err_attributes_are_not_compatible)
8818
- << ArmNewStr << std::string (" '__arm_in(\" " ) + StateName.str () + " \" )'"
8819
- << true ;
8820
- AL.setInvalid ();
8821
- }
8822
-
8823
- if (State == FunctionType::ARM_Out) {
8824
- S.Diag (AL.getLoc (), diag::err_attributes_are_not_compatible)
8825
- << ArmNewStr << std::string (" '__arm_out(\" " ) + StateName.str () + " \" )'"
8826
- << true ;
8827
- AL.setInvalid ();
8828
- }
8829
-
8830
- if (State == FunctionType::ARM_InOut) {
8831
- S.Diag (AL.getLoc (), diag::err_attributes_are_not_compatible)
8832
- << ArmNewStr
8833
- << std::string (" '__arm_inout(\" " ) + StateName.str () + " \" )'" << true ;
8834
- AL.setInvalid ();
8835
- }
8836
-
8837
- if (State == FunctionType::ARM_Preserves) {
8838
- S.Diag (AL.getLoc (), diag::err_attributes_are_not_compatible)
8839
- << ArmNewStr
8840
- << std::string (" '__arm_preserves(\" " ) + StateName.str () + " \" )'"
8841
- << true ;
8842
- AL.setInvalid ();
8843
- }
8813
+ auto CheckForIncompatibleAttr =
8814
+ [&](FunctionType::ArmStateValue IncompatibleState,
8815
+ StringRef IncompatibleStateName) {
8816
+ if (CurrentState == IncompatibleState) {
8817
+ S.Diag (AL.getLoc (), diag::err_attributes_are_not_compatible)
8818
+ << (std::string (" '__arm_new(\" " ) + StateName.str () + " \" )'" )
8819
+ << (std::string (" '" ) + IncompatibleStateName.str () + " (\" " +
8820
+ StateName.str () + " \" )'" )
8821
+ << true ;
8822
+ AL.setInvalid ();
8823
+ }
8824
+ };
8844
8825
8826
+ CheckForIncompatibleAttr (FunctionType::ARM_In, " __arm_in" );
8827
+ CheckForIncompatibleAttr (FunctionType::ARM_Out, " __arm_out" );
8828
+ CheckForIncompatibleAttr (FunctionType::ARM_InOut, " __arm_inout" );
8829
+ CheckForIncompatibleAttr (FunctionType::ARM_Preserves, " __arm_preserves" );
8845
8830
return AL.isInvalid ();
8846
8831
}
8847
8832
0 commit comments