https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/203672
We unfortunately have to check this for every function call, so don't consult the decl every time here. >From e2d715ec9a2987fb267736b64e4d2ca90595ab73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]> Date: Fri, 12 Jun 2026 15:31:19 +0200 Subject: [PATCH] func explicit flag --- clang/lib/AST/ByteCode/Function.cpp | 5 +++++ clang/lib/AST/ByteCode/Function.h | 19 ++++++++----------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clang/lib/AST/ByteCode/Function.cpp b/clang/lib/AST/ByteCode/Function.cpp index e08e2790dbd4f..cd0f7eb125230 100644 --- a/clang/lib/AST/ByteCode/Function.cpp +++ b/clang/lib/AST/ByteCode/Function.cpp @@ -29,12 +29,15 @@ Function::Function(Program &P, FunctionDeclTy Source, unsigned ArgSize, Constexpr = F->isConstexpr(); if (const auto *CD = dyn_cast<CXXConstructorDecl>(F)) { Virtual = CD->isVirtual(); + ExplicitThisPointer = CD->isExplicitObjectMemberFunction(); Kind = CD->isCopyOrMoveConstructor() ? FunctionKind::CopyOrMoveCtor : FunctionKind::Ctor; } else if (const auto *CD = dyn_cast<CXXDestructorDecl>(F)) { + ExplicitThisPointer = CD->isExplicitObjectMemberFunction(); Virtual = CD->isVirtual(); Kind = FunctionKind::Dtor; } else if (const auto *MD = dyn_cast<CXXMethodDecl>(F)) { + ExplicitThisPointer = MD->isExplicitObjectMemberFunction(); Virtual = MD->isVirtual(); if (IsLambdaStaticInvoker) Kind = FunctionKind::LambdaStaticInvoker; @@ -43,9 +46,11 @@ Function::Function(Program &P, FunctionDeclTy Source, unsigned ArgSize, else if (MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) Kind = FunctionKind::CopyOrMoveOperator; } else { + ExplicitThisPointer = false; Virtual = false; } } else { + ExplicitThisPointer = false; Variadic = false; Virtual = false; Immediate = false; diff --git a/clang/lib/AST/ByteCode/Function.h b/clang/lib/AST/ByteCode/Function.h index d9a286937cadd..2ef529b6d586b 100644 --- a/clang/lib/AST/ByteCode/Function.h +++ b/clang/lib/AST/ByteCode/Function.h @@ -233,6 +233,12 @@ class Function final { bool isVariadic() const { return Variadic; } + bool isThisPointerExplicit() const { return ExplicitThisPointer; } + + bool hasImplicitThisParam() const { + return hasThisPointer() && !ExplicitThisPointer; + } + unsigned getNumParams() const { return ParamDescriptors.size() + hasThisPointer() + hasRVO(); } @@ -247,17 +253,6 @@ class Function final { return ArgSize - (align(primSize(PT_Ptr)) * (hasThisPointer() + hasRVO())); } - bool isThisPointerExplicit() const { - if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>( - dyn_cast<const FunctionDecl *>(Source))) - return MD->isExplicitObjectMemberFunction(); - return false; - } - - bool hasImplicitThisParam() const { - return hasThisPointer() && !isThisPointerExplicit(); - } - private: /// Construct a function representing an actual function. Function(Program &P, FunctionDeclTy Source, unsigned ArgSize, @@ -315,6 +310,8 @@ class Function final { /// as the first implicit argument LLVM_PREFERRED_TYPE(bool) unsigned HasThisPointer : 1; + LLVM_PREFERRED_TYPE(bool) + unsigned ExplicitThisPointer : 1; /// Whether this function has Return Value Optimization, i.e. /// the return value is constructed in the caller's stack frame. /// This is done for functions that return non-primive values. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
