aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-30 05:23:00 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-30 05:23:00 +0000
commit936a5b44eea36a698946dde3b0a1e35b21244209 (patch)
treea765e3c9a8e1528c6ea204d48a6b9a39fff753e5 /clang/lib/Frontend
parentebd45a004d6a1cd6e2cebb36fbaf07fc612b0be6 (diff)
downloadllvm-936a5b44eea36a698946dde3b0a1e35b21244209.zip
llvm-936a5b44eea36a698946dde3b0a1e35b21244209.tar.gz
llvm-936a5b44eea36a698946dde3b0a1e35b21244209.tar.bz2
When loading a precompiled preamble, use the file ID of the
precompiled preamble as the "main" source file's file ID within the source manager. This makes compiling with a precompiled preamble produce the same source locations as when compiling without the precompiled preamble; prior to this change, we ended up with different file IDs for source locations within the precompiled preamble vs. those after the precompiled preamble, even for entities (e.g., preprocessing entities) in the same file. llvm-svn: 120390
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index b5feadb..30c3b62 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -474,8 +474,11 @@ bool CompilerInstance::InitializeSourceManager(llvm::StringRef InputFile,
FileManager &FileMgr,
SourceManager &SourceMgr,
const FrontendOptions &Opts) {
- // Figure out where to get and map in the main file.
- if (InputFile != "-") {
+ // Figure out where to get and map in the main file, unless it's already
+ // been created (e.g., by a precompiled preamble).
+ if (!SourceMgr.getMainFileID().isInvalid()) {
+ // Do nothing: the main file has already been set.
+ } else if (InputFile != "-") {
const FileEntry *File = FileMgr.getFile(InputFile);
if (!File) {
Diags.Report(diag::err_fe_error_reading) << InputFile;