Fix crash exposed by r328025

The issue was that the ASTDumper was being passed a null pointer
(because we did not create any declaration for the operator==).  The
crash was in logging code, so it only manifested it self if you ran the
tests with logging enabled (like our bots do).

Given that this is logging code and the rest of the debugger is fine
with the declaration being null, I just make sure the logging code can
handle it as well. Right now I just do the null check in
ClangExpressionDeclMap, but if the ASTDumper class is meant to be a
debugging/logging aid, then it might be a good idea move the check
inside the class itself.

llvm-svn: 328088
This commit is contained in:
Pavel Labath 2018-03-21 11:10:57 +00:00
parent 369e97511d
commit 03a77e9a39
1 changed files with 3 additions and 2 deletions

View File

@ -2116,7 +2116,8 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
parser_vars->m_llvm_value = NULL; parser_vars->m_llvm_value = NULL;
if (log) { if (log) {
ASTDumper ast_dumper(function_decl); std::string function_str =
function_decl ? ASTDumper(function_decl).GetCString() : "nullptr";
StreamString ss; StreamString ss;
@ -2127,7 +2128,7 @@ void ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context,
log->Printf( log->Printf(
" CEDM::FEVD[%u] Found %s function %s (description %s), returned %s", " CEDM::FEVD[%u] Found %s function %s (description %s), returned %s",
current_id, (function ? "specific" : "generic"), decl_name.c_str(), current_id, (function ? "specific" : "generic"), decl_name.c_str(),
ss.GetData(), ast_dumper.GetCString()); ss.GetData(), function_str.c_str());
} }
} }