diff options
| author | Dmitri Gribenko <gribozavr@gmail.com> | 2014-02-10 12:31:34 +0000 |
|---|---|---|
| committer | Dmitri Gribenko <gribozavr@gmail.com> | 2014-02-10 12:31:34 +0000 |
| commit | b41e7e2c926206f8bb74797ebd2a85340e220628 (patch) | |
| tree | 478f88731544620f9c650c1512455edf7cd31c41 /clang/lib | |
| parent | 4b27eb588cd95d953110e1eb009f5e5018a9955c (diff) | |
| download | bcm5719-llvm-b41e7e2c926206f8bb74797ebd2a85340e220628.tar.gz bcm5719-llvm-b41e7e2c926206f8bb74797ebd2a85340e220628.zip | |
ASTUnit: simplify remapping files by using the exact same logic in Preprocessor
llvm-svn: 201082
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Frontend/ASTUnit.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp index 37838ea46fa..dd08282252f 100644 --- a/clang/lib/Frontend/ASTUnit.cpp +++ b/clang/lib/Frontend/ASTUnit.cpp @@ -711,22 +711,10 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, AST->ASTFileLangOpts, /*Target=*/0)); - for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) { - const llvm::MemoryBuffer *MemBuf = RemappedFiles[I].second; - // Create the file entry for the file that we're mapping from. - const FileEntry *FromFile = AST->getFileManager().getVirtualFile( - RemappedFiles[I].first, MemBuf->getBufferSize(), 0); - if (!FromFile) { - AST->getDiagnostics().Report(diag::err_fe_remap_missing_from_file) - << RemappedFiles[I].first; - delete MemBuf; - continue; - } + PreprocessorOptions *PPOpts = new PreprocessorOptions(); - // Override the contents of the "from" file with the contents of - // the "to" file. - AST->getSourceManager().overrideFileContents(FromFile, MemBuf); - } + for (unsigned I = 0, N = RemappedFiles.size(); I != N; ++I) + PPOpts->addRemappedFile(RemappedFiles[I].first, RemappedFiles[I].second); // Gather Info for preprocessor construction later on. @@ -735,7 +723,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename, OwningPtr<ASTReader> Reader; - AST->PP = new Preprocessor(new PreprocessorOptions(), + AST->PP = new Preprocessor(PPOpts, AST->getDiagnostics(), AST->ASTFileLangOpts, /*Target=*/0, AST->getSourceManager(), HeaderInfo, *AST, |

