Frontend: Fix layering between create{,Default}OutputFile, NFC

Authored by dexonsmith on Nov 20 2020, 6:04 PM.


Frontend: Fix layering between create{,Default}OutputFile, NFC

Fix layering between CompilerInstance::createDefaultOutputFile and the
two versions of createOutputFile.

  • Add missing configuration flags to createDefaultOutputFile so that GeneratePCHAction and GenerateModuleFromModuleMapAction can use it. They previously promised that temporary files were turned on; now createDefaultOutputFile handles that logic.
  • Lift the logic handling InFile and Extension to createDefaultOutputFile, since it's only the callers of that function that are using it.
  • Rename the deeper of the two createOutputFiles to createOutputFileImpl and make it private to CompilerInstance (to prove that no one else is using it).
  • Sink the logic for adding to CompilerInstance::OutputFiles down to createOutputFileImpl, allowing two "optional" (but always used) std::string* out parameters to be removed.
  • Instead of passing a std::error_code out parameter into createOutputFileImpl, have it return Expected<>.
  • As a drive-by, inline CompilerInstance::addOutputFile into its only caller, createOutputFileImpl.

Clean layering makes it easier for a future commit to extract
createOutputFileImpl out of CompilerInstance.

Differential Revision: https://reviews.llvm.org/D93248