[clang] [libcxx] [Clang] Add __builtin_invoke and detect std::invoke as a builtin (PR #116709)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 18 15:19:06 PST 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 811186764d1add4d83972db3ad0d2e7c96bb15a7 b72d52b8cbadc460feb813d40433146c2dc9f780 --extensions ,h,cpp -- clang/test/CodeGenCXX/builtin-invoke.cpp clang/test/SemaCXX/builtin-invoke.cpp clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExprCXX.cpp libcxx/include/__algorithm/make_projected.h libcxx/include/__functional/bind.h libcxx/include/__functional/function.h libcxx/include/__functional/hash.h libcxx/include/__functional/mem_fn.h libcxx/include/__functional/reference_wrapper.h libcxx/include/__hash_table libcxx/include/__tree libcxx/include/__type_traits/invoke.h libcxx/include/__type_traits/is_core_convertible.h libcxx/include/__type_traits/result_of.h libcxx/include/future libcxx/include/unordered_map libcxx/include/unordered_set
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 4cf71004aa..9b5d21061c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5185,8 +5185,7 @@ ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) {
auto Loc = TheCall->getBeginLoc();
auto Args = MutableArrayRef(TheCall->getArgs(), TheCall->getNumArgs());
- assert(llvm::none_of(Args,
- [](Expr *Arg) { return Arg->isTypeDependent(); }));
+ assert(llvm::none_of(Args, [](Expr *Arg) { return Arg->isTypeDependent(); }));
if (Args.size() == 0) {
Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_few_args_at_least)
@@ -5199,7 +5198,7 @@ ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) {
if (auto *MPT = FuncT->getAs<MemberPointerType>()) {
if (Args.size() < 2) {
Diag(TheCall->getBeginLoc(),
- diag::err_typecheck_call_too_few_args_at_least)
+ diag::err_typecheck_call_too_few_args_at_least)
<< 0 << 2 << 1 << 0 << TheCall->getSourceRange();
return ExprError();
}
@@ -5207,7 +5206,6 @@ ExprResult Sema::BuiltinInvoke(CallExpr *TheCall) {
auto *MemPtrClass = MPT->getClass();
auto ObjectT = Args[1]->getType();
-
if (MPT->isMemberDataPointer() && Args.size() != 2) {
Diag(TheCall->getBeginLoc(), diag::err_typecheck_call_too_many_args)
<< 0 << 2 << Args.size() << 0 << TheCall->getSourceRange();
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index fe27073bdb..011b2e303a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -6106,18 +6106,20 @@ bool Sema::BuiltinIsBaseOf(SourceLocation RhsTLoc, QualType LhsT,
return false;
return cast<CXXRecordDecl>(rhsRecord->getDecl())
- ->isDerivedFrom(cast<CXXRecordDecl>(lhsRecord->getDecl()));
+ ->isDerivedFrom(cast<CXXRecordDecl>(lhsRecord->getDecl()));
}
-static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, const TypeSourceInfo *Lhs,
- const TypeSourceInfo *Rhs, SourceLocation KeyLoc) {
+static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT,
+ const TypeSourceInfo *Lhs,
+ const TypeSourceInfo *Rhs,
+ SourceLocation KeyLoc) {
QualType LhsT = Lhs->getType();
QualType RhsT = Rhs->getType();
assert(!LhsT->isDependentType() && !RhsT->isDependentType() &&
"Cannot evaluate traits of dependent types");
- switch(BTT) {
+ switch (BTT) {
case BTT_IsBaseOf:
return Self.BuiltinIsBaseOf(Rhs->getTypeLoc().getBeginLoc(), LhsT, RhsT);
diff --git a/libcxx/include/__functional/mem_fn.h b/libcxx/include/__functional/mem_fn.h
index 83390352ed..690393988c 100644
--- a/libcxx/include/__functional/mem_fn.h
+++ b/libcxx/include/__functional/mem_fn.h
@@ -43,7 +43,7 @@ public:
};
template <class _Rp, class _Tp>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::* __pm) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*> mem_fn(_Rp _Tp::*__pm) _NOEXCEPT {
return __mem_fn<_Rp _Tp::*>(__pm);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/116709
More information about the cfe-commits
mailing list