<div dir="ltr">Hi, I am traversing the AST for an obj-c file using a clang plugin. I have a code snippet like the following:<div><br></div><div><div>#define JK_ATTRIBUTES(attr, ...)        __attribute__((attr, ##__VA_ARGS__))</div>
<div>#define JK_STATIC_INLINE static __inline__ JK_ATTRIBUTES(always_inline)</div><div><br></div><div>JK_STATIC_INLINE int jk_parse_skip_newline();</div><div><br></div><div>@implementation Hello</div><div>- (void)say:(int)i {</div>
<div>  if (i > 0) {</div><div>    NSLog(@"Hello, world! (%d)", i);</div><div>  }</div><div><br></div><div>  // Example of selector with unknown method declaration.</div><div>  [(id)@"Anything" length];</div>
<div>}</div><div>@end</div><div><br></div><div>JK_STATIC_INLINE int jk_parse_skip_newline() {</div><div>  return 0;</div><div>}</div></div><div><br></div><div>so while traversing the AST, I am trying to find the SourceRange of the jk_parse_skip_newline() definition at the bottom of the file. For non-macro expanded functions, this is very straightforward. But due to the macro expansion, I get a SourceRange that spans from the start of the macro to the end of my code snippet. That means that it also includes the Hello class, which has nothing to do with jk_parse_skip_newline(). This is a problem because I am trying to use the AST to determine where jk_parse_skip_newline is defined so I can comment it out of the source file.</div>
<div><br></div><div>Is it possible for me to get the necessary SourceRange from the clang API? Ideally, I would get a SourceRange that identifies only the last three lines of my code sample.</div><div><br></div><div>Thank you,</div>
<div>Michael</div></div>