This is an archive of the discontinued LLVM Phabricator instance.

Thread safety analysis: Mock getter for private mutexes can be undefined
ClosedPublic

Authored by aaronpuchert on Jul 20 2021, 9:11 AM.

Details

Summary

Usage in an annotation is no odr-use, so I think there needs to be no
definition. Upside is that in practice one will get linker errors if it
is actually odr-used instead of calling a function that returns 0.

Diff Detail

Event Timeline

aaronpuchert requested review of this revision.Jul 20 2021, 9:11 AM
aaronpuchert created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2021, 9:11 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman accepted this revision.Jul 22 2021, 7:55 AM

LGTM! It took me a minute to convince myself it wasn't really an ODR use (the argument goes through the usual expression evaluation parsing and sema bits), but because the arguments to these attributes never wind up being used in codegen, they're not really a use as far as the ODR is concerned.

This revision is now accepted and ready to land.Jul 22 2021, 7:55 AM

LGTM! It took me a minute to convince myself it wasn't really an ODR use (the argument goes through the usual expression evaluation parsing and sema bits), but because the arguments to these attributes never wind up being used in codegen, they're not really a use as far as the ODR is concerned.

Right, the standard doesn't know about our attributes. My reasoning was that they are basically an unevaluated context like a sizeof expression.

This revision was landed with ongoing or failed builds.Jul 23 2021, 5:50 AM
This revision was automatically updated to reflect the committed changes.

LGTM! It took me a minute to convince myself it wasn't really an ODR use (the argument goes through the usual expression evaluation parsing and sema bits), but because the arguments to these attributes never wind up being used in codegen, they're not really a use as far as the ODR is concerned.

Right, the standard doesn't know about our attributes. My reasoning was that they are basically an unevaluated context like a sizeof expression.

Nonstandard attributes are wholly up to the implementation for what their semantic effects are, so they can be unevaluated *or* constant evaluated *or* runtime evaluated depending on need. I mostly just needed to make sure we weren't accidentally marking these uses as ODR uses, and happily, we weren't.