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

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 14:06:10 PDT 2023


================
@@ -45,18 +46,21 @@ 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 is a macro that starts with
+  // __llvm_libc, we're good.
   const auto *NS = dyn_cast<NamespaceDecl>(getOutermostNamespace(FuncDecl));
-  if (NS && NS->getName() == "__llvm_libc")
+  if (NS && Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) &&
----------------
michaelrj-google wrote:

I can improve this in a followup patch if necessary.

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


More information about the cfe-commits mailing list