[clang-tools-extra] [clang-tidy] Add support for in-class initializers in readability-redundant-member-init (PR #77206)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 14 03:37:57 PST 2024


================
@@ -18,52 +19,80 @@ using namespace clang::tidy::matchers;
 
 namespace clang::tidy::readability {
 
+static SourceRange
+getFullInitRangeInclWhitespaces(SourceRange Range, const SourceManager &SM,
+                                const LangOptions &LangOpts) {
+  const Token PrevToken =
+      utils::lexer::getPreviousToken(Range.getBegin(), SM, LangOpts, false);
+  if (PrevToken.is(tok::unknown))
+    return Range;
+
+  if (PrevToken.isNot(tok::equal))
+    return {PrevToken.getEndLoc(), Range.getEnd()};
----------------
phyBrackets wrote:

So I was just curious if its fine to merge the above two if conditions into a single one, and then based on ternary operator returning the Range? If you think that's not a good idea for readability purpose then it's totally fine.

https://github.com/llvm/llvm-project/pull/77206


More information about the cfe-commits mailing list