mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 08:36:06 +00:00
[clang][bytecode] Implement __noop (#106714)
This does nothing and returns 0.
This commit is contained in:
parent
4ed90920a8
commit
f838d6b1b2
@ -61,7 +61,8 @@ bool Function::isVirtual() const {
|
||||
static bool isUnevaluatedBuiltin(unsigned BuiltinID) {
|
||||
return BuiltinID == Builtin::BI__builtin_classify_type ||
|
||||
BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size ||
|
||||
BuiltinID == Builtin::BI__builtin_constant_p;
|
||||
BuiltinID == Builtin::BI__builtin_constant_p ||
|
||||
BuiltinID == Builtin::BI__noop;
|
||||
}
|
||||
|
||||
bool Function::isUnevaluatedBuiltin() const {
|
||||
|
@ -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)
|
||||
|
@ -1,5 +1,5 @@
|
||||
// RUN: %clang_cc1 -verify=ref,both %s -fms-extensions
|
||||
// RUN: %clang_cc1 -verify=expected,both %s -fexperimental-new-constant-interpreter -fms-extensions
|
||||
// RUN: %clang_cc1 -verify=ref,both %s -fms-extensions -fcxx-exceptions
|
||||
// RUN: %clang_cc1 -verify=expected,both %s -fexperimental-new-constant-interpreter -fms-extensions -fcxx-exceptions
|
||||
|
||||
// ref-no-diagnostics
|
||||
// expected-no-diagnostics
|
||||
@ -8,3 +8,14 @@
|
||||
static_assert(_rotl(0x01, 5) == 32);
|
||||
|
||||
static_assert(alignof(__unaligned int) == 1, "");
|
||||
|
||||
static_assert(__noop() == 0, "");
|
||||
|
||||
constexpr int noopIsActuallyNoop() {
|
||||
int a = 0;
|
||||
__noop(throw);
|
||||
__noop(++a);
|
||||
__noop(a = 100);
|
||||
return a;
|
||||
}
|
||||
static_assert(noopIsActuallyNoop() == 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user