clang-tools
11.0.0
clang-tools-extra
clangd
fuzzer
clangd-fuzzer.cpp
Go to the documentation of this file.
1
//===-- ClangdFuzzer.cpp - Fuzz clangd ------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// This file implements a function that runs clangd on a single input.
11
/// This function is then linked into the Fuzzer library.
12
///
13
//===----------------------------------------------------------------------===//
14
15
#include "
ClangdLSPServer.h
"
16
#include "
ClangdServer.h
"
17
#include "
CodeComplete.h
"
18
#include "
refactor/Rename.h
"
19
#include "
support/ThreadsafeFS.h
"
20
#include <cstdio>
21
#include <sstream>
22
23
using namespace
clang::clangd
;
24
25
extern
"C"
int
LLVMFuzzerTestOneInput
(uint8_t *data,
size_t
size) {
26
if
(size == 0)
27
return
0;
28
29
// fmemopen isn't portable, but I think we only run the fuzzer on Linux.
30
std::FILE *In = fmemopen(data, size,
"r"
);
31
auto
Transport
=
newJSONTransport
(In, llvm::nulls(),
32
/*InMirror=*/
nullptr
,
/*Pretty=*/
false
,
33
/*Style=*/
JSONStreamStyle::Delimited
);
34
RealThreadsafeFS
FS
;
35
CodeCompleteOptions
CCOpts
;
36
CCOpts
.
EnableSnippets
=
false
;
37
ClangdServer::Options
Opts;
38
39
// Initialize and run ClangdLSPServer.
40
ClangdLSPServer
LSPServer(*
Transport
,
FS
,
CCOpts
,
RenameOptions
(),
llvm::None
,
41
false
,
llvm::None
, Opts);
42
LSPServer.
run
();
43
return
0;
44
}
clang::clangd::ClangdLSPServer::run
bool run()
Run LSP server loop, communicating with the Transport provided in the constructor.
Definition:
ClangdLSPServer.cpp:1417
CCOpts
CodeCompleteOptions CCOpts
Definition:
ClangdLSPServerTests.cpp:67
CodeComplete.h
clang::clangd::TextDocumentSyncKind::None
Documents should not be synced at all.
clang::clangd::RealThreadsafeFS
Definition:
ThreadsafeFS.h:49
clang::clangd
Definition:
AST.cpp:39
ThreadsafeFS.h
clang::clangd::ClangdLSPServer
This class exposes ClangdServer's capabilities via Language Server Protocol.
Definition:
ClangdLSPServer.h:37
clang::clangd::ClangdServer::Options
Definition:
ClangdServer.h:90
Rename.h
ClangdLSPServer.h
FS
MockFS FS
Definition:
ClangdLSPServerTests.cpp:66
LLVMFuzzerTestOneInput
int LLVMFuzzerTestOneInput(uint8_t *data, size_t size)
Definition:
clangd-fuzzer.cpp:25
clang::clangd::RenameOptions
Definition:
Rename.h:29
clang::clangd::CodeCompleteOptions
Definition:
CodeComplete.h:44
clang::clangd::Transport
Definition:
Transport.h:34
clang::clangd::CodeCompleteOptions::EnableSnippets
bool EnableSnippets
When true, completion items will contain expandable code snippets in completion (e....
Definition:
CodeComplete.h:51
ClangdServer.h
clang::clangd::newJSONTransport
std::unique_ptr< Transport > newJSONTransport(std::FILE *In, llvm::raw_ostream &Out, llvm::raw_ostream *InMirror, bool Pretty, JSONStreamStyle Style)
Definition:
JSONTransport.cpp:320
clang::clangd::Delimited
Definition:
Transport.h:69
Generated on Tue Jul 28 2020 16:14:01 for clang-tools by
1.8.16