[PATCH] D136936: [clang][Interp] Handle undefined functions better

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 4 00:28:10 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:24-31
+  bool HasBody = true;
+
+  // Function is not defined at all or not yet. We will
+  // create a Function instance but not compile the body. That
+  // will (maybe) happen later.
   if (!FuncDecl->isDefined(FuncDecl) ||
       (!FuncDecl->hasBody() && FuncDecl->willHaveBody()))
----------------
aaron.ballman wrote:
> .... negating the Boolean calculation and applying deMorgan's law did not make that code more clear, did it (assuming I did everything right)? If you agree, then I'm fine with the more complicated form and letting the optimizer make it faster.
I can see that going either way. I think your version is a more confusing though because the two body conditions are coupled with the `isDefined` condition. E.g. `HasBody` is `true` if `isDefined() && !willHaveBody()`, which doesn't make sense to me I think.

I think I just read this code too many times now.  How does being defined even relate to the function having a body? Should that code just be `HasBody = hasBody() || willHaveBody()`?


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

https://reviews.llvm.org/D136936



More information about the cfe-commits mailing list