[cfe-dev] Add additional #include header file as a result of a refactor
Alberto Lagos via cfe-dev
cfe-dev at lists.llvm.org
Mon Oct 28 03:47:53 PDT 2019
Like Diana said, overriding InclusionDirective will help you getting the
include that you want to replace. That method will give you everything you
need (location, name, if is an angled include, etc). Since is called in
when it finds an include one you TU.
https://clang.llvm.org/doxygen/classclang_1_1PPCallbacks.html#ad5509ca394c21faaead91ec8add75dd2
Take a look to the details of the InclusionDirective.
On Mon, 28 Oct 2019 at 07:23 Diana Picus <diana.picus at linaro.org> wrote:
> 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
>
--
Enviado con Gmail Mobile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20191028/b8dbbe05/attachment.html>
More information about the cfe-dev
mailing list