summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/CommentSema.cpp
diff options
context:
space:
mode:
authorDmitri Gribenko <gribozavr@gmail.com>2019-09-02 18:24:33 +0000
committerDmitri Gribenko <gribozavr@gmail.com>2019-09-02 18:24:33 +0000
commitd94b42f4228ee8647fa20111ffa996535ee5de67 (patch)
treea3cb3ec3a2877f8a0d4fb0d7c86e69ce604dca06 /clang/lib/AST/CommentSema.cpp
parenta95ec59fa5e297eedfd073a4722c8c5be86a3e5d (diff)
downloadbcm5719-llvm-d94b42f4228ee8647fa20111ffa996535ee5de67.tar.gz
bcm5719-llvm-d94b42f4228ee8647fa20111ffa996535ee5de67.zip
[Wdocumentation] fixes an assertion failure with typedefed function and block pointer
Summary: The assertion happens when compiling with -Wdocumentation with variable declaration to a typedefed function pointer. I not too familiar with the ObjC syntax but first two tests assert without this patch. Fixes https://bugs.llvm.org/show_bug.cgi?id=42844 Reviewers: gribozavr Reviewed By: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66706 llvm-svn: 370677
Diffstat (limited to 'clang/lib/AST/CommentSema.cpp')
-rw-r--r--clang/lib/AST/CommentSema.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 067b3ae4222..69d61dc5516 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -588,6 +588,8 @@ void Sema::checkReturnsCommand(const BlockCommandComment *Command) {
if (isObjCPropertyDecl())
return;
if (isFunctionDecl() || isFunctionOrBlockPointerVarLikeDecl()) {
+ assert(!ThisDeclInfo->ReturnType.isNull() &&
+ "should have a valid return type");
if (ThisDeclInfo->ReturnType->isVoidType()) {
unsigned DiagKind;
switch (ThisDeclInfo->CommentDecl->getKind()) {
@@ -873,6 +875,12 @@ bool Sema::isFunctionOrBlockPointerVarLikeDecl() {
// can be ignored.
if (QT->getAs<TypedefType>())
return false;
+ if (const auto *P = QT->getAs<PointerType>())
+ if (P->getPointeeType()->getAs<TypedefType>())
+ return false;
+ if (const auto *P = QT->getAs<BlockPointerType>())
+ if (P->getPointeeType()->getAs<TypedefType>())
+ return false;
return QT->isFunctionPointerType() || QT->isBlockPointerType();
}
OpenPOWER on IntegriCloud