llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Samira Bazuzi (bazuzi) <details> <summary>Changes</summary> Only return nullptr when we don't have an available QualType. --- Full diff: https://github.com/llvm/llvm-project/pull/102196.diff 1 Files Affected: - (modified) clang/lib/AST/DeclBase.cpp (+8-3) ``````````diff diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 98a7746b7d997..129a119267890 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -1161,15 +1161,20 @@ int64_t Decl::getID() const { const FunctionType *Decl::getFunctionType(bool BlocksToo) const { QualType Ty; - if (isa<BindingDecl>(this)) - return nullptr; - else if (const auto *D = dyn_cast<ValueDecl>(this)) + if (const auto *D = dyn_cast<ValueDecl>(this)) Ty = D->getType(); else if (const auto *D = dyn_cast<TypedefNameDecl>(this)) Ty = D->getUnderlyingType(); else return nullptr; + if (Ty.isNull()) { + // BindingDecls do not have types during parsing, so return nullptr. This is + // the only known case where `Ty` is null. + assert(isa<BindingDecl>(this)); + return nullptr; + } + if (Ty->isFunctionPointerType()) Ty = Ty->castAs<PointerType>()->getPointeeType(); else if (Ty->isFunctionReferenceType()) `````````` </details> https://github.com/llvm/llvm-project/pull/102196 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits