<div dir="auto">I really believe this has way too many deps to live in the clang repro, as said on the review already. Maybe this could live in clang-extra instead? </div><div class="gmail_extra"><br><div class="gmail_quote">On Aug 8, 2017 4:15 PM, "Matt Morehouse via cfe-commits" <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: morehouse<br>
Date: Tue Aug 8 13:15:04 2017<br>
New Revision: 310408<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=310408&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=310408&view=rev</a><br>
Log:<br>
Integrate Kostya's clang-proto-fuzzer with LLVM.<br>
<br>
Summary:<br>
The clang-proto-fuzzer models a subset of C++ as a protobuf and<br>
uses libprotobuf-mutator to generate interesting mutations of C++<br>
programs. Clang-proto-fuzzer has already found several bugs in<br>
Clang (e.g., <a href="https://bugs.llvm.org/show_bug.cgi?id=33747" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=33747</a>,<br>
<a href="https://bugs.llvm.org/show_bug.cgi?id=33749" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=33749</a>).<br>
<br>
As with clang-fuzzer, clang-proto-fuzzer requires the following<br>
cmake flags:<br>
- CMAKE_C_COMPILER=clang<br>
- CMAKE_CXX_COMPILER=clang++<br>
- LLVM_USE_SANITIZE_COVERAGE=YESÂ // needed for libFuzzer<br>
- LLVM_USE_SANITIZER=Address // needed for libFuzzer<br>
<br>
In addition, clang-proto-fuzzer requires:<br>
- CLANG_ENABLE_PROTO_FUZZER=ON<br>
<br>
clang-proto-fuzzer also requires the following dependencies:<br>
- binutils // needed for libprotobuf-mutator<br>
- liblzma-dev // needed for libprotobuf-mutator<br>
- libz-dev // needed for libprotobuf-mutator<br>
- docbook2x // needed for libprotobuf-mutator<br>
- Recent version of protobuf [3.3.0 is known to work]<br>
<br>
A working version of libprotobuf-mutator will automatically be<br>
downloaded and built as an external project.<br>
<br>
Implementation of clang-proto-fuzzer provided by Kostya<br>
Serebryany.<br>
<br>
<a href="https://bugs.llvm.org/show_bug.cgi?id=33829" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_<wbr>bug.cgi?id=33829</a><br>
<br>
Reviewers: kcc, vitalybuka, bogner<br>
<br>
Reviewed By: kcc, vitalybuka<br>
<br>
Subscribers: thakis, mgorny, cfe-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D36324" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D36324</a><br>
<br>
Added:<br>
  cfe/trunk/cmake/modules/<wbr>ProtobufMutator.cmake<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>ExampleClangProtoFuzzer.cpp<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>README.txt<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>cxx_proto.proto<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/CMakeLists.txt<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.cpp<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.h<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/CMakeLists.txt<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.cpp<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.h<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx_<wbr>main.cpp<br>
Modified:<br>
  cfe/trunk/CMakeLists.txt<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>CMakeLists.txt<br>
  cfe/trunk/tools/clang-fuzzer/<wbr>ClangFuzzer.cpp<br>
<br>
Modified: cfe/trunk/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=310408&r1=310407&r2=310408&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/CMakeLists.<wbr>txt?rev=310408&r1=310407&r2=<wbr>310408&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/CMakeLists.txt (original)<br>
+++ cfe/trunk/CMakeLists.txt Tue Aug 8 13:15:04 2017<br>
@@ -377,6 +377,8 @@ option(CLANG_ENABLE_STATIC_<wbr>ANALYZER "Bui<br>
 option(CLANG_ANALYZER_BUILD_Z3<br>
  "Build the static analyzer with the Z3 constraint manager." OFF)<br>
<br>
+option(CLANG_ENABLE_PROTO_<wbr>FUZZER "Build Clang protobuf fuzzer." OFF)<br>
+<br>
 if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3))<br>
  message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")<br>
 endif()<br>
