[clang] [clang][bytecode] Use IsNonNull op in visitBool() (PR #139846)

via cfe-commits cfe-commits at lists.llvm.org
Tue May 13 22:06:43 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We don't need to emit the nullptr and compare to it anymore.

---
Full diff: https://github.com/llvm/llvm-project/pull/139846.diff


1 Files Affected:

- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2-5) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp b/clang/lib/AST/ByteCode/Compiler.cpp
index c7fb5e8466686..96ae1f58ef4a6 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -4107,11 +4107,8 @@ template <class Emitter> bool Compiler<Emitter>::visitBool(const Expr *E) {
     return true;
 
   // Convert pointers to bool.
-  if (T == PT_Ptr) {
-    if (!this->emitNull(*T, 0, nullptr, E))
-      return false;
-    return this->emitNE(*T, E);
-  }
+  if (T == PT_Ptr)
+    return this->emitIsNonNullPtr(E);
 
   // Or Floats.
   if (T == PT_Float)

``````````

</details>


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


More information about the cfe-commits mailing list