<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I have some thoughts on this proposal, but rather than nitpick it
inline, I think the issues would probably be better left to a code
review. The primary concern about my proposal seems to be "it may
be risky or infeasible to patch everything else to handle this
change," which could be made more concrete by me attempting to
actually do it. Let me know if I'm misunderstanding. For now, I
have a working prototype, but it has some ugly workarounds. I want
to see if I can fix them properly without being too invasive, and
how confident I am in the result.<br>
<p>Purely from a semantic perspective, hanging ParmVarDecls off of a
VarDecl or FieldDecl seems the correct solution for function
pointer parameters. Going through the type information and the
redeclaration chain seems highly unfortunate even if it might be
less code motion.</p>
<p>Thanks,<br>
-David</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 02/06/2017 10:20 PM, Serge Pavlov
wrote:<br>
</div>
<blockquote
cite="mid:CACOhrX6bsCvhWLoie-G1NGU9cKXbfsnC4cvEpbbGWddhQx0B=w@mail.gmail.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">2017-02-07 9:41 GMT+07:00 David
Fontaine <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:dfontaine@nvidia.com" target="_blank">dfontaine@nvidia.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div dir="ltr"
style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:calibri,arial,helvetica,sans-serif">
<p
style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span
style="color:rgb(33,33,33)">"The DeclContext is a
declaration that is a container for other
declarations. All non-leaf nodes of AST inherit
it. If a contained declaration itself can contain
other declarations (nested class, method of a class
etc), it will be a nested DeclContext."</span><br>
</p>
<span class="gmail-">
<p
style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span
style="color:rgb(33,33,33);background-color:rgb(255,255,255)"><br>
</span></p>
</span>
<p
style="font-family:calibri,arial,helvetica,sans-serif;font-size:16px"><span
style="color:rgb(33,33,33);background-color:rgb(255,255,255)">Based on
this, it seems that VarDecl and FieldDecl should
also inherit DeclContext, because a function pointer
declaration, which may contain named parameters,
would be one of those two. Any opinion on this?</span></p>
</div>
</blockquote>
<div>Nor VarDecl neither FieldDecl contain other
declarations, so making them DeclContext is not obvious.
DeclContext is used in many places including name lookup
and such drastic semantic change can require redesign of
other compiler components. And what about such case:</div>
<div><br>
</div>
<div>int (* (*abc)(long x))(int x);<br>
</div>
<div><br>
</div>
<div>Two DeclContexts would be needed here.</div>
<div><br>
</div>
<div>I would propose you another way, which probably is less
invasive. The parameter names are not attributes of
VarDecl, it looks more natural to obtained from
corresponding function type, which can be obtained:</div>
<div><br>
</div>
<div>VarDecl->getType()->getAs<PointerType>()->getPointeeType()->getAs<FunctionProtoType>()</div>
<div><br>
</div>
<div>If FunctionProtoType had method `getDecl` as
`RecordDecl` has, you could get the parameter declarations
from corresponding FunctionDecl. So you need to construct
bogus function declaration when parsing function pointer
declaration and attach it to the FunctionProtoType. There
is however a problem with different declarations for the
same type:</div>
<div><br>
</div>
<div>void (*pFn)(int x);<br>
</div>
<div>void (*pFn2)(int y);<br>
</div>
<div><br>
</div>
<div>The variables have the same type, but to keep named
parameters you need different FunctionDecls. Probably the
bogus declarations should be linked into redeclaration
chain.</div>
<div><br>
</div>
<div>It is only an idea, I don't know if it is viable.</div>
<div><br>
</div>
<div>
<div class="gmail_signature">Thanks,<br>
--Serge<br>
</div>
</div>
<div><br>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<DIV>
<HR>
</DIV>
<DIV>This email message is for the sole use of the intended recipient(s) and may
contain confidential information. Any unauthorized review, use, disclosure
or distribution is prohibited. If you are not the intended recipient,
please contact the sender by reply email and destroy all copies of the original
message. </DIV>
<DIV>
<HR>
</DIV>
</body>
</html>