@@ -1966,9 +1966,24 @@ void collect_type_info(const FunctionDecl* FD, QualType& QT,
19661966 PrintingPolicy Policy (C.getPrintingPolicy ());
19671967 Policy.SuppressElaboration = true ;
19681968 refType = kNotReference ;
1969- if (QT->isRecordType () && forArgument) {
1970- get_type_as_string (QT, type_name, C, Policy);
1971- return ;
1969+ if (QT->isRecordType ()) {
1970+ if (forArgument) {
1971+ get_type_as_string (QT, type_name, C, Policy);
1972+ return ;
1973+ }
1974+ if (auto * CXXRD = QT->getAsCXXRecordDecl ()) {
1975+ if (CXXRD->isLambda ()) {
1976+ std::string fn_name;
1977+ llvm::raw_string_ostream stream (fn_name);
1978+ Policy.FullyQualifiedName = true ;
1979+ Policy.SuppressUnwrittenScope = true ;
1980+ FD->getNameForDiagnostic (stream, Policy,
1981+ /* Qualified=*/ false );
1982+ type_name = " __internal_CppInterOp::function<decltype(" + fn_name +
1983+ " )>::result_type" ;
1984+ return ;
1985+ }
1986+ }
19721987 }
19731988 if (QT->isFunctionPointerType ()) {
19741989 std::string fp_typedef_name;
@@ -3223,6 +3238,17 @@ TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
32233238 llvm::cl::ParseCommandLineOptions (NumArgs + 1 , Args.get ());
32243239 }
32253240
3241+ I->declare (R"(
3242+ namespace __internal_CppInterOp {
3243+ template <typename Signature>
3244+ struct function;
3245+ template <typename Res, typename... ArgTypes>
3246+ struct function<Res(ArgTypes...)> {
3247+ typedef Res result_type;
3248+ };
3249+ } // namespace __internal_CppInterOp
3250+ )" );
3251+
32263252 sInterpreters ->emplace_back (I, /* Owned=*/ true );
32273253
32283254 return I;
0 commit comments