[clang] [Clang][Sema] Fix crash when diagnosing near-match for 'constexpr' redeclaration in C++11 (PR #92452)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon May 20 07:19:32 PDT 2024


================
@@ -9203,15 +9203,15 @@ static NamedDecl *DiagnoseInvalidRedeclaration(
         << Idx << FDParam->getType()
         << NewFD->getParamDecl(Idx - 1)->getType();
     } else if (FDisConst != NewFDisConst) {
-      SemaRef.Diag(FD->getLocation(), diag::note_member_def_close_const_match)
-          << NewFDisConst << FD->getSourceRange().getEnd()
-          << (NewFDisConst
-                  ? FixItHint::CreateRemoval(ExtraArgs.D.getFunctionTypeInfo()
-                                                 .getConstQualifierLoc())
-                  : FixItHint::CreateInsertion(ExtraArgs.D.getFunctionTypeInfo()
-                                                   .getRParenLoc()
-                                                   .getLocWithOffset(1),
-                                               " const"));
+      auto DB = SemaRef.Diag(FD->getLocation(),
+                             diag::note_member_def_close_const_match)
+                << NewFDisConst << FD->getSourceRange().getEnd();
+      if (const auto &FTI = ExtraArgs.D.getFunctionTypeInfo(); !NewFDisConst)
----------------
erichkeane wrote:

Yeah, I agree it is not really a meaningful change, besides being a bit of a 'say what you mean'.  That is, use the variable that is more closely related to what we MEAN.  I haven't reviewed this in long enough to know if I was correct here, so if you're sure that the variable you're using is the one that properly states the intent, feel free to ignore hte comment.

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


More information about the cfe-commits mailing list