From: Raphael Isemann Date: Wed, 21 Aug 2019 07:39:17 +0000 (+0000) Subject: [NFC] Mark CallTargetComparator() as const to fix libc++ warnings X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=304b258884c1aca2471546256d4e73f618f9a9b9;p=llvm [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, llvm::sampleprof::SampleRecord::CallTargetComparator, std::__1::allocator > >' 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, 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@369500 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ProfileData/SampleProf.h b/include/llvm/ProfileData/SampleProf.h index 609ba19f763..453e1a08bd0 100644 --- a/include/llvm/ProfileData/SampleProf.h +++ b/include/llvm/ProfileData/SampleProf.h @@ -146,7 +146,7 @@ class SampleRecord { public: using CallTarget = std::pair; struct CallTargetComparator { - bool operator() (const CallTarget &LHS, const CallTarget &RHS) { + bool operator()(const CallTarget &LHS, const CallTarget &RHS) const { if (LHS.second != RHS.second) return LHS.second > RHS.second;