Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
cfe/trunk/lib/Frontend/CompilerInstance.cpp
Show First 20 Lines • Show All 847 Lines • ▼ Show 20 Lines | assert(SourceMgr.getMainFileID().isValid() && | ||||
"Couldn't establish MainFileID!"); | "Couldn't establish MainFileID!"); | ||||
return true; | return true; | ||||
} | } | ||||
StringRef InputFile = Input.getFile(); | StringRef InputFile = Input.getFile(); | ||||
// Figure out where to get and map in the main file. | // Figure out where to get and map in the main file. | ||||
if (InputFile != "-") { | if (InputFile != "-") { | ||||
const FileEntry *File; | const FileEntry *File = FileMgr.getFile(InputFile, /*OpenFile=*/true); | ||||
if (Opts.FindPchSource.empty()) { | |||||
File = FileMgr.getFile(InputFile, /*OpenFile=*/true); | |||||
} else { | |||||
// When building a pch file in clang-cl mode, the .h file is built as if | |||||
// it was included by a cc file. Since the driver doesn't know about | |||||
// all include search directories, the frontend must search the input | |||||
// file through HeaderSearch here, as if it had been included by the | |||||
// cc file at Opts.FindPchSource. | |||||
const FileEntry *FindFile = FileMgr.getFile(Opts.FindPchSource); | |||||
if (!FindFile) { | |||||
Diags.Report(diag::err_fe_error_reading) << Opts.FindPchSource; | |||||
return false; | |||||
} | |||||
const DirectoryLookup *UnusedCurDir; | |||||
SmallVector<std::pair<const FileEntry *, const DirectoryEntry *>, 16> | |||||
Includers; | |||||
Includers.push_back(std::make_pair(FindFile, FindFile->getDir())); | |||||
File = HS->LookupFile(InputFile, SourceLocation(), /*isAngled=*/false, | |||||
/*FromDir=*/nullptr, | |||||
/*CurDir=*/UnusedCurDir, Includers, | |||||
/*SearchPath=*/nullptr, | |||||
/*RelativePath=*/nullptr, | |||||
/*RequestingModule=*/nullptr, | |||||
/*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr, | |||||
/*SkipCache=*/true); | |||||
// Also add the header to /showIncludes output. | |||||
if (File) | |||||
DepOpts.ShowIncludesPretendHeader = File->getName(); | |||||
} | |||||
if (!File) { | if (!File) { | ||||
Diags.Report(diag::err_fe_error_reading) << InputFile; | Diags.Report(diag::err_fe_error_reading) << InputFile; | ||||
return false; | return false; | ||||
} | } | ||||
// The natural SourceManager infrastructure can't currently handle named | // The natural SourceManager infrastructure can't currently handle named | ||||
// pipes, but we would at least like to accept them for the main | // pipes, but we would at least like to accept them for the main | ||||
// file. Detect them here, read them with the volatile flag so FileMgr will | // file. Detect them here, read them with the volatile flag so FileMgr will | ||||
▲ Show 20 Lines • Show All 1,278 Lines • Show Last 20 Lines |