<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 17, 2008, at 8:09 AM, Steve Naroff wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div>As far as the AST's go, I really don't see the hardship here. The fact that the FunctionDecls are chained accurately reflects the source code...doesn't it? For me, the problem with the chain is memory efficiency (more than convenience). In C, it is fairly uncommon to have more than one function decl for the same name (yet every FunctionDecl has a chain!). Nevertheless, we already have some bloat in FunctionDecl...every prototype has a Body slot (ouch). Clearly room for improvement here.</div></span></blockquote><div><br></div><div>I'm actually not arguing about adding anything to the AST. I agree with you and Argiris that we should keep the ASTs to faithfully representing the syntax. My issue has more to resolving which declarations refer to the same entity. Your IdResolver idea (below) is more or less what I was thinking of.</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div><br></div><div>A related issue which I consider more problematic is the lack of *any* "chain" for VarDecls. Consider the following code:</div><div><br></div><div><div>int i4;</div><div>int i4;</div><div>extern int i4;</div><div><br></div><div>const int a [1] = {1};</div><div>extern const int a[];</div><div><br></div><div>extern const int b[];</div><div>const int b [1] = {1};</div><div><br></div><div><div><br></div></div><div>At the moment, there is no way to get to the previous declaration! Since I've already whined about the memory inefficiency for FunctionDecl's, I certainly wouldn't recommend adding a chain for all VarDecls!</div></div></span></blockquote><div><br></div><div>Agreed.</div><div><br></div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div><div><span class="Apple-style-span" style="color: rgb(20, 79, 174); -webkit-text-stroke-width: -1; ">I remember writing Sema::CheckForFileScopedRefefinitions() where I had to deal with this. Fortunately, Sema's "IdResolver" came to the rescue (thanks Argiris:-). That said, my gut says it might be worth using an IdResolver-like mechanism to solve this "navigation problem" for *both* VarDecls and FunctionDecls. Architecturally, it would make sense for this new API to be part of ASTContext.</span></div></div></span></blockquote><br></div><div>Sounds great to me. What I would like to see is a nice way for clients of the ASTs to go from syntactic constructs (e.g. declarations) to the higher-level concepts. I don't want to add bloat to the AST; the problem is that some of this information just simply cannot be recovered once we exit Sema. I think having the notion of an IdResolver in ASTContext seems like a very reasonable idea; not certain about the performance characteristics.</div></body></html>