[PATCH] D33841: [clang-tidy] redundant 'extern' keyword check
Alexander Kornienko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 17 05:56:36 PDT 2019
alexfh added inline comments.
================
Comment at: clang-tidy/readability/RedundantExternCheck.cpp:38-40
+ Message = "'extern' keyword has no effect";
+ } else {
+ Message = "redundant 'extern' keyword";
----------------
These messages alone will be quite confusing unless the user has enough context. Please expand the messages with the explanations.
================
Comment at: clang-tidy/readability/RedundantExternCheck.cpp:48-50
+ StringRef Text =
+ Lexer::getSourceText(CharSourceRange::getTokenRange(BeginLoc, EndLoc),
+ *Result.SourceManager, getLangOpts());
----------------
I suspect there are many ways the `extern` substring can appear in a function definition (`void my_extern()`, `[[some_attribute("extern")]] void f()`, `void /*extern*/ f()`, etc.). I don't immediately see how these possible false positives are handled here. Am I missing something obvious?
Is it more robust to re-lex the range and search for the raw identifier token with the text `extern`?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D33841/new/
https://reviews.llvm.org/D33841
More information about the cfe-commits
mailing list