diff options
author | Alp Toker <alp@nuanti.com> | 2014-07-07 06:05:00 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-07-07 06:05:00 +0000 |
commit | c358000ed34f074d9393fce692b67b32e370f09a (patch) | |
tree | 639a6faaf47c5003404ba46ad19337a25d2e830c /clang/lib/Frontend/InitPreprocessor.cpp | |
parent | 22a5d61b5d3913b5967f5fa43ed4b1764a131a62 (diff) | |
download | llvm-c358000ed34f074d9393fce692b67b32e370f09a.zip llvm-c358000ed34f074d9393fce692b67b32e370f09a.tar.gz llvm-c358000ed34f074d9393fce692b67b32e370f09a.tar.bz2 |
Fix layering of file remapping and header search initialization
These two functions initialize the source manager and header search objects and
shouldn't be in InitPreprocessor which is concerned with priming the
preprocessor itself and predefining macros.
llvm-svn: 212434
Diffstat (limited to 'clang/lib/Frontend/InitPreprocessor.cpp')
-rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index 77099395..f987236 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -835,74 +835,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI, TI.getTargetDefines(LangOpts, Builder); } -// Initialize the remapping of files to alternative contents, e.g., -// those specified through other files. -static void InitializeFileRemapping(DiagnosticsEngine &Diags, - SourceManager &SourceMgr, - FileManager &FileMgr, - const PreprocessorOptions &InitOpts) { - // Remap files in the source manager (with buffers). - for (PreprocessorOptions::const_remapped_file_buffer_iterator - Remap = InitOpts.remapped_file_buffer_begin(), - RemapEnd = InitOpts.remapped_file_buffer_end(); - Remap != RemapEnd; - ++Remap) { - // Create the file entry for the file that we're mapping from. - const FileEntry *FromFile = FileMgr.getVirtualFile(Remap->first, - Remap->second->getBufferSize(), - 0); - if (!FromFile) { - Diags.Report(diag::err_fe_remap_missing_from_file) - << Remap->first; - if (!InitOpts.RetainRemappedFileBuffers) - delete Remap->second; - continue; - } - - // Override the contents of the "from" file with the contents of - // the "to" file. - SourceMgr.overrideFileContents(FromFile, Remap->second, - InitOpts.RetainRemappedFileBuffers); - } - - // Remap files in the source manager (with other files). - for (PreprocessorOptions::const_remapped_file_iterator - Remap = InitOpts.remapped_file_begin(), - RemapEnd = InitOpts.remapped_file_end(); - Remap != RemapEnd; - ++Remap) { - // Find the file that we're mapping to. - const FileEntry *ToFile = FileMgr.getFile(Remap->second); - if (!ToFile) { - Diags.Report(diag::err_fe_remap_missing_to_file) - << Remap->first << Remap->second; - continue; - } - - // Create the file entry for the file that we're mapping from. - const FileEntry *FromFile = FileMgr.getVirtualFile(Remap->first, - ToFile->getSize(), 0); - if (!FromFile) { - Diags.Report(diag::err_fe_remap_missing_from_file) - << Remap->first; - continue; - } - - // Override the contents of the "from" file with the contents of - // the "to" file. - SourceMgr.overrideFileContents(FromFile, ToFile); - } - - SourceMgr.setOverridenFilesKeepOriginalName( - InitOpts.RemappedFilesKeepOriginalName); -} - /// InitializePreprocessor - Initialize the preprocessor getting it and the /// environment ready to process a single file. This returns true on error. /// void clang::InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions &InitOpts, - const HeaderSearchOptions &HSOpts, const FrontendOptions &FEOpts) { const LangOptions &LangOpts = PP.getLangOpts(); std::string PredefineBuffer; @@ -910,9 +847,6 @@ void clang::InitializePreprocessor(Preprocessor &PP, llvm::raw_string_ostream Predefines(PredefineBuffer); MacroBuilder Builder(Predefines); - InitializeFileRemapping(PP.getDiagnostics(), PP.getSourceManager(), - PP.getFileManager(), InitOpts); - // Emit line markers for various builtin sections of the file. We don't do // this in asm preprocessor mode, because "# 4" is not a line marker directive // in this mode. @@ -986,9 +920,4 @@ void clang::InitializePreprocessor(Preprocessor &PP, // Copy PredefinedBuffer into the Preprocessor. PP.setPredefines(Predefines.str()); - - // Initialize the header search object. - ApplyHeaderSearchOptions(PP.getHeaderSearchInfo(), HSOpts, - PP.getLangOpts(), - PP.getTargetInfo().getTriple()); } |