[PATCH] [clang-tidy] Add a checker that suggests replacing short/long/long long with fixed-size types.

Alexander Kornienko alexfh at google.com
Fri Aug 29 07:24:51 PDT 2014


================
Comment at: clang-tidy/google/IntegerTypesCheck.cpp:84
@@ +83,3 @@
+  // the sockets API.
+  const char Port[] = "unsigned short port";
+  const char *Data = Result.SourceManager->getCharacterData(Loc);
----------------
Why not static const StringRef?

================
Comment at: clang-tidy/google/IntegerTypesCheck.cpp:94
@@ +93,3 @@
+
+  // Emit a warning. QualTypes are printed with implicit quotes. We don't
+  // add a fix-it as changing the type can easily break code, e.g. when a
----------------
nit:
The "Emit a warning. " part is obvious, I'd remove it.

I'd swap the other two sentences and put each starting from its own line:

  // We don't add a fix-it as changing the type can easily break code, 
  // e.g. when a function requires a 'long' argument on all platforms.
  // QualTypes are printed with implicit quotes.

================
Comment at: clang-tidy/google/IntegerTypesCheck.h:20
@@ +19,3 @@
+/// \brief Finds uses of short, long and long long and suggest replacing them
+/// with intXX.
+/// Correspondig cpplint.py check: runtime/int.
----------------
Maybe:

  ... with u?intXX(_t)?

?

================
Comment at: clang-tidy/google/IntegerTypesCheck.h:25
@@ +24,3 @@
+  IntegerTypesCheck()
+      : UnsignedTypePrefix("uint"), SignedTypePrefix("int"), TypeSuffix("") {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
----------------
I'd use a bool flag instead of TypeSuffix or at least would add a comment describing the "_t" option for standard types.

================
Comment at: clang-tidy/google/IntegerTypesCheck.h:30
@@ +29,3 @@
+private:
+  StringRef UnsignedTypePrefix;
+  StringRef SignedTypePrefix;
----------------
Mark these fields "const"?

http://reviews.llvm.org/D5119






More information about the cfe-commits mailing list