This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Intermediate representation


Hello again,

to answer your question my code's purpose is to write a kind of tree in a file, the main arborescence is the classes, their method (with parameters, return type, ...), their attributes, etc... it will also recognize some new keywords I will introduce thanks to "__attribute__".
In this condition, where is the best place to put my code please ?


Thank you a lot, I would haven't made any progress without your help.

Nicolas COLLIN

Dave Korn a écrit :

Bear in mind that global_namespace only exists in the C++ compiler
'cc1plus', so if you access it directly in toplev.c, the plain C compiler
'cc1' will fail to build with a link error.  This might or might not matter to
you for your purposes, but it's better for that reason to keep any code that
needs to understand about anything to do with C++ in the /cp/ subdirectory.

 Without knowing what your code does, I can't say where is the best place to
put it.  The flow of control is that compile_file in gcc/toplev.c calls to the
language-specific parser yyparse, which then calls into hooks in the
language-specific files in gcc/ or gcc/cp/, ending eventually in finish_decl
in either gcc/c-decl.c or gcc/cp/decl.c, where it calls rest_of_compilation to
hand off the tree representation to the mid/backend for translation to
assembler code.

 So, the C++ specific finish_decl would be one good place to add code that
needs to analyse the trees.  Bear in mind that by the time you see them there,
some elementary optimisations like constant folding may already have been
performed, so you might not see what exactly reflects the form of the original
sources.


cheers, DaveK



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]