summaryrefslogtreecommitdiffstats
path: root/clang-plugin
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-22 11:21:34 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-22 11:21:34 +0100
commit5c8a82ded139e2490daa83298d3e1f29c6e7b422 (patch)
tree39e32b400b7df260cdd8ceb0125827bb20283548 /clang-plugin
parentd524e67086f2802dd019adbfff3cc4ebd5eacf5d (diff)
downloadrspamd-5c8a82ded139e2490daa83298d3e1f29c6e7b422.tar.gz
rspamd-5c8a82ded139e2490daa83298d3e1f29c6e7b422.zip
[Minor] Fix clang plugin functions on OSX
Diffstat (limited to 'clang-plugin')
-rw-r--r--clang-plugin/CMakeLists.txt16
-rw-r--r--clang-plugin/printf_check.cc21
2 files changed, 26 insertions, 11 deletions
diff --git a/clang-plugin/CMakeLists.txt b/clang-plugin/CMakeLists.txt
index 3a0b8ab8b..dc5de4717 100644
--- a/clang-plugin/CMakeLists.txt
+++ b/clang-plugin/CMakeLists.txt
@@ -1,6 +1,5 @@
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")
@@ -14,6 +13,13 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
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)
@@ -22,7 +28,9 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
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)
@@ -33,9 +41,5 @@ IF (ENABLE_CLANG_PLUGIN MATCHES "ON")
target_link_libraries(rspamd-clang PRIVATE ${llvm_libs})
endif()
- set(clang_libs
- clangAST
- clangBasic
- clangFrontend)
target_link_libraries(rspamd-clang PRIVATE ${clang_libs})
ENDIF()
diff --git a/clang-plugin/printf_check.cc b/clang-plugin/printf_check.cc
index 35df5952d..37042d47a 100644
--- a/clang-plugin/printf_check.cc
+++ b/clang-plugin/printf_check.cc
@@ -590,11 +590,22 @@ namespace rspamd {
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,