<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hello everyone, 
<div class=""><br class="">
</div>
<div class="">We are working on a ClangTool that analyzes C/C++ projects on the clang AST level.</div>
<div class="">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 class="">Using </div>
<div class=""><font face="Calibri" size="2" class="">clang++ file.cpp -emit-ast -o file.ast</font></div>
<div class="">we generate and store AST files.</div>
<div class=""><br class="">
</div>
<div class="">However, when reading in .ast files with the tool we run into two problems:</div>
<div class="">- 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 class=""><font size="2" class=""><span style="font-family: Calibri, Helvetica, sans-serif;" class="">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;" class="">
<span style="font-family: Calibri, Helvetica, sans-serif;" class="">1 error generated.</span></font></div>
<div class=""><span style="font-family: Calibri, Helvetica, sans-serif; font-size: 16px;" class=""><br class="">
</span></div>
<div class="">- 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 class=""><font size="2" class=""><span style="font-family: Calibri, Helvetica, sans-serif;" class="">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;" class="">
<span style="font-family: Calibri, Helvetica, sans-serif;" class="">note: please rebuild precompiled header '/home/fba_code/source/lib/altsvc.ast'</span><br style="font-family: Calibri, Helvetica, sans-serif;" class="">
<span style="font-family: Calibri, Helvetica, sans-serif;" class="">1 error generated.</span></font></div>
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">Best,</div>
<div class="">Siegfried</div>
</body>
</html>