diff --git a/NativeScript/inspector/JsV8InspectorClient.mm b/NativeScript/inspector/JsV8InspectorClient.mm index fafe0c68..60210f56 100644 --- a/NativeScript/inspector/JsV8InspectorClient.mm +++ b/NativeScript/inspector/JsV8InspectorClient.mm @@ -22,6 +22,13 @@ namespace v8_inspector { +namespace { +StringView Make8BitStringView(const std::string& value) { + return StringView(reinterpret_cast(value.data()), + value.size()); +} +} // namespace + #define NOTIFICATION(name) \ [[NSString stringWithFormat:@"%@:NativeScript.Debug.%s", \ [[NSBundle mainBundle] bundleIdentifier], name] UTF8String] @@ -257,8 +264,7 @@ } void JsV8InspectorClient::dispatchMessage(const std::string& message) { - std::vector vector = tns::ToVector(message); - StringView messageView(vector.data(), vector.size()); + StringView messageView = Make8BitStringView(message); Isolate* isolate = isolate_; v8::Locker locker(isolate); Isolate::Scope isolate_scope(isolate); @@ -343,8 +349,7 @@ auto returnString = GetReturnMessageFromDomainHandlerResult(result, requestId); if (returnString.size() > 0) { - std::vector vector = tns::ToVector(returnString); - StringView messageView(vector.data(), vector.size()); + StringView messageView = Make8BitStringView(returnString); auto msg = StringBuffer::create(messageView); this->sendNotification(std::move(msg)); } @@ -486,8 +491,7 @@ Local arg = args[0].As(); std::string message = tns::ToString(isolate, arg); - std::vector vector = tns::ToVector(message); - StringView messageView(vector.data(), vector.size()); + StringView messageView = Make8BitStringView(message); auto msg = StringBuffer::create(messageView); client->sendNotification(std::move(msg)); } diff --git a/NativeScript/inspector/src/inspector/string-16.h b/NativeScript/inspector/src/inspector/string-16.h index 7dfc5e34..ac9892f5 100644 --- a/NativeScript/inspector/src/inspector/string-16.h +++ b/NativeScript/inspector/src/inspector/string-16.h @@ -17,7 +17,7 @@ namespace v8_inspector { -using UChar = uint16_t; +using UChar = char16_t; class String16 { public: diff --git a/NativeScript/inspector/src/inspector/string-util.h b/NativeScript/inspector/src/inspector/string-util.h index 7f427d9b..82055588 100644 --- a/NativeScript/inspector/src/inspector/string-util.h +++ b/NativeScript/inspector/src/inspector/string-util.h @@ -30,13 +30,13 @@ class StringUtil { } static String fromUTF16LE(const uint16_t* data, size_t length) { - return String16::fromUTF16LE(data, length); + return String16::fromUTF16LE(reinterpret_cast(data), length); } static const uint8_t* CharactersLatin1(const String& s) { return nullptr; } static const uint8_t* CharactersUTF8(const String& s) { return nullptr; } static const uint16_t* CharactersUTF16(const String& s) { - return s.characters16(); + return reinterpret_cast(s.characters16()); } static size_t CharacterCount(const String& s) { return s.length(); } }; diff --git a/NativeScript/inspector/utils.mm b/NativeScript/inspector/utils.mm index d078e525..63a1f898 100644 --- a/NativeScript/inspector/utils.mm +++ b/NativeScript/inspector/utils.mm @@ -35,17 +35,16 @@ } std::string v8_inspector::ToStdString(const StringView& value) { - std::vector buffer(value.length()); + std::u16string value16; + value16.resize(value.length()); for (size_t i = 0; i < value.length(); i++) { if (value.is8Bit()) { - buffer[i] = value.characters8()[i]; + value16[i] = static_cast(value.characters8()[i]); } else { - buffer[i] = value.characters16()[i]; + value16[i] = static_cast(value.characters16()[i]); } } - std::u16string value16(buffer.begin(), buffer.end()); - #pragma GCC diagnostic ignored "-Wdeprecated-declarations" // FIXME: std::codecvt_utf8_utf16 is deprecated std::wstring_convert, char16_t> convert; diff --git a/NativeScript/v8runtime/V8Runtime.cpp b/NativeScript/v8runtime/V8Runtime.cpp index 42355bdf..2d49a34d 100644 --- a/NativeScript/v8runtime/V8Runtime.cpp +++ b/NativeScript/v8runtime/V8Runtime.cpp @@ -431,7 +431,7 @@ std::shared_ptr V8Runtime::prepareJavaScript( jsi::Value V8Runtime::evaluatePreparedJavaScript( const std::shared_ptr& js) { - return evaluateJavaScript(nullptr, nullptr); + return evaluateJavaScript(nullptr, ""); } void V8Runtime::queueMicrotask(const jsi::Function& callback) { @@ -1586,4 +1586,4 @@ void V8Runtime::OnHostFuncionContainerCallback( } } -} // namespace rnv8 \ No newline at end of file +} // namespace rnv8 diff --git a/download_llvm.sh b/download_llvm.sh index 568d7720..81251087 100755 --- a/download_llvm.sh +++ b/download_llvm.sh @@ -2,7 +2,7 @@ set -e source "$(dirname "$0")/build_utils.sh" -LLVM_VERSION="17.0.6" +LLVM_VERSION="17.0.7" function download_llvm() { checkpoint "Downloading llvm (version $LLVM_VERSION)..." diff --git a/metadata-generator/CMakeLists.txt b/metadata-generator/CMakeLists.txt index a8974978..e46d29b0 100644 --- a/metadata-generator/CMakeLists.txt +++ b/metadata-generator/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 3.20) project(MetadataGenerator) include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) #set(CMAKE_VERBOSE_MAKEFILE ON) @@ -13,7 +14,7 @@ if (NOT LIBXML2_FOUND) message(FATAL_ERROR "libXML2 not found") endif () -get_filename_component(LLVM_ROOT "../../llvm/17.0.6" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") +get_filename_component(LLVM_ROOT "../../llvm/17.0.7" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0) set(LLVM_SYSTEM_LIBS "-lz -lcurses -lm -lxml2") @@ -36,6 +37,18 @@ if (HAS_UNUSED_BUT_SET_VARIABLE) add_compile_options(-Wno-unused-but-set-variable) endif() +# LLVM 17.0.7 triggers this diagnostic in Clang's own headers on newer Apple toolchains. +# Keep warnings-as-errors for project code, but don't fail the build on this upstream warning. +check_cxx_compiler_flag(-Wno-error=preferred-type-bitfield-enum-conversion HAS_NO_ERROR_PREFERRED_TYPE_BITFIELD_ENUM_CONVERSION) +if (HAS_NO_ERROR_PREFERRED_TYPE_BITFIELD_ENUM_CONVERSION) + add_compile_options(-Wno-error=preferred-type-bitfield-enum-conversion) +endif() + +check_cxx_compiler_flag(-Wno-error=unnecessary-virtual-specifier HAS_NO_ERROR_UNNECESSARY_VIRTUAL_SPECIFIER) +if (HAS_NO_ERROR_UNNECESSARY_VIRTUAL_SPECIFIER) + add_compile_options(-Wno-error=unnecessary-virtual-specifier) +endif() + set(LLVM_LINKER_FLAGS "${LLVM_LINKER_FLAGS} ${LLVM_SYSTEM_LIBS} ${LLVM_LIBS}") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/lib) diff --git a/metadata-generator/src/Binary/binarySerializer.cpp b/metadata-generator/src/Binary/binarySerializer.cpp index 27d99f3b..17880b45 100644 --- a/metadata-generator/src/Binary/binarySerializer.cpp +++ b/metadata-generator/src/Binary/binarySerializer.cpp @@ -254,7 +254,7 @@ static llvm::ErrorOr isStaticFramework(clang::Module* framework) if (path.getError()) { return path.getError(); - } else if (path.get().endswith(".tbd")) { + } else if (path.get().ends_with(".tbd")) { return true; } diff --git a/metadata-generator/src/HeadersParser/Parser.cpp b/metadata-generator/src/HeadersParser/Parser.cpp index 41307597..40ac15ad 100644 --- a/metadata-generator/src/HeadersParser/Parser.cpp +++ b/metadata-generator/src/HeadersParser/Parser.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -31,9 +32,9 @@ static std::error_code addHeaderInclude(StringRef headerName, std::vector>& includes) +static std::error_code addHeaderInclude(FileEntryRef header, std::vector>& includes) { - return addHeaderInclude(header->getName(), includes); + return addHeaderInclude(header.getName(), includes); } static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleMap& modMap, const Module* module, std::vector>& includes) @@ -42,17 +43,15 @@ static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleM if (!module->isAvailable()) return std::error_code(); - if (module->Umbrella && module->Umbrella.is()) { - const FileEntry* umbrellaHeader = module->Umbrella.get(); - if (std::error_code err = addHeaderInclude(umbrellaHeader, includes)) + if (const auto* umbrellaHeader = std::get_if(&module->Umbrella)) { + if (std::error_code err = addHeaderInclude(*umbrellaHeader, includes)) return err; } - else if (module->Umbrella && module->Umbrella.is()) { - const DirectoryEntryRef umbrellaDir = module->Umbrella.get(); + else if (const auto* umbrellaDir = std::get_if(&module->Umbrella)) { // Add all of the headers we find in this subdirectory. std::error_code ec; SmallString<128> dirNative; - path::native(umbrellaDir.getName(), dirNative); + path::native(umbrellaDir->getName(), dirNative); for (fs::recursive_directory_iterator dir(dirNative.str(), ec), dirEnd; dir != dirEnd && !ec; dir.increment(ec)) { // Check whether this entry has an extension typically associated with headers. if (!llvm::StringSwitch(path::extension(dir->path())) @@ -77,8 +76,8 @@ static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleM if (ec) return ec; } else { - for (auto header : module->Headers[Module::HK_Normal]) { - if (auto err = addHeaderInclude(header.Entry, includes)) + for (FileEntryRef header : const_cast(module)->getTopHeaders(fileMgr)) { + if (auto err = addHeaderInclude(header, includes)) return err; } } diff --git a/metadata-generator/src/TypeScript/DefinitionWriter.cpp b/metadata-generator/src/TypeScript/DefinitionWriter.cpp index d081c8fb..6c75345b 100644 --- a/metadata-generator/src/TypeScript/DefinitionWriter.cpp +++ b/metadata-generator/src/TypeScript/DefinitionWriter.cpp @@ -583,7 +583,7 @@ std::string DefinitionWriter::writeMethod(MethodMeta* meta, BaseClassMeta* owner } } - if ((owner->type == MetaType::Protocol && methodDecl.getImplementationControl() == clang::ObjCMethodDecl::ImplementationControl::Optional) || (owner->is(MetaType::Protocol) && meta->getFlags(MethodIsInitializer))) { + if ((owner->type == MetaType::Protocol && methodDecl.getImplementationControl() == clang::ObjCImplementationControl::Optional) || (owner->is(MetaType::Protocol) && meta->getFlags(MethodIsInitializer))) { output << "?"; }