[LLDB] Remove uneeded CopyType from BlockPointerSyntheticFrontEnd

BlockPointerSyntheticFrontEnd does a CopyType which results in it copying the type
back into its own context. This will result in a call to ASTImporterDelegate::setOrigin
with &decl->getASTContext() == origin.ctx this can result in an infinite recursion
later on in ASTImporter since it will attempt to find the decl in its origin which will be itself.

Differential Revision: https://reviews.llvm.org/D96366

GitOrigin-RevId: 4f14c17df70916913d71914343dd4f6c709e218d
diff --git a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp b/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 35788a6..1c498a2 100644
--- a/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/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;
diff --git a/test/API/lang/c/blocks/TestBlocks.py b/test/API/lang/c/blocks/TestBlocks.py
index cd82d15..99ea22a 100644
--- a/test/API/lang/c/blocks/TestBlocks.py
+++ b/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()
diff --git a/test/API/lang/c/blocks/main.c b/test/API/lang/c/blocks/main.c
index 415e6c6..b1b215e 100644
--- a/test/API/lang/c/blocks/main.c
+++ b/test/API/lang/c/blocks/main.c
@@ -1,5 +1,17 @@
 #include <stdio.h>
 
+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;
 }