[PATCH] D78273: [clang-tools-extra] reimplement PreprocessorTracker in terms of StringSet.

Chris Lattner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 22:45:07 PDT 2020


lattner created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
MaskRay added inline comments.


================
Comment at: clang-tools-extra/modularize/PreprocessorTracker.cpp:912
   // Lookup/add string.
-  StringHandle addString(llvm::StringRef Str) { return Strings.intern(Str); }
+  StringHandle addString(llvm::StringRef Str) {
+    return Strings.insert(Str).first->first();
----------------
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.


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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78273

Files:
  clang-tools-extra/modularize/PreprocessorTracker.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78273.257958.patch
Type: text/x-patch
Size: 6138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200416/69a6d621/attachment.bin>


More information about the cfe-commits mailing list