}
// pre-compilation pass for generating tracepoint structures
- auto invocation0 = make_unique<CompilerInvocation>();
- if (!CompilerInvocation::CreateFromArgs(*invocation0, const_cast<const char **>(ccargs.data()),
+ CompilerInstance compiler0;
+ CompilerInvocation &invocation0 = compiler0.getInvocation();
+ if (!CompilerInvocation::CreateFromArgs(invocation0, const_cast<const char **>(ccargs.data()),
const_cast<const char **>(ccargs.data()) + ccargs.size(), diags))
return -1;
- invocation0->getPreprocessorOpts().RetainRemappedFileBuffers = true;
+ invocation0.getPreprocessorOpts().RetainRemappedFileBuffers = true;
for (const auto &f : remapped_files_)
- invocation0->getPreprocessorOpts().addRemappedFile(f.first, &*f.second);
+ invocation0.getPreprocessorOpts().addRemappedFile(f.first, &*f.second);
if (in_memory) {
- invocation0->getPreprocessorOpts().addRemappedFile(main_path, &*main_buf);
- invocation0->getFrontendOpts().Inputs.clear();
- invocation0->getFrontendOpts().Inputs.push_back(FrontendInputFile(main_path, IK_C));
+ invocation0.getPreprocessorOpts().addRemappedFile(main_path, &*main_buf);
+ invocation0.getFrontendOpts().Inputs.clear();
+ invocation0.getFrontendOpts().Inputs.push_back(FrontendInputFile(main_path, IK_C));
}
- invocation0->getFrontendOpts().DisableFree = false;
+ invocation0.getFrontendOpts().DisableFree = false;
- CompilerInstance compiler0;
- compiler0.setInvocation(invocation0.release());
compiler0.createDiagnostics(new IgnoringDiagConsumer());
// capture the rewritten c file
unique_ptr<llvm::MemoryBuffer> out_buf = llvm::MemoryBuffer::getMemBuffer(out_str);
// first pass
- auto invocation1 = make_unique<CompilerInvocation>();
- if (!CompilerInvocation::CreateFromArgs(*invocation1, const_cast<const char **>(ccargs.data()),
+ CompilerInstance compiler1;
+ CompilerInvocation &invocation1 = compiler1.getInvocation();
+ if (!CompilerInvocation::CreateFromArgs(invocation1, const_cast<const char **>(ccargs.data()),
const_cast<const char **>(ccargs.data()) + ccargs.size(), diags))
return -1;
// This option instructs clang whether or not to free the file buffers that we
// give to it. Since the embedded header files should be copied fewer times
// and reused if possible, set this flag to true.
- invocation1->getPreprocessorOpts().RetainRemappedFileBuffers = true;
+ invocation1.getPreprocessorOpts().RetainRemappedFileBuffers = true;
for (const auto &f : remapped_files_)
- invocation1->getPreprocessorOpts().addRemappedFile(f.first, &*f.second);
- invocation1->getPreprocessorOpts().addRemappedFile(main_path, &*out_buf);
- invocation1->getFrontendOpts().Inputs.clear();
- invocation1->getFrontendOpts().Inputs.push_back(FrontendInputFile(main_path, IK_C));
- invocation1->getFrontendOpts().DisableFree = false;
+ invocation1.getPreprocessorOpts().addRemappedFile(f.first, &*f.second);
+ invocation1.getPreprocessorOpts().addRemappedFile(main_path, &*out_buf);
+ invocation1.getFrontendOpts().Inputs.clear();
+ invocation1.getFrontendOpts().Inputs.push_back(FrontendInputFile(main_path, IK_C));
+ invocation1.getFrontendOpts().DisableFree = false;
- CompilerInstance compiler1;
- compiler1.setInvocation(invocation1.release());
compiler1.createDiagnostics();
// capture the rewritten c file
*tables = bact.take_tables();
// second pass, clear input and take rewrite buffer
- auto invocation2 = make_unique<CompilerInvocation>();
- if (!CompilerInvocation::CreateFromArgs(*invocation2, const_cast<const char **>(ccargs.data()),
+ CompilerInstance compiler2;
+ CompilerInvocation &invocation2 = compiler2.getInvocation();
+ if (!CompilerInvocation::CreateFromArgs(invocation2, const_cast<const char **>(ccargs.data()),
const_cast<const char **>(ccargs.data()) + ccargs.size(), diags))
return -1;
- CompilerInstance compiler2;
- invocation2->getPreprocessorOpts().RetainRemappedFileBuffers = true;
+ invocation2.getPreprocessorOpts().RetainRemappedFileBuffers = true;
for (const auto &f : remapped_files_)
- invocation2->getPreprocessorOpts().addRemappedFile(f.first, &*f.second);
- invocation2->getPreprocessorOpts().addRemappedFile(main_path, &*out_buf1);
- invocation2->getFrontendOpts().Inputs.clear();
- invocation2->getFrontendOpts().Inputs.push_back(FrontendInputFile(main_path, IK_C));
- invocation2->getFrontendOpts().DisableFree = false;
+ invocation2.getPreprocessorOpts().addRemappedFile(f.first, &*f.second);
+ invocation2.getPreprocessorOpts().addRemappedFile(main_path, &*out_buf1);
+ invocation2.getFrontendOpts().Inputs.clear();
+ invocation2.getFrontendOpts().Inputs.push_back(FrontendInputFile(main_path, IK_C));
+ invocation2.getFrontendOpts().DisableFree = false;
// suppress warnings in the 2nd pass, but bail out on errors (our fault)
- invocation2->getDiagnosticOpts().IgnoreWarnings = true;
- compiler2.setInvocation(invocation2.release());
+ invocation2.getDiagnosticOpts().IgnoreWarnings = true;
compiler2.createDiagnostics();
EmitLLVMOnlyAction ir_act(&*ctx_);