[cfe-dev] Getting ASTContext within an AST Matcher

Vane, Edwin edwin.vane at intel.com
Tue Nov 27 07:48:50 PST 2012


But MatchFinder is only available to a Callback that's called as the result of a match. I'm writing a custom matcher and all I have access to is an ASTMatchFinder, the AST Node being considered at the time and the BoundNodesTreeBuilder.

From: Manuel Klimek [mailto:klimek at google.com]
Sent: Tuesday, November 27, 2012 3:35 AM
To: Vane, Edwin
Cc: cfe-dev at cs.uiuc.edu
Subject: Re: [cfe-dev] Getting ASTContext within an AST Matcher

On Mon, Nov 26, 2012 at 9:46 PM, Vane, Edwin <edwin.vane at intel.com<mailto:edwin.vane at intel.com>> wrote:
Hi all,

I'm writing an AST Matcher that operates on Expr. I'd like to use isNullPointerConstant() but it requires an ASTContext. In the past I've been able to get an ASTContext from a Decl subclassed object using Decl::getASTContext() but that clearly won't work with Expr. So how does one get access to the ASTContext in my situation? Must the matcher mechanism be modified to provide the ASTContext to matchers?

The MatchFinder::MatchResult has a field Context.

How global is an ASTContext? Given the name it seems to imply there's one context for one particular AST the matchers are being run on. If so it should be pretty easy to modify the matcher mechanism to provide this info, perhaps through MatchFinder.

Assessment correct :)

Cheers,
/Manuel


--
Edwin Vane
  Software Developer
  Intel of Canada, Inc.


_______________________________________________
cfe-dev mailing list
cfe-dev at cs.uiuc.edu<mailto: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/20121127/49569a81/attachment.html>


More information about the cfe-dev mailing list