<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>I did some digging and it looks like it builds the "Map" on
demand, storing it in ASTContext (PointerParents, OtherParents). I
thought it might be a buggy implementation of ParentMapASTVisitor,
so I tried writing my own ASTVisitor. However, after doing so,
both my own and ParentMapASTVisitor reported the
TranslationUnitDecl traversing only one user-defined FunctionDecl
and not all of them (there are 4 in my test). The root cause
appears to be TUDecl missing some of the function decls. I think
all that needs to repro this is calling
"getContext().getParents<Stmt>(*E)" inside
CodeGenFunction::EmitArraySubscriptExpr(). DAE know if there is
any specific reason why I can't getParents from CGExpr.cpp?<br>
</p>
<p>Best,</p>
<p>Kevin<br>
</p>
<br>
<div class="moz-cite-prefix">On 2018-10-23 1:21 PM, David Blaikie
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAENS6EsZeNKSQTj81XWuyJPn3Kiep8_p97oKegJ0kCnC-f0LbQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">I believe the parent map that powers getParents is
not populated by default (it's not used by Clang proper - so it
doesn't want to pay that cost) - not sure where/when/how you
call to populate it - but hopefully that gives you some hints
for what to look for.</div>
<br>
<div class="gmail_quote">
<div dir="ltr">On Tue, Oct 23, 2018 at 3:49 AM Kevin Choi via
cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org"
moz-do-not-send="true">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
developers,<br>
<br>
I wasn't sure if this was the relevant channel to ask this,
and I <br>
apologize if so.<br>
<br>
I've hit a puzzle with an out-of-tree build based on 6.0.0 and
was <br>
wondering if anyone could share their wisdom on it.<br>
ASTContext::getParents seems to be returning an empty list in
a <br>
particular case:<br>
Run on ArraySubscriptExpr node looking for Stmt parents.<br>
<br>
I have four ArraySubscriptExprs in my AST dump, the faulty one
being:<br>
<br>
|-FunctionDecl 0x6190f58 <line:33:1, line:35:1>
line:33:5 used fib 'int <br>
(int)'$<br>
| |-ParmVarDecl 0x6190ec8 <col:9, col:13> col:13 used n
'int'$<br>
| `-CompoundStmt 0x61915d8 <col:16, line:35:1>$<br>
| `-ReturnStmt 0x6191518 <line:34:3, col:13>$<br>
| `-ImplicitCastExpr 0x6191460 <col:10, col:13>
'int' <LValueToRValue>$<br>
| `-ArraySubscriptExpr 0x6191390 <col:10, col:13>
'int' lvalue$<br>
| |-ImplicitCastExpr 0x6191220 <col:10> 'int *'
<br>
<ArrayToPointerDecay>$<br>
| | `-DeclRefExpr 0x6191080 <col:10> 'int [16]'
lvalue Var <br>
0x618c780 'b' 'int [16]'$<br>
| `-ImplicitCastExpr 0x61912d8 <col:12> 'int'
<LValueToRValue>$<br>
| `-DeclRefExpr 0x6191150 <col:12> 'int'
lvalue ParmVar <br>
0x6190ec8 'n' 'int'$<br>
<br>
In this case, getParents returns empty list even though
ImplicitCastExpr <br>
is clearly a parent and is a Stmt. My modification simply
calls "const <br>
auto Parents = getContext().getParents<Stmt>(ERef);" in
<br>
EmitArraySubscriptExpr. Has anyone run into a similar problem
before?<br>
<br>
Best,<br>
<br>
Kevin<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank"
moz-do-not-send="true">cfe-dev@lists.llvm.org</a><br>
<a
href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</blockquote>
<br>
</body>
</html>