<html>
<head></head>
<body>
<p>Hi,</p>
<p>Regarding the problem I exposed, I found the next tutorial:</p>
<p><a href="https://github.com/loarabia/Clang-tutorial/blob/master/tutorial6.cpp">https://github.com/loarabia/Clang-tutorial/blob/master/tutorial6.cpp</a></p>
<p>In that tutorial, they use the option:</p>
<div id="LC106" class="line" style="box-sizing: border-box; padding-left: 10px; height: 18px;"><span class="n" style="box-sizing: border-box; color: #333333;">headerSearchOptions</span><span class="o" style="box-sizing: border-box; font-weight: bold;">-></span><span class="n" style="box-sizing: border-box; color: #333333;">AddPath</span><span class="p" style="box-sizing: border-box;">(</span><span class="s" style="box-sizing: border-box; color: #dd1144;">"/usr/include/linux"</span><span class="p" style="box-sizing: border-box;">,</span></div><div id="LC107" class="line" style="box-sizing: border-box; padding-left: 10px; height: 18px;">            <span class="n" style="box-sizing: border-box; color: #333333;">clang</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box; color: #333333;">frontend</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box; color: #333333;">Angled</span><span class="p" style="box-sizing: border-box;">,</span></div><div id="LC109" class="line" style="box-sizing: border-box; padding-left: 10px; height: 18px;">            <span class="nb" style="box-sizing: border-box; color: #0086b3;">false, </span><span class="nb" style="box-sizing: border-box; color: #0086b3;">false</span><span class="p" style="box-sizing: border-box;">);</span></div><br/>
<p>But:<br/>
1- I don't know if this is what I'm looking for (how could my tool know that a header file like "<name_x/file.h> is in a path which does not even has the directory "name_x" in it?)<br/>
2- I don't know how can I adapt this code to my tool, as I don't use anything similar to:</p>
<p><span class="n" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">clang</span><span class="o" style="box-sizing: border-box; font-weight: bold; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">::</span><span class="n" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">ParseAST</span><span class="p" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">(</span><span class="n" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">preprocessor</span><span class="p" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span><span class="o" style="box-sizing: border-box; font-weight: bold; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class="n" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">astConsumer</span><span class="p" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span><span class="n" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">astContext</span><span class="p" style="box-sizing: border-box; color: #333333; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 18px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">);</span></p>
<p>Can anyone give me a clue to solve this? </p>
<blockquote class="replyBlock" style="border-left: 2px solid #000083; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br/>
<p>Hi,</p>
<p>Some C++ programs include headers which are not in the same directory as the file being processed. In some cases, it is used a path relative to the file, for instance "directory/file.h". And in some other cases, the headers are included in a way understandable to the build system of the program, even using angled headers "<name/file.h> and that path is not relative to its location. <br/>
The problem for me is that I don't know how can I indicate in my tool the exact location of headers which are not in the same directory when creating the AST.<br/>
I'm using something like this to parse the code:<br/>
 ...<br /> ClangTool Tool(OptionsParser.getCompilations(), file); <br /> Tool.run(newFrontendActionFactory(&mytool));<br /> ...<br /><br /> so I would need to tell the object "Tool" to find also in other directories, for instance, a mapping of the headers included and their directory. Or is there a simple way to do this that I'm overlooking?</p>
<p>Thanks,<br/>
Pedro.</p>
</blockquote>
</body>
</html>