@@ -365,6 +365,16 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
365
365
return result;
366
366
}
367
367
368
+ bool ClangASTImporter::CanImport (const Decl *d) {
369
+ if (!d)
370
+ return false ;
371
+ if (isa<TagDecl>(d))
372
+ return GetDeclOrigin (d).Valid ();
373
+ if (isa<ObjCInterfaceDecl>(d))
374
+ return GetDeclOrigin (d).Valid ();
375
+ return false ;
376
+ }
377
+
368
378
bool ClangASTImporter::CanImport (const CompilerType &type) {
369
379
if (!ClangUtil::IsClangType (type))
370
380
return false ;
@@ -374,24 +384,10 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
374
384
375
385
const clang::Type::TypeClass type_class = qual_type->getTypeClass ();
376
386
switch (type_class) {
377
- case clang::Type::Record: {
378
- const clang::CXXRecordDecl *cxx_record_decl =
379
- qual_type->getAsCXXRecordDecl ();
380
- if (cxx_record_decl) {
381
- if (GetDeclOrigin (cxx_record_decl).Valid ())
382
- return true ;
383
- }
384
- } break ;
385
-
386
- case clang::Type::Enum: {
387
- clang::EnumDecl *enum_decl =
388
- llvm::cast<clang::EnumType>(qual_type)->getDecl ();
389
- if (enum_decl) {
390
- if (GetDeclOrigin (enum_decl).Valid ())
391
- return true ;
392
- }
393
- } break ;
394
-
387
+ case clang::Type::Record:
388
+ return CanImport (qual_type->getAsRecordDecl ());
389
+ case clang::Type::Enum:
390
+ return CanImport (llvm::cast<clang::EnumType>(qual_type)->getDecl ());
395
391
case clang::Type::ObjCObject:
396
392
case clang::Type::ObjCInterface: {
397
393
const clang::ObjCObjectType *objc_class_type =
@@ -401,10 +397,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
401
397
objc_class_type->getInterface ();
402
398
// We currently can't complete objective C types through the newly added
403
399
// ASTContext because it only supports TagDecl objects right now...
404
- if (class_interface_decl) {
405
- if (GetDeclOrigin (class_interface_decl).Valid ())
406
- return true ;
407
- }
400
+ return CanImport (class_interface_decl);
408
401
}
409
402
} break ;
410
403
0 commit comments