clang -cc1: Move real diagnostics client initialization to earlier.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110902 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2010-08-12 02:53:07 +00:00
Родитель 507384f007
Коммит a6bf47f855
1 изменённых файлов: 14 добавлений и 13 удалений

Просмотреть файл

@ -222,6 +222,18 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
Clang->getHeaderSearchOpts().ResourceDir =
CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
// Create the actual diagnostics engine.
Clang->createDiagnostics(ArgEnd - ArgBegin, const_cast<char**>(ArgBegin));
if (!Clang->hasDiagnostics())
return 1;
// Set an error handler, so that any LLVM backend diagnostics go through our
// error handler.
llvm::install_fatal_error_handler(LLVMErrorHandler,
static_cast<void*>(&Clang->getDiagnostics()));
DiagsBuffer.FlushDiagnostics(Clang->getDiagnostics());
// Honor -help.
if (Clang->getFrontendOpts().ShowHelp) {
llvm::OwningPtr<driver::OptTable> Opts(driver::createCC1OptTable());
@ -251,25 +263,14 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
llvm::cl::ParseCommandLineOptions(NumArgs + 1, const_cast<char **>(Args));
}
// Create the actual diagnostics engine.
Clang->createDiagnostics(ArgEnd - ArgBegin, const_cast<char**>(ArgBegin));
if (!Clang->hasDiagnostics())
return 1;
// Set an error handler, so that any LLVM backend diagnostics go through our
// error handler.
llvm::install_fatal_error_handler(LLVMErrorHandler,
static_cast<void*>(&Clang->getDiagnostics()));
DiagsBuffer.FlushDiagnostics(Clang->getDiagnostics());
// Load any requested plugins.
for (unsigned i = 0,
e = Clang->getFrontendOpts().Plugins.size(); i != e; ++i) {
const std::string &Path = Clang->getFrontendOpts().Plugins[i];
std::string Error;
if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error))
Diags.Report(diag::err_fe_unable_to_load_plugin) << Path << Error;
Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin)
<< Path << Error;
}
// If there were errors in processing arguments, don't do anything else.