Daniel Jacobowitz wrote: > On Sat, Feb 09, 2008 at 12:21:02AM -0500, Aleksandar Ristovski wrote: >> Hello, >> >> Currently we synthesize typedef info for java and c++ (and ada, but I am >> not familiar with that language) for any symbol with STRUCT_DOMAIN domain. >> This can add up to a lot of redundant data. For partial symbols, we >> generate two identical names for the same symbol, once as struct second as >> typedef. The same happens with symbols, except we do not duplicate symbol >> name, but we do allocate another symbol struture. >> >> Instead of generating redundant data for symbols with STRUCT_DOMAIN domain >> in java and c++ languages, treat STRUCT_DOMAIN as equal to VAR_DOMAIN for >> these two languages when looking up symbols. > > Sorry for taking so long to look at this. It's a great idea and the > patch seems correct to me. Just some cosmetic issues, and then it can > go in. > >> - if (cu->language == language_cplus >> - || cu->language == language_java >> - || cu->language == language_ada) >> + if (cu->language == language_ada) >> { >> - /* For C++ and Java, these implicitly act as typedefs as well. */ >> + /* FIXME: Check if Ada really >> + needs to implicitly set typedef. */ > > If this works for C++ and Java, it will work for Ada too. If you > can't test Ada, please post a final version of the patch and ask Joel > to run tests for you - I'm sure he won't mind getting all that memory > back for Ada too. Ok, here is the revised patch. Cc-ing Joel to take a look if it affects ada. >> - >> - /* The semantics of C++ state that "struct foo { ... }" also >> - defines a typedef for "foo". A Java class declaration also >> - defines a typedef for the class. Synthesize a typedef symbol >> - so that "ptype foo" works as expected. */ >> + > > Since we still need to set the typedef name here, leave the first two > sentences of the comment. Sentences put back. > >> + if (symbol_language == language_cplus >> + || symbol_language == language_java) > > Only need one space there. > One space. Waiting for an OK to commit. Thanks, Aleksandar ChangeLog: * dwarf2read.c (add_partial_symbol): Do not add new psym for STRUCT_DOMAIN. Make sure you recognize c++ struct and java and ada class as typedefs. See lookup_partial_symbol function. (new_symbol): Similar to add_partial_symbol, do not create symbol for the typedef. See lookup_block_symbol. * symtab.c (symbol_matches_domain): New function, takes care of dual meaning of STRUCT_DOMAIN symbol for c++, ada and java. (lookup_partial_symbol): Use symbol_matches_domain to see if the found psym domain matches the given domain. (lookup_block_symbol): Likewise.