[clang] [clang][ExtractAPI] Add support for blocks in declaration fragments (PR #73369)
Erick Velez via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 27 10:25:48 PST 2023
================
@@ -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
More information about the cfe-commits
mailing list