This is an archive of the discontinued LLVM Phabricator instance.

Relax assert in ExprConstant to a return None.
ClosedPublic

Authored by JonChesterfield on Oct 20 2021, 10:11 AM.

Details

Summary

Fixes a compiler assert on passing a compile time integer to atomic builtins.

Assert introduced in D61522
Function changed from ->bool to ->Optional in D76646
Simplifies call sites to getIntegerConstantExpr to elide the now-redundant
isValueDependent checks.

Diff Detail

Event Timeline

JonChesterfield requested review of this revision.Oct 20 2021, 10:11 AM
JonChesterfield created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptOct 20 2021, 10:11 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

This makes sense, any reason we don't remove the check at the call sites right away?

This makes sense, any reason we don't remove the check at the call sites right away?

There are ~85 of them, will start looking through now.

  • fix up call sites
  • fix up call sites
  • drop spurious nl
JonChesterfield edited the summary of this revision. (Show Details)Oct 20 2021, 11:25 AM

Patched up the call sites that are straightforward. There are ~4 calls in SemaOpenMP where an !isValueDependent() could be dropped if it is safe to call PerformContextualImplicitConversion on such a value, which it probably is, but it's hard to be certain. There are a few places where Diag() calls would be changed by dropping the call, those are also left unchanged here.

clang/lib/Sema/SemaExprCXX.cpp
2137

Shame about the whitespace noise. getIntegerConstantExpr guards the block and is dominated by isValueDependent.

clang/lib/Sema/SemaTemplateDeduction.cpp
2171–2172

this parses as !ArgExpr->isValueDependent() && ArgExpr->getIntegerConstantExpr(S.Context) && ...

aaron.ballman accepted this revision.Oct 21 2021, 4:44 AM

I checked the call sites to see if any were missed and I did not spot uses that should also be changed. LGTM, thanks!

This revision is now accepted and ready to land.Oct 21 2021, 4:44 AM

Thanks! Lots of call sites to check, appreciate the check

This revision was automatically updated to reflect the committed changes.