This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Fixed an issue where diagnostics printed expressions in a roundabout way
Needs ReviewPublic

Authored by wchilders on Nov 6 2020, 2:53 PM.

Details

Reviewers
yaxunl
hans
rsmith
Summary

Previously expressions were being printed in diagnostics via an implicit conversion to an expression template argument -- which would then be printed via some code with a comment suggesting the code path was only for completeness and rarely/never used; this was both roundabout, and subtle. This patch provides a more direct overload, though the patch is still imperfect, as it does not solve the associated LangOpts issue.

Additionally, to prevent similar issues in the future, this patch makes conversions from expressions to template arguments explicit.

Diff Detail

Event Timeline

wchilders created this revision.Nov 6 2020, 2:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2020, 2:53 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
wchilders requested review of this revision.Nov 6 2020, 2:53 PM
wchilders updated this revision to Diff 303953.Nov 9 2020, 12:20 PM

Formatting fixes

wchilders retitled this revision from Fixed an issue where diagnostics printed expressions in a roundabout way to [NFC] Fixed an issue where diagnostics printed expressions in a roundabout way.Dec 29 2020, 9:08 AM
hans added inline comments.Jan 11 2021, 6:51 AM
clang/lib/AST/TemplateBase.cpp
485

This code looks like a very special case, and the LangOptions comments suggests it's a bit hacky.
Because of that I'm not sure it makes sense to promote it to what looks like a general-purpose operator<< for Expr. What's the motivation for that?

clang/lib/Sema/SemaTemplateDeduction.cpp
463

nit: I guess TV is tor template value, but maybe TA would be a better name?