aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorSamira Bazuzi <bazuzi@google.com>2024-08-09 15:09:55 -0400
committerGitHub <noreply@github.com>2024-08-09 21:09:55 +0200
commite5697d7f99b441064a4e4c3c27c2fc8e5d2784c0 (patch)
treef969f14e73b34e6e37831b5bd90790c70874764e /clang/lib/AST/DeclBase.cpp
parent2eb6e30fe83ccce3cf01e596e73fa6385facd44b (diff)
downloadllvm-e5697d7f99b441064a4e4c3c27c2fc8e5d2784c0.zip
llvm-e5697d7f99b441064a4e4c3c27c2fc8e5d2784c0.tar.gz
llvm-e5697d7f99b441064a4e4c3c27c2fc8e5d2784c0.tar.bz2
Return available function types for BindingDecls. (#102196)
Only return nullptr when we don't have an available QualType.
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r--clang/lib/AST/DeclBase.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 55dbc37..f42857f 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1177,15 +1177,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())