From 936a5b44eea36a698946dde3b0a1e35b21244209 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 30 Nov 2010 05:23:00 +0000 Subject: 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 --- clang/lib/Frontend/CompilerInstance.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/Frontend/CompilerInstance.cpp') 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; -- cgit v1.1