This is an archive of the discontinued LLVM Phabricator instance.

[libc] Add LIBC_INLINE_VAR for inline variables
ClosedPublic

Authored by abrachet on Jun 14 2023, 12:48 PM.

Details

Summary

These are the only variables I could find that use LIBC_INLINE. Note, these are namespace scoped constexpr so local linkage is implied. inline is useful here to silence clang's unused-const-variable variable. For Fuchsia, the distinction between LIBC_INLINE and LIBC_INLINE_VAR is helpful because we define LIBC_INLINE as [[gnu::always_inline]] inline when building with gcc. This isn't meaningful on variables.

Alternatively, we could make these variables simply constexpr and also add [[maybe_unused]]

Diff Detail

Event Timeline

abrachet created this revision.Jun 14 2023, 12:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 14 2023, 12:48 PM
Herald added a subscriber: jdoerfert. · View Herald Transcript
abrachet requested review of this revision.Jun 14 2023, 12:48 PM
Caslyn added a subscriber: Caslyn.Jun 15 2023, 9:06 AM
mcgrathr accepted this revision.Jun 15 2023, 2:20 PM
mcgrathr added a subscriber: mcgrathr.

LGTM but maybe there's some doc pages somewhere that should be updated to mention using LIBC_INLINE_VAR.

This revision is now accepted and ready to land.Jun 15 2023, 2:20 PM
sivachandra added a project: Restricted Project.Jun 15 2023, 2:22 PM
sivachandra added a subscriber: libc-commits.
sivachandra accepted this revision.Jun 15 2023, 2:24 PM

Sorry, I missed this because it was not copied to libc-commits.
+1 for documentation - a section similar to this may be: https://libc.llvm.org/dev/code_style.html#inline-functions-defined-in-header-files

This revision was automatically updated to reflect the committed changes.