|
4 | 4 | #include "converter/converter.h" |
5 | 5 |
|
6 | 6 | #include <clang/AST/APValue.h> |
| 7 | +#include <clang/AST/IgnoreExpr.h> |
7 | 8 | #include <clang/AST/ParentMapContext.h> |
8 | 9 | #include <clang/Basic/LangOptions.h> |
9 | 10 | #include <clang/Basic/SourceManager.h> |
@@ -2004,6 +2005,16 @@ std::string Converter::GetFunctionRefName(const clang::FunctionDecl *fn_decl) { |
2004 | 2005 |
|
2005 | 2006 | void Converter::ConvertFunctionToFunctionPointer( |
2006 | 2007 | const clang::FunctionDecl *fn_decl) { |
| 2008 | + if (auto *method = clang::dyn_cast<clang::CXXMethodDecl>(fn_decl); |
| 2009 | + method && method->isLambdaStaticInvoker()) { |
| 2010 | + assert(!method->getParent()->isGenericLambda()); |
| 2011 | + StrCat("Some"); |
| 2012 | + PushParen paren(*this); |
| 2013 | + ConvertLambdaClosure(method->getParent(), |
| 2014 | + method->getParent()->getLambdaCallOperator()); |
| 2015 | + computed_expr_type_ = ComputedExprType::FreshPointer; |
| 2016 | + return; |
| 2017 | + } |
2007 | 2018 | StrCat(std::format("Some({})", GetFunctionRefName(fn_decl))); |
2008 | 2019 | computed_expr_type_ = ComputedExprType::FreshPointer; |
2009 | 2020 | } |
@@ -2055,7 +2066,11 @@ Converter::CallInfo Converter::CollectCallInfo(clang::CallExpr *expr) { |
2055 | 2066 | unsigned num_named_params = |
2056 | 2067 | function ? function->getNumParams() : proto->getNumParams(); |
2057 | 2068 | info.is_variadic = function ? function->isVariadic() : proto->isVariadic(); |
2058 | | - info.is_fn_ptr_call = !function || AsLambdaClass(callee->getType()); |
| 2069 | + info.is_fn_ptr_call = |
| 2070 | + !function || AsLambdaClass(callee->getType()) || |
| 2071 | + clang::isa<clang::SubstNonTypeTemplateParmExpr>( |
| 2072 | + clang::IgnoreExprNodes(callee, clang::IgnoreParensSingleStep, |
| 2073 | + clang::IgnoreImplicitCastsSingleStep)); |
2059 | 2074 | info.is_libc_passthrough = RuleRegistry::IsLibcPassthrough(ctx_, expr); |
2060 | 2075 |
|
2061 | 2076 | for (unsigned i = 0; i < num_named_params && i < num_args; ++i) { |
|
0 commit comments