[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:
Raphael Isemann 2019-09-11 14:33:11 +00:00
parent 1ccba7c1a1
commit 3ad8278737
4 changed files with 10 additions and 11 deletions

View File

@ -213,16 +213,15 @@ private:
std::shared_ptr<clang::TextDiagnosticBuffer> m_passthrough;
};
static void
SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector<ConstString> include_directories,
static void SetupModuleHeaderPaths(CompilerInstance *compiler,
std::vector<std::string> include_directories,
lldb::TargetSP target_sp) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts();
for (ConstString dir : include_directories) {
search_opts.AddPath(dir.AsCString(), frontend::System, false, true);
for (const std::string &dir : include_directories) {
search_opts.AddPath(dir, frontend::System, false, true);
LLDB_LOG(log, "Added user include dir: {0}", dir);
}
@ -261,7 +260,7 @@ SetupModuleHeaderPaths(CompilerInstance *compiler,
ClangExpressionParser::ClangExpressionParser(
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(),
m_pp_callbacks(nullptr),
m_include_directories(std::move(include_directories)) {

View File

@ -55,7 +55,7 @@ public:
/// expression.
ClangExpressionParser(ExecutionContextScope *exe_scope, Expression &expr,
bool generate_debug_info,
std::vector<ConstString> include_directories = {});
std::vector<std::string> include_directories = {});
/// Destructor
~ClangExpressionParser() override;
@ -177,7 +177,7 @@ private:
///encounters module imports
std::unique_ptr<ClangASTContext> m_ast_context;
std::vector<ConstString> m_include_directories;
std::vector<std::string> m_include_directories;
};
}

View File

@ -469,7 +469,7 @@ ClangUserExpression::GetModulesToImport(ExecutionContext &exe_ctx) {
}
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.
// We currently don't support importing any other modules in the expression

View File

@ -209,7 +209,7 @@ private:
/// The language type of the current expression.
lldb::LanguageType m_expr_lang = lldb::eLanguageTypeUnknown;
/// 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
/// user code (as typed by the user) starts. If the variable is empty, then we