summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-20 20:16:10 +0000
committerChris Lattner <sabre@nondot.org>2009-03-20 20:16:10 +0000
commit1d1d80e5f9173c6924006db6fcec87417b8f1be7 (patch)
treecea1f8cb2000810dec51f383e62ded82e42fee3a /clang/lib/Lex/Preprocessor.cpp
parent6b31533ad11572f175eb7d9adb9246f56641a6d5 (diff)
downloadbcm5719-llvm-1d1d80e5f9173c6924006db6fcec87417b8f1be7.tar.gz
bcm5719-llvm-1d1d80e5f9173c6924006db6fcec87417b8f1be7.zip
rename the <predefines> buffer to <built-in> to solve PR3849.
Add a #include directive around the command line buffer so that diagnostics generated from -include directives get diagnostics like: In file included from <built-in>:98: In file included from <command line>:3: ./t.h:2:1: warning: type specifier missing, defaults to 'int' b; ^ llvm-svn: 67396
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index b06050f984b..811ea69760a 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -642,8 +642,6 @@ static void InitializePredefinedMacros(Preprocessor &PP,
// Get other target #defines.
TI.getTargetDefines(PP.getLangOptions(), Buf);
-
- // FIXME: Should emit a #line directive here.
}
@@ -670,9 +668,18 @@ void Preprocessor::EnterMainSourceFile() {
// Install things like __POWERPC__, __GNUC__, etc into the macro table.
InitializePredefinedMacros(*this, PrologFile);
- // Add on the predefines from the driver.
+ // Add on the predefines from the driver. Wrap in a #line directive to report
+ // that they come from the command line.
+ const char *LineDirective = "# 1 \"<command line>\" 1\n";
+ PrologFile.insert(PrologFile.end(),
+ LineDirective, LineDirective+strlen(LineDirective));
+
PrologFile.insert(PrologFile.end(), Predefines.begin(), Predefines.end());
+ LineDirective = "# 2 \"<built-in>\" 2\n";
+ PrologFile.insert(PrologFile.end(),
+ LineDirective, LineDirective+strlen(LineDirective));
+
// Memory buffer must end with a null byte!
PrologFile.push_back(0);
@@ -680,7 +687,7 @@ void Preprocessor::EnterMainSourceFile() {
// PrologFile, preprocess it to populate the initial preprocessor state.
llvm::MemoryBuffer *SB =
llvm::MemoryBuffer::getMemBufferCopy(&PrologFile.front(),&PrologFile.back(),
- "<predefines>");
+ "<built-in>");
assert(SB && "Cannot fail to create predefined source buffer");
FileID FID = SourceMgr.createFileIDForMemBuffer(SB);
assert(!FID.isInvalid() && "Could not create FileID for predefines?");
OpenPOWER on IntegriCloud