[PATCH] D33841: [clang-tidy] redundant keyword check

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 14 11:30:15 PDT 2019


aaron.ballman added inline comments.


================
Comment at: clang-tidy/readability/RedundantExternCheck.cpp:27
+void RedundantExternCheck::check(const MatchFinder::MatchResult &Result) {
+  auto* FD =
+      Result.Nodes.getNodeAs<FunctionDecl>("redundant_extern");
----------------
Formatting is incorrect (elsewhere too). You should run the patch through clang-format.


================
Comment at: clang-tidy/readability/RedundantExternCheck.cpp:32
+
+  if(!(FD->getStorageClass() == SC_Extern))
+    return;
----------------
`FD->getStorageClass() != SC_Extern`


================
Comment at: clang-tidy/readability/RedundantExternCheck.cpp:35
+
+  auto Diag = diag(FD->getBeginLoc(), "redundant 'extern' keyword");
+
----------------
How about "redundant 'extern' storage class specifier"?


================
Comment at: test/clang-tidy/readability-redundant-extern.cpp:37
+
+void another_file_scope(int _extern);
----------------
More tests that I figured out:
```
namespace {
extern void f(); // 'extern' is not redundant
}

namespace a {
namespace {
namespace b {
extern void f(); // 'extern' is not redundant
}
}
}

// Note, the above are consequences of http://eel.is/c++draft/basic.link#6

#define FOO_EXTERN extern
typedef int extern_int;

extern_int FOO_EXTERN foo(); // 'extern' is redundant, but hopefully we don't try to fixit this to be '_int FOO_EXTERN foo();'

// The above is a weird consequence of how specifiers are parsed in C and C++
```


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

https://reviews.llvm.org/D33841





More information about the cfe-commits mailing list