forked from OSchip/llvm-project
Nuke SetUpBuildDumpLog.
Also, it was the only reason that `argc` and `argv` were being passed into createDiagnostics, so remove those parameters and clean up callers. llvm-svn: 172945
This commit is contained in:
parent
2118a5cd2b
commit
f1b49e237f
|
@ -128,7 +128,7 @@ int main(int argc, const char **argv, char * const *envp) {
|
||||||
Clang.setInvocation(CI.take());
|
Clang.setInvocation(CI.take());
|
||||||
|
|
||||||
// Create the compilers actual diagnostics engine.
|
// Create the compilers actual diagnostics engine.
|
||||||
Clang.createDiagnostics(int(CCArgs.size()),const_cast<char**>(CCArgs.data()));
|
Clang.createDiagnostics();
|
||||||
if (!Clang.hasDiagnostics())
|
if (!Clang.hasDiagnostics())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,6 @@ protected:
|
||||||
#include "clang/Basic/DiagnosticOptions.def"
|
#include "clang/Basic/DiagnosticOptions.def"
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// If non-empty, a file to log extended build information to, for development
|
|
||||||
/// testing and analysis.
|
|
||||||
std::string DumpBuildInformation;
|
|
||||||
|
|
||||||
/// The file to log diagnostic output to.
|
/// The file to log diagnostic output to.
|
||||||
std::string DiagnosticLogFile;
|
std::string DiagnosticLogFile;
|
||||||
|
|
||||||
|
|
|
@ -215,9 +215,6 @@ def header_include_file : Separate<["-"], "header-include-file">,
|
||||||
// Diagnostic Options
|
// Diagnostic Options
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
def dump_build_information : Separate<["-"], "dump-build-information">,
|
|
||||||
MetaVarName<"<filename>">,
|
|
||||||
HelpText<"output a dump of some build information to a file">;
|
|
||||||
def diagnostic_log_file : Separate<["-"], "diagnostic-log-file">,
|
def diagnostic_log_file : Separate<["-"], "diagnostic-log-file">,
|
||||||
HelpText<"Filename (or -) to log diagnostics to">;
|
HelpText<"Filename (or -) to log diagnostics to">;
|
||||||
def diagnostic_serialized_file : Separate<["-"], "serialize-diagnostic-file">,
|
def diagnostic_serialized_file : Separate<["-"], "serialize-diagnostic-file">,
|
||||||
|
|
|
@ -479,17 +479,12 @@ public:
|
||||||
///
|
///
|
||||||
/// \param ShouldCloneClient If Client is non-NULL, specifies whether that
|
/// \param ShouldCloneClient If Client is non-NULL, specifies whether that
|
||||||
/// client should be cloned.
|
/// client should be cloned.
|
||||||
void createDiagnostics(int Argc, const char* const *Argv,
|
void createDiagnostics(DiagnosticConsumer *Client = 0,
|
||||||
DiagnosticConsumer *Client = 0,
|
|
||||||
bool ShouldOwnClient = true,
|
bool ShouldOwnClient = true,
|
||||||
bool ShouldCloneClient = true);
|
bool ShouldCloneClient = true);
|
||||||
|
|
||||||
/// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
|
/// Create a DiagnosticsEngine object with a the TextDiagnosticPrinter.
|
||||||
///
|
///
|
||||||
/// The \p Argc and \p Argv arguments are used only for logging purposes,
|
|
||||||
/// when the diagnostic options indicate that the compiler should output
|
|
||||||
/// logging information.
|
|
||||||
///
|
|
||||||
/// If no diagnostic client is provided, this creates a
|
/// If no diagnostic client is provided, this creates a
|
||||||
/// DiagnosticConsumer that is owned by the returned diagnostic
|
/// DiagnosticConsumer that is owned by the returned diagnostic
|
||||||
/// object, if using directly the caller is responsible for
|
/// object, if using directly the caller is responsible for
|
||||||
|
@ -507,8 +502,7 @@ public:
|
||||||
///
|
///
|
||||||
/// \return The new object on success, or null on failure.
|
/// \return The new object on success, or null on failure.
|
||||||
static IntrusiveRefCntPtr<DiagnosticsEngine>
|
static IntrusiveRefCntPtr<DiagnosticsEngine>
|
||||||
createDiagnostics(DiagnosticOptions *Opts, int Argc,
|
createDiagnostics(DiagnosticOptions *Opts,
|
||||||
const char* const *Argv,
|
|
||||||
DiagnosticConsumer *Client = 0,
|
DiagnosticConsumer *Client = 0,
|
||||||
bool ShouldOwnClient = true,
|
bool ShouldOwnClient = true,
|
||||||
bool ShouldCloneClient = true,
|
bool ShouldCloneClient = true,
|
||||||
|
|
|
@ -151,8 +151,7 @@ class ToolInvocation {
|
||||||
|
|
||||||
bool runInvocation(const char *BinaryName,
|
bool runInvocation(const char *BinaryName,
|
||||||
clang::driver::Compilation *Compilation,
|
clang::driver::Compilation *Compilation,
|
||||||
clang::CompilerInvocation *Invocation,
|
clang::CompilerInvocation *Invocation);
|
||||||
const clang::driver::ArgStringList &CC1Args);
|
|
||||||
|
|
||||||
std::vector<std::string> CommandLine;
|
std::vector<std::string> CommandLine;
|
||||||
OwningPtr<FrontendAction> ToolAction;
|
OwningPtr<FrontendAction> ToolAction;
|
||||||
|
|
|
@ -656,8 +656,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> &Diags,
|
||||||
if (CaptureDiagnostics)
|
if (CaptureDiagnostics)
|
||||||
Client = new StoredDiagnosticConsumer(AST.StoredDiagnostics);
|
Client = new StoredDiagnosticConsumer(AST.StoredDiagnostics);
|
||||||
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(),
|
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(),
|
||||||
ArgEnd-ArgBegin,
|
Client,
|
||||||
ArgBegin, Client,
|
|
||||||
/*ShouldOwnClient=*/true,
|
/*ShouldOwnClient=*/true,
|
||||||
/*ShouldCloneClient=*/false);
|
/*ShouldCloneClient=*/false);
|
||||||
} else if (CaptureDiagnostics) {
|
} else if (CaptureDiagnostics) {
|
||||||
|
@ -1946,9 +1945,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
|
||||||
if (!Diags.getPtr()) {
|
if (!Diags.getPtr()) {
|
||||||
// No diagnostics engine was provided, so create our own diagnostics object
|
// No diagnostics engine was provided, so create our own diagnostics object
|
||||||
// with the default options.
|
// with the default options.
|
||||||
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(),
|
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions());
|
||||||
ArgEnd - ArgBegin,
|
|
||||||
ArgBegin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
|
SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
|
||||||
|
|
|
@ -92,29 +92,6 @@ void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Diagnostics
|
// Diagnostics
|
||||||
static void SetUpBuildDumpLog(DiagnosticOptions *DiagOpts,
|
|
||||||
unsigned argc, const char* const *argv,
|
|
||||||
DiagnosticsEngine &Diags) {
|
|
||||||
std::string ErrorInfo;
|
|
||||||
OwningPtr<raw_ostream> OS(
|
|
||||||
new llvm::raw_fd_ostream(DiagOpts->DumpBuildInformation.c_str(),ErrorInfo));
|
|
||||||
if (!ErrorInfo.empty()) {
|
|
||||||
Diags.Report(diag::err_fe_unable_to_open_logfile)
|
|
||||||
<< DiagOpts->DumpBuildInformation << ErrorInfo;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
(*OS) << "clang -cc1 command line arguments: ";
|
|
||||||
for (unsigned i = 0; i != argc; ++i)
|
|
||||||
(*OS) << argv[i] << ' ';
|
|
||||||
(*OS) << '\n';
|
|
||||||
|
|
||||||
// Chain in a diagnostic client which will log the diagnostics.
|
|
||||||
DiagnosticConsumer *Logger =
|
|
||||||
new TextDiagnosticPrinter(*OS.take(), DiagOpts, /*OwnsOutputStream=*/true);
|
|
||||||
Diags.setClient(new ChainedDiagnosticConsumer(Diags.takeClient(), Logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
static void SetUpDiagnosticLog(DiagnosticOptions *DiagOpts,
|
||||||
const CodeGenOptions *CodeGenOpts,
|
const CodeGenOptions *CodeGenOpts,
|
||||||
DiagnosticsEngine &Diags) {
|
DiagnosticsEngine &Diags) {
|
||||||
|
@ -167,18 +144,16 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
|
||||||
SerializedConsumer));
|
SerializedConsumer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompilerInstance::createDiagnostics(int Argc, const char* const *Argv,
|
void CompilerInstance::createDiagnostics(DiagnosticConsumer *Client,
|
||||||
DiagnosticConsumer *Client,
|
|
||||||
bool ShouldOwnClient,
|
bool ShouldOwnClient,
|
||||||
bool ShouldCloneClient) {
|
bool ShouldCloneClient) {
|
||||||
Diagnostics = createDiagnostics(&getDiagnosticOpts(), Argc, Argv, Client,
|
Diagnostics = createDiagnostics(&getDiagnosticOpts(), Client,
|
||||||
ShouldOwnClient, ShouldCloneClient,
|
ShouldOwnClient, ShouldCloneClient,
|
||||||
&getCodeGenOpts());
|
&getCodeGenOpts());
|
||||||
}
|
}
|
||||||
|
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine>
|
IntrusiveRefCntPtr<DiagnosticsEngine>
|
||||||
CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
|
CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
|
||||||
int Argc, const char* const *Argv,
|
|
||||||
DiagnosticConsumer *Client,
|
DiagnosticConsumer *Client,
|
||||||
bool ShouldOwnClient,
|
bool ShouldOwnClient,
|
||||||
bool ShouldCloneClient,
|
bool ShouldCloneClient,
|
||||||
|
@ -205,9 +180,6 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
|
||||||
if (!Opts->DiagnosticLogFile.empty())
|
if (!Opts->DiagnosticLogFile.empty())
|
||||||
SetUpDiagnosticLog(Opts, CodeGenOpts, *Diags);
|
SetUpDiagnosticLog(Opts, CodeGenOpts, *Diags);
|
||||||
|
|
||||||
if (!Opts->DumpBuildInformation.empty())
|
|
||||||
SetUpBuildDumpLog(Opts, Argc, Argv, *Diags);
|
|
||||||
|
|
||||||
if (!Opts->DiagnosticSerializationFile.empty())
|
if (!Opts->DiagnosticSerializationFile.empty())
|
||||||
SetupSerializedDiagnostics(Opts, *Diags,
|
SetupSerializedDiagnostics(Opts, *Diags,
|
||||||
Opts->DiagnosticSerializationFile);
|
Opts->DiagnosticSerializationFile);
|
||||||
|
@ -854,8 +826,7 @@ static void compileModule(CompilerInstance &ImportingInstance,
|
||||||
// module.
|
// module.
|
||||||
CompilerInstance Instance;
|
CompilerInstance Instance;
|
||||||
Instance.setInvocation(&*Invocation);
|
Instance.setInvocation(&*Invocation);
|
||||||
Instance.createDiagnostics(/*argc=*/0, /*argv=*/0,
|
Instance.createDiagnostics(&ImportingInstance.getDiagnosticClient(),
|
||||||
&ImportingInstance.getDiagnosticClient(),
|
|
||||||
/*ShouldOwnClient=*/true,
|
/*ShouldOwnClient=*/true,
|
||||||
/*ShouldCloneClient=*/true);
|
/*ShouldCloneClient=*/true);
|
||||||
|
|
||||||
|
|
|
@ -577,7 +577,6 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
|
||||||
<< Opts.TabStop << DiagnosticOptions::DefaultTabStop;
|
<< Opts.TabStop << DiagnosticOptions::DefaultTabStop;
|
||||||
}
|
}
|
||||||
Opts.MessageLength = Args.getLastArgIntValue(OPT_fmessage_length, 0, Diags);
|
Opts.MessageLength = Args.getLastArgIntValue(OPT_fmessage_length, 0, Diags);
|
||||||
Opts.DumpBuildInformation = Args.getLastArgValue(OPT_dump_build_information);
|
|
||||||
addWarningArgs(Args, Opts.Warnings);
|
addWarningArgs(Args, Opts.Warnings);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
|
|
@ -34,9 +34,7 @@ clang::createInvocationFromCommandLine(ArrayRef<const char *> ArgList,
|
||||||
if (!Diags.getPtr()) {
|
if (!Diags.getPtr()) {
|
||||||
// No diagnostics engine was provided, so create our own diagnostics object
|
// No diagnostics engine was provided, so create our own diagnostics object
|
||||||
// with the default options.
|
// with the default options.
|
||||||
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions,
|
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions);
|
||||||
ArgList.size(),
|
|
||||||
ArgList.begin());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SmallVector<const char *, 16> Args;
|
SmallVector<const char *, 16> Args;
|
||||||
|
|
|
@ -179,15 +179,13 @@ bool ToolInvocation::run() {
|
||||||
}
|
}
|
||||||
OwningPtr<clang::CompilerInvocation> Invocation(
|
OwningPtr<clang::CompilerInvocation> Invocation(
|
||||||
newInvocation(&Diagnostics, *CC1Args));
|
newInvocation(&Diagnostics, *CC1Args));
|
||||||
return runInvocation(BinaryName, Compilation.get(), Invocation.take(),
|
return runInvocation(BinaryName, Compilation.get(), Invocation.take());
|
||||||
*CC1Args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToolInvocation::runInvocation(
|
bool ToolInvocation::runInvocation(
|
||||||
const char *BinaryName,
|
const char *BinaryName,
|
||||||
clang::driver::Compilation *Compilation,
|
clang::driver::Compilation *Compilation,
|
||||||
clang::CompilerInvocation *Invocation,
|
clang::CompilerInvocation *Invocation) {
|
||||||
const clang::driver::ArgStringList &CC1Args) {
|
|
||||||
// Show the invocation, with -v.
|
// Show the invocation, with -v.
|
||||||
if (Invocation->getHeaderSearchOpts().Verbose) {
|
if (Invocation->getHeaderSearchOpts().Verbose) {
|
||||||
llvm::errs() << "clang Invocation:\n";
|
llvm::errs() << "clang Invocation:\n";
|
||||||
|
@ -207,8 +205,7 @@ bool ToolInvocation::runInvocation(
|
||||||
OwningPtr<FrontendAction> ScopedToolAction(ToolAction.take());
|
OwningPtr<FrontendAction> ScopedToolAction(ToolAction.take());
|
||||||
|
|
||||||
// Create the compilers actual diagnostics engine.
|
// Create the compilers actual diagnostics engine.
|
||||||
Compiler.createDiagnostics(CC1Args.size(),
|
Compiler.createDiagnostics();
|
||||||
const_cast<char**>(CC1Args.data()));
|
|
||||||
if (!Compiler.hasDiagnostics())
|
if (!Compiler.hasDiagnostics())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,7 @@ createDiagnostics(unsigned int argc, char **argv) {
|
||||||
|
|
||||||
// Build the diagnostics parser
|
// Build the diagnostics parser
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine> FinalDiags =
|
IntrusiveRefCntPtr<DiagnosticsEngine> FinalDiags =
|
||||||
CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(),
|
CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts());
|
||||||
argc, argv);
|
|
||||||
if (!FinalDiags)
|
if (!FinalDiags)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
|
||||||
CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
|
CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
|
||||||
|
|
||||||
// Create the actual diagnostics engine.
|
// Create the actual diagnostics engine.
|
||||||
Clang->createDiagnostics(ArgEnd - ArgBegin, const_cast<char**>(ArgBegin));
|
Clang->createDiagnostics();
|
||||||
if (!Clang->hasDiagnostics())
|
if (!Clang->hasDiagnostics())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -2587,9 +2587,7 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
|
||||||
|
|
||||||
// Configure the diagnostics.
|
// Configure the diagnostics.
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine>
|
IntrusiveRefCntPtr<DiagnosticsEngine>
|
||||||
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions,
|
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
|
||||||
num_command_line_args,
|
|
||||||
command_line_args));
|
|
||||||
|
|
||||||
// Recover resources if we crash before exiting this function.
|
// Recover resources if we crash before exiting this function.
|
||||||
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
|
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,
|
||||||
|
|
|
@ -543,8 +543,6 @@ static void clang_indexSourceFile_Impl(void *UserData) {
|
||||||
// Configure the diagnostics.
|
// Configure the diagnostics.
|
||||||
IntrusiveRefCntPtr<DiagnosticsEngine>
|
IntrusiveRefCntPtr<DiagnosticsEngine>
|
||||||
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions,
|
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions,
|
||||||
num_command_line_args,
|
|
||||||
command_line_args,
|
|
||||||
CaptureDiag,
|
CaptureDiag,
|
||||||
/*ShouldOwnClient=*/true,
|
/*ShouldOwnClient=*/true,
|
||||||
/*ShouldCloneClient=*/false));
|
/*ShouldCloneClient=*/false));
|
||||||
|
|
|
@ -60,7 +60,7 @@ TEST(ASTFrontendAction, Sanity) {
|
||||||
invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
|
invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
|
||||||
CompilerInstance compiler;
|
CompilerInstance compiler;
|
||||||
compiler.setInvocation(invocation);
|
compiler.setInvocation(invocation);
|
||||||
compiler.createDiagnostics(0, NULL);
|
compiler.createDiagnostics();
|
||||||
|
|
||||||
TestASTFrontendAction test_action;
|
TestASTFrontendAction test_action;
|
||||||
ASSERT_TRUE(compiler.ExecuteAction(test_action));
|
ASSERT_TRUE(compiler.ExecuteAction(test_action));
|
||||||
|
|
Loading…
Reference in New Issue