On Thursday 28 of November 2013, Alp Toker wrote: > #include "rewrite-includes-bom.h"#endif /* expanded by -frewrite-includes > */ > > On 27/11/2013 18:24, Lubos Lunak wrote: > > As discussed in " [PATCH] PR14795 : -frewrite-includes sometimes > > results in incorrect line number", the following leads to a crash: > > I don't see a crash mentioned in PR14795. Wrong bug?
That is a reference to the mailing list thread, not to the PR itself. > Be aware however that with this change, you'll get invalid expansions like: > > #include "rewrite-includes-bom.h"#endif /* expanded by -frewrite-includes > */ > > Unless this is expected behaviour, you'll need to add special handling > for end-of-directive in the include rewriter. Rather unlikely in practice, but why not, attached. -- Lubos Lunak
From 85d20f0d25c8fa59241e07cc9d8129184ab01a53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= <[email protected]> Date: Thu, 28 Nov 2013 17:03:12 +0100 Subject: [PATCH] ensure newline if last line is #include without trailing \n --- lib/Rewrite/Frontend/InclusionRewriter.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp index bd4250a..0effec6 100644 --- a/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -259,6 +259,12 @@ void InclusionRewriter::CommentOutDirective(Lexer &DirectiveLex, OutputContentUpTo(FromFile, NextToWrite, SM.getFileOffset(DirectiveToken.getLocation()) + DirectiveToken.getLength(), EOL, Line); + // Ensure newline before the #endif directive. + char LastChar = + FromFile.getBufferStart()[SM.getFileOffset(DirectiveToken.getLocation()) + + DirectiveToken.getLength() - 1]; + if (LastChar != '\n' && LastChar != '\r') + OS << EOL; OS << "#endif /* expanded by -frewrite-includes */" << EOL; } -- 1.8.1.4
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
