<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>checkPreCall wouldn't work for this, because there's no CallEvent for the entry point, because there's no call expression or argument values. It's definitely a flaw that we don't have a checkInitialConditons or something for this, though...we've needed it several times.</div><div><br></div><div>If you're interested, patches welcome. In theory it shouldn't be too difficult; the current equivalent is the hardcoded ExprEngine::getInitialState.</div><div><br></div><div>Jordan</div><div><br></div><br><div><div>On Dec 4, 2013, at 2:16 , Gabor Kozar <<a href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">


<title></title>

<div><div>Ah, that changes things. I just did some tests, and indeed, when there is just a class definition in a translation unit, the class' ctor is indeed treated as an entry point.<br></div>
<div> </div>
<div>Unfortunately, as far as I can tell, checkPreCall is NOT called on it - when it calls other functions, I get a checkPreCall for them, but not for the entry point itself.<br></div>
<div> </div>
<div>We're using Clang 3.3. Is this by design? Is there a way I can get notified of this?<br></div>
<div> </div>
<div>Thanks!<br></div>
<div> </div>
<div id="sig19426269"><div class="signature">-- <br></div>
<div class="signature">  Gábor 'ShdNx' Kozár<br></div>
<div class="signature">  <a href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a><br></div>
<div class="signature"> </div>
</div>
<div> </div>
<div> </div>
<div>On Mon, Dec 2, 2013, at 20:47, Jordan Rose wrote:<br></div>
<blockquote type="cite"><div>By default, the static analyzer treats all functions declared in the main<br></div>
<div>source file as possible entry points, then removes those that get called<br></div>
<div>from another function being analyzed. That should include constructors<br></div>
<div>and other member functions. There's a scan-build option (whose name<br></div>
<div>escapes me right now) to also analyze functions declared in header files,<br></div>
<div>and there's a secret (-cc1) option -analyze-function=NAME that only<br></div>
<div>analyzes decls with a matching name. (I'm not sure if that works for<br></div>
<div>constructors.)<br></div>
<div> </div>
<div>To Philip's point, being able to specify explicit entry points does seem<br></div>
<div>reasonable; a patch to specify this in scan-build and thread it through<br></div>
<div>to AnalysisConsumer would probably be accepted. Specifically, check out<br></div>
<div>getModeForDecl.<br></div>
<div> </div>
<div>Jordan<br></div>
<div> </div>
<div> </div>
<div>On Dec 2, 2013, at 8:31, Gabor Kozar <<a href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a>> wrote:<br></div>
<div> </div>
<blockquote><div>We have a Clang Static Analyzer plugin that exposes several custom checkers. Currently I'm working on a checker that aims to enforce the practice that it is the responsibility of the class ctors to initialize all member variables.<br></div>
<div> </div>
<div>Unfortunately, this requires the Static Analyzer to analyze the constructor, which does not happen without having the ctor called from a global function, which the SA treats as entry points.<br></div>
<div>This, however, leads to a problem: in production code, the definition of the class members and the user of the class are usually in different TUs, i.e. the SA won't be able to analyze the ctor call.<br></div>
<div> </div>
<div>Therefore, I'd like to make the SA treat constructors as entry points. More generally, how can I control which functions are analyzed (i.e. treated as entry points)? If this is not really something that can be done externally (i.e. outside Clang itself), where should I look inside the Clang source for this logic? (We can then create a patch, and ship a custom-patched version of Clang alongside with our checker library.)<br></div>
<div> </div>
<div>Thanks!<br></div>
<div> </div>
<div>-- <br></div>
<div>Gábor 'ShdNx' Kozár<br></div>
<div><a href="mailto:kozargabor@gmail.com">kozargabor@gmail.com</a><br></div>
<div> </div>
<div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br></div>
<div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></div>
</blockquote><div> </div>
</blockquote></div>

</blockquote></div><br></body></html>