Reapply "[lldb][dwarf] Compute fully qualified names on simplified template names...
[llvm-project.git] / clang / tools / clang-fuzzer / fuzzer-initialize / fuzzer_initialize.cpp
blob94f3b937d83fc9c16ffa726e74f54c31da59fd55
1 //===-- fuzzer_initialize.cpp - Fuzz Clang --------------------------------===//
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 two functions: one that returns the command line
11 /// arguments for a given call to the fuzz target and one that initializes
12 /// the fuzzer with the correct command line arguments.
13 ///
14 //===----------------------------------------------------------------------===//
16 #include "fuzzer_initialize.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/PassRegistry.h"
20 #include "llvm/Support/TargetSelect.h"
21 #include <cstring>
23 using namespace clang_fuzzer;
24 using namespace llvm;
27 namespace clang_fuzzer {
29 static std::vector<const char *> CLArgs;
31 const std::vector<const char *>& GetCLArgs() {
32 return CLArgs;
37 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
38 InitializeAllTargets();
39 InitializeAllTargetMCs();
40 InitializeAllAsmPrinters();
41 InitializeAllAsmParsers();
43 PassRegistry &Registry = *PassRegistry::getPassRegistry();
44 initializeCore(Registry);
45 initializeScalarOpts(Registry);
46 initializeVectorization(Registry);
47 initializeIPO(Registry);
48 initializeAnalysis(Registry);
49 initializeTransformUtils(Registry);
50 initializeInstCombine(Registry);
51 initializeTarget(Registry);
53 CLArgs.push_back("-O2");
54 for (int I = 1; I < *argc; I++) {
55 if (strcmp((*argv)[I], "-ignore_remaining_args=1") == 0) {
56 for (I++; I < *argc; I++)
57 CLArgs.push_back((*argv)[I]);
58 break;
61 return 0;