r308045 - do more processing in clang-fuzzer (use EmitAssemblyAction)
Kostya Serebryany via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 14 11:42:07 PDT 2017
Author: kcc
Date: Fri Jul 14 11:42:07 2017
New Revision: 308045
URL: http://llvm.org/viewvc/llvm-project?rev=308045&view=rev
Log:
do more processing in clang-fuzzer (use EmitAssemblyAction)
Summary: use EmitAssemblyAction in clang-fuzzer
Reviewers: klimek, rsmith
Reviewed By: klimek
Subscribers: cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D34267
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=308045&r1=308044&r2=308045&view=diff
==============================================================================
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Fri Jul 14 11:42:07 2017
@@ -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
Modified: cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=308045&r1=308044&r2=308045&view=diff
==============================================================================
--- cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp (original)
+++ cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp Fri Jul 14 11:42:07 2017
@@ -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(ui
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,
More information about the cfe-commits
mailing list