<div dir="ltr"><div dir="ltr">Hi Torbjörn:<div><br></div><div>This behavior appears to be intentional, though it would be friendly to emit a warning. I believe this is the case your are hitting:</div><div><br></div><div><div> 794 } else if (!Context->hasSameType(CanonicalInitVarType,</div><div> 795 CanonicalBeginType)) {</div><div> 796 // Check for qualified types to avoid conversions from non-const to const</div><div> 797 // iterator types.</div><div> 798 return false;</div><div> 799 }</div></div><div><br></div><div>hth...</div><div>don</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 7, 2019 at 1:06 PM Torbjörn Klatt 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">Hi all,<br>
<br>
I'm trying to fix the clang-tidy bug 35082 [1] as a starter for getting into LLVM development and contribution.<br>
<br>
I think, I've tracked down the issue to<br>
<br>
clang-tidy/modernize/LoopConvertCheck.cpp:123ff: clang::tidy::modernize::makeIteratorLoopMatcher()<br>
```<br>
DeclarationMatcher InitDeclMatcher =<br>
varDecl(hasInitializer(anyOf(ignoringParenImpCasts(BeginCallMatcher),<br>
materializeTemporaryExpr(<br>
ignoringParenImpCasts(BeginCallMatcher)),<br>
hasDescendant(BeginCallMatcher))))<br>
.bind(InitVarName);<br>
```<br>
The definition of `InitDeclMatcher` seems to not match the AST tree<br>
```<br>
|-ForStmt<br>
| |-DeclStmt<br>
| | `-VarDecl<br>
| | `-ExprWithCleanups<br>
| | `-ImplicitCastExpr<br>
| | `-CXXConstructExpr<br>
| | `-MaterializeTemporaryExpr<br>
| | `-ImplicitCastExpr<br>
| | `-CXXMemberCallExpr<br>
| | `-MemberExpr <br>
| | `-DeclRefExpr<br>
```<br>
of<br>
```<br>
std::vector<int> vec{1, 2, 3, 4, 5};<br>
for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { ... }<br>
```<br>
<br>
In my naivety, I tried to include the following into the `anyOf`:<br>
```<br>
exprWithCleanups(<br>
ignoringParenImpCasts(<br>
cxxConstructExpr(<br>
materializeTemporaryExpr(<br>
ignoringParenImpCasts(<br>
BeginCallMatcher))))),<br>
```<br>
mimicking the specific AST tree. Without luck.<br>
<br>
I browsed through include/clang/ASTMatchers.h for better suited matchers, but couldn't find any.<br>
<br>
What important detail am I missing?<br>
<br>
Best<br>
Torbjörn<br>
<br>
[1]: <a href="https://bugs.llvm.org/show_bug.cgi?id=35082" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=35082</a><br>
<br>
<br>
<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="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>