<br>
Added: cfe/trunk/cmake/modules/<wbr>ProtobufMutator.cmake<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/ProtobufMutator.cmake?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/cmake/<wbr>modules/ProtobufMutator.cmake?<wbr>rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/cmake/modules/<wbr>ProtobufMutator.cmake (added)<br>
+++ cfe/trunk/cmake/modules/<wbr>ProtobufMutator.cmake Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,24 @@<br>
+set(PBM_PREFIX protobuf_mutator)<br>
+set(PBM_PATH ${CMAKE_CURRENT_BINARY_DIR}/${<wbr>PBM_PREFIX}/src/${PBM_PREFIX})<br>
+set(PBM_LIB_PATH ${PBM_PATH}/src/libprotobuf-<wbr>mutator.a)<br>
+set(PBM_FUZZ_LIB_PATH ${PBM_PATH}/src/libfuzzer/<wbr>libprotobuf-mutator-libfuzzer.<wbr>a)<br>
+<br>
+ExternalProject_Add(${PBM_<wbr>PREFIX}<br>
+Â PREFIX ${PBM_PREFIX}<br>
+Â GIT_REPOSITORY <a href="https://github.com/google/libprotobuf-mutator.git" rel="noreferrer" target="_blank">https://github.com/google/<wbr>libprotobuf-mutator.git</a><br>
+Â GIT_TAG 34287f8<br>
+Â CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}<br>
+Â Â -DCMAKE_C_COMPILER=${CMAKE_C_<wbr>COMPILER}<br>
+Â Â -DCMAKE_CXX_COMPILER=${CMAKE_<wbr>CXX_COMPILER}<br>
+Â Â -DCMAKE_BUILD_TYPE=${CMAKE_<wbr>BUILD_TYPE}<br>
+Â BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}<br>
+Â BUILD_BYPRODUCTS ${PBM_LIB_PATH} ${PBM_FUZZ_LIB_PATH}<br>
+Â BUILD_IN_SOURCE 1<br>
+Â INSTALL_COMMAND ""<br>
+Â LOG_DOWNLOAD 1<br>
+Â LOG_CONFIGURE 1<br>
+Â LOG_BUILD 1<br>
+Â )<br>
+<br>
+set(ProtobufMutator_INCLUDE_<wbr>DIRS ${PBM_PATH})<br>
+set(ProtobufMutator_LIBRARIES ${PBM_FUZZ_LIB_PATH} ${PBM_LIB_PATH})<br>
<br>
Modified: cfe/trunk/tools/clang-fuzzer/<wbr>CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=310408&r1=310407&r2=310408&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/CMakeLists.txt?rev=<wbr>310408&r1=310407&r2=310408&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>CMakeLists.txt (original)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>CMakeLists.txt Tue Aug 8 13:15:04 2017<br>
@@ -1,21 +1,60 @@<br>
 if( LLVM_USE_SANITIZE_COVERAGE )<br>
  set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})<br>
<br>
+Â if(CLANG_ENABLE_PROTO_FUZZER)<br>
+Â Â # Create protobuf .h and .cc files, and put them in a library for use by<br>
+Â Â # clang-proto-fuzzer components.<br>
+Â Â find_package(Protobuf REQUIRED)<br>
+Â Â add_definitions(-DGOOGLE_<wbr>PROTOBUF_NO_RTTI)<br>
+Â Â include_directories(${<wbr>PROTOBUF_INCLUDE_DIRS})<br>
+Â Â include_directories(${CMAKE_<wbr>CURRENT_BINARY_DIR})<br>
+Â Â protobuf_generate_cpp(PROTO_<wbr>SRCS PROTO_HDRS cxx_proto.proto)<br>
+Â Â # Hack to bypass LLVM's cmake sources check and allow multiple libraries and<br>
+Â Â # executables from this directory.<br>
+Â Â set(LLVM_OPTIONAL_SOURCES<br>
+Â Â Â ClangFuzzer.cpp<br>
+Â Â Â ExampleClangProtoFuzzer.cpp<br>
+Â Â Â ${PROTO_SRCS}<br>
+Â Â Â )<br>
+Â Â add_clang_library(<wbr>clangCXXProto<br>
+Â Â Â ${PROTO_SRCS}<br>
+Â Â Â ${PROTO_HDRS}<br>
+<br>
+Â Â Â LINK_LIBS<br>
+Â Â Â ${PROTOBUF_LIBRARIES}<br>
+Â Â Â )<br>
+<br>
+Â Â # Build and include libprotobuf-mutator<br>
+Â Â include(ProtobufMutator)<br>
+Â Â include_directories(${<wbr>ProtobufMutator_INCLUDE_DIRS})<br>
+<br>
+Â Â # Build the protobuf->C++ translation library and driver.<br>
+Â Â add_clang_subdirectory(proto-<wbr>to-cxx)<br>
+<br>
+Â Â # Build the protobuf fuzzer<br>
+Â Â add_clang_executable(clang-<wbr>proto-fuzzer ExampleClangProtoFuzzer.cpp)<br>
+Â Â target_link_libraries(clang-<wbr>proto-fuzzer<br>
+Â Â Â ${ProtobufMutator_LIBRARIES}<br>
+Â Â Â clangCXXProto<br>
+Â Â Â clangHandleCXX<br>
+Â Â Â clangProtoToCXX<br>
+Â Â Â LLVMFuzzer<br>
+Â Â Â )<br>
+Â else()<br>
+Â Â # Hack to bypass LLVM's cmake sources check and allow multiple libraries and<br>
+Â Â # executables from this directory.<br>
+Â Â set(LLVM_OPTIONAL_SOURCES ClangFuzzer.cpp ExampleClangProtoFuzzer.cpp)<br>
+Â endif()<br>
+<br>
+Â add_clang_subdirectory(handle-<wbr>cxx)<br>
+<br>
  add_clang_executable(clang-<wbr>fuzzer<br>
   EXCLUDE_FROM_ALL<br>
   ClangFuzzer.cpp<br>
   )<br>
