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

Michael Jones via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 16 10:58:16 PST 2021


michaelrj added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:13
 
+#include <stdio.h>
+
----------------
sivachandra wrote:
> Eugene.Zelenko wrote:
> > Should  be `<cstdio>` and without newline separation form rest of headers.
> Looks like this is present only for the debug `printf`?
yes, I didn't mean to leave that in there.


================
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:
> 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.


================
Comment at: clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp:59
+            llvm::StringRef(FUNCTIONS_TO_IGNORE_NAMESPACE[i]))) {
+      printf("String found %s\n", FuncDecl->getName().str().c_str());
+      return;
----------------
sivachandra wrote:
> lntue wrote:
> > Look like diag() is used to print messages in this module?
> This looks like a debug `printf`?
yes, I didn't mean to leave that in there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946



More information about the cfe-commits mailing list