Skip to content

Commit 4572efe

Browse files
authored
[Clang][Interp] __builtin_os_log_format_buffer_size should be an unevaluated builtin (llvm#99895)
Follow the current behavior of constant evaluator, `__builtin_os_log_format_buffer_size` should be an unevaluated builtin. The following code is well-formed: ``` void test_builtin_os_log(void *buf, int i, const char *data) { constexpr int len = __builtin_os_log_format_buffer_size("%d %{public}s %{private}.16P", i, data, data); } ``` Signed-off-by: yronglin <[email protected]>
1 parent d251a32 commit 4572efe

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/AST/Interp/ByteCodeEmitter.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ using namespace clang::interp;
2727
/// Similar information is available via ASTContext::BuiltinInfo,
2828
/// but that is not correct for our use cases.
2929
static bool isUnevaluatedBuiltin(unsigned BuiltinID) {
30-
return BuiltinID == Builtin::BI__builtin_classify_type;
30+
return BuiltinID == Builtin::BI__builtin_classify_type ||
31+
BuiltinID == Builtin::BI__builtin_os_log_format_buffer_size;
3132
}
3233

3334
Function *ByteCodeEmitter::compileFunc(const FunctionDecl *FuncDecl) {

clang/test/CodeGen/builtins.c

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 -emit-llvm -o %t %s
22
// RUN: not grep __builtin %t
33
// RUN: %clang_cc1 -emit-llvm -triple x86_64-darwin-apple -o - %s | FileCheck %s
4+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-darwin-apple -fexperimental-new-constant-interpreter -o - %s | FileCheck %s
45

56
int printf(const char *, ...);
67

0 commit comments

Comments
 (0)