This is an archive of the discontinued LLVM Phabricator instance.

[clang] Implement `PointerLikeTraits` for `{File,Directory}EntryRef`
ClosedPublic

Authored by jansvoboda11 on Jul 10 2023, 4:04 PM.

Details

Summary

This patch implements llvm::PointerLikeTraits<FileEntryRef> and llvm::PointerLikeTraits<DirectoryEntryRef>, allowing some simplifications around umbrella header/directory code.

Diff Detail

Event Timeline

jansvoboda11 created this revision.Jul 10 2023, 4:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 4:04 PM
Herald added a subscriber: ributzka. · View Herald Transcript
jansvoboda11 requested review of this revision.Jul 10 2023, 4:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 10 2023, 4:04 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Note that this enables usage of {File,Directory}EntryRef in other containers using PointerLikeTraits such as SmallPtrSet.

benlangmuir added inline comments.Jul 10 2023, 4:17 PM
clang/include/clang/Basic/DirectoryEntry.h
211

I suggest not hard-coding it if you can get away with it; maybe PointerLikeTypeTraits<clang::DirectoryEntryRef::MapEntry *>::NumLowBitsAvailable? I think 3 could be wrong on a 32-bit platform for example.

Forward NumLowBitsAvailable to PointerLikeTypeTraits of the underlying pointer.

jansvoboda11 marked an inline comment as done.Jul 11 2023, 7:29 AM
jansvoboda11 added inline comments.
clang/include/clang/Basic/DirectoryEntry.h
211

Good idea, updated.

benlangmuir accepted this revision.Jul 11 2023, 9:08 AM

Thanks!

This revision is now accepted and ready to land.Jul 11 2023, 9:08 AM
This revision was landed with ongoing or failed builds.Jul 11 2023, 11:17 AM
This revision was automatically updated to reflect the committed changes.
jansvoboda11 marked an inline comment as done.