llvm-project/clang/lib/AST/Interp/InterpBuiltin.cpp
Timm Bäder 760136ff13 [clang][Interp] Implement __builtin_assume
Just ignore it.

As part of this, move the Ret and RetVoid implementation to Interp.h, so
they can be shared with InterpBuiltin.cpp.

Differential Revision: https://reviews.llvm.org/D141193
2023-01-27 07:54:37 +01:00

34 lines
950 B
C++

//===--- InterpBuiltin.cpp - Interpreter for the constexpr VM ---*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "Boolean.h"
#include "Interp.h"
#include "PrimType.h"
#include "clang/Basic/Builtins.h"
namespace clang {
namespace interp {
bool InterpretBuiltin(InterpState &S, CodePtr &PC, unsigned BuiltinID) {
APValue Dummy;
switch (BuiltinID) {
case Builtin::BI__builtin_is_constant_evaluated:
S.Stk.push<Boolean>(Boolean::from(S.inConstantContext()));
return Ret<PT_Bool, true>(S, PC, Dummy);
case Builtin::BI__builtin_assume:
return RetVoid<true>(S, PC, Dummy);
default:
return false;
}
return false;
}
} // namespace interp
} // namespace clang