diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-07-19 07:02:30 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-07-19 07:02:30 +0000 |
commit | de51d671486b6ac9a2ad9ee5fcfdb1a23cc59238 (patch) | |
tree | 17ff629bd1f00b82d8dbb66a022e2f59e218c3c2 /tools/clang-fuzzer | |
parent | 8746d127c04f5bbaf6c6e88cef8606ca5a6a54e9 (diff) |
Vendor import of clang trunk r308421:vendor/clang/clang-trunk-r308421
Notes
Notes:
svn path=/vendor/clang/dist/; revision=321186
svn path=/vendor/clang/clang-trunk-r308421/; revision=321187; tag=vendor/clang/clang-trunk-r308421
Diffstat (limited to 'tools/clang-fuzzer')
-rw-r--r-- | tools/clang-fuzzer/CMakeLists.txt | 3 | ||||
-rw-r--r-- | tools/clang-fuzzer/ClangFuzzer.cpp | 11 |
2 files changed, 11 insertions, 3 deletions
diff --git a/tools/clang-fuzzer/CMakeLists.txt b/tools/clang-fuzzer/CMakeLists.txt index 87d21c6bf116..a4ea4ca19cdd 100644 --- a/tools/clang-fuzzer/CMakeLists.txt +++ b/tools/clang-fuzzer/CMakeLists.txt @@ -1,5 +1,5 @@ if( LLVM_USE_SANITIZE_COVERAGE ) - set(LLVM_LINK_COMPONENTS support) + set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD}) add_clang_executable(clang-fuzzer EXCLUDE_FROM_ALL @@ -10,6 +10,7 @@ if( LLVM_USE_SANITIZE_COVERAGE ) ${CLANG_FORMAT_LIB_DEPS} clangAST clangBasic + clangCodeGen clangDriver clangFrontend clangRewriteFrontend diff --git a/tools/clang-fuzzer/ClangFuzzer.cpp b/tools/clang-fuzzer/ClangFuzzer.cpp index 1692882c0b5f..9eceb843e581 100644 --- a/tools/clang-fuzzer/ClangFuzzer.cpp +++ b/tools/clang-fuzzer/ClangFuzzer.cpp @@ -14,18 +14,25 @@ //===----------------------------------------------------------------------===// #include "clang/Tooling/Tooling.h" -#include "clang/Frontend/FrontendActions.h" +#include "clang/CodeGen/CodeGenAction.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/PreprocessorOptions.h" #include "llvm/Option/Option.h" +#include "llvm/Support/TargetSelect.h" using namespace clang; extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { std::string s((const char *)data, size); + llvm::InitializeAllTargets(); + llvm::InitializeAllTargetMCs(); + llvm::InitializeAllAsmPrinters(); + llvm::InitializeAllAsmParsers(); + llvm::opt::ArgStringList CC1Args; CC1Args.push_back("-cc1"); CC1Args.push_back("./test.cc"); + CC1Args.push_back("-O2"); llvm::IntrusiveRefCntPtr<FileManager> Files( new FileManager(FileSystemOptions())); IgnoringDiagConsumer Diags; @@ -39,7 +46,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) { llvm::MemoryBuffer::getMemBuffer(s); Invocation->getPreprocessorOpts().addRemappedFile("./test.cc", Input.release()); std::unique_ptr<tooling::ToolAction> action( - tooling::newFrontendActionFactory<clang::SyntaxOnlyAction>()); + tooling::newFrontendActionFactory<clang::EmitObjAction>()); std::shared_ptr<PCHContainerOperations> PCHContainerOps = std::make_shared<PCHContainerOperations>(); action->runInvocation(std::move(Invocation), Files.get(), PCHContainerOps, |