<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Hm, no, you're right there—"code body" refers to a function or method body. checkASTDecl would do every declaration, but you still can't get an AnalysisDeclContext for globals.</div><div><br></div><div>I guess when all else fails you just go for the "minimal" form of a PathDiagnosticLocation: the constructor that takes a SourceLocation and a SourceManager.</div><div><br></div><div>Jordan</div><div><br></div><br><div><div>On May 8, 2013, at 1:24 , Gábor Kozár <<a href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div>Hi Jordan,<br></div><div><br></div><div>Okay, so that Decl I need to specify is the parent for the Stmt I want to report? That makes sense.</div><div>The reason I'm running my matchers in checkEndOfTranslationUnit, is because a lot of matches are not actually inside function bodies, but are for example data members of classes. I was under the impression that checkASTCodeBody would only be called for functions (although I can't quite remember why). Is that not the case?</div>

<div><br></div><div>Thanks!</div><div><br></div><div>Gabor</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/5/8 Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, Gábor. The LocationContext/AnalysisDeclContext is used to find an appropriate location for the statement, which may be in an enclosing expression. You need a Decl for this because we don't want to build a parent map for the entire ASTContext.<br>


<br>
May I suggest running your matcher in checkASTCodeBody instead of checkEndOfTranslationUnit?<br>
<br>
Jordan<br>
<div><div class="h5"><br>
<br>
On May 7, 2013, at 9:32 , Gábor Kozár <<a href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a>> wrote:<br>
<br>
> Hi,<br>
><br>
> In a Static Analyzer checker, using AST matchers, I located an IntegerLiteral that I want to report. I'm trying to do this with BugReporter::EmitBasicReport, which requires a PathDiagnosticLocation.<br>
><br>
> There is PathDiagnosticLocation::createBegin that I've used before with previous checkers - unfortunately, the overload that accepts an Stmt* (as an IntegerLiteral is not a Decl, but it is an Stmt) also requires a mysterious third parameter, a LocationOrAnalysisDeclContext. I tried looking through the documentation, but apparently anything that returns a LocationDeclContext or AnalysisDeclContext either require a CheckerContext (which I don't have, because I'm in checkEndOfTranslationUnit: all I have is the TranslationUnitDecl, the AnalysisManager and the BugReporter), or a Decl*.<br>


><br>
> Any clues on how could I do this? I'm using Clang 3.2.<br>
><br>
> Note: I'm aware that the Clang Static Analyzer by default is not linked to libASTMatchers, but I solved that, that is NOT the issue here.<br>
><br>
> Thanks!<br>
><br>
> Gabor<br>
</div></div>> _______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br>
</blockquote></div><br></div>
</blockquote></div><br></body></html>