move the fuzzer to tools/fuzzer

http://reviews.llvm.org/D7289

Files:
  tools/CMakeLists.txt
  tools/fuzzer/
  tools/fuzzer/CMakeLists.txt
  tools/fuzzer/ClangFuzzer.cpp

Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -15,6 +15,10 @@
   add_subdirectory(clang-check)
 endif()
 
+if( LLVM_USE_SANITIZE_COVERAGE )
+  add_subdirectory(fuzzer)
+endif()
+
 # We support checking out the clang-tools-extra repository into the 'extra'
 # subdirectory. It contains tools developed as part of the Clang/LLVM project
 # on top of the Clang tooling platform. We keep them in a separate repository
Index: tools/fuzzer/CMakeLists.txt
===================================================================
--- /dev/null
+++ tools/fuzzer/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_executable(clang-fuzzer
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangFrontend
+  clangLex
+  clangRewrite
+  clangTooling
+  clangToolingCore
+  LLVMFuzzer
+  )
Index: tools/fuzzer/ClangFuzzer.cpp
===================================================================
--- /dev/null
+++ tools/fuzzer/ClangFuzzer.cpp
@@ -0,0 +1,34 @@
+//===-- ClangFuzzer.cpp - Fuzz Clang 
--------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file implements a function that runs Clang on a single
+///  input. This function is then linked into the Fuzzer library.
+///  See llvm/lib/Fuzzer/README.txt for more instructions.
+///
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "clang/Tooling/Tooling.h"
+#include <string>
+
+// FIXME: The current implementation is very naive an inefficient:
+// - buildASTFromCode does a lot of driver work which slows down things.
+// - Errors are reported to stderr slowing things even further.
+//
+// What we really need here is a function that takes the array of bytes
+// and invokes preprocessor and/or parser on it, sending messages to dev/null.
+
+extern "C" void TestOneInput(uint8_t *data, size_t size) {
+  std::string S((char*)data, size);
+  clang::tooling::buildASTFromCode(S);
+}

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: tools/CMakeLists.txt
===================================================================
--- tools/CMakeLists.txt
+++ tools/CMakeLists.txt
@@ -15,6 +15,10 @@
   add_subdirectory(clang-check)
 endif()
 
+if( LLVM_USE_SANITIZE_COVERAGE )
+  add_subdirectory(fuzzer)
+endif()
+
 # We support checking out the clang-tools-extra repository into the 'extra'
 # subdirectory. It contains tools developed as part of the Clang/LLVM project
 # on top of the Clang tooling platform. We keep them in a separate repository
Index: tools/fuzzer/CMakeLists.txt
===================================================================
--- /dev/null
+++ tools/fuzzer/CMakeLists.txt
@@ -0,0 +1,17 @@
+set(LLVM_LINK_COMPONENTS support)
+
+add_clang_executable(clang-fuzzer
+  ClangFuzzer.cpp
+  )
+
+target_link_libraries(clang-fuzzer
+  clangAST
+  clangASTMatchers
+  clangBasic
+  clangFrontend
+  clangLex
+  clangRewrite
+  clangTooling
+  clangToolingCore
+  LLVMFuzzer
+  )
Index: tools/fuzzer/ClangFuzzer.cpp
===================================================================
--- /dev/null
+++ tools/fuzzer/ClangFuzzer.cpp
@@ -0,0 +1,34 @@
+//===-- ClangFuzzer.cpp - Fuzz Clang --------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// \brief This file implements a function that runs Clang on a single
+///  input. This function is then linked into the Fuzzer library.
+///  See llvm/lib/Fuzzer/README.txt for more instructions.
+///
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "clang/Tooling/Tooling.h"
+#include <string>
+
+// FIXME: The current implementation is very naive an inefficient:
+// - buildASTFromCode does a lot of driver work which slows down things.
+// - Errors are reported to stderr slowing things even further.
+//
+// What we really need here is a function that takes the array of bytes
+// and invokes preprocessor and/or parser on it, sending messages to dev/null.
+
+extern "C" void TestOneInput(uint8_t *data, size_t size) {
+  std::string S((char*)data, size);
+  clang::tooling::buildASTFromCode(S);
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to