@@ -1942,9 +1942,24 @@ void collect_type_info(const FunctionDecl* FD, QualType& QT,
1942
1942
PrintingPolicy Policy (C.getPrintingPolicy ());
1943
1943
Policy.SuppressElaboration = true ;
1944
1944
refType = kNotReference ;
1945
- if (QT->isRecordType () && forArgument) {
1946
- get_type_as_string (QT, type_name, C, Policy);
1947
- return ;
1945
+ if (QT->isRecordType ()) {
1946
+ if (forArgument) {
1947
+ get_type_as_string (QT, type_name, C, Policy);
1948
+ return ;
1949
+ }
1950
+ if (auto * CXXRD = QT->getAsCXXRecordDecl ()) {
1951
+ if (CXXRD->isLambda ()) {
1952
+ std::string fn_name;
1953
+ llvm::raw_string_ostream stream (fn_name);
1954
+ Policy.FullyQualifiedName = true ;
1955
+ Policy.SuppressUnwrittenScope = true ;
1956
+ FD->getNameForDiagnostic (stream, Policy,
1957
+ /* Qualified=*/ false );
1958
+ type_name = " __internal_CppInterOp::function<decltype(" + fn_name +
1959
+ " )>::result_type" ;
1960
+ return ;
1961
+ }
1962
+ }
1948
1963
}
1949
1964
if (QT->isFunctionPointerType ()) {
1950
1965
std::string fp_typedef_name;
@@ -3199,6 +3214,17 @@ TInterp_t CreateInterpreter(const std::vector<const char*>& Args /*={}*/,
3199
3214
llvm::cl::ParseCommandLineOptions (NumArgs + 1 , Args.get ());
3200
3215
}
3201
3216
3217
+ I->declare (R"(
3218
+ namespace __internal_CppInterOp {
3219
+ template <typename Signature>
3220
+ struct function;
3221
+ template <typename Res, typename... ArgTypes>
3222
+ struct function<Res(ArgTypes...)> {
3223
+ typedef Res result_type;
3224
+ };
3225
+ } // namespace __internal_CppInterOp
3226
+ )" );
3227
+
3202
3228
sInterpreters ->emplace_back (I, /* Owned=*/ true );
3203
3229
3204
3230
return I;
0 commit comments