[PATCH] D143670: Stop claiming we support [[carries_dependency]]

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 9 11:26:27 PST 2023


aaron.ballman created this revision.
aaron.ballman added reviewers: clang-language-wg, erichkeane, rsmith, hubert.reinterpretcast.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

The `[[carries_dependency]]` attribute was added to the standard in C++11, but implementations have (uniformly, as best I can tell) been ignoring this attribute for the past decade. In Clang, we would parse the attribute and otherwise do nothing useful with it (no additional analyses, no communication of the attribute to the backend, etc). As far as I know, we have no future plans to implement the semantics of the attribute. However, `__has_cpp_attribute(carries_dependency)` returns a nonzero value which suggests we actually do support the attribute and do useful things with it, especially because we documented that it might improve performance.

This removes all support for `[[carries_dependency]]` and treats it as an unknown attribute instead (the same as we do for other standard attributes we don't support, like `[[no_unique_address]]` on some targets). We now return zero from `__has_cpp_attribute(carries_dependency)`, which matches the behavior of GCC.

I can find no evidence of user code that should be impacted by this. All uses of the GNU version of the attribute were in compiler test suites: https://sourcegraph.com/search?q=context:global+__attribute__%28%28carries_dependency%29%29+-file:.*test.*+-file:clang&patternType=standard&sm=1&groupBy=repo All uses of the C++ version of the attribute are also in compiler implementations or documentation: https://sourcegraph.com/search?q=context:global+%5B%5Bcarries_dependency%5D%5D+-file:.*test.*+-file:clang&patternType=standard&sm=1&groupBy=repo

Incidentally, this also helps people in WG21 build a case for deprecating and removing this attribute in a future revision of C++.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143670

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p1.cpp
  clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.depend/p2.cpp
  clang/test/CodeCompletion/attr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/Parser/cxx11-stmt-attributes.cpp
  clang/test/Parser/stmt-attributes.c
  clang/test/Preprocessor/has_attribute.cpp
  clang/test/SemaCXX/attr-cxx0x.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143670.496189.patch
Type: text/x-patch
Size: 26146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230209/4fcba95f/attachment-0001.bin>


More information about the cfe-commits mailing list