This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Prevent false positives with simple template names in SymbolFileDWARF::FindTypes
ClosedPublic

Authored by aeubanks on Dec 16 2022, 11:59 AM.

Details

Summary

The provided test case was crashing because of confusion attempting to find types for ns::Foo under -gsimple-template-names. (This looks broken normally because it's attempting to find ns::Foo rather than ns::Foo<T>)

Looking up types can't give false positives, as opposed to looking up functions as mentioned in https://reviews.llvm.org/D137098.

Diff Detail

Event Timeline

aeubanks created this revision.Dec 16 2022, 11:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2022, 11:59 AM
aeubanks requested review of this revision.Dec 16 2022, 11:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2022, 11:59 AM
aeubanks added inline comments.Dec 16 2022, 12:00 PM
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
2522

I'm looking into whether or not this can be sped up by checking if the type is templated some other way

aeubanks updated this revision to Diff 484077.Dec 19 2022, 2:33 PM

check if type is template by looking at underlying clang Type, rather than looking for a '<'
properly handle typedefs

aeubanks added inline comments.Dec 19 2022, 2:37 PM
lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
16

this makes handling of -gsimple-template-names the same as the current handling of -gno-simple-template-names

I haven't dug too deep into the existing difference between FooDouble/FooInt vs the others

for the "no member named" errors, I believe clang is attempting to get the uninstantiated declarations of Foo/Bar, which the dwarf knows nothing about

Michael137 added inline comments.Dec 19 2022, 2:43 PM
lldb/test/API/lang/cpp/unique-types4/TestUniqueTypes4.py
16

Yup that's exactly what it is. For expr Foo<double>, clang::Sema's template lookup would ask LLDB to give it type Foo, but we can't service that request from DWARF currently

Michael137 accepted this revision.Dec 19 2022, 2:44 PM

look reasonable to me

This revision is now accepted and ready to land.Dec 19 2022, 2:44 PM
Michael137 added inline comments.Dec 20 2022, 7:20 AM
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
2521

You could consider using CompilerType::GetTypeInfo instead of introducing CompilerType::IsTemplateType. Though that function looks a bit chunky

aeubanks added inline comments.Dec 20 2022, 10:01 AM
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
2521

just tried this but it's recognizing the type as just a normal record instead of a template instantiation