HomePhabricator

[NFC] Mark CallTargetComparator() as const to fix libc++ warnings

Description

[NFC] Mark CallTargetComparator() as const to fix libc++ warnings

We currently get this warning when compiling with libc++:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/set:454:26: warning: the specified comparator type does not provide a const call operator [-Wuser-defined-warnings]

static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
                     ^

llvm-project/llvm/include/llvm/ProfileData/SampleProf.h:193:29: note: in instantiation of template class 'std::1::set<std::1::pair<llvm::StringRef, unsigned long long>, llvm::sampleprof::SampleRecord::CallTargetComparator, std::1::allocator<std::1::pair<llvm::StringRef, unsigned long long> > >' requested here

const SortedCallTargetSet getSortedCallTargets() const {
                          ^

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__tree:967:5: note: from 'diagnose_if' attribute on 'diagnose_non_const_comparator<std::1::pair<llvm::StringRef, unsigned long long>, llvm::sampleprof::SampleRecord::CallTargetComparator>':

_LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
^                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__config:1320:21: note: expanded from macro '_LIBCPP_DIAGNOSE_WARNING'

__attribute__((diagnose_if(__VA_ARGS__, "warning")))
               ^           ~~~~~~~~~~~

1 warning generated.

Details

Committed
teemperorWed, Aug 21, 12:39 AM
Parents
rL369499: Merging r369251:
Branches
Unknown
Tags
Unknown