Index: tools/llvm-demangle-fuzzer/CMakeLists.txt =================================================================== --- /dev/null +++ tools/llvm-demangle-fuzzer/CMakeLists.txt @@ -0,0 +1,6 @@ +set(LLVM_LINK_COMPONENTS + Demangle +) +add_llvm_fuzzer(llvm-demangle-fuzzer + EXCLUDE_FROM_ALL + llvm-demangle-fuzzer.cpp) Index: tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp =================================================================== --- /dev/null +++ tools/llvm-demangle-fuzzer/llvm-demangle-fuzzer.cpp @@ -0,0 +1,24 @@ +//===--- llvm-demangle-fuzzer.cpp - Fuzzer for the Itanium Demangler ------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Demangle/Demangle.h" + +#include +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { + int status = 0; + char *demangle = + llvm::itaniumDemangle((const char *)Data, nullptr, nullptr, &status); + + if (demangle) + free(demangle); + + return 0; +}