[cfe-dev] Help - Matchers for ObjC AST nodes?

Dean Sutherland dfsuther at yahoo-inc.com
Wed Nov 5 11:59:57 PST 2014


I'd already read the matcher guide, as well as reading through the suggested .h files.  Sadly, I completely missed seeing that the various .cc files that implement the matchers lacked imports of the *ObjC.h files from the AST.  Adding those imports has made my compilation errors evaporate. I'm back to making progress!
Dean 

     On Wednesday, November 5, 2014 12:26 AM, Gabor Kozar <kozargabor at gmail.com> wrote:
   

 Take a look at the AST matcher guide: http://clang.llvm.org/docs/LibASTMatchers.html
In the source tree, check out clang/include/clang/ASTMatchers/ASTMatchersMacros.h for the macros used for writing matchers, and clang/include/clang/ASTMatchers/ASTMatchers.h to look at how existing matchers are implemented.
 ---
Best regards,
 Gábor 'ShdNx' Kozár
http://gaborkozar.me
   On Wed, Nov 5, 2014, at 00:27, Dean Sutherland wrote:

I'd like to write a matcher that would find the following ObjectiveC
snippet:
 [self.externalWebView loadHTMLString:@"" baseURL:nil];
 (A dump of the AST for this code snippet is appended at the end of this
message.)
 If matchers for ObjC AST nodes existed, the matcher I want might look
something like this:
 objcMessageExpr(hasSelector("loadHTMLString:baseURL:"),
hasArgument(1, ignoringParenImpCasts(integerLiteral(equals(0)))));
 How do I go about writing the matchers I need, such as objcMessageExpr
and hasSelector?  I took a whack at the writing objcMessageExpr and
promptly got lost in failed template instantiation errors.
 Suggestions or guidance would be most welcome.
  Dean
dfsuther at yahoo-inc.com
 -----------------------
`-ExprWithCleanups 0x7fb8af3f4210 <line:927:13,col:72> 'void'
`-ObjCMessageExpr 0x7fb8af3f41c8 <col:13,col:72> 'void'
selector=loadHTMLString:baseURL:
|-PseudoObjectExpr 0x7fb8af3f4188 <col:14,col:34> 'UIWebView *'
| |-ObjCPropertyRefExpr 0x7fb8af3f4110 <col:14,col:34> '<pseudo-object
type>' lvalue objcproperty Kind=PropertyRef Property="webview"
Messaging=Getter
| | `-OpaqueValueExpr 0x7fb8af3f40f0 <col:14,col:19> 'HRBookendedWebView
*'
| |   `-PseudoObjectExpr 0x7fb8af3f17c8 <col:14,col:19>
'HRBookendedWebView *'
| |     |-ObjCPropertyRefExpr 0x7fb8af3f1750 <col:14,col:19>
'<pseudo-object type>' lvalue objcproperty Kind=PropertyRef
Property="articleWebView" Messaging=Getter
| |     | `-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
| |     |   `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
| |     |     `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
| |     |-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
| |     | `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
| |     |   `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
| |     `-ImplicitCastExpr 0x7fb8af3f17b0 <col:19> 'HRBookendedWebView *'
<ARCReclaimReturnedObject>
| |       `-ObjCMessageExpr 0x7fb8af3f1780 <col:19> 'HRBookendedWebView
*' selector=articleWebView
| |         `-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
| |           `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
| |             `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
| |-OpaqueValueExpr 0x7fb8af3f40f0 <col:14,col:19> 'HRBookendedWebView
*'
| | `-PseudoObjectExpr 0x7fb8af3f17c8 <col:14,col:19>
'HRBookendedWebView *'
| |   |-ObjCPropertyRefExpr 0x7fb8af3f1750 <col:14,col:19>
'<pseudo-object type>' lvalue objcproperty Kind=PropertyRef
Property="articleWebView" Messaging=Getter
| |   | `-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
| |   |   `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
| |   |     `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
| |   |-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
| |   | `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
| |   |   `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
| |   `-ImplicitCastExpr 0x7fb8af3f17b0 <col:19> 'HRBookendedWebView *'
<ARCReclaimReturnedObject>
| |     `-ObjCMessageExpr 0x7fb8af3f1780 <col:19> 'HRBookendedWebView *'
selector=articleWebView
| |       `-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
| |         `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
| |           `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
| `-ImplicitCastExpr 0x7fb8af3f4170 <col:34> 'UIWebView *'
<ARCReclaimReturnedObject>
|   `-ObjCMessageExpr 0x7fb8af3f4140 <col:34> 'UIWebView *'
selector=webview
|     `-OpaqueValueExpr 0x7fb8af3f40f0 <col:14,col:19>
'HRBookendedWebView *'
|       `-PseudoObjectExpr 0x7fb8af3f17c8 <col:14,col:19>
'HRBookendedWebView *'
|         |-ObjCPropertyRefExpr 0x7fb8af3f1750 <col:14,col:19>
'<pseudo-object type>' lvalue objcproperty Kind=PropertyRef
Property="articleWebView" Messaging=Getter
|         | `-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
|         |   `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
|         |     `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
|         |-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
|         | `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
|         |   `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
|         `-ImplicitCastExpr 0x7fb8af3f17b0 <col:19> 'HRBookendedWebView
*' <ARCReclaimReturnedObject>
|           `-ObjCMessageExpr 0x7fb8af3f1780 <col:19> 'HRBookendedWebView
*' selector=articleWebView
|             `-OpaqueValueExpr 0x7fb8af3f1730 <col:14>
'HRiPadArticleViewController *'
|               `-ImplicitCastExpr 0x7fb8af3f16e8 <col:14>
'HRiPadArticleViewController *' <LValueToRValue>
|                 `-DeclRefExpr 0x7fb8af3f16c0 <col:14>
'HRiPadArticleViewController *const __strong' lvalue ImplicitParam
0x7fb8af3f0dd0 'self' 'HRiPadArticleViewController *const __strong'
|-ObjCStringLiteral 0x7fb8af3f4058 <col:57,col:58> 'NSString *'
| `-StringLiteral 0x7fb8af3f4030 <col:58> 'char [1]' lvalue ""
`-ImplicitCastExpr 0x7fb8af3f41b0
</Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.1.sdk/usr/include/sys/_types.h:52:23,
col:33> 'NSURL *' <NullToPointer>
`-ParenExpr 0x7fb8af3f40d0 <col:23,col:33> 'void *'
`-CStyleCastExpr 0x7fb8af3f40a8 <col:24,col:32> 'void *' <NullToPointer>
`-IntegerLiteral 0x7fb8af3f4078 <col:32> 'int' 0
_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

 
_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141105/55814248/attachment.html>


More information about the cfe-dev mailing list