mirror of
https://github.com/frida/tinycc
synced 2024-12-25 22:46:49 +03:00
minor pp optimizations
* remove free_defines() from tcc_preprocess() all cleanup will be done in tcc_delete * move a preprocessor file closing to tcc_delete too
This commit is contained in:
parent
1234beccb8
commit
06e0753fce
4
libtcc.c
4
libtcc.c
@ -1217,6 +1217,10 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
|
|||||||
|
|
||||||
tcc_cleanup();
|
tcc_cleanup();
|
||||||
|
|
||||||
|
/* close a preprocessor output */
|
||||||
|
if (s1->ppfp && s1->ppfp != stdout)
|
||||||
|
fclose(s1->ppfp);
|
||||||
|
|
||||||
/* free all sections */
|
/* free all sections */
|
||||||
for(i = 1; i < s1->nb_sections; i++)
|
for(i = 1; i < s1->nb_sections; i++)
|
||||||
free_section(s1->sections[i]);
|
free_section(s1->sections[i]);
|
||||||
|
24
tcc.c
24
tcc.c
@ -247,7 +247,6 @@ int main(int argc, char **argv)
|
|||||||
TCCState *s;
|
TCCState *s;
|
||||||
int ret, optind, i, bench;
|
int ret, optind, i, bench;
|
||||||
int64_t start_time = 0;
|
int64_t start_time = 0;
|
||||||
const char *first_file = NULL;
|
|
||||||
|
|
||||||
s = tcc_new();
|
s = tcc_new();
|
||||||
|
|
||||||
@ -315,17 +314,16 @@ int main(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
if (1 == s->verbose)
|
if (1 == s->verbose)
|
||||||
printf("-> %s\n", filename);
|
printf("-> %s\n", filename);
|
||||||
|
if (!s->outfile)
|
||||||
|
s->outfile = default_outputfile(s, filename);
|
||||||
if (tcc_add_file(s, filename, filetype) < 0)
|
if (tcc_add_file(s, filename, filetype) < 0)
|
||||||
ret = 1;
|
ret = 1;
|
||||||
else
|
else
|
||||||
if (s->output_type == TCC_OUTPUT_OBJ) {
|
if (s->output_type == TCC_OUTPUT_OBJ) {
|
||||||
if (!s->outfile)
|
|
||||||
s->outfile = default_outputfile(s, filename);
|
|
||||||
ret = !!tcc_output_file(s, s->outfile);
|
ret = !!tcc_output_file(s, s->outfile);
|
||||||
if (!ret) {
|
if (s->gen_deps && !ret)
|
||||||
/* dump collected dependencies */
|
|
||||||
if (s->gen_deps)
|
|
||||||
gen_makedeps(s, s->outfile, s->deps_outfile);
|
gen_makedeps(s, s->outfile, s->deps_outfile);
|
||||||
|
if (!ret) {
|
||||||
if ((i+1) < s->nb_files) {
|
if ((i+1) < s->nb_files) {
|
||||||
tcc_delete(s);
|
tcc_delete(s);
|
||||||
s = tcc_new();
|
s = tcc_new();
|
||||||
@ -337,9 +335,6 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if (!first_file)
|
|
||||||
first_file = filename;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,14 +349,11 @@ int main(int argc, char **argv)
|
|||||||
tcc_error_noabort("-run is not available in a cross compiler");
|
tcc_error_noabort("-run is not available in a cross compiler");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
#endif
|
#endif
|
||||||
} else if (s->output_type == TCC_OUTPUT_PREPROCESS) {
|
} else
|
||||||
if (s->outfile)
|
if (s->output_type == TCC_OUTPUT_EXE ||
|
||||||
fclose(s->ppfp);
|
s->output_type == TCC_OUTPUT_DLL)
|
||||||
} else if (s->output_type != TCC_OUTPUT_OBJ) {
|
{
|
||||||
if (!s->outfile)
|
|
||||||
s->outfile = default_outputfile(s, first_file);
|
|
||||||
ret = !!tcc_output_file(s, s->outfile);
|
ret = !!tcc_output_file(s, s->outfile);
|
||||||
/* dump collected dependencies */
|
|
||||||
if (s->gen_deps && !ret)
|
if (s->gen_deps && !ret)
|
||||||
gen_makedeps(s, s->outfile, s->deps_outfile);
|
gen_makedeps(s, s->outfile, s->deps_outfile);
|
||||||
}
|
}
|
||||||
|
3
tccpp.c
3
tccpp.c
@ -3332,12 +3332,10 @@ static void pp_line(TCCState *s1, BufferedFile *f, int level)
|
|||||||
/* Preprocess the current file */
|
/* Preprocess the current file */
|
||||||
ST_FUNC int tcc_preprocess(TCCState *s1)
|
ST_FUNC int tcc_preprocess(TCCState *s1)
|
||||||
{
|
{
|
||||||
Sym *define_start;
|
|
||||||
BufferedFile **iptr;
|
BufferedFile **iptr;
|
||||||
int token_seen, spcs, level;
|
int token_seen, spcs, level;
|
||||||
|
|
||||||
preprocess_init(s1);
|
preprocess_init(s1);
|
||||||
define_start = define_stack;
|
|
||||||
ch = file->buf_ptr[0];
|
ch = file->buf_ptr[0];
|
||||||
tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
|
tok_flags = TOK_FLAG_BOL | TOK_FLAG_BOF;
|
||||||
parse_flags = PARSE_FLAG_PREPROCESS
|
parse_flags = PARSE_FLAG_PREPROCESS
|
||||||
@ -3388,6 +3386,5 @@ ST_FUNC int tcc_preprocess(TCCState *s1)
|
|||||||
fputs(get_tok_str(tok, &tokc), s1->ppfp);
|
fputs(get_tok_str(tok, &tokc), s1->ppfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_defines(define_start);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user