<div dir="ltr">Dear developers,<div><br></div><div>I'm trying to parse everything  in a source file (including skipped code under conditional preprocessor directives #ifdef, #ifndef, etc.) and create AST with multiple nodes of the same function/data structure, which eventually generates code with multiple definitions. I've following questions:</div><div><br></div><div>I'm using Clang PluginASTAction that taps into PPCallbacks::SourceRangeSkipped() to find out skipped code under a conditional PP directive (e.g., #ifdef, #ifndef, etc.). I use rewriter and create multiple definitions of the decl (function, record, etc.) currently being lexed, but reports "multiple definition error" while parsing. Is it possible to allow multiple definition in AST (similar to --allow-multiple-definition during linker), and finally in the generated code and choose one during link time (unlike --allow-multiple-definition that picks the first one by default)?</div><div><br></div><div>Alternatively, I can create a new TU for the code skipped and try parsing it (either in isolation or using cross-TU functionality recently introduced in clang), but how do I handle dependencies? The other concern is parsing everything can quickly become intractable (2^n explosion), which can only be handled by generating code with variable-length data structures and functions. The desired ones can then be chosen at link time similar to relocation info or --allow-multiple-definition. </div><div><br></div><div>Any pointers would be highly appreciated.</div><div><br></div><div>Thanks,</div><div>Riya</div></div>