[clang-tools-extra] [include-cleaner] Report refs for enum constants used through namespace aliases (PR #106706)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 30 07:04:47 PDT 2024


================
@@ -146,9 +148,24 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
     //
     // If it's an enum constant, it must be due to prior decl. Report references
     // to it when qualifier isn't a type.
-    if (llvm::isa<EnumConstantDecl>(FD)) {
-      if (!DRE->getQualifier() || DRE->getQualifier()->getAsNamespace())
-        report(DRE->getLocation(), FD);
+    auto QualifierIsNamepsaceOrNone = [&DRE]() {
----------------
ilya-biryukov wrote:

NIT: Maybe make this a helper function instead?
Having a lambda reduces the scope of visibility, but we also loose the benefits of making the body of our function smaller. I tend to prefer smaller functions, but up to you.

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


More information about the cfe-commits mailing list