How to disable the generation of TypedefDecl for __builtin_va_list

Hi,

I found out that for the following code (only containing two variable declarations), clang will generate three internal typedef declarations. Is there any way to disable the generation of the three typedef?

Thank you.

Hi,

I found out that for the following code (only containing two variable
declarations), clang will generate three internal typedef declarations. Is
there any way to disable the generation of the three typedef?

Not that I know of. What problem are you trying to solve by disabling them?

-- Meador

I want to randomly remove the variable declaration “a” or “b” from the source file. There are two ways to do this.

  1. I can pretty print the VarDecl of “a” and “b”. However, these three builtin typedefs mentioned above make the modified source file not compilable, as the _builtin_va_list is not defined.
  2. I can use rewriter to change the source file. However, as both “a” and “b” are declared in one statement, removing either of them makes the deletion complex.

I think another way to do this is to separate the statement “int a, b;” into “int a; int b”. Any existing functionality in clang to do this?

Thank you. Any advice is appreciated.

I want to randomly remove the variable declaration "a" or "b" from the
source file. There are two ways to do this.
    1) I can pretty print the VarDecl of "a" and "b". However, these three
builtin typedefs mentioned above make the modified source file not
compilable, as the _builtin_va_list is not defined.

Why not skip things marked as implicit (clang::Decl::isImplicit) ?

Thank you for letting me know this API. However, I have another problem: when I have the forward declaration of vprintf (produced by the preprocessor), the clang AST will assign the type int to va_list. Is it a correct way to use prettyprint to dump code from AST?

You are missing a typdef which would provide the definition of va_list. Because va_list is not defined, we parse ‘va_list’ in the function parameter as a parameter name. Via the C rules, we implicitly give it type int.

Thanks, David.

The clang::Decl::isImplicit solves my problem.