<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Stmt::IgnoreImplicit() should ignore non-trailing ImplicitCastExpr"
href="https://bugs.llvm.org/show_bug.cgi?id=37327">37327</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Stmt::IgnoreImplicit() should ignore non-trailing ImplicitCastExpr
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>steveire@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>The implementation of Stmt::IgnoreImplicit() should ignore ImplicitCastExpr
which appear after MaterializeTemporaryExpr. Currently it does not, meaning I
have to nest two ignoringImplicit() calls when using AST matchers:
C:\dev\src\playground\cpp>type clang_impl.cpp
struct OtherType;
struct SomeType
{
SomeType() {}
SomeType(const OtherType&) {}
SomeType& operator=(OtherType const&) { return *this; }
};
struct OtherType
{
OtherType() {}
~OtherType() {}
};
OtherType something()
{
return {};
}
int main()
{
SomeType i = something();
}
C:\dev\src\llvm\build\releaseprefix\bin\clang-query.exe clang_impl.cpp --
clang-query> m varDecl(hasName("i"),
hasInitializer(exprWithCleanups(has(cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr().bind("e")))))))))
Match #1:
Binding for "e":
CXXConstructExpr 0x2c4ab85a588 <C:\dev\src\playground\cpp\clang_impl.cpp:24:18,
col:28> 'struct SomeType' 'void (const struct OtherType &)'
`-MaterializeTemporaryExpr 0x2c4ab85a570 <col:18, col:28> 'const struct
OtherType' lvalue
`-ImplicitCastExpr 0x2c4ab85a558 <col:18, col:28> 'const struct OtherType'
<NoOp>
`-CXXBindTemporaryExpr 0x2c4ab85a1a0 <col:18, col:28> 'struct OtherType'
(CXXTemporary 0x2c4ab85a198)
`-CallExpr 0x2c4ab85a170 <col:18, col:28> 'struct OtherType'
`-ImplicitCastExpr 0x2c4ab85a158 <col:18> 'struct OtherType (*)(void)'
<FunctionToPointerDecay>
`-DeclRefExpr 0x2c4ab85a100 <col:18> 'struct OtherType (void)' lvalue
Function 0x2c4ab84fd00 'something' 'struct OtherType (void)'
Binding for "root":
VarDecl 0x2c4ab85a040 <C:\dev\src\playground\cpp\clang_impl.cpp:24:5, col:28>
col:14 i 'SomeType' cinit
`-ExprWithCleanups 0x2c4ab85a760 <col:14, col:28> 'SomeType'
`-CXXConstructExpr 0x2c4ab85a728 <col:14, col:28> 'SomeType' 'void (SomeType
&&) noexcept' elidable
`-MaterializeTemporaryExpr 0x2c4ab85a6c8 <col:18, col:28> 'SomeType' xvalue
`-ImplicitCastExpr 0x2c4ab85a5c0 <col:18, col:28> 'SomeType'
<ConstructorConversion>
`-CXXConstructExpr 0x2c4ab85a588 <col:18, col:28> 'SomeType' 'void
(const OtherType &)'
`-MaterializeTemporaryExpr 0x2c4ab85a570 <col:18, col:28> 'const
OtherType' lvalue
`-ImplicitCastExpr 0x2c4ab85a558 <col:18, col:28> 'const OtherType'
<NoOp>
`-CXXBindTemporaryExpr 0x2c4ab85a1a0 <col:18, col:28> 'OtherType'
(CXXTemporary 0x2c4ab85a198)
`-CallExpr 0x2c4ab85a170 <col:18, col:28> 'OtherType'
`-ImplicitCastExpr 0x2c4ab85a158 <col:18> 'OtherType (*)()'
<FunctionToPointerDecay>
`-DeclRefExpr 0x2c4ab85a100 <col:18> 'OtherType ()' lvalue
Function 0x2c4ab84fd00 'something' 'OtherType ()'
1 match.
clang-query> m varDecl(hasName("i"),
hasInitializer(exprWithCleanups(has(cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(has(expr(ignoringImplicit(callExpr())))).bind("e")))))))))
0 matches.
clang-query> m varDecl(hasName("i"),
hasInitializer(exprWithCleanups(has(cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(has(expr(ignoringImplicit(cxxBindTemporaryExpr())))).bind("e")))))))))
Match #1:
Binding for "e":
CXXConstructExpr 0x2c4ab85a588 <C:\dev\src\playground\cpp\clang_impl.cpp:24:18,
col:28> 'struct SomeType' 'void (const struct OtherType &)'
`-MaterializeTemporaryExpr 0x2c4ab85a570 <col:18, col:28> 'const struct
OtherType' lvalue
`-ImplicitCastExpr 0x2c4ab85a558 <col:18, col:28> 'const struct OtherType'
<NoOp>
`-CXXBindTemporaryExpr 0x2c4ab85a1a0 <col:18, col:28> 'struct OtherType'
(CXXTemporary 0x2c4ab85a198)
`-CallExpr 0x2c4ab85a170 <col:18, col:28> 'struct OtherType'
`-ImplicitCastExpr 0x2c4ab85a158 <col:18> 'struct OtherType (*)(void)'
<FunctionToPointerDecay>
`-DeclRefExpr 0x2c4ab85a100 <col:18> 'struct OtherType (void)' lvalue
Function 0x2c4ab84fd00 'something' 'struct OtherType (void)'
Binding for "root":
VarDecl 0x2c4ab85a040 <C:\dev\src\playground\cpp\clang_impl.cpp:24:5, col:28>
col:14 i 'SomeType' cinit
`-ExprWithCleanups 0x2c4ab85a760 <col:14, col:28> 'SomeType'
`-CXXConstructExpr 0x2c4ab85a728 <col:14, col:28> 'SomeType' 'void (SomeType
&&) noexcept' elidable
`-MaterializeTemporaryExpr 0x2c4ab85a6c8 <col:18, col:28> 'SomeType' xvalue
`-ImplicitCastExpr 0x2c4ab85a5c0 <col:18, col:28> 'SomeType'
<ConstructorConversion>
`-CXXConstructExpr 0x2c4ab85a588 <col:18, col:28> 'SomeType' 'void
(const OtherType &)'
`-MaterializeTemporaryExpr 0x2c4ab85a570 <col:18, col:28> 'const
OtherType' lvalue
`-ImplicitCastExpr 0x2c4ab85a558 <col:18, col:28> 'const OtherType'
<NoOp>
`-CXXBindTemporaryExpr 0x2c4ab85a1a0 <col:18, col:28> 'OtherType'
(CXXTemporary 0x2c4ab85a198)
`-CallExpr 0x2c4ab85a170 <col:18, col:28> 'OtherType'
`-ImplicitCastExpr 0x2c4ab85a158 <col:18> 'OtherType (*)()'
<FunctionToPointerDecay>
`-DeclRefExpr 0x2c4ab85a100 <col:18> 'OtherType ()' lvalue
Function 0x2c4ab84fd00 'something' 'OtherType ()'
1 match.
clang-query> m varDecl(hasName("i"),
hasInitializer(exprWithCleanups(has(cxxConstructExpr(has(expr(ignoringImplicit(cxxConstructExpr(has(expr(ignoringImplicit(ignoringImplicit(callExpr()))))).bind("e")))))))))
Match #1:
Binding for "e":
CXXConstructExpr 0x2c4ab85a588 <C:\dev\src\playground\cpp\clang_impl.cpp:24:18,
col:28> 'struct SomeType' 'void (const struct OtherType &)'
`-MaterializeTemporaryExpr 0x2c4ab85a570 <col:18, col:28> 'const struct
OtherType' lvalue
`-ImplicitCastExpr 0x2c4ab85a558 <col:18, col:28> 'const struct OtherType'
<NoOp>
`-CXXBindTemporaryExpr 0x2c4ab85a1a0 <col:18, col:28> 'struct OtherType'
(CXXTemporary 0x2c4ab85a198)
`-CallExpr 0x2c4ab85a170 <col:18, col:28> 'struct OtherType'
`-ImplicitCastExpr 0x2c4ab85a158 <col:18> 'struct OtherType (*)(void)'
<FunctionToPointerDecay>
`-DeclRefExpr 0x2c4ab85a100 <col:18> 'struct OtherType (void)' lvalue
Function 0x2c4ab84fd00 'something' 'struct OtherType (void)'
Binding for "root":
VarDecl 0x2c4ab85a040 <C:\dev\src\playground\cpp\clang_impl.cpp:24:5, col:28>
col:14 i 'SomeType' cinit
`-ExprWithCleanups 0x2c4ab85a760 <col:14, col:28> 'SomeType'
`-CXXConstructExpr 0x2c4ab85a728 <col:14, col:28> 'SomeType' 'void (SomeType
&&) noexcept' elidable
`-MaterializeTemporaryExpr 0x2c4ab85a6c8 <col:18, col:28> 'SomeType' xvalue
`-ImplicitCastExpr 0x2c4ab85a5c0 <col:18, col:28> 'SomeType'
<ConstructorConversion>
`-CXXConstructExpr 0x2c4ab85a588 <col:18, col:28> 'SomeType' 'void
(const OtherType &)'
`-MaterializeTemporaryExpr 0x2c4ab85a570 <col:18, col:28> 'const
OtherType' lvalue
`-ImplicitCastExpr 0x2c4ab85a558 <col:18, col:28> 'const OtherType'
<NoOp>
`-CXXBindTemporaryExpr 0x2c4ab85a1a0 <col:18, col:28> 'OtherType'
(CXXTemporary 0x2c4ab85a198)
`-CallExpr 0x2c4ab85a170 <col:18, col:28> 'OtherType'
`-ImplicitCastExpr 0x2c4ab85a158 <col:18> 'OtherType (*)()'
<FunctionToPointerDecay>
`-DeclRefExpr 0x2c4ab85a100 <col:18> 'OtherType ()' lvalue
Function 0x2c4ab84fd00 'something' 'OtherType ()'
1 match.
clang-query></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>