Use __has_attribute to check for __counted_by__ support

The initial clang patch to support __counted_by__ was landed and
reverted several times. There are some clang toolchains (e.g. the
Android toolchain) that report themselves as version 18 but do not
support __counted_by__. While it is debatable if Android should be
shipping a pre-release clang, using __has_attribute should be a bit
simpler overall.

Note that this doesn't migrate everything else to use __has_attribute:
while clang has always supported __has_attribute, gcc didn't support
it until a bit later.

Bug: 390685327
Change-Id: I4a612f6373ec298c4bf9793a74e4c3a9e9a30591
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6237055
Commit-Queue: Daniel Cheng <[email protected]>
Reviewed-by: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1416877}
NOKEYCHECK=True
GitOrigin-RevId: 0011e70a76784545f9c07493659052f1f30ec648
4 files changed