<div dir="ltr">There's certainly something we do that can make clang header modules standalone - including the source inside the module. But I don't know the name of the flags to do that... </div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jan 26, 2021 at 1:14 PM Hartogs Siegfried via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;">
Hello everyone,
<div><br>
</div>
<div>We are working on a ClangTool that analyzes C/C++ projects on the clang AST level.</div>
<div>Our goal is to first store ASTs of the translation units on disk s.t. we later read and analyze them with our tool.</div>
<div>Using </div>
<div><font face="Calibri" size="2">clang++ file.cpp -emit-ast -o file.ast</font></div>
<div>we generate and store AST files.</div>
<div><br>
</div>
<div>However, when reading in .ast files with the tool we run into two problems:</div>
<div>- If you move source/header files the .ast was generated from to a different location, the tool complains that it can no longer find those. It seems that the source file location is hardcoded in absolute form inside the AST file, which is especially
bad if you want to build AST and use the tool on different machines. E.g.</div>
<div><font size="2"><span style="font-family:Calibri,Helvetica,sans-serif">fatal error: malformed or corrupted AST file: 'could not find file '/home/fba_code/source/lib/memdebug.h' referenced by AST file '/home/fba_code/source/lib/altsvc.ast''</span><br style="font-family:Calibri,Helvetica,sans-serif">
<span style="font-family:Calibri,Helvetica,sans-serif">1 error generated.</span></font></div>
<div><span style="font-family:Calibri,Helvetica,sans-serif;font-size:16px"><br>
</span></div>
<div>- mtime changed: analyzing some a.ast, whose source the tool is able to find, it prompts that a header b.h it depends on has been modified, and that we should rebuilt b.ast. E.g.</div>
<div><font size="2"><span style="font-family:Calibri,Helvetica,sans-serif">fatal error: file '/home/fba_code/source/lib/memdebug.h' has been modified since the AST file '/home/fba_code/source/lib/altsvc.ast' was built: mtime changed</span><br style="font-family:Calibri,Helvetica,sans-serif">
<span style="font-family:Calibri,Helvetica,sans-serif">note: please rebuild precompiled header '/home/fba_code/source/lib/altsvc.ast'</span><br style="font-family:Calibri,Helvetica,sans-serif">
<span style="font-family:Calibri,Helvetica,sans-serif">1 error generated.</span></font></div>
<div><br>
</div>
<div>Are there any flags we can use when doing -emit-ast s.t. the AST files no longer depend on the source files or are otherwise "relocatable"?</div>
<div><br>
</div>
<div>Best,</div>
<div>Siegfried</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>