I am trying to use clang to preprocess source code and pipe the output
to gcc. With a current clang and gcc 4.5 I am getting the warning
line-map.c: file "test.c" left but not entered
This is caused by clang exiting the main file "test.c":
# 1 "test.c" 2
The attached patch fixes the problem.
Cheers,
--
Rafael Ávila de Espíndola
Index: test/Preprocessor/line-directive-main-file.c
===================================================================
--- test/Preprocessor/line-directive-main-file.c (revision 0)
+++ test/Preprocessor/line-directive-main-file.c (revision 0)
@@ -0,0 +1 @@
+// RUN: clang-cc -E %s -o - | not grep line-directive-main-file.c.*2
Index: lib/Frontend/PrintPreprocessedOutput.cpp
===================================================================
--- lib/Frontend/PrintPreprocessedOutput.cpp (revision 82992)
+++ lib/Frontend/PrintPreprocessedOutput.cpp (working copy)
@@ -90,6 +90,7 @@
bool EmittedMacroOnThisLine;
SrcMgr::CharacteristicKind FileType;
llvm::SmallString<512> CurFilename;
+ llvm::SmallString<512> MainFilename;
bool Initialized;
bool DisableLineMarkers;
bool DumpDefines;
@@ -228,6 +229,7 @@
FileType = NewFileType;
if (!Initialized) {
+ MainFilename = CurFilename;
WriteLineInfo(CurLine);
Initialized = true;
}
@@ -237,7 +239,8 @@
WriteLineInfo(CurLine, " 1", 2);
break;
case PPCallbacks::ExitFile:
- WriteLineInfo(CurLine, " 2", 2);
+ if (MainFilename != CurFilename)
+ WriteLineInfo(CurLine, " 2", 2);
break;
case PPCallbacks::SystemHeaderPragma:
case PPCallbacks::RenameFile:
@@ -502,4 +505,3 @@
PrintPreprocessedTokens(PP, Tok, Callbacks, *OS);
*OS << '\n';
}
-
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits