xref: /llvm-project/llvm/tools/llvm-rust-demangle-fuzzer/llvm-rust-demangle-fuzzer.cpp (revision 12d967c95f1633bebd1b225ddd53573951a7ca43)
10e7c2aeaSTomasz Miąsko //===--- llvm-demangle-fuzzer.cpp - Fuzzer for the Rust Demangler ---------===//
20e7c2aeaSTomasz Miąsko //
30e7c2aeaSTomasz Miąsko // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40e7c2aeaSTomasz Miąsko // See https://llvm.org/LICENSE.txt for license information.
50e7c2aeaSTomasz Miąsko // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60e7c2aeaSTomasz Miąsko //
70e7c2aeaSTomasz Miąsko //===----------------------------------------------------------------------===//
80e7c2aeaSTomasz Miąsko 
90e7c2aeaSTomasz Miąsko #include "llvm/Demangle/Demangle.h"
100e7c2aeaSTomasz Miąsko #include <cstdint>
110e7c2aeaSTomasz Miąsko #include <cstdlib>
12d789ed11SSimon Pilgrim #include <string>
130e7c2aeaSTomasz Miąsko 
LLVMFuzzerTestOneInput(const uint8_t * Data,size_t Size)140e7c2aeaSTomasz Miąsko extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
150e7c2aeaSTomasz Miąsko   std::string NullTerminatedString((const char *)Data, Size);
16*12d967c9SNick Desaulniers   char *Demangled = llvm::rustDemangle(NullTerminatedString);
170e7c2aeaSTomasz Miąsko   std::free(Demangled);
180e7c2aeaSTomasz Miąsko   return 0;
190e7c2aeaSTomasz Miąsko }
20