[patch] Improve diagnostic on default-initializing const variables (PR20208)

Nico Weber thakis at chromium.org
Wed Jul 9 14:48:42 PDT 2014


Hi,

the attached patch attempts to fix PR20208 in the way I understood
Richard's suggestion in comment 1.

The patch is a bit hairy (but short) since it adds a fixit on an error
emitted by InitializationSequence – this means it needs to build a correct
AST, which in turn means InitializationSequence::Failed() cannot return
true when this fixit is applied. As a workaround, the patch adds a fixit
member to InitializationSequence, and InitializationSequence::Perform()
prints the diagnostic if the fixit member is set right after its call to
Diagnose. I think that function is usually called when
InitializationSequences are used – InitListChecker::PerformEmptyInit()
doesn't call it though, so there might be bugs there.

Ideas? Easiest would be to put the fixit on a note, but the note would just
repeat the snippet from the diag itself, which isn't great. Or we could
omit the fixit and just do the wording change, but the fixit makes the
diagnostic much clearer.

Nico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140709/84edf297/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-init.patch
Type: application/octet-stream
Size: 10802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140709/84edf297/attachment.obj>


More information about the cfe-commits mailing list