r201082 - ASTUnit: simplify remapping files by using the exact same logic in Preprocessor
Dmitri Gribenko
gribozavr at gmail.com
Mon Feb 10 04:31:35 PST 2014
Author: gribozavr
Date: Mon Feb 10 06:31:34 2014
New Revision: 201082
URL: http://llvm.org/viewvc/llvm-project?rev=201082&view=rev
Log:
ASTUnit: simplify remapping files by using the exact same logic in Preprocessor
Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=201082&r1=201081&r2=201082&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Feb 10 06:31:34 2014
@@ -711,22 +711,10 @@ ASTUnit *ASTUnit::LoadFromASTFile(const
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;
- }
-
- // Override the contents of the "from" file with the contents of
- // the "to" file.
- AST->getSourceManager().overrideFileContents(FromFile, MemBuf);
- }
+ PreprocessorOptions *PPOpts = new PreprocessorOptions();
+
+ 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
OwningPtr<ASTReader> Reader;
- AST->PP = new Preprocessor(new PreprocessorOptions(),
+ AST->PP = new Preprocessor(PPOpts,
AST->getDiagnostics(), AST->ASTFileLangOpts,
/*Target=*/0, AST->getSourceManager(), HeaderInfo,
*AST,
More information about the cfe-commits
mailing list