aboutsummaryrefslogtreecommitdiff
path: root/lib/Rewrite/Frontend/InclusionRewriter.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-10 01:53:37 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2013-04-10 01:53:37 +0000
commit507d496e18fb7bf54e4cb8f79df56941f93f1eda (patch)
treeaee575b671dc7716f6b6a3d542b4baa593534365 /lib/Rewrite/Frontend/InclusionRewriter.cpp
parent60c99d34cf28c002718b61c2f058d1e84923a634 (diff)
[frontend] -frewrite-includes: if there was no inclusion, don't add lineinfo that indicates return from another file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179143 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Rewrite/Frontend/InclusionRewriter.cpp')
-rw-r--r--lib/Rewrite/Frontend/InclusionRewriter.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp
index d95fb073b1..5740a8407e 100644
--- a/lib/Rewrite/Frontend/InclusionRewriter.cpp
+++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp
@@ -253,7 +253,7 @@ bool InclusionRewriter::Process(FileID FileId,
bool Invalid;
const MemoryBuffer &FromFile = *SM.getBuffer(FileId, &Invalid);
if (Invalid) // invalid inclusion
- return true;
+ return false;
const char *FileName = FromFile.getBufferIdentifier();
Lexer RawLex(FileId, &FromFile, PP.getSourceManager(), PP.getLangOpts());
RawLex.SetCommentRetentionState(false);
@@ -264,7 +264,7 @@ bool InclusionRewriter::Process(FileID FileId,
WriteLineInfo(FileName, 1, FileType, EOL, " 1");
if (SM.getFileIDSize(FileId) == 0)
- return true;
+ return false;
// The next byte to be copied from the source file
unsigned NextToWrite = 0;
@@ -292,12 +292,17 @@ bool InclusionRewriter::Process(FileID FileId,
if (const FileChange *Change = FindFileChangeLocation(
HashToken.getLocation())) {
// now include and recursively process the file
- if (Process(Change->Id, Change->FileType))
+ if (Process(Change->Id, Change->FileType)) {
// and set lineinfo back to this file, if the nested one was
// actually included
// `2' indicates returning to a file (after having included
// another file.
WriteLineInfo(FileName, Line, FileType, EOL, " 2");
+ } else {
+ // fix up lineinfo (since commented out directive changed line
+ // numbers).
+ WriteLineInfo(FileName, Line, FileType, EOL);
+ }
} else
// fix up lineinfo (since commented out directive changed line
// numbers) for inclusions that were skipped due to header guards