Author: jdevlieghere Date: Thu Feb 14 10:05:43 2019 New Revision: 354041 URL: http://llvm.org/viewvc/llvm-project?rev=354041&view=rev Log: [ExpressionParser] Reuse the FileManager from the compiler instance.
I was looking at the ClangExpressionParser and noticed that we have a FileManager owned by the expression parser and later ask the compiler instance to create a new FileManager, owned by the clang CI. Looking at the code I don't see a good reason for having two instances. This patch removes the one owned by LLDB. Differential revision: https://reviews.llvm.org/D58222 Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp?rev=354041&r1=354040&r2=354041&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp Thu Feb 14 10:05:43 2019 @@ -11,7 +11,6 @@ #include "clang/AST/ExternalASTSource.h" #include "clang/AST/PrettyPrinter.h" #include "clang/Basic/DiagnosticIDs.h" -#include "clang/Basic/FileManager.h" #include "clang/Basic/SourceLocation.h" #include "clang/Basic/TargetInfo.h" #include "clang/Basic/Version.h" @@ -490,14 +489,9 @@ ClangExpressionParser::ClangExpressionPa m_compiler->getDiagnostics().setClient(new ClangDiagnosticManagerAdapter); // 7. Set up the source management objects inside the compiler - - clang::FileSystemOptions file_system_options; - m_file_manager.reset(new clang::FileManager(file_system_options)); - - if (!m_compiler->hasSourceManager()) - m_compiler->createSourceManager(*m_file_manager); - m_compiler->createFileManager(); + if (!m_compiler->hasSourceManager()) + m_compiler->createSourceManager(m_compiler->getFileManager()); m_compiler->createPreprocessor(TU_Complete); if (ClangModulesDeclVendor *decl_vendor = @@ -855,9 +849,9 @@ ClangExpressionParser::ParseInternal(Dia if (file.Write(expr_text, bytes_written).Success()) { if (bytes_written == expr_text_len) { file.Close(); - source_mgr.setMainFileID( - source_mgr.createFileID(m_file_manager->getFile(result_path), - SourceLocation(), SrcMgr::C_User)); + source_mgr.setMainFileID(source_mgr.createFileID( + m_compiler->getFileManager().getFile(result_path), + SourceLocation(), SrcMgr::C_User)); created_main_file = true; } } Modified: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h?rev=354041&r1=354040&r2=354041&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h (original) +++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h Thu Feb 14 10:05:43 2019 @@ -178,8 +178,6 @@ private: std::unique_ptr<llvm::LLVMContext> m_llvm_context; ///< The LLVM context to generate IR into - std::unique_ptr<clang::FileManager> - m_file_manager; ///< The Clang file manager object used by the compiler std::unique_ptr<clang::CompilerInstance> m_compiler; ///< The Clang compiler used to parse expressions into IR std::unique_ptr<clang::CodeGenerator> _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits