[llvm-dev] multiple definitions
riya khanna via llvm-dev
llvm-dev at lists.llvm.org
Sat Dec 30 07:33:01 PST 2017
Dear developers,
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:
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)?
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.
Any pointers would be highly appreciated.
Thanks,
Riya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171230/70dd7295/attachment.html>
More information about the llvm-dev
mailing list