This is an archive of the discontinued LLVM Phabricator instance.

Thread safety analysis: Handle additional cast in scoped capability construction
ClosedPublic

Authored by aaronpuchert on Jul 14 2022, 4:44 AM.

Details

Summary

We might have a CK_NoOp cast and a further CK_ConstructorConversion.
As an optimization, drop some IgnoreParens calls: inside of the
CK_{Constructor,UserDefined}Conversion should be no more parentheses,
and inside the CXXBindTemporaryExpr should also be none.

Lastly, we factor out the unpacking so that we can reuse it for
MaterializeTemporaryExprs later on.

Diff Detail

Event Timeline

aaronpuchert created this revision.Jul 14 2022, 4:44 AM
Herald added a project: Restricted Project. · View Herald Transcript
aaronpuchert requested review of this revision.Jul 14 2022, 4:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 4:44 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

@efriedma, added you because this removes one of the IgnoreParens calls that you added in D76943, and that I think should be dead code. (The one after CXXBindTemporaryExpr.)

aaron.ballman accepted this revision.Jul 27 2022, 11:28 AM

LGTM! Do you think this warrants a release note (or did it close any open issues in the tracker)?

clang/lib/Analysis/ThreadSafety.cpp
2091–2097

I almost wonder if we should just turn this into a while loop rather than two casts in a specific order. However, I can't think of a situation where we'd need the loop, so I think this is fine. At the very least, it's incremental progress!

This revision is now accepted and ready to land.Jul 27 2022, 11:28 AM
aaronpuchert marked an inline comment as done.Jul 28 2022, 8:32 AM

Do you think this warrants a release note (or did it close any open issues in the tracker)?

It's probably too technical/minor to be worth mentioning. It also doesn't close any issues that I'm aware of, I mostly did it in preparation for D129755, where I'm reusing the new function.

clang/lib/Analysis/ThreadSafety.cpp
2091–2097

They should always be in that order, or at least until we get to the CXXConstructExpr or CXXMemberCallExpr that we want (there could be another standard conversion sequence for the argument inside of that, but that's not our concern here). The reason is that this constructor or conversion function call is the CK_ConstructorConversion or CK_UserDefinedConversion, respectively, while the remaining standard conversion sequence (to which the NoOp belongs) happens after/above that.

aaron.ballman added inline comments.Jul 28 2022, 9:00 AM
clang/lib/Analysis/ThreadSafety.cpp
2091–2097

Ah, thank you for confirming my intuition!

This revision was landed with ongoing or failed builds.Oct 6 2022, 1:21 PM
This revision was automatically updated to reflect the committed changes.
aaronpuchert marked an inline comment as done.