================
@@ -301,41 +368,52 @@ void UseDefaultMemberInitCheck::checkDefaultInit(
   if (StartLoc.isMacroID() && IgnoreMacros)
     return;
 
-  const SourceLocation FieldEnd =
-      Lexer::getLocForEndOfToken(Field->getSourceRange().getEnd(), 0,
-                                 *Result.SourceManager, getLangOpts());
-  const SourceLocation LParenEnd = Lexer::getLocForEndOfToken(
-      Init->getLParenLoc(), 0, *Result.SourceManager, getLangOpts());
-  const CharSourceRange InitRange =
-      CharSourceRange::getCharRange(LParenEnd, Init->getRParenLoc());
-
-  const Expr *InitExpression = Init->getInit();
-  const QualType InitType = InitExpression->getType();
-
-  const bool ValueInit =
-      isa<ImplicitValueInitExpr>(InitExpression) && !isa<ArrayType>(InitType);
-  const bool CanAssign =
-      UseAssignment && (!ValueInit || !InitType->isEnumeralType());
-  const bool NeedsBraces = !CanAssign || isa<ArrayType>(InitType);
-
-  auto Diag =
-      diag(Field->getLocation(), "use default member initializer for %0")
-      << Field;
-
-  if (CanAssign)
-    Diag << FixItHint::CreateInsertion(FieldEnd, " = ");
-  if (NeedsBraces)
-    Diag << FixItHint::CreateInsertion(FieldEnd, "{");
-
-  if (CanAssign && ValueInit)
-    Diag << FixItHint::CreateInsertion(FieldEnd, 
getValueOfValueInit(InitType));
-  else
-    Diag << FixItHint::CreateInsertionFromRange(FieldEnd, InitRange);
-
-  if (NeedsBraces)
-    Diag << FixItHint::CreateInsertion(FieldEnd, "}");
+  {
----------------
vbvictor wrote:

Instead of making another scope, can we do:

```cpp

auto Diag = ...

if (!EmitFixit) {
  Diag.Emit();
  diag("...", Note)
  return;
}

// Fixit logic

```

https://github.com/llvm/llvm-project/pull/191607
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to