[PATCH] D16700: [Clang-tidy] Make null pointer literals for fixes configurable for two checks

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 2 05:48:54 PST 2016


aaron.ballman added a comment.

Missing test cases.

As for a global option, once http://reviews.llvm.org/D16113 lands, you can use `getLocalOrGlobal()` if you want to use a global option for this functionality.


================
Comment at: clang-tidy/readability/ImplicitBoolCastCheck.cpp:69
@@ -68,2 +68,3 @@
 StringRef
-getZeroLiteralToCompareWithForGivenType(CastKind CastExpressionKind,
+getZeroLiteralToCompareWithForGivenType(ImplicitBoolCastCheck *Check,
+                                        CastKind CastExpressionKind,
----------------
Check can be a const pointer.

================
Comment at: clang-tidy/readability/ImplicitBoolCastCheck.cpp:126
@@ -124,3 +125,3 @@
 void addFixItHintsForGenericExpressionCastToBool(
-    DiagnosticBuilder &Diagnostic, const ImplicitCastExpr *CastExpression,
-    const Stmt *ParentStatement, ASTContext &Context) {
+    ImplicitBoolCastCheck *Check, DiagnosticBuilder &Diagnostic,
+    const ImplicitCastExpr *CastExpression, const Stmt *ParentStatement,
----------------
Same here.

================
Comment at: clang-tidy/readability/ImplicitBoolCastCheck.h:32
@@ -30,1 +31,3 @@
+            Options.get("NullPointerLiteral",
+            Context->getLangOpts().CPlusPlus11 ? "nullptr" : "0")) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
----------------
I know you are following the pattern used in the code here, but I think this class needs a storeOptions() function as well. See AssertSideEffectCheck as an example.

================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:175
@@ -174,2 +174,3 @@
 
-std::string replacementExpression(const MatchFinder::MatchResult &Result,
+std::string replacementExpression(SimplifyBooleanExprCheck *Check,
+                                  const MatchFinder::MatchResult &Result,
----------------
Check can be a const pointer.

================
Comment at: clang-tidy/readability/SimplifyBooleanExprCheck.cpp:276
@@ +275,3 @@
+      NullPointerLiteral(
+          Options.get("NullPointerLiteral",
+          Context->getLangOpts().CPlusPlus11 ? "nullptr" : "0")) {}
----------------
I think this also needs a storeOptions() method.


Repository:
  rL LLVM

http://reviews.llvm.org/D16700





More information about the cfe-commits mailing list