<br>
  target_link_libraries(clang-<wbr>fuzzer<br>
-Â Â ${CLANG_FORMAT_LIB_DEPS}<br>
-Â Â clangAST<br>
-Â Â clangBasic<br>
-Â Â clangCodeGen<br>
-Â Â clangDriver<br>
-Â Â clangFrontend<br>
-Â Â clangRewriteFrontend<br>
-Â Â clangStaticAnalyzerFrontend<br>
-Â Â clangTooling<br>
+Â Â clangHandleCXX<br>
   LLVMFuzzer<br>
   )<br>
 endif()<br>
<br>
Modified: cfe/trunk/tools/clang-fuzzer/<wbr>ClangFuzzer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ClangFuzzer.cpp?rev=310408&r1=310407&r2=310408&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/ClangFuzzer.cpp?rev=<wbr>310408&r1=310407&r2=310408&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>ClangFuzzer.cpp (original)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>ClangFuzzer.cpp Tue Aug 8 13:15:04 2017<br>
@@ -13,43 +13,12 @@<br>
 ///<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
-#include "clang/Tooling/Tooling.h"<br>
-#include "clang/CodeGen/CodeGenAction.<wbr>h"<br>
-#include "clang/Frontend/<wbr>CompilerInstance.h"<br>
-#include "clang/Lex/<wbr>PreprocessorOptions.h"<br>
-#include "llvm/Option/Option.h"<br>
-#include "llvm/Support/TargetSelect.h"<br>
+#include "handle-cxx/handle_cxx.h"<br>
<br>
-using namespace clang;<br>
+using namespace clang_fuzzer;<br>
<br>
 extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {<br>
  std::string s((const char *)data, size);<br>
-Â llvm::InitializeAllTargets();<br>
-Â llvm::InitializeAllTargetMCs()<wbr>;<br>
-Â llvm::<wbr>InitializeAllAsmPrinters();<br>
-Â llvm::InitializeAllAsmParsers(<wbr>);<br>
-<br>
-Â llvm::opt::ArgStringList CC1Args;<br>
-Â CC1Args.push_back("-cc1");<br>
-Â CC1Args.push_back("./test.cc")<wbr>;<br>
-Â CC1Args.push_back("-O2");<br>
-Â llvm::IntrusiveRefCntPtr<<wbr>FileManager> Files(<br>
-Â Â Â new FileManager(FileSystemOptions(<wbr>)));<br>
-Â IgnoringDiagConsumer Diags;<br>
-Â IntrusiveRefCntPtr<<wbr>DiagnosticOptions> DiagOpts = new DiagnosticOptions();<br>
-Â DiagnosticsEngine Diagnostics(<br>
-Â Â Â IntrusiveRefCntPtr<clang::<wbr>DiagnosticIDs>(new DiagnosticIDs()), &*DiagOpts,<br>
-Â Â Â &Diags, false);<br>
-Â std::unique_ptr<clang::<wbr>CompilerInvocation> Invocation(<br>
-Â Â Â tooling::newInvocation(&<wbr>Diagnostics, CC1Args));<br>
-Â std::unique_ptr<llvm::<wbr>MemoryBuffer> Input =<br>
-Â Â Â llvm::MemoryBuffer::<wbr>getMemBuffer(s);<br>
-Â Invocation-><wbr>getPreprocessorOpts().<wbr>addRemappedFile("./test.cc", Input.release());<br>
-Â std::unique_ptr<tooling::<wbr>ToolAction> action(<br>
-Â Â Â tooling::<wbr>newFrontendActionFactory<<wbr>clang::EmitObjAction>());<br>
-Â std::shared_ptr<<wbr>PCHContainerOperations> PCHContainerOps =<br>
-Â Â Â std::make_shared<<wbr>PCHContainerOperations>();<br>
-Â action->runInvocation(std::<wbr>move(Invocation), Files.get(), PCHContainerOps,<br>
-Â Â Â Â Â Â Â Â Â Â Â Â &Diags);<br>
+Â HandleCXX(s, {"-O2"});<br>
  return 0;<br>
 }<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>ExampleClangProtoFuzzer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangProtoFuzzer.cpp?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/<wbr>ExampleClangProtoFuzzer.cpp?<wbr>rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>ExampleClangProtoFuzzer.cpp (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>ExampleClangProtoFuzzer.cpp Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,28 @@<br>
+//===-- ExampleClangProtoFuzzer.cpp - Fuzz Clang --------------------------===/<wbr>/<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+///<br>
+/// \file<br>
+/// \brief This file implements a function that runs Clang on a single<br>
+///Â input and uses libprotobuf-mutator to find new inputs. This function is<br>
+///Â then linked into the Fuzzer library.<br>
+///<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include "cxx_proto.pb.h"<br>
+#include "handle-cxx/handle_cxx.h"<br>
+#include "proto-to-cxx/proto_to_cxx.h"<br>
+<br>
+#include "src/libfuzzer/libfuzzer_<wbr>macro.h"<br>
+<br>
+using namespace clang_fuzzer;<br>
+<br>
+DEFINE_BINARY_PROTO_FUZZER(<wbr>const Function& input) {<br>
+Â auto S = FunctionToString(input);<br>
+Â HandleCXX(S, {"-O2"});<br>
+}<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>README.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/README.txt?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/README.txt?rev=310408&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>README.txt (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>README.txt Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,73 @@<br>
+This directory contains two utilities for fuzzing Clang: clang-fuzzer and<br>
+clang-proto-fuzzer. Both use libFuzzer to generate inputs to clang via<br>
+coverage-guided mutation.<br>
+<br>
+The two utilities differ, however, in how they structure inputs to Clang.<br>
+clang-fuzzer makes no attempt to generate valid C++ programs and is therefore<br>
+primarily useful for stressing the surface layers of Clang (i.e. lexer, parser).<br>
+clang-proto-fuzzer uses a protobuf class to describe a subset of the C++<br>
+language and then uses libprotobuf-mutator to mutate instantiations of that<br>
+class, producing valid C++ programs in the process. As a result,<br>
+clang-proto-fuzzer is better at stressing deeper layers of Clang and LLVM.<br>
+<br>
+=============================<wbr>======<br>
+ Building clang-fuzzer<br>
+=============================<wbr>======<br>
+Within your LLVM build directory, run CMake with the following variable<br>
+definitions:<br>
+- CMAKE_C_COMPILER=clang<br>
+- CMAKE_CXX_COMPILER=clang++<br>
+- LLVM_USE_SANITIZE_COVERAGE=YES<br>
+- LLVM_USE_SANITIZER=Address<br>
+<br>
+Then build the clang-fuzzer target.<br>
+<br>
+Example:<br>
+Â cd $LLVM_SOURCE_DIR<br>
+Â mkdir build && cd build<br>
+Â cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \<br>
+Â Â -DLLVM_USE_SANITIZE_COVERAGE=<wbr>YES -DLLVM_USE_SANITIZER=Address<br>
+Â ninja clang-fuzzer<br>
+<br>
+<br>
+=============================<wbr>==========================<br>
+ Building clang-proto-fuzzer (Linux-only instructions)<br>
+=============================<wbr>==========================<br>
+Install the necessary dependencies:<br>
+- binutils // needed for libprotobuf-mutator<br>
+- liblzma-dev // needed for libprotobuf-mutator<br>
+- libz-dev // needed for libprotobuf-mutator<br>
+- docbook2x // needed for libprotobuf-mutator<br>
+- Recent version of protobuf [3.3.0 is known to work]<br>
+<br>
+Within your LLVM build directory, run CMake with the following variable<br>
+definitions:<br>
+- CMAKE_C_COMPILER=clang<br>
+- CMAKE_CXX_COMPILER=clang++<br>
+- LLVM_USE_SANITIZE_COVERAGE=YES<br>
+- LLVM_USE_SANITIZER=Address<br>
+- CLANG_ENABLE_PROTO_FUZZER=ON<br>
+<br>
+Then build the clang-proto-fuzzer and clang-proto-to-cxx targets. Optionally,<br>
+you may also build clang-fuzzer with this setup.<br>
+<br>
+Example:<br>
+Â cd $LLVM_SOURCE_DIR<br>
+Â mkdir build && cd build<br>
+Â cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \<br>
+Â Â -DLLVM_USE_SANITIZE_COVERAGE=<wbr>YES -DLLVM_USE_SANITIZER=Address \<br>
+Â Â -DCLANG_ENABLE_PROTO_FUZZER=ON<br>
+Â ninja clang-proto-fuzzer clang-proto-to-cxx<br>
+<br>
+<br>
+=====================<br>
+ Running the fuzzers<br>
+=====================<br>
+clang-fuzzer:<br>
+Â bin/clang-fuzzer CORPUS_DIR<br>
+<br>
+clang-proto-fuzzer:<br>
+Â bin/clang-proto-fuzzer CORPUS_DIR<br>
+<br>
+Translating a clang-proto-fuzzer corpus output to C++:<br>
+Â bin/clang-proto-to-cxx CORPUS_OUTPUT_FILE<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>cxx_proto.proto<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/cxx_proto.proto?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/cxx_proto.proto?rev=<wbr>310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>cxx_proto.proto (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>cxx_proto.proto Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,93 @@<br>
+//===-- cxx_proto.proto - Protobuf description of C++ ---------------------===//<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+///<br>
+/// \file<br>
+/// \brief This file describes a subset of C++ as a protobuf. It is used to<br>
+///Â more easily find interesting inputs for fuzzing Clang.<br>
+///<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+syntax = "proto2";<br>
+<br>
+message VarRef {<br>
+Â required int32 varnum = 1;<br>
+}<br>
+<br>
+message Lvalue {<br>
+Â required VarRef varref = 1;<br>
+}<br>
+<br>
+message Const {<br>
+Â required int32 val = 1;<br>
+}<br>
+<br>
+message BinaryOp {<br>
+Â enum Op {<br>
+Â Â PLUS = 0;<br>
+Â Â MINUS = 1;<br>
+Â Â MUL = 2;<br>
+Â Â DIV = 3;<br>
+Â Â MOD = 4;<br>
+Â Â XOR = 5;<br>
+Â Â AND = 6;<br>
+Â Â OR = 7;<br>
+Â Â EQ = 8;<br>
+Â Â NE = 9;<br>
+Â Â LE = 10;<br>
+Â Â GE = 11;<br>
+Â Â LT = 12;<br>
+Â Â GT = 13;<br>
+Â };<br>
+Â required Op op = 1;<br>
+Â required Rvalue left = 2;<br>
+Â required Rvalue right = 3;<br>
+}<br>
+<br>
+message Rvalue {<br>
+Â oneof rvalue_oneof {<br>
+Â Â VarRef varref = 1;<br>
+Â Â Const cons = 2;<br>
+Â Â BinaryOp binop = 3;<br>
+Â }<br>
+}<br>
+<br>
+message AssignmentStatement {<br>
+Â required Lvalue lvalue = 1;<br>
+Â required Rvalue rvalue = 2;<br>
+}<br>
+<br>
+<br>
+message IfElse {<br>
+Â required Rvalue cond = 1;<br>
+Â required StatementSeq if_body = 2;<br>
+Â required StatementSeq else_body = 3;<br>
+}<br>
+<br>
+message While {<br>
+Â required Rvalue cond = 1;<br>
+Â required StatementSeq body = 2;<br>
+}<br>
+<br>
+message Statement {<br>
+Â oneof stmt_oneof {<br>
+Â Â AssignmentStatement assignment = 1;<br>
+  IfElse       ifelse   = 2;<br>
+  While        while_loop = 3;<br>
+Â }<br>
+}<br>
+<br>
+message StatementSeq {<br>
+Â repeated Statement statements = 1;<br>
+}<br>
+<br>
+message Function {<br>
+Â required StatementSeq statements = 1;<br>
+}<br>
+<br>
+package clang_fuzzer;<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-cxx/CMakeLists.txt?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/handle-cxx/CMakeLists.<wbr>txt?rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/CMakeLists.txt (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/CMakeLists.txt Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,11 @@<br>
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})<br>
+<br>
+add_clang_library(<wbr>clangHandleCXX<br>
+Â handle_cxx.cpp<br>
+<br>
+Â LINK_LIBS<br>
+Â clangCodeGen<br>
+Â clangFrontend<br>
+Â clangLex<br>
+Â clangTooling<br>
+Â )<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.cpp?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/handle-cxx/handle_cxx.<wbr>cpp?rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.cpp (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.cpp Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,58 @@<br>
+//==-- handle_cxx.cpp - Helper function for Clang fuzzers ------------------==//<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+// Implements HandleCXX for use by the Clang fuzzers.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include "handle_cxx.h"<br>
+<br>
+#include "clang/CodeGen/CodeGenAction.<wbr>h"<br>
+#include "clang/Frontend/<wbr>CompilerInstance.h"<br>
+#include "clang/Lex/<wbr>PreprocessorOptions.h"<br>
+#include "clang/Tooling/Tooling.h"<br>
+#include "llvm/Option/Option.h"<br>
+#include "llvm/Support/TargetSelect.h"<br>
+<br>
+using namespace clang;<br>
+<br>
+void clang_fuzzer::HandleCXX(const std::string &S,<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const std::vector<const char *> &ExtraArgs) {<br>
+Â llvm::InitializeAllTargets();<br>
+Â llvm::InitializeAllTargetMCs()<wbr>;<br>
+Â llvm::<wbr>InitializeAllAsmPrinters();<br>
+Â llvm::InitializeAllAsmParsers(<wbr>);<br>
+<br>
+Â llvm::opt::ArgStringList CC1Args;<br>
+Â CC1Args.push_back("-cc1");<br>
+Â for (auto &A : ExtraArgs)<br>
+Â Â CC1Args.push_back(A);<br>
+Â CC1Args.push_back("./test.cc")<wbr>;<br>
+<br>
+Â llvm::IntrusiveRefCntPtr<<wbr>FileManager> Files(<br>
+Â Â Â new FileManager(FileSystemOptions(<wbr>)));<br>
+Â IgnoringDiagConsumer Diags;<br>
+Â IntrusiveRefCntPtr<<wbr>DiagnosticOptions> DiagOpts = new DiagnosticOptions();<br>
+Â DiagnosticsEngine Diagnostics(<br>
+Â Â Â IntrusiveRefCntPtr<clang::<wbr>DiagnosticIDs>(new DiagnosticIDs()), &*DiagOpts,<br>
+Â Â Â &Diags, false);<br>
+Â std::unique_ptr<clang::<wbr>CompilerInvocation> Invocation(<br>
+Â Â Â tooling::newInvocation(&<wbr>Diagnostics, CC1Args));<br>
+Â std::unique_ptr<llvm::<wbr>MemoryBuffer> Input =<br>
+Â Â Â llvm::MemoryBuffer::<wbr>getMemBuffer(S);<br>
+Â Invocation-><wbr>getPreprocessorOpts().<wbr>addRemappedFile("./test.cc",<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Input.release());<br>
+Â std::unique_ptr<tooling::<wbr>ToolAction> action(<br>
+Â Â Â tooling::<wbr>newFrontendActionFactory<<wbr>clang::EmitObjAction>());<br>
+Â std::shared_ptr<<wbr>PCHContainerOperations> PCHContainerOps =<br>
+Â Â Â std::make_shared<<wbr>PCHContainerOperations>();<br>
+Â action->runInvocation(std::<wbr>move(Invocation), Files.get(), PCHContainerOps,<br>
+Â Â Â Â Â Â Â Â Â Â Â Â &Diags);<br>
+}<br>
+<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/handle-cxx/handle_cxx.h?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/handle-cxx/handle_cxx.<wbr>h?rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.h (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>handle-cxx/handle_cxx.h Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,25 @@<br>
+//==-- handle_cxx.h - Helper function for Clang fuzzers --------------------==//<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+// Defines HandleCXX for use by the Clang fuzzers.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#ifndef LLVM_CLANG_TOOLS_CLANG_FUZZER_<wbr>HANDLE_CXX_HANDLECXX_H<br>
+#define LLVM_CLANG_TOOLS_CLANG_FUZZER_<wbr>HANDLE_CXX_HANDLECXX_H<br>
+<br>
+#include <string><br>
+#include <vector><br>
+<br>
+namespace clang_fuzzer {<br>
+void HandleCXX(const std::string &S,<br>
+Â Â Â Â Â Â Â Â const std::vector<const char *> &ExtraArgs);<br>
+} // namespace clang_fuzzer<br>
+<br>
+#endif<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/proto-to-cxx/<wbr>CMakeLists.txt?rev=310408&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/CMakeLists.txt (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/CMakeLists.txt Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,10 @@<br>
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD})<br>
+<br>
+# Hack to bypass LLVM's CMake source checks so we can have both a library and<br>
+# an executable built from this directory.<br>
+set(LLVM_OPTIONAL_SOURCES proto_to_cxx.cpp proto_to_cxx_main.cpp)<br>
+<br>
+add_clang_library(<wbr>clangProtoToCXX proto_to_cxx.cpp LINK_LIBS clangCXXProto)<br>
+<br>
+add_clang_executable(clang-<wbr>proto-to-cxx proto_to_cxx_main.cpp)<br>
+target_link_libraries(clang-<wbr>proto-to-cxx clangProtoToCXX)<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.cpp?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/proto-to-cxx/proto_to_<wbr>cxx.cpp?rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.cpp (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.cpp Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,102 @@<br>
+//==-- proto_to_cxx.cpp - Protobuf-C++ conversion --------------------------==//<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+// Implements functions for converting between protobufs and C++.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include "proto_to_cxx.h"<br>
+#include "cxx_proto.pb.h"<br>
+<br>
+#include <ostream><br>
+#include <sstream><br>
+<br>
+namespace clang_fuzzer {<br>
+<br>
+// Forward decls.<br>
+std::ostream &operator<<(std::ostream &os, const BinaryOp &x);<br>
+std::ostream &operator<<(std::ostream &os, const StatementSeq &x);<br>
+<br>
+// Proto to C++.<br>
+std::ostream &operator<<(std::ostream &os, const Const &x) {<br>
+Â return os << "(" << x.val() << ")";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const VarRef &x) {<br>
+Â return os << "a[" << (static_cast<uint32_t>(x.<wbr>varnum()) % 100) << "]";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const Lvalue &x) {<br>
+Â return os << x.varref();<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const Rvalue &x) {<br>
+Â Â if (x.has_varref()) return os << x.varref();<br>
+Â Â if (x.has_cons())Â Â return os << x.cons();<br>
+Â Â if (x.has_binop())Â return os << x.binop();<br>
+Â Â return os << "1";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const BinaryOp &x) {<br>
+Â os << "(" << x.left();<br>
+Â switch (x.op()) {<br>
+Â Â case BinaryOp::PLUS: os << "+"; break;<br>
+Â Â case BinaryOp::MINUS: os << "-"; break;<br>
+Â Â case BinaryOp::MUL: os << "*"; break;<br>
+Â Â case BinaryOp::DIV: os << "/"; break;<br>
+Â Â case BinaryOp::MOD: os << "%"; break;<br>
+Â Â case BinaryOp::XOR: os << "^"; break;<br>
+Â Â case BinaryOp::AND: os << "&"; break;<br>
+Â Â case BinaryOp::OR: os << "|"; break;<br>
+Â Â case BinaryOp::EQ: os << "=="; break;<br>
+Â Â case BinaryOp::NE: os << "!="; break;<br>
+Â Â case BinaryOp::LE: os << "<="; break;<br>
+Â Â case BinaryOp::GE: os << ">="; break;<br>
+Â Â case BinaryOp::LT: os << "<"; break;<br>
+Â Â case BinaryOp::GT: os << ">"; break;<br>
+Â }<br>
+Â return os << x.right() << ")";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const AssignmentStatement &x) {<br>
+Â return os << x.lvalue() << "=" << x.rvalue() << ";\n";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const IfElse &x) {<br>
+Â return os << "if (" << x.cond() << "){\n"<br>
+Â Â Â Â Â Â << x.if_body() << "} else { \n"<br>
+Â Â Â Â Â Â << x.else_body() << "}\n";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const While &x) {<br>
+Â return os << "while (" << x.cond() << "){\n" << x.body() << "}\n";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const Statement &x) {<br>
+Â if (x.has_assignment()) return os << x.assignment();<br>
+Â if (x.has_ifelse())Â Â Â return os << x.ifelse();<br>
+Â if (x.has_while_loop()) return os << x.while_loop();<br>
+Â return os << "(void)0;\n";<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const StatementSeq &x) {<br>
+Â for (auto &st : x.statements()) os << st;<br>
+Â return os;<br>
+}<br>
+std::ostream &operator<<(std::ostream &os, const Function &x) {<br>
+Â return os << "void foo(int *a) {\n" << x.statements() << "}\n";<br>
+}<br>
+<br>
+// ------------------------------<wbr>---<br>
+<br>
+std::string FunctionToString(const Function &input) {<br>
+Â std::ostringstream os;<br>
+Â os << input;<br>
+Â return os.str();<br>
+<br>
+}<br>
+std::string ProtoToCxx(const uint8_t *data, size_t size) {<br>
+Â Function message;<br>
+Â if (!message.ParseFromArray(data, size))<br>
+Â Â return "#error invalid proto\n";<br>
+Â return FunctionToString(message);<br>
+}<br>
+<br>
+} // namespace clang_fuzzer<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/proto-to-cxx/proto_to_<wbr>cxx.h?rev=310408&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.h (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx.h Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,22 @@<br>
+//==-- proto_to_cxx.h - Protobuf-C++ conversion ----------------------------==<wbr>//<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+// Defines functions for converting between protobufs and C++.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+<br>
+#include <cstdint><br>
+#include <cstddef><br>
+#include <string><br>
+<br>
+namespace clang_fuzzer {<br>
+class Function;<br>
+std::string FunctionToString(const Function &input);<br>
+std::string ProtoToCxx(const uint8_t *data, size_t size);<br>
+}<br>
<br>
Added: cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx_<wbr>main.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx_main.cpp?rev=310408&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/tools/clang-<wbr>fuzzer/proto-to-cxx/proto_to_<wbr>cxx_main.cpp?rev=310408&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx_<wbr>main.cpp (added)<br>
+++ cfe/trunk/tools/clang-fuzzer/<wbr>proto-to-cxx/proto_to_cxx_<wbr>main.cpp Tue Aug 8 13:15:04 2017<br>
@@ -0,0 +1,30 @@<br>
+//==-- proto_to_cxx_main.cpp - Driver for protobuf-C++ conversion ----------==//<br>
+//<br>
+//Â Â Â Â Â Â Â Â Â Â Â The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+//<br>
+// Implements a simple driver to print a C++ program from a protobuf.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+#include <fstream><br>
+#include <iostream><br>
+#include <streambuf><br>
+#include <string><br>
+<br>
+#include "proto_to_cxx.h"<br>
+<br>
+int main(int argc, char **argv) {<br>
+Â for (int i = 1; i < argc; i++) {<br>
+Â Â std::fstream in(argv[i]);<br>
+Â Â std::string str((std::istreambuf_iterator<<wbr>char>(in)),<br>
+Â Â Â Â Â Â Â Â Â Â std::istreambuf_iterator<char><wbr>());<br>
+Â Â std::cout << "// " << argv[i] << std::endl;<br>
+Â Â std::cout << clang_fuzzer::ProtoToCxx(<br>
+Â Â Â Â reinterpret_cast<const uint8_t *>(str.data()), str.size());<br>
+Â }<br>
+}<br>
+<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>