IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
- cmake_minimum_required(VERSION 3.9)
# Clang plugin for static analysis
PROJECT(RspamdClangPlugin)
if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
ADD_DEFINITIONS(${LLVM_DEFINITIONS})
find_package(Clang REQUIRED)
+
+ set(clang_libs
+ clangAST
+ clangBasic
+ clangFrontend)
+
+ message(STATUS "Found LibClang in: ${CLANG_INSTALL_PREFIX}")
include_directories(${CLANG_INCLUDE_DIRS})
SET(CLANGPLUGINSRC plugin.cc printf_check.cc)
SET_TARGET_PROPERTIES(rspamd-clang PROPERTIES
COMPILE_FLAGS "-O2 -Wall -Wextra -Wno-unused-parameter -Werror"
LINKER_LANGUAGE CXX)
- set_property(TARGET rspamd-clang APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined -Wl,--as-needed")
+ IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set_property(TARGET rspamd-clang APPEND_STRING PROPERTY LINK_FLAGS " -Wl,--no-undefined -Wl,--as-needed")
+ ENDIF()
find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS})
if(found_LLVM)
target_link_libraries(rspamd-clang PRIVATE ${llvm_libs})
endif()
- set(clang_libs
- clangAST
- clangBasic
- clangFrontend)
target_link_libraries(rspamd-clang PRIVATE ${clang_libs})
ENDIF()
size_arg_handler (const Expr *arg, struct PrintfArgChecker *ctx)
{
if (sizeof (size_t) == sizeof (long)) {
- return check_builtin_type (arg,
- ctx,
- {BuiltinType::Kind::ULong,
- BuiltinType::Kind::Long},
- "%z");
+ if (sizeof (long long) == sizeof (long)) {
+ return check_builtin_type (arg,
+ ctx,
+ {BuiltinType::Kind::ULong,
+ BuiltinType::Kind::Long,
+ BuiltinType::Kind::LongLong,
+ BuiltinType::Kind::ULongLong},
+ "%z");
+ }
+ else {
+ return check_builtin_type (arg,
+ ctx,
+ {BuiltinType::Kind::ULong,
+ BuiltinType::Kind::Long},
+ "%z");
+ }
}
else if (sizeof (size_t) == sizeof (int)) {
return check_builtin_type (arg,
# Rspamd core components
IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
SET(CMAKE_C_FLAGS
- "${CMAKE_C_FLAGS} -Xclang -load -Xclang ${CMAKE_CURRENT_BINARY_DIR}/../clang-plugin/librspamd-clang.so -Xclang -add-plugin -Xclang rspamd-ast")
+ "${CMAKE_C_FLAGS} -Xclang -load -Xclang ${CMAKE_CURRENT_BINARY_DIR}/../clang-plugin/librspamd-clang${CMAKE_SHARED_LIBRARY_SUFFIX} -Xclang -add-plugin -Xclang rspamd-ast")
IF(CLANG_EXTRA_PLUGINS_LIBS)
FOREACH(_lib ${CLANG_EXTRA_PLUGINS_LIBS})
SET(CMAKE_C_FLAGS
if (offset > (gulong)st.st_size) {
msg_err_task ("invalid offset %ul (%ul available) for shm "
- "segment %s", offset, st.st_size, fp);
+ "segment %s", offset, (gulong)st.st_size, fp);
munmap (map, st.st_size);
close (fd);
if (shmem_size > (gulong)st.st_size) {
msg_err_task ("invalid length %ul (%ul available) for %s "
- "segment %s", shmem_size, st.st_size, ft, fp);
+ "segment %s", shmem_size, (gulong)st.st_size, ft, fp);
munmap (map, st.st_size);
close (fd);