This is an archive of the discontinued LLVM Phabricator instance.

[clang-tools-extra] reimplement PreprocessorTracker in terms of StringSet.
ClosedPublic

Authored by lattner on Apr 15 2020, 10:28 PM.

Details

Summary

PreprocessorTracker is the last user of the old StringPool class, which
isn't super loved and isn't a great improvement over a plan StringSet.
Once this goes in we can remove StringPool entirely.

This is as discussed on cfe-dev.

Diff Detail

Event Timeline

lattner created this revision.Apr 15 2020, 10:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2020, 10:28 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay added inline comments.
clang-tools-extra/modularize/PreprocessorTracker.cpp
912–914

Is it well-known that a StringSet (= StringMap<NoneType, ...>) returned StringRef is stable? Is that property something we can reliably depend on?

If not, StringSaver.h:UniqueStringSaver may be a better choice.

Hey @MaskRay, yes StringSet/StringMap's entries are separately allocated and the iterators/pointers are stable. The strings are held in each entry.

rnk accepted this revision.Apr 16 2020, 12:21 PM
rnk added a subscriber: rnk.

lgtm

clang-tools-extra/modularize/PreprocessorTracker.cpp
466

Nice.

912–914

I am only one data point, but yes, I knew that before this came up. :)

This revision is now accepted and ready to land.Apr 16 2020, 12:21 PM

Thank you for the review Reid!

MaskRay accepted this revision.Apr 16 2020, 1:00 PM
This revision was automatically updated to reflect the committed changes.