[clang] [Clang][Sema] Fix -Whigher-precision-for-complex-division (PR #131477)

Mészáros Gergely via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 19 14:09:26 PDT 2025


================
@@ -10555,6 +10555,43 @@ static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS,
       << LHS.get()->getSourceRange() << RHS.get()->getSourceRange();
 }
 
+static void DetectPrecisionLossInComplexDivision(Sema &S, QualType DivisorTy,
+                                                 SourceLocation OpLoc) {
+  // Either real/real or complex/real division.
+  // Either way there can be no precision loss.
+  auto *CT = DivisorTy->getAs<ComplexType>();
+  if (!CT)
+    return;
----------------
Maetveis wrote:

Changing to RHS (divisor) is intended. If the divisor is real (**not** `isAnyComplexType`) its either complex / real or real / real divison. I think the code is right. I also double checked the names of the terms of division because English isn't my primary language, but that seems right too.

https://github.com/llvm/llvm-project/pull/131477


More information about the cfe-commits mailing list