This is an archive of the discontinued LLVM Phabricator instance.

[TextAPI] Introduce SymbolSet
ClosedPublic

Authored by cishida on May 4 2023, 8:49 AM.

Details

Summary

SymbolSet is a structure that acts as a simple container class for exported symbols that
belong to a library interface. It allows tapi to decouple the globals
from the other library attributes. It's uniqued by symbol name and kind, which all contain their assigned target triples.

Diff Detail

Event Timeline

cishida created this revision.May 4 2023, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 8:49 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
cishida requested review of this revision.May 4 2023, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 8:49 AM
ributzka added inline comments.May 15 2023, 1:36 PM
llvm/lib/TextAPI/SymbolSet.cpp
29

Why add the corresponding Objective-C class here too?

cishida added inline comments.May 15 2023, 2:36 PM
llvm/lib/TextAPI/SymbolSet.cpp
29

hm, I'll try removing it. TAPI always expects these symbols to also have a corresponding class symbol. In theory, these should always exist so it doesn't need to be implicitly added. Though it's possible to export a ObjectiveCClassEHType without a ObjectiveCClass

cishida updated this revision to Diff 531120.Jun 13 2023, 5:12 PM

Remove extra call to create objc class symbols

cishida updated this revision to Diff 531121.Jun 13 2023, 5:17 PM

Fix bad docstrings

zixuw added inline comments.Jul 7 2023, 2:01 PM
llvm/include/llvm/TextAPI/InterfaceFile.h
346

nit: why do we need an std::optional instead of using the nullptr to indicate non-existence? And if the method returns the query element maybe we should give it another name than contains?

zixuw added inline comments.Jul 10 2023, 1:24 PM
llvm/include/llvm/TextAPI/Symbol.h
73–75

nit: I think lower_bound already uses operator< for comparison. Is this needed? Or maybe use std::less{}?

llvm/lib/TextAPI/Symbol.cpp
68–70

Could you explain more about this change? Is this change related to SymbolSet?

cishida added inline comments.Jul 10 2023, 3:01 PM
llvm/include/llvm/TextAPI/InterfaceFile.h
346

nullptr and std::nullopt evaluate differently in e.g. if (auto x = file->contains(sym)). I don't feel that strongly about supporting but it is used that way downstream.
I'll update the name though.

llvm/include/llvm/TextAPI/Symbol.h
73–75

This is just moved from InterfaceFile.cpp, I realized I forgot to delete that in this patch (will fix that) but I'd rather not update this code unless theres a strong reason to since its used in a lot of tapi data structure operations. Maybe worth revisiting though, if the code can be cleaned up.

llvm/lib/TextAPI/Symbol.cpp
68–70

I needed it to pass tests. This was an attempt to still check a TBD-v5 only attribute against older TBD file formats. Its not very useful or sound so I just removed it. The lambda should be removed too though.

cishida added inline comments.Jul 10 2023, 3:14 PM
llvm/lib/TextAPI/Symbol.cpp
68–70

NVM, I meant the removal is valid to be able to compare older files. Just trying to conditionalize it based off indirect assumptions isn't useful ATM. To be able to do this accurately I'd need to pass FileType down to this comparator.

cishida updated this revision to Diff 538849.Jul 10 2023, 3:19 PM

Remove redundant code and rename contains method.

zixuw accepted this revision.Jul 11 2023, 1:24 PM
This revision is now accepted and ready to land.Jul 11 2023, 1:24 PM
This revision was automatically updated to reflect the committed changes.