[PATCH] D129951: [clang] teaches Clang the special ADL rules for functions in std::ranges

Christopher Di Bella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 16 20:23:05 PDT 2022


cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a project: All.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Per per [range.iter.ops]/2 and [algorithms.requirements]/2, functions
declared in the namespace 'std::ranges' aren't found by ADL, and
suppress ADL when they're called in an unqualified context (e.g. a
using-directive).

Libraries have been implementing these functions as function objects
with varying rules (e.g. libc++ and Microsoft/STL both try their best to
make the function objects appear as standard library function templates,
while libstdc++ makes them plain function objects).

Having a large number of types typically has a negative impact on both
compile-times and progam size, and there are approximately 130 of these
at present. Furthermore, the diagnostics can be marginally improved by
switching to proper functions, which will make it clearer that the
problem is at the user level, rather than the implementation level (see
https://godbolt.org/z/1sYMsxdfM for an example).

By making it possible to implement ranges functions as functions, it's
hoped that the library will be incentivised to migrate over.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129951

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Sema/disable-adl.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129951.445284.patch
Type: text/x-patch
Size: 5774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220717/a3882810/attachment.bin>


More information about the cfe-commits mailing list