From 3d612a930dce229c887cd9a731084df419f43791 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Tue, 19 Apr 2022 16:28:33 -0700 Subject: [PATCH] [NFC] Avoid unnecessary duplication of code generating diagnostic. The previous code unneccessarily duplicated the creation of a diagnostic where the only difference was the `AssignmentAction` being passed. rdar://88664722 Differential Revision: https://reviews.llvm.org/D124054 --- clang/lib/Sema/SemaExpr.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 7fbe083571e6..58aab637ff30 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -16932,10 +16932,12 @@ bool Sema::DiagnoseAssignmentResult(AssignConvertType ConvTy, } PartialDiagnostic FDiag = PDiag(DiagKind); + AssignmentAction ActionForDiag = Action; if (Action == AA_Passing_CFAudited) - FDiag << FirstType << SecondType << AA_Passing << SrcExpr->getSourceRange(); - else - FDiag << FirstType << SecondType << Action << SrcExpr->getSourceRange(); + ActionForDiag = AA_Passing; + + FDiag << FirstType << SecondType << ActionForDiag + << SrcExpr->getSourceRange(); if (DiagKind == diag::ext_typecheck_convert_incompatible_pointer_sign || DiagKind == diag::err_typecheck_convert_incompatible_pointer_sign) {