Commit 4d67cae5 by Ian Lance Taylor

compiler: generalize cleanup of unresolved placeholder pointer types

    
    This change extends the work in https://golang.org/cl/51131 to include
    placeholder pointer types created for Go function types, which can
    also be left dangling/unresolved in some instances. This fixes an
    assert in Llvm_backend::materializeComposite.
    
    Test case can be found in https://golang.org/cl/191743.
    
    Updates golang/go#33020.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191744

From-SVN: r274935
parent 0e883151
c9ca1c6bf887c752cc75cf1ddaec8ddd1ec962d4 58c0fc64d91edc53ef9828b85cf3dc86aeb94e12
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -1138,6 +1138,7 @@ Type::get_backend_placeholder(Gogo* gogo) ...@@ -1138,6 +1138,7 @@ Type::get_backend_placeholder(Gogo* gogo)
// A Go function type is a pointer to a struct type. // A Go function type is a pointer to a struct type.
Location loc = this->function_type()->location(); Location loc = this->function_type()->location();
bt = gogo->backend()->placeholder_pointer_type("", loc, false); bt = gogo->backend()->placeholder_pointer_type("", loc, false);
Type::placeholder_pointers.push_back(this);
} }
break; break;
...@@ -1145,8 +1146,7 @@ Type::get_backend_placeholder(Gogo* gogo) ...@@ -1145,8 +1146,7 @@ Type::get_backend_placeholder(Gogo* gogo)
{ {
Location loc = Linemap::unknown_location(); Location loc = Linemap::unknown_location();
bt = gogo->backend()->placeholder_pointer_type("", loc, false); bt = gogo->backend()->placeholder_pointer_type("", loc, false);
Pointer_type* pt = this->convert<Pointer_type, TYPE_POINTER>(); Type::placeholder_pointers.push_back(this);
Type::placeholder_pointers.push_back(pt);
} }
break; break;
...@@ -5474,10 +5474,11 @@ Pointer_type::do_import(Import* imp) ...@@ -5474,10 +5474,11 @@ Pointer_type::do_import(Import* imp)
Type::Pointer_type_table Type::pointer_types; Type::Pointer_type_table Type::pointer_types;
// A list of placeholder pointer types. We keep this so we can ensure // A list of placeholder pointer types; items on this list will be either be
// they are finalized. // Pointer_type or Function_type. We keep this so we can ensure they are
// finalized.
std::vector<Pointer_type*> Type::placeholder_pointers; std::vector<Type*> Type::placeholder_pointers;
// Make a pointer type. // Make a pointer type.
...@@ -5513,11 +5514,11 @@ Type::finish_pointer_types(Gogo* gogo) ...@@ -5513,11 +5514,11 @@ Type::finish_pointer_types(Gogo* gogo)
// placeholder pointer types as we finalized existing ones. // placeholder pointer types as we finalized existing ones.
for (size_t i = 0; i < Type::placeholder_pointers.size(); i++) for (size_t i = 0; i < Type::placeholder_pointers.size(); i++)
{ {
Pointer_type* pt = Type::placeholder_pointers[i]; Type* typ = Type::placeholder_pointers[i];
Type_btypes::iterator tbti = Type::type_btypes.find(pt); Type_btypes::iterator tbti = Type::type_btypes.find(typ);
if (tbti != Type::type_btypes.end() && tbti->second.is_placeholder) if (tbti != Type::type_btypes.end() && tbti->second.is_placeholder)
{ {
pt->finish_backend(gogo, tbti->second.btype); typ->finish_backend(gogo, tbti->second.btype);
tbti->second.is_placeholder = false; tbti->second.is_placeholder = false;
} }
} }
......
...@@ -1409,7 +1409,7 @@ class Type ...@@ -1409,7 +1409,7 @@ class Type
static Pointer_type_table pointer_types; static Pointer_type_table pointer_types;
// List of placeholder pointer types. // List of placeholder pointer types.
static std::vector<Pointer_type*> placeholder_pointers; static std::vector<Type*> placeholder_pointers;
// The type classification. // The type classification.
Type_classification classification_; Type_classification classification_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment