aaron.ballman added inline comments.
================ Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:25 + isa<DoStmt>(S) || + isa<ReturnStmt>(S) || + isa<GotoStmt>(S) || ---------------- How about `throw` expressions? ================ Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:61-65 + const auto *DRE = dyn_cast<DeclRefExpr>(Value); + if (!DRE) + return false; + + return isa<EnumConstantDecl>(DRE->getDecl()); ---------------- ``` if (const auto *DRE = dyn_cast<DeclRefExpr>(Value)) return isa<EnumConstantDecl>(DRE->getDecl()) return false; ``` ================ Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:126-128 + const auto *Body = dyn_cast_or_null<CompoundStmt>(Ctor->getBody()); + if (!Body) + return; ---------------- This can be hoisted into the matcher with `hasBody(anything())` I believe. One interesting test case that's somewhat related are constructors that use a function-try-block instead of a compound statement. e.g., ``` class C { int i; public: C() try { i = 12; } catch (...) { } }; ``` ================ Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst:6 + +Finds member initializations in the constructor body which can be placed to +the member initializers of the constructor instead. This does not only improves ---------------- placed to the -> converted into ================ Comment at: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst:7 +Finds member initializations in the constructor body which can be placed to +the member initializers of the constructor instead. This does not only improves +the readability of the code but also positively affects its performance. ---------------- does not -> not CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71199/new/ https://reviews.llvm.org/D71199 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits