forked from OSchip/llvm-project
[lldb][NFC] Make include directories in Clang expression parser a std::string
We never compare these directories (where ConstString would be good) and essentially just convert this back to a normal string in the end. So we might as well just use std::string. Also makes it easier to unittest this code (which was the main motivation for this change). llvm-svn: 371623
This commit is contained in:
parent
1ccba7c1a1
commit
3ad8278737
|
@ -213,16 +213,15 @@ private:
|
||||||
std::shared_ptr<clang::TextDiagnosticBuffer> m_passthrough;
|
std::shared_ptr<clang::TextDiagnosticBuffer> m_passthrough;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void SetupModuleHeaderPaths(CompilerInstance *compiler,
|
||||||
SetupModuleHeaderPaths(CompilerInstance *compiler,
|
std::vector<std::string> include_directories,
|
||||||
std::vector<ConstString> include_directories,
|
|
||||||
lldb::TargetSP target_sp) {
|
lldb::TargetSP target_sp) {
|
||||||
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
|
||||||
|
|
||||||
HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts();
|
HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts();
|
||||||
|
|
||||||
for (ConstString dir : include_directories) {
|
for (const std::string &dir : include_directories) {
|
||||||
search_opts.AddPath(dir.AsCString(), frontend::System, false, true);
|
search_opts.AddPath(dir, frontend::System, false, true);
|
||||||
LLDB_LOG(log, "Added user include dir: {0}", dir);
|
LLDB_LOG(log, "Added user include dir: {0}", dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +260,7 @@ SetupModuleHeaderPaths(CompilerInstance *compiler,
|
||||||
|
|
||||||
ClangExpressionParser::ClangExpressionParser(
|
ClangExpressionParser::ClangExpressionParser(
|
||||||
ExecutionContextScope *exe_scope, Expression &expr,
|
ExecutionContextScope *exe_scope, Expression &expr,
|
||||||
bool generate_debug_info, std::vector<ConstString> include_directories)
|
bool generate_debug_info, std::vector<std::string> include_directories)
|
||||||
: ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(),
|
: ExpressionParser(exe_scope, expr, generate_debug_info), m_compiler(),
|
||||||
m_pp_callbacks(nullptr),
|
m_pp_callbacks(nullptr),
|
||||||
m_include_directories(std::move(include_directories)) {
|
m_include_directories(std::move(include_directories)) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ public:
|
||||||
/// expression.
|
/// expression.
|
||||||
ClangExpressionParser(ExecutionContextScope *exe_scope, Expression &expr,
|
ClangExpressionParser(ExecutionContextScope *exe_scope, Expression &expr,
|
||||||
bool generate_debug_info,
|
bool generate_debug_info,
|
||||||
std::vector<ConstString> include_directories = {});
|
std::vector<std::string> include_directories = {});
|
||||||
|
|
||||||
/// Destructor
|
/// Destructor
|
||||||
~ClangExpressionParser() override;
|
~ClangExpressionParser() override;
|
||||||
|
@ -177,7 +177,7 @@ private:
|
||||||
///encounters module imports
|
///encounters module imports
|
||||||
std::unique_ptr<ClangASTContext> m_ast_context;
|
std::unique_ptr<ClangASTContext> m_ast_context;
|
||||||
|
|
||||||
std::vector<ConstString> m_include_directories;
|
std::vector<std::string> m_include_directories;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -469,7 +469,7 @@ ClangUserExpression::GetModulesToImport(ExecutionContext &exe_ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const SourceModule &m : sc.comp_unit->GetImportedModules())
|
for (const SourceModule &m : sc.comp_unit->GetImportedModules())
|
||||||
m_include_directories.push_back(m.search_path);
|
m_include_directories.emplace_back(m.search_path.GetCString());
|
||||||
|
|
||||||
// Check if we imported 'std' or any of its submodules.
|
// Check if we imported 'std' or any of its submodules.
|
||||||
// We currently don't support importing any other modules in the expression
|
// We currently don't support importing any other modules in the expression
|
||||||
|
|
|
@ -209,7 +209,7 @@ private:
|
||||||
/// The language type of the current expression.
|
/// The language type of the current expression.
|
||||||
lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown;
|
lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown;
|
||||||
/// The include directories that should be used when parsing the expression.
|
/// The include directories that should be used when parsing the expression.
|
||||||
std::vector<ConstString> m_include_directories;
|
std::vector<std::string> m_include_directories;
|
||||||
|
|
||||||
/// The absolute character position in the transformed source code where the
|
/// The absolute character position in the transformed source code where the
|
||||||
/// user code (as typed by the user) starts. If the variable is empty, then we
|
/// user code (as typed by the user) starts. If the variable is empty, then we
|
||||||
|
|
Loading…
Reference in New Issue