[libc-commits] [PATCH] D113946: [libc][clang-tidy] fix namespace check for externals

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Nov 17 10:44:35 PST 2021


michaelrj added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:39
+// intercepted.
+static const char *FUNCTIONS_TO_IGNORE_NAMESPACE[] = {
+    "__errno_location", "malloc", "calloc", "realloc", "free"};
----------------
sivachandra wrote:
> michaelrj wrote:
> > sivachandra wrote:
> > > Eugene.Zelenko wrote:
> > > > Why not `std::array` of appropriate LLVM container?
> > > May be `static const std::uordered_set<llvm::StringRef>`? It would likely make the lookup below much neater.
> > an unordered set is a good idea, but the documentation for `StringRef` says it's best not to use them for storage, so I went with `std::string` instead. The code is still a lot nicer.
> Literal strings will not count as "storage". They are global data. On the other hand, `std::string` will make copies of the literals and require "storage".
When I tried to put a `StringRef` into an `unordered_set` it told me that `StringRef` doesn't have a hash function, so I went looking for what the proper, LLVM way of doing this was. In the end, I discovered that `unordered_set` is not recommended, and that `StringSet` does exactly what we need here, so I've switched to that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113946/new/

https://reviews.llvm.org/D113946



More information about the libc-commits mailing list