forked from OSchip/llvm-project
Make clangd-fuzzer use the normal add_llvm_fuzzer() machinery
This allows building it even if no fuzzer is enabled. (Sadly, it only builds on Linux at the moment.) Differential Revision: https://reviews.llvm.org/D60201 llvm-svn: 357654
This commit is contained in:
parent
c5615c2326
commit
920f6c8163
|
@ -116,7 +116,8 @@ add_clang_library(clangDaemon
|
|||
)
|
||||
|
||||
add_subdirectory(refactor/tweaks)
|
||||
if( LLVM_LIB_FUZZING_ENGINE OR LLVM_USE_SANITIZE_COVERAGE )
|
||||
if (LINUX)
|
||||
# FIXME: Make fuzzer not use linux-specific APIs, build it everywhere.
|
||||
add_subdirectory(fuzzer)
|
||||
endif()
|
||||
add_subdirectory(tool)
|
||||
|
|
|
@ -2,13 +2,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
|||
|
||||
set(LLVM_LINK_COMPONENTS support)
|
||||
|
||||
if(LLVM_USE_SANITIZE_COVERAGE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer")
|
||||
endif()
|
||||
|
||||
add_clang_executable(clangd-fuzzer
|
||||
EXCLUDE_FROM_ALL
|
||||
ClangdFuzzer.cpp
|
||||
# This fuzzer runs on oss-fuzz, so keep it around even if it looks unreferenced.
|
||||
add_llvm_fuzzer(clangd-fuzzer
|
||||
clangd-fuzzer.cpp
|
||||
DUMMY_MAIN DummyClangdMain.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(clangd-fuzzer
|
||||
|
@ -20,5 +17,4 @@ target_link_libraries(clangd-fuzzer
|
|||
clangSema
|
||||
clangTooling
|
||||
clangToolingCore
|
||||
${LLVM_LIB_FUZZING_ENGINE}
|
||||
)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
//===---- DummyClangdMain.cpp - Entry point to sanity check the fuzzer ----===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Implementation of main so we can build and test without linking libFuzzer.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/FuzzMutate/FuzzerCLI.h"
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size);
|
||||
int main(int argc, char *argv[]) {
|
||||
return llvm::runFuzzerOnInputs(argc, argv, LLVMFuzzerTestOneInput);
|
||||
}
|
Loading…
Reference in New Issue