================ @@ -24,6 +26,40 @@ using namespace clang::extractapi; using namespace llvm; +namespace { + +void findTypeLocForBlockDecl(const clang::TypeSourceInfo *TSInfo, + clang::FunctionTypeLoc &Block, + clang::FunctionProtoTypeLoc &BlockProto) { + if (!TSInfo) + return; + + clang::TypeLoc TL = TSInfo->getTypeLoc().getUnqualifiedLoc(); + while (true) { + // Look through qualified types + if (auto QualifiedTL = TL.getAs<clang::QualifiedTypeLoc>()) { + TL = QualifiedTL.getUnqualifiedLoc(); + continue; + } + + if (auto AttrTL = TL.getAs<clang::AttributedTypeLoc>()) { + TL = AttrTL.getModifiedLoc(); + continue; + } + + // Try to get the function prototype behind the block pointer type, + // then we're done. + if (auto BlockPtr = TL.getAs<clang::BlockPointerTypeLoc>()) { + TL = BlockPtr.getPointeeLoc().IgnoreParens(); + Block = TL.getAs<clang::FunctionTypeLoc>(); + BlockProto = TL.getAs<clang::FunctionProtoTypeLoc>(); + } + break; ---------------- evelez7 wrote:
Wouldn't this while just break on the first iteration? https://github.com/llvm/llvm-project/pull/73369 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits