MCPcopy Create free account
hub / github.com/Samsung/UTopia / UTModify

Method UTModify

lib/generation/UTModify.cpp:20–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18const std::string UTModify::UTEntryFuncName = "enterAutofuzz";
19
20UTModify::UTModify(const Fuzzer &F, const SourceAnalysisReport &SourceReport) {
21 clang::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFS =
22 new llvm::vfs::OverlayFileSystem(llvm::vfs::getRealFileSystem());
23 FManager = new clang::FileManager(clang::FileSystemOptions(), OverlayFS);
24
25 clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagOpts =
26 new clang::DiagnosticOptions();
27 auto DiagnosticPrinter = std::make_unique<clang::TextDiagnosticPrinter>(
28 llvm::outs(), DiagOpts.get());
29 clang::IntrusiveRefCntPtr<clang::DiagnosticIDs> DiagID =
30 new clang::DiagnosticIDs();
31 auto Diagnostics = std::make_unique<clang::DiagnosticsEngine>(
32 DiagID, DiagOpts.get(), DiagnosticPrinter.get(), false);
33 SManager = std::make_unique<clang::SourceManager>(*Diagnostics, *FManager);
34
35 std::map<std::string, std::string> FuzzVarDecls;
36 std::map<std::string, std::vector<std::string>> FuzzVarFlagDecls;
37 std::map<std::string, std::vector<UTModify::GlobalVarSetter>> Setters;
38 auto UTPath = F.getUT().getFilePath();
39 for (const auto &Iter : F.getFuzzInputMap()) {
40 auto &Input = Iter.second;
41 assert(Input && "Unexpected Program State");
42 if (!Input->getCopyFrom()) {
43 generateFuzzVarDeclarations(FuzzVarDecls, FuzzVarFlagDecls, *Input);
44 generateFuzzVarGlobalSetters(Setters, *Input);
45 }
46 generateFuzzVarReplacements(*Input);
47 }
48 generateTop(FuzzVarDecls, FuzzVarFlagDecls, Setters, UTPath, SourceReport);
49 generateBottom(FuzzVarFlagDecls, Setters, F.getUT(), SourceReport);
50 if (!generateHeader(fs::path(UTPath).parent_path().string())) {
51 clear();
52 return;
53 }
54 generateMainDeletion(SourceReport);
55
56 for (const auto &Iter : Replaces) {
57 auto Replace = Iter.second;
58 if (FileReplaceMap[Replace.getFilePath().str()].add(Replace)) {
59 clear();
60 return;
61 }
62 }
63}
64
65bool UTModify::addReplace(const clang::tooling::Replacement &Replace) {
66 auto Key = std::make_pair(Replace.getFilePath().str(), Replace.getOffset());

Callers

nothing calls this directly

Calls 4

getCopyFromMethod · 0.80
getMethod · 0.45
getFilePathMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected