diff options
author | Sean Callanan <scallanan@apple.com> | 2011-12-22 21:24:49 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2011-12-22 21:24:49 +0000 |
commit | 694e24417675ea81f628c2844d42d98a47b7bfbf (patch) | |
tree | 0706f1d490813968ff7f7465709145546c40a3e7 /lldb/source/Expression/IRForTarget.cpp | |
parent | a33843f5b4f5b61933022c5dd5c81ba101233152 (diff) | |
download | bcm5719-llvm-694e24417675ea81f628c2844d42d98a47b7bfbf.tar.gz bcm5719-llvm-694e24417675ea81f628c2844d42d98a47b7bfbf.zip |
Added checking to prevent a rare crash when getting
the name for an external variable in the IR.
llvm-svn: 147178
Diffstat (limited to 'lldb/source/Expression/IRForTarget.cpp')
-rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index 2c0d8ba80fa..c16e1266b91 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -1831,19 +1831,27 @@ IRForTarget::ResolveExternals (Function &llvm_function) global != end; ++global) { + if (!global) + { + if (m_error_stream) + m_error_stream->Printf("Internal error [IRForTarget]: global variable is NULL"); + + return false; + } + + std::string global_name = (*global).getName().str(); + if (log) log->Printf("Examining %s, DeclForGlobalValue returns %p", - (*global).getName().str().c_str(), + global_name.c_str(), DeclForGlobal(global)); - - std::string global_name = (*global).getName().str(); if (global_name.find("OBJC_IVAR") == 0) { if (!HandleSymbol(global)) { if (m_error_stream) - m_error_stream->Printf("Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol %s\n", (*global).getName().str().c_str()); + m_error_stream->Printf("Error [IRForTarget]: Couldn't find Objective-C indirect ivar symbol %s\n", global_name.c_str()); return false; } @@ -1863,7 +1871,7 @@ IRForTarget::ResolveExternals (Function &llvm_function) if (!MaybeHandleVariable (global)) { if (m_error_stream) - m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite external variable %s\n", (*global).getName().str().c_str()); + m_error_stream->Printf("Internal error [IRForTarget]: Couldn't rewrite external variable %s\n", global_name.c_str()); return false; } |