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