[PATCH] D72630: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init

Malcolm Parsons via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 14 02:13:42 PST 2020


This revision was automatically updated to reflect the committed changes.
malcolm.parsons marked an inline comment as done.
Closed by commit rG45924eb46716: [clang-tidy] Ignore implicit casts in modernize-use-default-member-init (authored by malcolm.parsons).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72630

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-default-member-init.cpp
@@ -291,7 +291,7 @@
   int e1{};
   int e2 = 0;
   int e3 = {5};
-  int e4 = 5;
+  int e4{5};
   int e5 = -5;
   int e6 = +5;
 };
@@ -315,7 +315,7 @@
   double e1{};
   double e2 = 0.0;
   double e3 = 5.0;
-  double e4 = -5.0;
+  double e4{-5.0};
   double e5 = +5.0;
 };
 
@@ -333,7 +333,7 @@
   // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
   bool e1{};
   bool e2 = false;
-  bool e3 = true;
+  bool e3{true};
 };
 
 struct ExistingEnum {
@@ -365,7 +365,7 @@
   // CHECK-FIXES: ExistingPointer(long) :  e4(&e2) {}
   int *e1{};
   int *e2 = 0;
-  int *e3 = nullptr;
+  int *e3{nullptr};
   int **e4 = &e1;
 };
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -137,7 +137,7 @@
 static const Expr *getInitializer(const Expr *E) {
   auto *InitList = dyn_cast<InitListExpr>(E);
   if (InitList && InitList->getNumInits() == 1)
-    return InitList->getInit(0);
+    return InitList->getInit(0)->IgnoreParenImpCasts();
   return E;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72630.237890.patch
Type: text/x-patch
Size: 1522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200114/252a9a5d/attachment.bin>


More information about the cfe-commits mailing list