【问题标题】:Getting information from ObjCPropertyRefExpr in Clang AST从 Clang AST 中的 ObjCPropertyRefExpr 获取信息
【发布时间】:2016-07-04 01:59:29
【问题描述】:
ObjCPropertyRefExpr 0x7fc2f9a80ac0 '<pseudo-object type>' lvalue objcproperty Kind=PropertyRef Property="text" Messaging=Getter
`-OpaqueValueExpr 0x7fc2f9a80aa0 'UITextField *'
  `-PseudoObjectExpr 0x7fc2f9a61d30 'UITextField *'
    |-ObjCPropertyRefExpr 0x7fc2f9a61cb8 '<pseudo-object type>' lvalue objcproperty Kind=PropertyRef Property="txtFirstname" Messaging=Getter
    | `-OpaqueValueExpr 0x7fc2f9a61c98 'EditInfoViewController *'
    |   `-ImplicitCastExpr 0x7fc2f9a61c50 'EditInfoViewController *' <LValueToRValue>
    |     `-DeclRefExpr 0x7fc2f9a61c28 'EditInfoViewController *const __strong' lvalue ImplicitParam 0x7fc2f9a61828 'self' 'EditInfoViewController *const __strong'
    |-OpaqueValueExpr 0x7fc2f9a61c98 'EditInfoViewController *'
    | `-ImplicitCastExpr 0x7fc2f9a61c50 'EditInfoViewController *' <LValueToRValue>
    |   `-DeclRefExpr 0x7fc2f9a61c28 'EditInfoViewController *const __strong' lvalue ImplicitParam 0x7fc2f9a61828 'self' 'EditInfoViewController *const __strong'
    `-ImplicitCastExpr 0x7fc2f9a61d18 'UITextField *' <ARCReclaimReturnedObject>
      `-ObjCMessageExpr 0x7fc2f9a61ce8 'UITextField *' selector=txtFirstname
        `-OpaqueValueExpr 0x7fc2f9a61c98 'EditInfoViewController *'
          `-ImplicitCastExpr 0x7fc2f9a61c50 'EditInfoViewController *' <LValueToRValue>
            `-DeclRefExpr 0x7fc2f9a61c28 'EditInfoViewController *const __strong' lvalue ImplicitParam 0x7fc2f9a61828 'self' 'EditInfoViewController *const __strong'

鉴于上面的 AST,是否可以从 ObjCPropertyRefExpr 中获取元素“UITextField”?

现在我正在疯狂地尝试所有的 getter 方法,但到目前为止还没有运气好......任何建议都将不胜感激

【问题讨论】:

    标签: ios objective-c clang abstract-syntax-tree llvm-clang


    【解决方案1】:

    ObjectiveCPropertyRefExpr-&gt;getReceiverType(*ASTContext).getAsString() 可以很好地解决这个问题

    虽然这将返回'UITextField *',但需要简单的定界/substr 来检索'UITextField'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-21
      • 1970-01-01
      • 1970-01-01
      • 2019-11-15
      • 2013-03-06
      • 1970-01-01
      • 2021-01-06
      相关资源
      最近更新 更多