[lldb][ClangASTImporter][NFC] Create helper for CanImport
Upstreams a `CanImport` helper for `clang::Decl`s.
This commit is contained in:
parent
89681839e3
commit
c68b4d64dd
@ -371,6 +371,16 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
|
||||
return result;
|
||||
}
|
||||
|
||||
bool ClangASTImporter::CanImport(const Decl *d) {
|
||||
if (!d)
|
||||
return false;
|
||||
if (isa<TagDecl>(d))
|
||||
return GetDeclOrigin(d).Valid();
|
||||
if (isa<ObjCInterfaceDecl>(d))
|
||||
return GetDeclOrigin(d).Valid();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ClangASTImporter::CanImport(const CompilerType &type) {
|
||||
if (!ClangUtil::IsClangType(type))
|
||||
return false;
|
||||
@ -380,23 +390,10 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
|
||||
|
||||
const clang::Type::TypeClass type_class = qual_type->getTypeClass();
|
||||
switch (type_class) {
|
||||
case clang::Type::Record: {
|
||||
const clang::CXXRecordDecl *cxx_record_decl =
|
||||
qual_type->getAsCXXRecordDecl();
|
||||
if (cxx_record_decl) {
|
||||
if (GetDeclOrigin(cxx_record_decl).Valid())
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
|
||||
case clang::Type::Enum: {
|
||||
auto *enum_decl = llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl();
|
||||
if (enum_decl) {
|
||||
if (GetDeclOrigin(enum_decl).Valid())
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
|
||||
case clang::Type::Record:
|
||||
return CanImport(qual_type->getAsCXXRecordDecl());
|
||||
case clang::Type::Enum:
|
||||
return CanImport(llvm::cast<clang::EnumType>(qual_type)->getOriginalDecl());
|
||||
case clang::Type::ObjCObject:
|
||||
case clang::Type::ObjCInterface: {
|
||||
const clang::ObjCObjectType *objc_class_type =
|
||||
@ -406,10 +403,7 @@ bool ClangASTImporter::CanImport(const CompilerType &type) {
|
||||
objc_class_type->getInterface();
|
||||
// We currently can't complete objective C types through the newly added
|
||||
// ASTContext because it only supports TagDecl objects right now...
|
||||
if (class_interface_decl) {
|
||||
if (GetDeclOrigin(class_interface_decl).Valid())
|
||||
return true;
|
||||
}
|
||||
return CanImport(class_interface_decl);
|
||||
}
|
||||
} break;
|
||||
|
||||
|
@ -157,6 +157,8 @@ public:
|
||||
/// \see ClangASTImporter::Import
|
||||
bool CanImport(const CompilerType &type);
|
||||
|
||||
bool CanImport(const clang::Decl *d);
|
||||
|
||||
/// If the given type was copied from another TypeSystemClang then copy over
|
||||
/// all missing information (e.g., the definition of a 'class' type).
|
||||
///
|
||||
|
Loading…
x
Reference in New Issue
Block a user