[PATCH] Add readability-remove-void-arg check to clang-tidy
Alexander Kornienko
alexfh at google.com
Mon Mar 2 07:50:56 PST 2015
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:164
@@ +163,3 @@
+ const MatchFinder::MatchResult &Result, SourceLocation StartLoc,
+ const std::string &DeclText, const StringRef GrammarLocation) {
+ clang::Lexer PrototypeLexer(StartLoc, Result.Context->getLangOpts(),
----------------
s/const std::string&/StringRef/, s/const StringRef/StringRef/
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:176
@@ +175,3 @@
+ Token ProtoToken;
+ const auto Diagnostic = "redundant void argument list in " + GrammarLocation;
+ while (!PrototypeLexer.LexFromRawLexer(ProtoToken)) {
----------------
s/const auto/std::string/
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:186
@@ +185,3 @@
+ if (ProtoToken.is(tok::TokenKind::kw_void) ||
+ (ProtoToken.is(tok::TokenKind::raw_identifier) &&
+ ProtoToken.getRawIdentifier() == "void")) {
----------------
You don't need to check for both kw_void and raw_identifier + "void". You won't see the former unless you resolve the identifier and set the token kind yourself.
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:219
@@ +218,3 @@
+ if (protoTypeHasNoParms(Typedef->getUnderlyingType())) {
+ auto Text = getText(Result, *Typedef);
+ removeVoidArgumentTokens(Result, Typedef->getLocStart(), Text, "typedef");
----------------
Please use `StringRef` instead of `auto` here (see the other code review thread for an explanation).
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:227
@@ +226,3 @@
+ if (protoTypeHasNoParms(Member->getType())) {
+ const auto Text = getText(Result, *Member);
+ removeVoidArgumentTokens(Result, Member->getLocStart(), Text,
----------------
StringRef
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:241
@@ +240,3 @@
+ .getLocWithOffset(-1);
+ const auto Text = getText(Result, Begin, InitStart);
+ removeVoidArgumentTokens(Result, Begin, Text,
----------------
s/const auto/StringRef/
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:255
@@ +254,3 @@
+ if (protoTypeHasNoParms(NamedCast->getTypeAsWritten())) {
+ const auto AngleBrackets = NamedCast->getAngleBrackets();
+ const auto Begin = AngleBrackets.getBegin().getLocWithOffset(1);
----------------
s/const auto/SourceLocation/
================
Comment at: clang-tidy/readability/RemoveVoidArg.cpp:267
@@ +266,3 @@
+ if (protoTypeHasNoParms(CStyleCast->getTypeAsWritten())) {
+ const auto Begin = CStyleCast->getLParenLoc().getLocWithOffset(1);
+ const auto End = CStyleCast->getRParenLoc().getLocWithOffset(-1);
----------------
auto
================
Comment at: clang-tidy/readability/RemoveVoidArg.h:38
@@ +37,3 @@
+private:
+ bool CPlusPlusFile_;
+
----------------
1. You don't need to store this flag as it's easy and cheap to check it on each call to `check()`: it's available as `Result.Context->getLangOpts().CPlusPlus`.
2. This name violates LLVM Naming conventions: http://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
http://reviews.llvm.org/D7639
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list