Clang requires them to have complete types, but
we were previously only completing them if they
were of tag or Objective-C object types.
I have implemented a method on the ASTImporter
whose job is to complete a type. It handles not
only the cases mentioned above, but also array
and atomic types.
<rdar://problem/
13446777>
llvm-svn: 177672
CompleteObjCInterfaceDecl (clang::ObjCInterfaceDecl *interface_decl);
bool
+ RequireCompleteType (clang::QualType type);
+
+ bool
ResolveDeclOrigin (const clang::Decl *decl, clang::Decl **original_decl, clang::ASTContext **original_ctx)
{
DeclOrigin origin = GetDeclOrigin(decl);
{
QualType copied_field_type = copied_field->getType();
- if (const TagType *copied_field_tag_type = copied_field_type->getAs<TagType>())
- m_ast_importer->CompleteTagDecl(copied_field_tag_type->getDecl());
- if (const ObjCObjectType *copied_field_object_type = copied_field_type->getAs<ObjCObjectType>())
- if (ObjCInterfaceDecl *copied_field_objc_interface_decl = copied_field_object_type->getInterface())
- m_ast_importer->CompleteObjCInterfaceDecl(copied_field_objc_interface_decl);
+ m_ast_importer->RequireCompleteType(copied_field_type);
}
decls.push_back(copied_decl);
return true;
}
+bool
+ClangASTImporter::RequireCompleteType (clang::QualType type)
+{
+ if (type.isNull())
+ return false;
+
+ if (const TagType *tag_type = type->getAs<TagType>())
+ {
+ return CompleteTagDecl(tag_type->getDecl());
+ }
+ if (const ObjCObjectType *objc_object_type = type->getAs<ObjCObjectType>())
+ {
+ if (ObjCInterfaceDecl *objc_interface_decl = objc_object_type->getInterface())
+ return CompleteObjCInterfaceDecl(objc_interface_decl);
+ else
+ return false;
+ }
+ if (const ArrayType *array_type = type->getAsArrayTypeUnsafe())
+ {
+ return RequireCompleteType(array_type->getElementType());
+ }
+ if (const AtomicType *atomic_type = type->getAs<AtomicType>())
+ {
+ return RequireCompleteType(atomic_type->getPointeeType());
+ }
+
+ return true;
+}
+
ClangASTMetadata *
ClangASTImporter::GetDeclMetadata (const clang::Decl *decl)
{