[clang] [clang] Adding an API to create a `CXStringSet` from a Vector of `StringRef`s (PR #136773)
Jan Svoboda via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 22 15:04:31 PDT 2025
================
@@ -116,6 +117,13 @@ CXStringSet *createSet(const std::vector<std::string> &Strings) {
return Set;
}
+CXStringSet *createSet(const std::vector<std::string> &Strings) {
+ return createSetImpl(Strings);
+}
+
+CXStringSet *createSet(const std::vector<StringRef> &Strings) {
+ return createSetImpl(Strings);
----------------
jansvoboda11 wrote:
This still ends up calling `createDup()` on line 116 though. I'd expect this to call `createRef()` so that we actually do avoid the copies.
Also, it'd be better to take the type-erasing `ArrayRef<StringRef>`, it's more general than `const std::vector<StringRef> &`. If some other client in the future ends up having something like `llvm::SmallVector<StringRef>`, they'll be able to use that right away (instead of having to allocate a new `std::vector`, or create yet another overload of this function for `SmallVector`).
https://github.com/llvm/llvm-project/pull/136773
More information about the cfe-commits
mailing list