[PATCH] D146904: [clang-tidy] Fix extern fixes in readability-redundant-declaration

Carlos Galvez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 8 09:54:40 PDT 2023


carlosgalvezp accepted this revision.
carlosgalvezp added a comment.
This revision is now accepted and ready to land.

Looks great, thanks!



================
Comment at: clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp:86
+              Result.Nodes.getNodeAs<LinkageSpecDecl>("extern");
+          Extern && !Extern->hasBraces())
+        BeginLoc = Extern->getExternLoc();
----------------
PiotrZSL wrote:
> carlosgalvezp wrote:
> > This can be removed, leaving it as:
> > 
> > ```
> > if (const auto *Extern = ... && !Extern->hasBraces())
> > ```
> If you mean:
> ```
>  if (const auto *Extern =
>               Result.Nodes.getNodeAs<LinkageSpecDecl>("extern");
>           !Extern->hasBraces())
> ````
> 
> then no, it cannot be like this because Extern can be null.
You are right, this can only be done when there's no other conditions in the `if`!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146904/new/

https://reviews.llvm.org/D146904



More information about the cfe-commits mailing list