[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 30 07:01:37 PDT 2023


aaron.ballman added a comment.

Thank you for working on this! The changes should also come with a release note in `clang/docs/ReleaseNotes.rst` to note the improvement.



================
Comment at: clang/lib/AST/ExprConstant.cpp:2357-2361
+    if (SubobjectDecl) {
+      Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << SubobjectDecl;
+      Info.Note(SubobjectDecl->getLocation(),
+                diag::note_constexpr_subobject_declared_here);
+    }
----------------
Hmm, this breaks one of the contracts of our constexpr evaluation engine, doesn't it? My understanding is that if constexpr evaluation fails, we will have emitted a note diagnostic for why it failed. But if the caller doesn't pass a nonnull `SubobjectDecl`, we'll return `false` but we won't issue a diagnostic.

I'm surprised no tests lost notes as a result of this change, that suggests we're missing test coverage for the cases where nullptr is passed in explicitly to this function.


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

https://reviews.llvm.org/D146358



More information about the cfe-commits mailing list