@@ -1700,7 +1700,7 @@ namespace {
17001700
17011701 std::vector<std::unique_ptr<ASTConsumer>> Consumers;
17021702
1703- if (!OnlyLex) {
1703+ if (!OnlyLex && !AutoComplete ) {
17041704 assert (customConsumer && " Need to specify a custom consumer"
17051705 " when not in OnlyLex mode" );
17061706 Consumers.push_back (std::move (customConsumer));
@@ -1834,25 +1834,27 @@ namespace {
18341834
18351835namespace cling {
18361836
1837- CompilerInstance*
1838- CIFactory::createCI (llvm::StringRef Code, const InvocationOptions& Opts,
1839- const char * LLVMDir,
1840- std::unique_ptr<clang::ASTConsumer> consumer,
1841- const ModuleFileExtensions& moduleExtensions,
1842- bool AutoComplete /* false*/ ) {
1837+ CompilerInstance* CIFactory::createCI (
1838+ llvm::StringRef Code, const InvocationOptions& Opts, const char * LLVMDir,
1839+ std::optional<std::unique_ptr<clang::ASTConsumer>> consumerOpt,
1840+ const ModuleFileExtensions& moduleExtensions,
1841+ bool AutoComplete /* false*/ ) {
18431842 return createCIImpl (llvm::MemoryBuffer::getMemBuffer (Code),
1844- Opts.CompilerOpts , LLVMDir, std::move (consumer),
1843+ Opts.CompilerOpts , LLVMDir,
1844+ consumerOpt ? std::move (*consumerOpt) : nullptr ,
18451845 moduleExtensions, false /* OnlyLex*/ ,
18461846 !Opts.IsInteractive (), AutoComplete);
18471847 }
18481848
1849- CompilerInstance* CIFactory::createCI (
1850- MemBufPtr_t Buffer, int argc, const char * const * argv, const char * LLVMDir,
1851- std::unique_ptr<clang::ASTConsumer> consumer,
1852- const ModuleFileExtensions& moduleExtensions, bool OnlyLex /* false*/ ) {
1853- return createCIImpl (std::move (Buffer), CompilerOptions (argc, argv), LLVMDir,
1854- std::move (consumer), moduleExtensions, OnlyLex);
1855- }
1849+ CompilerInstance* CIFactory::createCI (
1850+ MemBufPtr_t Buffer, int argc, const char * const * argv,
1851+ const char * LLVMDir,
1852+ std::optional<std::unique_ptr<clang::ASTConsumer>> consumerOpt,
1853+ const ModuleFileExtensions& moduleExtensions, bool OnlyLex /* false*/ ) {
1854+ return createCIImpl (std::move (Buffer), CompilerOptions (argc, argv), LLVMDir,
1855+ consumerOpt ? std::move (*consumerOpt) : nullptr ,
1856+ moduleExtensions, OnlyLex);
1857+ }
18561858
18571859} // namespace cling
18581860
0 commit comments