Skip to content

Commit 79b3cce

Browse files
committed
[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
1 parent 0a8bd77 commit 79b3cce

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lldb/source/Symbol/ClangASTContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3601,7 +3601,7 @@ bool ClangASTContext::IsDefined(lldb::opaque_compiler_type_t type) {
36013601
}
36023602

36033603
bool ClangASTContext::IsObjCClassType(const CompilerType &type) {
3604-
if (type) {
3604+
if (ClangUtil::IsClangType(type)) {
36053605
clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));
36063606

36073607
const clang::ObjCObjectPointerType *obj_pointer_type =
@@ -3886,7 +3886,7 @@ bool ClangASTContext::IsBeingDefined(lldb::opaque_compiler_type_t type) {
38863886

38873887
bool ClangASTContext::IsObjCObjectPointerType(const CompilerType &type,
38883888
CompilerType *class_type_ptr) {
3889-
if (!type)
3889+
if (!ClangUtil::IsClangType(type))
38903890
return false;
38913891

38923892
clang::QualType qual_type(ClangUtil::GetCanonicalQualType(type));

lldb/source/Symbol/ClangUtil.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ using namespace clang;
1515
using namespace lldb_private;
1616

1717
bool ClangUtil::IsClangType(const CompilerType &ct) {
18+
// Invalid types are never Clang types.
19+
if (!ct)
20+
return false;
21+
1822
if (llvm::dyn_cast_or_null<ClangASTContext>(ct.GetTypeSystem()) == nullptr)
1923
return false;
2024

0 commit comments

Comments
 (0)