https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/69072
On Mac M1, if you load something that transitively loads `#include <new>`, it will fail because ``` In file included from <<< inputs >>>:1: In file included from input_line_22:1: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/memory:671: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/__functional_base:23: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/new:214:70: error: 'internal_linkage' attribute does not appear on the first declaration 214 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} | ^ input_line_0:3:11: note: previous declaration is here 3 | void* operator new(__SIZE_TYPE__, void* __p) noexcept; | ^ Assertion failed: (Ptr && "dereferencing end() iterator"), function operator*, file DeclBase.h, line 1315. ``` This is because `MacOSX12.3.sdk/usr/include/c++/v1/__config` sets `_LIBCPP_INLINE_VISIBILITY` to be `__attribute__((__visibility__("hidden"))) __attribute__((internal_linkage))`, which makes the `new` in `<new>` incompatible with the hardcoded decl `void* operator new(__SIZE_TYPE__, void* __p) noexcept;` in `clang/lib/Interpreter/Interpreter::Runtimes`. I believe the correct thing to do is replace that decl with `#include <new>` (as I've done here). >From d7c57d94d7e75ed1e0df87ebf3c4464e7b951453 Mon Sep 17 00:00:00 2001 From: max <maksim.leven...@gmail.com> Date: Sat, 14 Oct 2023 12:46:42 -0500 Subject: [PATCH] [clang][repl] fix `new` --- clang/lib/Interpreter/Interpreter.cpp | 2 +- clang/test/Interpreter/execute.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 7968c62cbd3e7b3..ddfbc9ac01c6743 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -248,7 +248,7 @@ Interpreter::~Interpreter() { // can't find the precise resource directory in unittests so we have to hard // code them. const char *const Runtimes = R"( - void* operator new(__SIZE_TYPE__, void* __p) noexcept; + #include <new> void *__clang_Interpreter_SetValueWithAlloc(void*, void*, void*); void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*); void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*, void*); diff --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp index 6e73ed3927e8155..d54ab99749c1bac 100644 --- a/clang/test/Interpreter/execute.cpp +++ b/clang/test/Interpreter/execute.cpp @@ -20,4 +20,6 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long inline int foo() { return 42; } int r3 = foo(); +#include <memory> + %quit _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits