================
@@ -21,6 +21,17 @@ AST_MATCHER(NamedDecl, isInMacro) {
 
 AST_MATCHER(VarDecl, isLocalVariable) { return Node.isLocalVarDecl(); }
 
+AST_MATCHER(Decl, isLexicallyInAnonymousNamespace) {
+  for (const DeclContext *DC = Node.getLexicalDeclContext(); DC != nullptr;
+       DC = DC->getLexicalParent()) {
+    if (const auto *ND = dyn_cast<NamespaceDecl>(DC))
+      if (ND->isAnonymousNamespace())
+        return true;
+  }
+
+  return false;
+}
----------------
vbvictor wrote:

This code is the same as
https://github.com/llvm/llvm-project/blob/b71756852f5a41b35a74918374a11ae00365ee04/clang/lib/AST/DeclBase.cpp#L421-L429
But with change `getDeclContext` to `getLexicalDeclContext`

https://github.com/llvm/llvm-project/pull/148357
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to