From b7854baa232c47ae81470471e96d63fff09706e5 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 23 Dec 2015 00:22:57 -0800 Subject: [PATCH] Use CXCursor_AsmLabelAttr to fix $INODE64 on stat. --- Analyze.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Analyze.cpp b/Analyze.cpp index 791d8f4..c6e5777 100644 --- a/Analyze.cpp +++ b/Analyze.cpp @@ -40,6 +40,19 @@ static CXChildVisitResult CYFieldVisit(CXCursor cursor, CXCursor parent, CXClien return CXChildVisit_Continue; } +struct CYAttributeBaton { + std::string label; +}; + +static CXChildVisitResult CYAttributeVisit(CXCursor cursor, CXCursor parent, CXClientData arg) { + CYAttributeBaton &baton(*static_cast(arg)); + + if (clang_getCursorKind(cursor) == CXCursor_AsmLabelAttr) + baton.label = CYCXString(clang_getCursorSpelling(cursor)); + + return CXChildVisit_Continue; +} + typedef std::map CYKeyMap; struct CYChildBaton { @@ -143,8 +156,17 @@ static CXChildVisitResult CYChildVisit(CXCursor cursor, CXCursor parent, CXClien case CXCursor_FunctionDecl: case CXCursor_VarDecl: { + CYAttributeBaton baton; + clang_visitChildren(cursor, &CYAttributeVisit, &baton); + + if (baton.label.empty()) { + baton.label = spelling; + baton.label = '_' + baton.label; + } else if (baton.label[0] != '_') + goto skip; + CXType type(clang_getCursorType(cursor)); - value << "*(typedef " << CYCXString(clang_getTypeSpelling(type)) << ").pointerTo()(dlsym(RTLD_DEFAULT,'" << spelling << "'))"; + value << "*(typedef " << CYCXString(clang_getTypeSpelling(type)) << ").pointerTo()(dlsym(RTLD_DEFAULT,'" << baton.label.substr(1) << "'))"; } break; default: { -- 2.45.2