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