diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-12-02 18:12:28 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-12-02 18:12:28 +0000 |
commit | 407e2124bf2d692fb147e111f668f6869ae19990 (patch) | |
tree | 06889de567f2563abbba650a6026b50670b7c8f3 /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | f98849eb8aa991668e5c47eeb7b2899772af3810 (diff) | |
download | bcm5719-llvm-407e2124bf2d692fb147e111f668f6869ae19990.tar.gz bcm5719-llvm-407e2124bf2d692fb147e111f668f6869ae19990.zip |
Extend -remap-file=from;to to permit mapping from a non-existent
file. This is accomplished by introducing the notion of a "virtual"
file into the file manager, which provides a FileEntry* for a named
file whose size and modification time are known but which may not
exist on disk.
Added a cute little test that remaps both a .c file and a .h file it
includes to alternative files.
llvm-svn: 90329
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 9c42993cf05..aa05b34ef5c 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -19,6 +19,7 @@ #include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/System/Path.h" @@ -502,11 +503,11 @@ static void InitializeFileRemapping(Diagnostic &Diags, continue; } - // Find the file that we're mapping from. - const FileEntry *FromFile = FileMgr.getFile(Remap->first); + // Create the file entry for the file that we're mapping from. + const FileEntry *FromFile = FileMgr.getVirtualFile(Remap->first, + ToFile->getSize(), + 0); if (!FromFile) { - // FIXME: We could actually recover from this, by faking a - // FileEntry based on the "ToFile". Diags.Report(diag::err_fe_remap_missing_from_file) << Remap->first; continue; |