Skip to content

Commit

Permalink
Update Clang fuzzers to use libFuzzer bundled with the toolchain.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D37043

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@311516 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
George Karpenkov committed Oct 12, 2017
1 parent 2789910 commit 6609225
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tools/clang-format/fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
set(LLVM_LINK_COMPONENTS support)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")

add_clang_executable(clang-format-fuzzer
EXCLUDE_FROM_ALL
ClangFormatFuzzer.cpp
)

target_link_libraries(clang-format-fuzzer
${CLANG_FORMAT_LIB_DEPS}
LLVMFuzzer
)
${CLANG_FORMAT_LIB_DEPS})
58 changes: 48 additions & 10 deletions tools/clang-fuzzer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,59 @@
if( LLVM_USE_SANITIZE_COVERAGE )
set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")

if(CLANG_ENABLE_PROTO_FUZZER)
# Create protobuf .h and .cc files, and put them in a library for use by
# clang-proto-fuzzer components.
find_package(Protobuf REQUIRED)
add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
# executables from this directory.
set(LLVM_OPTIONAL_SOURCES
ClangFuzzer.cpp
ExampleClangProtoFuzzer.cpp
${PROTO_SRCS}
)
add_clang_library(clangCXXProto
${PROTO_SRCS}
${PROTO_HDRS}

LINK_LIBS
${PROTOBUF_LIBRARIES}
)

# Build and include libprotobuf-mutator
include(ProtobufMutator)
include_directories(${ProtobufMutator_INCLUDE_DIRS})

# Build the protobuf->C++ translation library and driver.
add_clang_subdirectory(proto-to-cxx)

# Build the protobuf fuzzer
add_clang_executable(clang-proto-fuzzer ExampleClangProtoFuzzer.cpp)
target_link_libraries(clang-proto-fuzzer
${ProtobufMutator_LIBRARIES}
clangCXXProto
clangHandleCXX
clangProtoToCXX
)
else()
# Hack to bypass LLVM's cmake sources check and allow multiple libraries and
# executables from this directory.
set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)
endif()

add_clang_subdirectory(handle-cxx)

add_clang_executable(clang-fuzzer
EXCLUDE_FROM_ALL
ClangFuzzer.cpp
)

target_link_libraries(clang-fuzzer
${CLANG_FORMAT_LIB_DEPS}
clangAST
clangBasic
clangCodeGen
clangDriver
clangFrontend
clangRewriteFrontend
clangStaticAnalyzerFrontend
clangTooling
LLVMFuzzer
clangHandleCXX
)
endif()

0 comments on commit 6609225

Please sign in to comment.