-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to unparse type declarations? #237
Comments
Hi, we already have an outliner. It has some support of moving dependent declarations into the newly generated source file containing the outlined code region enclosed in a function. We have a development branch which has even better support for this feature but there is no timeline to merge it. The relevant function is: The example use in line 636 of https://github.com/rose-compiler/rose/blob/weekly/src/midend/programTransformation/astOutlining/Transform.cc For more information about the outliner, please check: https://en.wikibooks.org/wiki/ROSE_Compiler_Framework/outliner |
Thanks for the suggestion. Since there is an Outliner already implemented by you all, I am thinking of using that for my work. I may need to customize it a bit to insert a few function calls before and after the outlined function. Is it easy to do? I also tested a simple program (adapted from the array1.c) and encountered an issue. Below is the code: typedef struct {
int x;
} MyType;
void foo()
{
int i,j=100, sum[100];
MyType bar;
#pragma rose_outline
for (i=0;i<100;i++)
{
sum[i] =i*2+j + bar.x;
}
#pragma rose_outline
for (i=0;i<100;i++)
{
sum[i] =i*2+j;
}
} Then I run the outliner using the following command and got some error due to type declaration of second outlined code: void OUT__2__2158__(int *ip__,int *jp__,int (*sump__)[100],void *barp__);
/* REQUIRED CPP DIRECTIVES */
/* REQUIRED DEPENDENT DECLARATIONS */
typedef struct {}MyType;
struct
{
int x;
}
;
/* OUTLINED FUNCTION */
void OUT__2__2158__(int *ip__,int *jp__,int (*sump__)[100],void *barp__)
{
int *i = (int *)ip__;
int *j = (int *)jp__;
int (*sum)[100] = (int (*)[100])sump__;
MyType *bar = (MyType *)barp__;
for ( *i = 0; *i < 100; ( *i)++) {
( *sum)[ *i] = *i * 2 + *j + ( *bar) . x;
}
} Is this issue fixed already? I am running ROSE 0.11.125.0. Thanks for the help! |
I have written an outliner for a code region to a new source file with that code region put in a function. In order for this new source file to be compilable, I need to include all type declarations needed for that code region. I have successfully collected all the types referenced.
Are there some utilities I can use to unparse the type declaration taking care of the order of type declaration in the presences of various C/C++ language features like namespace, typedef, nested type declaration, etc?
Thanks a lot!
The text was updated successfully, but these errors were encountered: