[clang] Return available function types for BindingDecls. (PR #102196)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 6 11:39:44 PDT 2024
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
More information about the cfe-commits
mailing list