[PATCH] Do not use "1" in linemarker for main file in -frewrite-includes
Richard Smith
richard at metafoo.co.uk
Thu May 1 13:09:27 PDT 2014
On Thu, May 1, 2014 at 7:47 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:
> On Sunday 13 of April 2014, Richard Smith wrote:
> > The check for MainFileID and accompanying test LGTM.
> >
> > Can you explain what the check for PredefinesFileID is for?
>
> Without that check, the output can look e.g. like this:
> =====
> # 1 "<built-in>" 1
> # 1 "a.cpp"
> void f() {}
> =====
>
> Which is wrong. Only now that I look at it, what's wrong is rather that
> there's no closing "2" linemarker for <built-in>.
>
> So how about this attached patch (on top of the previous one that had the
> predefines check removed)?
LGTM
> > AFAICS, there's
> > no test for that part of the change, and I'm concerned that we could end
> up
> > attributing lines in that FileID to some other file.
>
> The patch includes a test specifically for the predefines file, although
> that
> theoretically shouldn't be necessary, since there's no output from the
> predefines file anyway (OutputContentUpTo() skips it).
>
> > On Fri, Apr 4, 2014 at 3:09 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:
> > > The -frewrite-includes flag incorrectly uses at the beginning a
> > > linemarker for the main file with the "1" flag which suggests that the
> > > contents have been in fact included from another file. This for example
> > > disables -Wunused-macros, which warns only for macros from the main
> file:
> > >
> > > $ cat a.cpp
> > > #define FOO 1
> > > $ clang++ -E -frewrite-includes a.cpp | clang++ -Wall -Wunused-macros
> -x
> > > c++ -c -
> > > $ clang++ -Wall -Wunused-macros -c a.cpp
> > > a.cpp:1:9: warning: macro is not used [-Wunused-macros]
> > > #define FOO 1
> > > ^
> > > 1 warning generated.
> > >
> > > The attached patch fixes the code to start the resulting file with the
> > > correct linemarker.
>
> --
> Lubos Lunak
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140501/31f17a71/attachment.html>
More information about the cfe-commits
mailing list