[PATCH] D132098: [clang][Interp] Implement inv and neg unary operations

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 18 13:35:16 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:620
+  case UO_Deref:  // *x
+  case UO_Not:    // ~x
+  case UO_Real:   // __real x
----------------
aaron.ballman wrote:
> This is reachable and will always return true thanks to the magic of integer promotions:
> ```
> void func() {
>   bool b = true;
>   b = ~b;
> }
> ```
This code path is not just for boolean values though.


================
Comment at: clang/lib/AST/Interp/Interp.h:183
+
+  S.Stk.push<T>(Val);
+  return true;
----------------
shafik wrote:
> Shouldn't this be 
Haha, yes. I already found this bug once before locally but now imported the broken version in my main branch. Thanks for catching that.


================
Comment at: clang/test/AST/Interp/literals.cpp:2-15
+// RUN: %clang_cc1 -std=c++11 -verify %s -DREFERENCE
 
 static_assert(true, "");
 static_assert(false, ""); // expected-error{{failed}}
 static_assert(nullptr == nullptr, "");
 static_assert(1 == 1, "");
 static_assert(1 == 3, ""); // expected-error{{failed}}
----------------
aaron.ballman wrote:
> 
That works as well but is also fixed after https://reviews.llvm.org/D132136


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132098



More information about the cfe-commits mailing list