ladybird/Tests/ClangPlugins/CMakeLists.txt
Timothy Flynn 2803d66d87 AK: Support UTF-16 string formatting
The underlying storage used during string formatting is StringBuilder.
To support UTF-16 strings, this patch allows callers to specify a mode
during StringBuilder construction. The default mode is UTF-8, for which
StringBuilder remains unchanged.

In UTF-16 mode, we treat the StringBuilder's internal ByteBuffer as a
series of u16 code units. Appending a single character will append 2
bytes for that character (cast to a char16_t). Appending a StringView
will transcode the string to UTF-16.

Utf16String also gains the same memory optimization that we added for
String, where we hand-off the underlying buffer to Utf16String to avoid
having to re-allocate.

In the future, we may want to further optimize for ASCII strings. For
example, we could defer committing to the u16-esque storage until we
see a non-ASCII code point.
2025-07-18 12:45:38 -04:00

48 lines
1.6 KiB
CMake

include(clang_development)
include(AddLLVM)
find_package(Python3 REQUIRED COMPONENTS Interpreter)
get_property(CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS GLOBAL PROPERTY CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS)
list(APPEND CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS
-std=c++23
-Wno-invalid-offsetof
-Wno-literal-range
-Wno-unknown-warning-option
-Wno-unqualified-std-cast-call
-Wno-user-defined-literals
)
# Ensure we always check for invalid function field types regardless of the value of ENABLE_CLANG_PLUGINS_INVALID_FUNCTION_MEMBERS
# FIXME: Enabling this with lit and llvm 18 seems to not work as expected
# list(APPEND CLANG_PLUGINS_COMPILE_OPTIONS_FOR_TESTS -fplugin-arg-libjs_gc_scanner-detect-invalid-function-members)
get_property(CLANG_PLUGINS_INCLUDE_DIRECTORIES TARGET AK PROPERTY INCLUDE_DIRECTORIES)
configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
MAIN_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
PATHS
LLVM_BINARY_DIR
LLVM_TOOLS_DIR
LLVM_LIBS_DIR
CMAKE_LIBRARY_OUTPUT_DIRECTORY
CMAKE_CURRENT_SOURCE_DIR
)
add_custom_command(
OUTPUT venv
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/requirements.txt requirements.txt
COMMAND ${Python3_EXECUTABLE} -m venv venv
COMMAND ./venv/bin/pip install -r requirements.txt --upgrade
)
add_custom_target(TestClangPluginsDependencies ALL
DEPENDS venv JSClangPlugin GenericClangPlugin
SOURCES requirements.txt
)
add_test(
NAME TestClangPlugins
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/venv/bin/lit -v .
)