<p dir="ltr">Use clang-check to do the ast dump otherwise you have to specify the full command line. The 'invalid' in your dump indicates that there were parse errors, most likely due to headers that clang didn't find.</p>
<br><div class="gmail_quote"><div dir="ltr">On Tue, Jul 12, 2016, 1:12 AM Andre-Marcel Hellmund <<a href="mailto:hellmund@fzi.de">hellmund@fzi.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi Aaron, Hi Manuel,<br>
<br>
thank you for your prompt reply and sorry for my belated response!
Regarding the header omp.h, I meanwhile figured out that my
clang-3.8 installation (from the official apt-repo) does not include
the omp.h header file. If I add the omp.h from gcc, the error is
gone, while others appear. But this is not your problem. :-D<br>
<br>
Regarding the second issue with incorrect AST matches, this is the
reduced C++ code structure out of a larger C++ header file:<br>
<br>
[...] many class definitions [...]<br>
<br>
class RoadLink {<br>
public:<br>
[...] <br>
private:<br>
std::vector<int64_t> precedingRoads_;<br>
std::vector<int64_t> succeedingRoads_;<br>
};<br>
<br>
class Road {<br>
public:<br>
[...]<br>
std::vector<LaneSectionPtr>::const_iterator
sectionsBegin() const {<br>
return sections_.cbegin();<br>
}<br>
<br>
<br>
private:<br>
int64_t roadID_;<br>
std::vector<LaneSectionPtr> sections_;<br>
RoadLink roadLink_;<br>
const odd::RoadDescriptor* roadDesc_;<br>
}<br>
<br>
class MetaData {<br>
public:<br>
[...]<br>
private:<br>
double xMin_;<br>
double xMax_;<br>
double yMin_;<br>
double yMax_;<br>
};<br>
<br>
When I run the clang-query matcher, I get sections_ and roadLink_ as
public field decls for class Road. The private members of the class
before and after the class 'Road' are correctly matched. If I look
at the ast-dump for the class Road, I see the following shortened
dump:<br>
<br>
| |-CXXRecordDecl 0x9c7b668 prev 0x9c6bac0 <line:492:1,
line:531:1> line:492:7 referenced invalid class Road definition<br>
| | |-AccessSpecDecl 0x9c7b7e8 <line:493:1, col:7> col:1
public<br>
| | |-FieldDecl 0x9c7bff0 <line:510:32, col:34> col:34 invalid
const_iterator 'int'<br>
| | |-FieldDecl 0x9c7c048 <line:528:33> col:33 invalid
sections_ 'int'<br>
| | |-FieldDecl 0x9c7c0a0 <line:529:5, col:14> col:14 invalid
roadLink_ 'class opendrive::RoadLink'<br>
| | `-FieldDecl 0x9c7c140 <line:530:5, col:32> col:32
roadDesc_ 'const odd::RoadDescriptor *'<br>
<br>
So, I see a few errors in this AST:<br>
<br>
1. The AccessSpecDecl 'private' is missing in this class, while it
is available preceding and succeeding class<br>
2. The const_iterator from line 510 (Function: sectionsBegin()) is
added as a field decl while it is a type of the std::vector. <br>
<br>
BTW, the AST dump was generated by clang-3.9 (ToT, last week). <br>
<br>
Do you have any idea what could be wrong here? <br>
<br>
Thanks,<br>
Andi</div><div bgcolor="#FFFFFF" text="#000000"><br>
<br>
<br>
<br>
<br>
<div class="m_-7849682938841864540moz-cite-prefix">On 07.07.2016 14:39, Manuel Klimek
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_quote">
<div dir="ltr">On Thu, Jul 7, 2016 at 8:31 AM Andre-Marcel
Hellmund via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
Clang-Guys,<br>
<br>
I recently started to look into the clang-tools to enforce
coding<br>
guidelines for our development group. Therefore, I played
around with<br>
clang-tidy and clang-format (version 3.8 and trunk from
Monday), however<br>
ran into a two problems. Before I dive deeper into the code
details of<br>
both tools, I would like to check with you for known issues
or hints.<br>
<br>
1) While the compilation of the code using CMake (ninja)
works fine,<br>
loading the same code via clang-tidy (and the compilation
database)<br>
results in an error that a header, omp.h, could not be
found. Is this a<br>
known bug for clang-tidy or might this be caused by a defect
in CMake?<br>
</blockquote>
<div><br>
</div>
<div>This is really hard to diagnose without more info.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
2) Performing a simple AST match (reduced from the
clang-tidy check<br>
'readability-identifier-naming'), that is,<br>
<br>
fieldDecl(isPublic()).bind("public_member")<br>
<br>
results in incorrect matches meaning that privately declared
members or<br>
public type definitions of std containers like
const_iterator are<br>
matched. Interestingly, I was not yet able to reproduce
those errors<br>
with simplified test cases. Are there some known issues with
the AST<br>
matchers that could fit my description?<br>
</blockquote>
<div><br>
</div>
<div>The only known issue is that it's often hard to
intuitively understand why things are in the AST. It would
be great to have a smaller repro of your problem, otherwise
it's really hard to help.</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thank you for your help and support in advance,<br>
Andi<br>
_______________________________________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</div>
</blockquote>
<br>
</div><div bgcolor="#FFFFFF" text="#000000"><pre class="m_-7849682938841864540moz-signature" cols="72">--
.........................................................
André-Marcel Hellmund, M.Sc.
Wissenschaftlicher Mitarbeiter | Scientific Researcher
Mobile Perception Systems
FZI Forschungszentrum Informatik
Haid-und-Neu-Str. 10–14
76131 Karlsruhe, Germany
Tel.: +49 721 608-47146
Fax: +49 721 661874
<a class="m_-7849682938841864540moz-txt-link-abbreviated" href="mailto:hellmund@fzi.de" target="_blank">hellmund@fzi.de</a>
<a class="m_-7849682938841864540moz-txt-link-abbreviated" href="http://www.fzi.de/mitarbeiter/hellmund" target="_blank">www.fzi.de/mitarbeiter/hellmund</a>
.........................................................
FZI Forschungszentrum Informatik am Karlsruher Institut für Technologie
Stiftung des bürgerlichen Rechts
Stiftung Az: 14-0563.1 Regierungspräsidium Karlsruhe
Vorstand: Prof. Dr. Andreas Oberweis, Prof. Dr. Ralf Reussner,
Jan Wiesenberger, Prof. Dr.-Ing. J. Marius Zöllner
Vorsitzender des Kuratoriums: Ministerialdirigent Günther Leßnerkraus
.........................................................</pre>
</div>
</blockquote></div>