This is an updated version of an old patch.
clang's preprocessor output for
-------------------------------------------
int main(int argc, char*argv[]) {
return 0;
}
------------------------------------------
is
------------------------------------------
# 1 "test.c"
# 1 "test.c" 1
# 1 "<built-in>" 1
# 1 "<built-in>" 3
# 113 "<built-in>" 3
# 113 "<command line>" 1
# 1 "test.c" 2
int main(int argc, char*argv[]) {
return 0;
}
-----------------------------------
Compiling this with gcc produces the warning 'line-map.c: file
"test.c" left but not entered'. The wording is a bit confusing, but
it looks like what gcc is complaining about is that we have the
transitions
test.c -> <built-in> -> <command line> -> test.c
Adding a <command line> -> <built-in> transition avoids the warning.
This is done with the line
# 114 "<built-in>" 2
after
# 113 "<command line>" 1
Cheers,
--
Rafael Ávila de Espíndola
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
index 972c21f..e8e4749 100644
--- a/lib/Frontend/InitPreprocessor.cpp
+++ b/lib/Frontend/InitPreprocessor.cpp
@@ -523,6 +523,11 @@ void clang::InitializePreprocessor(Preprocessor &PP,
AddImplicitInclude(PredefineBuffer, Path);
}
+ // Exit the command line and go back to <built-in>
+ LineDirective = "# 1 \"<built-in>\" 2\n";
+ PredefineBuffer.insert(PredefineBuffer.end(),
+ LineDirective, LineDirective+strlen(LineDirective));
+
// Null terminate PredefinedBuffer and add it.
PredefineBuffer.push_back(0);
PP.setPredefines(&PredefineBuffer[0]);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits