[PATCH] D126960: [clang][sema] Unary not boolean to int conversion

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 10 06:27:58 PDT 2022


erichkeane added inline comments.


================
Comment at: clang/lib/Sema/SemaChecking.cpp:12328
       return IntRange::forValueOfType(C, GetExprType(E));
 
+    case UO_Not:
----------------
Richard mentions UO_PreInc, UO_PreDec, UO_Minus, and UO_Not.  What about the other 3?


================
Comment at: clang/lib/Sema/SemaChecking.cpp:12330
+    case UO_Not:
+      // unary not promotes boolean to integer
+      if (UO->getSubExpr()->isKnownToHaveBooleanValue())
----------------



================
Comment at: clang/lib/Sema/SemaChecking.cpp:12332
+      if (UO->getSubExpr()->isKnownToHaveBooleanValue())
+        return IntRange(MaxWidth, false);
+
----------------
Can you trace what MaxWidth ends up being every time?  Are we sure this will always just be int-width and not long long or something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126960



More information about the cfe-commits mailing list