[clang-tools-extra] [clang-tidy][libc] Fix namespace check with macro (PR #68134)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 5 12:58:03 PDT 2023


================
@@ -45,18 +45,20 @@ void CalleeNamespaceCheck::check(const MatchFinder::MatchResult &Result) {
   if (FuncDecl->getBuiltinID() != 0)
     return;
 
-  // If the outermost namespace of the function is __llvm_libc, we're good.
+  // If the outermost namespace of the function starts with __llvm_libc, we're
+  // good.
   const auto *NS = dyn_cast<NamespaceDecl>(getOutermostNamespace(FuncDecl));
-  if (NS && NS->getName() == "__llvm_libc")
+  if (NS && NS->getName().starts_with("__llvm_libc"))
----------------
michaelrj-google wrote:

The change is to make sure the clang-tidy check works on the new `LIBC_NAMESPACE`. I've added a check to make sure it comes from the macro. I've also added tests for this, and updated the existing tests to handle the changes to this check.

https://github.com/llvm/llvm-project/pull/68134


More information about the cfe-commits mailing list