Provide definitions for std::size_t and std::ptrdiff_t through type deduction #5699
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I previously added a feature to Clang that allows expressions producing
size_tandptrdiff_tthrough built-in language mechanisms (eg.sizeof) to have the sugared types__size_tand__ptrdiff_t, instead ofunsigned int/long/long longandint/long/long long(llvm/llvm-project#143653). This helps generate more portable diagnostic messages. However, the definitions ofsize_tandptrdiff_tin the STL andvcruntime.hare hardcoded to fixed built-in types, causing this benefit to be lost when arithmetic operations are performed, as Clang does not treatstd::size_tandstd::ptrdiff_tdiffer from othertypedefs when evaluates common sugared types.By using deduction to define
std::size_tandstd::ptrdiff_t, this advantage can be preserved.