[PATCH] D124054: [NFC] Avoid unnecessary duplication of code generating diagnostic.

Dan Liew via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 19 17:31:34 PDT 2022


delcypher created this revision.
delcypher added reviewers: rapidsna, fcloutier, aaron.ballman.
Herald added a project: All.
delcypher requested review of this revision.
Herald added a project: clang.

The previous code unneccessarily duplicated the creation of a diagnostic
where the only difference was the `AssignmentAction` being passed.

rdar://88664722


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124054

Files:
  clang/lib/Sema/SemaExpr.cpp


Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16943,10 +16943,12 @@
   }
 
   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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124054.423776.patch
Type: text/x-patch
Size: 778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220420/ba276a4b/attachment-0001.bin>


More information about the cfe-commits mailing list