[cfe-dev] Add additional #include header file as a result of a refactor

Diana Picus via cfe-dev cfe-dev at lists.llvm.org
Mon Oct 28 03:23:26 PDT 2019


On Mon, 28 Oct 2019 at 10:28, Kenth Eriksson via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> On Fri, 2019-10-25 at 20:59 -0300, Alberto Lagos wrote:
> > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
> >
> > Hi Keneth!,
> >
> > Did you try clang::PPCallbacks or clang::PreprocessorFrontEndAction?
> >
> > Probably PPCallbacks is what you are looking for.
> >
> Would it be possible to get the location for the header includes from
> the source manager? E.g. SourceManager::getLocForStartOfFile gives me
> the beginning of the file. But how can I get the location for the
> header files via SM?

What do you mean by this? Headers can be included anywhere in a file.
Having a big block of include directives close to the top of the file
is just a convention. If you're looking for the include directive for
a specific header (e.g. the one for the old API that you're
replacing), overriding PPCallbacks::InclusionDirective will probably
get you there. Otherwise, you need to think of a way to be more
specific about where you want to include your file (but you should be
very careful because include directives could be part of #if blocks).

Hope that helps,
Diana

>
> > Let me know if that help!
> >
> > Regards.
> >
> > On Fri, 25 Oct 2019 at 16:13 Kenth Eriksson via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> > > Hi!
> > >
> > > I'm refactoring some code with libtooling, replacing one API call with a new another one. This requires me to insert a new header file. How can this be done?
> > >
> > > Thanks,
> > > Kenth
> > > _______________________________________________
> > > cfe-dev mailing list
> > > cfe-dev at lists.llvm.org
> > > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> > >
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list