Author: Raphael Isemann Date: 2019-11-08T12:03:28+01:00 New Revision: 79b3cce7f143ebcbc57a3c4599cbd7a1541a742b
URL: https://github.com/llvm/llvm-project/commit/79b3cce7f143ebcbc57a3c4599cbd7a1541a742b DIFF: https://github.com/llvm/llvm-project/commit/79b3cce7f143ebcbc57a3c4599cbd7a1541a742b.diff LOG: [lldb][NFC] Refactor some IsClangType checks in ClangASTContext Summary: All type in these functions need be valid and Clang types, so we might as well replace these checks with IsClangType. Also lets IsClangType explicitly check for validity instead of assuming that the TypeSystem is a nullptr. Subscribers: abidh, JDevlieghere, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70001 Added: Modified: lldb/source/Symbol/ClangASTContext.cpp lldb/source/Symbol/ClangUtil.cpp Removed: ################################################################################ diff --git a/lldb/source/Symbol/ClangASTContext.cpp b/lldb/source/Symbol/ClangASTContext.cpp index 61b08ab9f516..31b62ebb615e 100644 --- a/lldb/source/Symbol/ClangASTContext.cpp +++ b/lldb/source/Symbol/ClangASTContext.cpp @@ -3601,7 +3601,7 @@ bool ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type) { } bool ClangASTContext::IsObjCClassType(const CompilerType &type) { - if (type) { + if (ClangUtil::IsClangType(type)) { clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type)); const clang::ObjCObjectPointerType *obj_pointer_type = @@ -3886,7 +3886,7 @@ bool ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) { bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type, CompilerType *class_type_ptr) { - if (!type) + if (!ClangUtil::IsClangType(type)) return false; clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type)); diff --git a/lldb/source/Symbol/ClangUtil.cpp b/lldb/source/Symbol/ClangUtil.cpp index 86be895fadcb..71ff36a5ebab 100644 --- a/lldb/source/Symbol/ClangUtil.cpp +++ b/lldb/source/Symbol/ClangUtil.cpp @@ -15,6 +15,10 @@ using namespace clang; using namespace lldb_private; bool ClangUtil::IsClangType(const CompilerType &ct) { + // Invalid types are never Clang types. + if (!ct) + return false; + if (llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) == nullptr) return false; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits