Re: symbol lookup and overload resolution

Stefan Seefeld <[email protected]>
Newsgroups gmane.comp.documentation.synopsis
Message-ID <[email protected]>
Richard Kelly wrote:

> For each software entity -- class, free function, member function, 
> whatever -- I have to be able to find all declarations and the 
> definition (if any) of that entity, wherever they may exist in the 
> original source code.  So far, I've been querying the AST for that 
> information, including AST.declarations(), AST.types(), and now 
> Type.Dictionary.lookup() to get the declarations.  After that, I'm 
> following the file() and line() information from each Declaration and 
> Comment.

During the translation of the parse tree into the AST all but the first
declaration referring to the same object are dropped, and the comments,
as you discovered earlier, are merged.

To find all declarations, even duplicate ones, you really have to walk
over the parse tree, looking for declarators.

> Of course, I now know that I should be using some of the Synopsis 
> features you've described to me, so I'll start switching over to them. 
> But from what I've seen up to this point, I haven't found in the AST all 
> of the references to all of the original declarations.  So maybe I'll 
> find the definition of function foo() in a .cpp file but not the 
> corresponding declaration of foo() in the .hpp file.  Note that this is 
> *after* running the Synopsis linker, like this:
> 
>     parser = Cxx.Parser( main_file_only = False )
>     linker = Linker( RmdcComments(), Previous(), JavaTags() )
>     self.__ast = AST.AST()
>     self.__ast = parser.process( self.__ast, input = inFiles )
>     self.__ast = linker.process( self.__ast )
> 
> So, am I interpreting the AST incorrectly?  Does it actually contain 
> references to every single declaration/definition of foo()?  Should I be 
> querying the AST before linking, instead of after?

Again, the AST is quite high-level, in that only one declaration per object
(type, variable) is kept. Linking will merge all symbols with the same
(qualified) name, following ODR.
To test whether there is a bug that masks some declarations I'd need to
run synopsis over some sample code, possibly with a sample synopsis script,
which show the wrong behavior.

Best regards,
		Stefan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.