Index: lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp =================================================================== --- lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp +++ lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp @@ -74,14 +74,12 @@ const CompilerType reserved_type = clang_ast_context->GetBasicType(lldb::eBasicTypeInt); const char *const FuncPtr_name("__FuncPtr"); - const CompilerType FuncPtr_type = - clang_ast_importer->CopyType(*clang_ast_context, function_pointer_type); m_block_struct_type = clang_ast_context->CreateStructForIdentifier( ConstString(), {{isa_name, isa_type}, {flags_name, flags_type}, {reserved_name, reserved_type}, - {FuncPtr_name, FuncPtr_type}}); + {FuncPtr_name, function_pointer_type}}); } ~BlockPointerSyntheticFrontEnd() override = default; Index: lldb/test/API/lang/c/blocks/TestBlocks.py =================================================================== --- lldb/test/API/lang/c/blocks/TestBlocks.py +++ lldb/test/API/lang/c/blocks/TestBlocks.py @@ -20,6 +20,7 @@ # Find the line numbers to break at. self.lines.append(line_number('main.c', '// Set breakpoint 0 here.')) self.lines.append(line_number('main.c', '// Set breakpoint 1 here.')) + self.lines.append(line_number('main.c', '// Set breakpoint 2 here.')) def launch_common(self): self.build() @@ -51,6 +52,10 @@ self.expect("expression (int)neg (-12)", VARIABLES_DISPLAYED_CORRECTLY, substrs=["= 12"]) + self.wait_for_breakpoint() + + self.expect_expr("h(cg)", result_type="int", result_value="42") + @skipUnlessDarwin def test_define(self): self.launch_common() Index: lldb/test/API/lang/c/blocks/main.c =================================================================== --- lldb/test/API/lang/c/blocks/main.c +++ lldb/test/API/lang/c/blocks/main.c @@ -1,5 +1,17 @@ #include +struct CG {int x; int y;}; + +int g(int (^callback)(struct CG)) { + struct CG cg = {.x=1,.y=2}; + + int z = callback(cg); // Set breakpoint 2 here. + + return z; +} + +int h(struct CG cg){return 42;} + int main() { int c = 1; @@ -17,5 +29,12 @@ printf("%d\n", add(3, 4)); printf("%d\n", neg(-5)); // Set breakpoint 1 here. + int (^add_struct)(struct CG) = ^int(struct CG cg) + { + return cg.x + cg.y; + }; + + g(add_struct); + return 0; }