This is an archive of the discontinued LLVM Phabricator instance.

Add null-pointer checks when accessing a TypeSystem's SymbolFile
ClosedPublic

Authored by augusto2112 on Apr 29 2021, 8:13 AM.

Details

Summary

A type system is not guaranteed to have a symbol file. This patch adds null-pointer checks so we don't crash when trying to access a type system's symbol file.

Diff Detail

Event Timeline

augusto2112 requested review of this revision.Apr 29 2021, 8:13 AM
augusto2112 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 29 2021, 8:13 AM

General question, is it possible to write a test for this? (I've not looked into this area of code before)

TypeSystemClang can be unit-tested just fine these days. It should also be possible to test Type (You can just model a random 'int' type from a TypeSystemClang instance).

aprantl accepted this revision.May 3 2021, 2:37 PM
This revision is now accepted and ready to land.May 3 2021, 2:37 PM

Add GetExeModuleWhenMissingSymbolFile tesst.

@teemperor let me know if this test is OK, or if there's a better way to test this :)

teemperor accepted this revision.May 10 2021, 1:42 PM

LGTM, just some nits and please address the clang-format issue.

lldb/unittests/Symbol/TestTypeSystemClang.cpp
747 ↗(On Diff #344151)

Can you make that CompilerType? (Just because it's not clear what this returns, e.g. Type or CompilerType)

753 ↗(On Diff #344151)

Can you also spell out the auto type and check that this is a nullptr? EXPECT_EQ(module, nullptr); Right now this could return some random pointer and pass.

Update test

This revision was landed with ongoing or failed builds.May 11 2021, 9:20 AM
This revision was automatically updated to reflect the committed changes.