[PATCH] D107420: [WIP][sema] Disallow __builtin_mul_overflow under special condition.

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 4 06:12:02 PDT 2021


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:334-335
+    const auto ResultTy = TheCall->getArg(2)->getType()->getPointeeType();
+    // Input compination below will also emit integer value larger than
+    // 128 bits in backend, disallow same as above.
+    if (LeftTy->isSignedIntegerType() &&
----------------



================
Comment at: clang/lib/Sema/SemaChecking.cpp:340
+        S.getASTContext().getIntWidth(RightTy) > 64 &&
+        !ResultTy->isSignedIntegerType() &&
+        S.getASTContext().getIntWidth(ResultTy) > 64) {
----------------
Isn't the result type a pointer type?


================
Comment at: clang/test/Sema/builtins-overflow.c:45
+    unsigned _ExtInt(128) result;
+    _Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support special combination operands (signed, signed, unsigned*) of more than 64 bits}}
+  }
----------------
Yeah, this diagnostic really doesn't tell me what's going wrong with the code or how to fix it. Do we basically want to prevent using larger-than-64-bit argument types with mixed signs? Or are there other problematic circumstances?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107420/new/

https://reviews.llvm.org/D107420



More information about the cfe-commits mailing list