<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<br>
<div class="moz-cite-prefix">On 03/15/16 01:10 PM, David Come via
cfe-dev wrote:<br>
</div>
<blockquote cite="mid:56E7DF8F.7090705@onera.fr" type="cite">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
Hello,<br>
<br>
I'm writing a some tool for doing static analysis on C++ code.<br>
<br>
My tool has obviously two inputs: the file(s) to check (let's say
<i>f.cpp</i>) and the property to check .<br>
<br>
Currently (I'm in a early stage of development), I want to
describe the property directly in C++ (let's say <i>prop.cpp</i>).<br>
and use clang/libtooling to read it .The thing is that the
property will use symbols that are defined in the code to analyze.<br>
<br>
Thus, I wish to parse <i>prop.cpp </i>knowing <i>f.cpp</i>'s
AST so I don't run into unknown symbols. But I haven't been
successful so far.<br>
<br>
i could cheat and merge the two files in a temporary file but I
don't like that idea.<br>
I could also require <i>prop.cpp </i>to be self contained (with
all the headers needed) but that would hinder the tool's usability
(headers to include, need to provide to clang all the compilation
options...). <br>
</blockquote>
You can try the trick with one pass: when prepare cmd line options
for parsing the second TU pass "-inlclude first_file.cpp" and add
cmd line options of first_file.cpp as well.<br>
it will invisibly add <br>
#include "first_file.cpp"<br>
as the first line text in your <br>
prop.cpp<br>
<br>
Note that you should add cmd line options of first_file.cpp as well,
because you want this phantom #include to be correctly handled.<br>
<br>
Hope it helps,<br>
Vladimir.<br>
<br>
<blockquote cite="mid:56E7DF8F.7090705@onera.fr" type="cite"> <br>
If you have any lead,<br>
<br>
Thanks,<br>
David.<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
</body>
</html>