This is an archive of the discontinued LLVM Phabricator instance.

[RFC] Handling implementation limits
Needs ReviewPublic

Authored by Mordante on Jan 1 2020, 7:50 AM.
This revision needs review, but there are no reviewers specified.

Details

Reviewers
None
Summary

This is a proof-of-concept patch to be discussed on the dev ml.

Diff Detail

Event Timeline

Mordante created this revision.Jan 1 2020, 7:50 AM

Unit tests: pass. 61168 tests passed, 0 failed and 728 were skipped.

clang-tidy: pass.

clang-format: pass.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Mordante updated this revision to Diff 236190.Jan 4 2020, 10:36 AM

Added support for some additional features:

  • Allow limits from the C standard, either sharing the C++ constants or separately.
  • Allow to document the design choices for the limit.
  • Allow to track the status of the limit. (This may become obsolete ones all limits are implemented, but that can take a while.)

Added some additional fields to test the C support.

Removed the .inc file from the patch, this should not be committed.

craig.topper added inline comments.
clang/docs/ImplementationQuantities.rst
71

should this say ‘not defined’?

Mordante marked 2 inline comments as done.Jan 4 2020, 1:51 PM
Mordante added inline comments.
clang/docs/ImplementationQuantities.rst
71

Yes, thanks for catching it!

Mordante updated this revision to Diff 236248.Jan 5 2020, 7:32 AM
Mordante marked an inline comment as done.

Made some improvements based on feedback of @craig.topper:

  • Adds a not
  • Implements an example of the maximum string length when using -Wpedantic
tahonermann added inline comments.
clang/docs/ImplementationQuantities.rst
11

Typo: imposse -> impose.

Mordante marked 2 inline comments as done.Jan 6 2020, 8:47 AM
Mordante added inline comments.
clang/docs/ImplementationQuantities.rst
11

Thanks, it will be updated in the next revision of the patch.

rsmith added a subscriber: rsmith.Jan 6 2020, 12:13 PM
rsmith added inline comments.
clang/include/clang/AST/Decl.h
903

These bitfields are assumed to fit into an unsigned, and this can no longer be verified locally (changes to the .td file can break this assumption). Please add a static_assert(sizeof(ParmVarDeclBitfields) <= sizeof(unsigned), "...") next to the union below (and likewise for NonParmVarDeclBitfields).

903

I think IQ is too terse. We don't need a really short name for this; how about ImpLimits:: or similar?

clang/include/clang/Basic/ImplementationQuantities.td
107–111

Switching between upper- and lower-case names for these fields seems surprising. Please pick a consistent capitalization scheme.

clang/lib/CodeGen/CGRecordLayout.h
72

These three bitfields no longer obviously fit in 32 bits. Please keep the hard-coded 15 here and add an adjacent static_assert(IQ::BitFieldBits <= 15, "...") instead, or use some similar strategy so that the bit-field allocation and layout remains locally obvious.

Mordante marked 6 inline comments as done.Jan 6 2020, 2:42 PM

Thanks for the feedback!

clang/include/clang/AST/Decl.h
903

I feared ImpLimits would be considered too verbose, but I'll change it in the next revision.

903

I'm not too fond to use the static_assert(sizeof(ParamVarDeclBitFields <= sizeof(unsigned), "..."); here and use a hardcoded value and a static_assert in other places. If it's important to see the size of bit-field directly I prefer the style you suggested later: "Please keep the hard-coded 15 here and add an adjacent static_assert(IQ::BitFieldBits <= 15, "...") instead, or use some similar strategy so that the bit-field allocation and layout remains locally obvious."

I'll give it some more thoughts before updating the proposal.

clang/include/clang/Basic/ImplementationQuantities.td
107–111

This style is used in other .td files. But I'll switch to capitalize the is/has in the next revision.