[clang] [clang][bytecode] Implement __noop (PR #106714)

via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 04:47:09 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

This does nothing and returns 0.

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


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+4) 
- (modified) clang/test/AST/ByteCode/ms.cpp (+2) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 1a71bff25d2540..81e49f203524b7 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -1593,6 +1593,10 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F,
       return false;
     break;
 
+  case Builtin::BI__noop:
+    pushInteger(S, 0, Call->getType());
+    break;
+
   default:
     S.FFDiag(S.Current->getLocation(OpPC),
              diag::note_invalid_subexpr_in_const_expr)
diff --git a/clang/test/AST/ByteCode/ms.cpp b/clang/test/AST/ByteCode/ms.cpp
index fe5ed219946e76..816f61fec37747 100644
--- a/clang/test/AST/ByteCode/ms.cpp
+++ b/clang/test/AST/ByteCode/ms.cpp
@@ -8,3 +8,5 @@
 static_assert(_rotl(0x01, 5) == 32);
 
 static_assert(alignof(__unaligned int) == 1, "");
+
+static_assert(__noop() == 0, "");

``````````

</details>


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


More information about the cfe-commits mailing list