[PATCH] D24656: [clang-tidy] Add check readability-redundant-declaration

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 12 05:10:36 PDT 2016


aaron.ballman added inline comments.


================
Comment at: clang-tidy/readability/RedundantDeclarationCheck.cpp:60
+    auto Diag = diag(D->getLocation(), "redundant '%0' declaration")
+        << cast<NamedDecl>(D)->getName();
+    if (!MultiVar && !DifferentHeaders)
----------------
danielmarjamaki wrote:
> alexfh wrote:
> > It should be possible to just use `D` here.
> Thanks. It's not possible:
> 
> ```
> RedundantDeclarationCheck.cpp:61:15: error: ‘const class clang::Decl’ has no member named ‘getName’
>          << D->getName();
>                ^
> ```
> 
`diag(...) << cast<NamedDecl>(D)` is required; the diagnostic engine properly handles quoting `NamedDecl` objects.


https://reviews.llvm.org/D24656





More information about the cfe-commits mailing list