[cfe-dev] Getting ASTContext within an AST Matcher

Manuel Klimek klimek at google.com
Tue Nov 27 00:34:49 PST 2012

On Mon, Nov 26, 2012 at 9:46 PM, Vane, Edwin <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 :)


> --
> Edwin Vane
>   Software Developer
>   Intel of Canada, Inc.
> _______________________________________________
> 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/20121127/d7ef3c89/attachment.html>

More information about the cfe-dev mailing list