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:
Sean Silva 2013-01-20 01:58:28 +00:00
parent 2118a5cd2b
commit f1b49e237f
15 changed files with 17 additions and 74 deletions

View File

@ -128,7 +128,7 @@ int main(int argc, const char **argv, char * const *envp) {
Clang.setInvocation(CI.take());
// Create the compilers actual diagnostics engine.
Clang.createDiagnostics(int(CCArgs.size()),const_cast<char**>(CCArgs.data()));
Clang.createDiagnostics();
if (!Clang.hasDiagnostics())
return 1;

View File

@ -49,10 +49,6 @@ protected:
#include "clang/Basic/DiagnosticOptions.def"
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.
std::string DiagnosticLogFile;

View File

@ -215,9 +215,6 @@ def header_include_file : Separate<["-"], "header-include-file">,
// 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">,
HelpText<"Filename (or -) to log diagnostics to">;
def diagnostic_serialized_file : Separate<["-"], "serialize-diagnostic-file">,

View File

@ -479,17 +479,12 @@ public:
///
/// \param ShouldCloneClient If Client is non-NULL, specifies whether that
/// client should be cloned.
void createDiagnostics(int Argc, const char* const *Argv,
DiagnosticConsumer *Client = 0,
void createDiagnostics(DiagnosticConsumer *Client = 0,
bool ShouldOwnClient = true,
bool ShouldCloneClient = true);
/// 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
/// DiagnosticConsumer that is owned by the returned diagnostic
/// object, if using directly the caller is responsible for
@ -507,8 +502,7 @@ public:
///
/// \return The new object on success, or null on failure.
static IntrusiveRefCntPtr<DiagnosticsEngine>
createDiagnostics(DiagnosticOptions *Opts, int Argc,
const char* const *Argv,
createDiagnostics(DiagnosticOptions *Opts,
DiagnosticConsumer *Client = 0,
bool ShouldOwnClient = true,
bool ShouldCloneClient = true,

View File

@ -151,8 +151,7 @@ class ToolInvocation {
bool runInvocation(const char *BinaryName,
clang::driver::Compilation *Compilation,
clang::CompilerInvocation *Invocation,
const clang::driver::ArgStringList &CC1Args);
clang::CompilerInvocation *Invocation);
std::vector<std::string> CommandLine;
OwningPtr<FrontendAction> ToolAction;

View File

@ -656,8 +656,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr<DiagnosticsEngine> &Diags,
if (CaptureDiagnostics)
Client = new StoredDiagnosticConsumer(AST.StoredDiagnostics);
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(),
ArgEnd-ArgBegin,
ArgBegin, Client,
Client,
/*ShouldOwnClient=*/true,
/*ShouldCloneClient=*/false);
} else if (CaptureDiagnostics) {
@ -1946,9 +1945,7 @@ ASTUnit *ASTUnit::LoadFromCommandLine(const char **ArgBegin,
if (!Diags.getPtr()) {
// No diagnostics engine was provided, so create our own diagnostics object
// with the default options.
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions(),
ArgEnd - ArgBegin,
ArgBegin);
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions());
}
SmallVector<StoredDiagnostic, 4> StoredDiagnostics;

View File

@ -92,29 +92,6 @@ void CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer *Value) {
}
// 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,
const CodeGenOptions *CodeGenOpts,
DiagnosticsEngine &Diags) {
@ -167,18 +144,16 @@ static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
SerializedConsumer));
}
void CompilerInstance::createDiagnostics(int Argc, const char* const *Argv,
DiagnosticConsumer *Client,
void CompilerInstance::createDiagnostics(DiagnosticConsumer *Client,
bool ShouldOwnClient,
bool ShouldCloneClient) {
Diagnostics = createDiagnostics(&getDiagnosticOpts(), Argc, Argv, Client,
Diagnostics = createDiagnostics(&getDiagnosticOpts(), Client,
ShouldOwnClient, ShouldCloneClient,
&getCodeGenOpts());
}
IntrusiveRefCntPtr<DiagnosticsEngine>
CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
int Argc, const char* const *Argv,
DiagnosticConsumer *Client,
bool ShouldOwnClient,
bool ShouldCloneClient,
@ -205,9 +180,6 @@ CompilerInstance::createDiagnostics(DiagnosticOptions *Opts,
if (!Opts->DiagnosticLogFile.empty())
SetUpDiagnosticLog(Opts, CodeGenOpts, *Diags);
if (!Opts->DumpBuildInformation.empty())
SetUpBuildDumpLog(Opts, Argc, Argv, *Diags);
if (!Opts->DiagnosticSerializationFile.empty())
SetupSerializedDiagnostics(Opts, *Diags,
Opts->DiagnosticSerializationFile);
@ -854,8 +826,7 @@ static void compileModule(CompilerInstance &ImportingInstance,
// module.
CompilerInstance Instance;
Instance.setInvocation(&*Invocation);
Instance.createDiagnostics(/*argc=*/0, /*argv=*/0,
&ImportingInstance.getDiagnosticClient(),
Instance.createDiagnostics(&ImportingInstance.getDiagnosticClient(),
/*ShouldOwnClient=*/true,
/*ShouldCloneClient=*/true);

View File

@ -577,7 +577,6 @@ bool clang::ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
<< Opts.TabStop << DiagnosticOptions::DefaultTabStop;
}
Opts.MessageLength = Args.getLastArgIntValue(OPT_fmessage_length, 0, Diags);
Opts.DumpBuildInformation = Args.getLastArgValue(OPT_dump_build_information);
addWarningArgs(Args, Opts.Warnings);
return Success;

View File

@ -34,9 +34,7 @@ clang::createInvocationFromCommandLine(ArrayRef<const char *> ArgList,
if (!Diags.getPtr()) {
// No diagnostics engine was provided, so create our own diagnostics object
// with the default options.
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions,
ArgList.size(),
ArgList.begin());
Diags = CompilerInstance::createDiagnostics(new DiagnosticOptions);
}
SmallVector<const char *, 16> Args;

View File

@ -179,15 +179,13 @@ bool ToolInvocation::run() {
}
OwningPtr<clang::CompilerInvocation> Invocation(
newInvocation(&Diagnostics, *CC1Args));
return runInvocation(BinaryName, Compilation.get(), Invocation.take(),
*CC1Args);
return runInvocation(BinaryName, Compilation.get(), Invocation.take());
}
bool ToolInvocation::runInvocation(
const char *BinaryName,
clang::driver::Compilation *Compilation,
clang::CompilerInvocation *Invocation,
const clang::driver::ArgStringList &CC1Args) {
clang::CompilerInvocation *Invocation) {
// Show the invocation, with -v.
if (Invocation->getHeaderSearchOpts().Verbose) {
llvm::errs() << "clang Invocation:\n";
@ -207,8 +205,7 @@ bool ToolInvocation::runInvocation(
OwningPtr<FrontendAction> ScopedToolAction(ToolAction.take());
// Create the compilers actual diagnostics engine.
Compiler.createDiagnostics(CC1Args.size(),
const_cast<char**>(CC1Args.data()));
Compiler.createDiagnostics();
if (!Compiler.hasDiagnostics())
return false;

View File

@ -71,8 +71,7 @@ createDiagnostics(unsigned int argc, char **argv) {
// Build the diagnostics parser
IntrusiveRefCntPtr<DiagnosticsEngine> FinalDiags =
CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(),
argc, argv);
CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts());
if (!FinalDiags)
return NULL;

View File

@ -81,7 +81,7 @@ int cc1_main(const char **ArgBegin, const char **ArgEnd,
CompilerInvocation::GetResourcesPath(Argv0, MainAddr);
// Create the actual diagnostics engine.
Clang->createDiagnostics(ArgEnd - ArgBegin, const_cast<char**>(ArgBegin));
Clang->createDiagnostics();
if (!Clang->hasDiagnostics())
return 1;

View File

@ -2587,9 +2587,7 @@ static void clang_parseTranslationUnit_Impl(void *UserData) {
// Configure the diagnostics.
IntrusiveRefCntPtr<DiagnosticsEngine>
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions,
num_command_line_args,
command_line_args));
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
// Recover resources if we crash before exiting this function.
llvm::CrashRecoveryContextCleanupRegistrar<DiagnosticsEngine,

View File

@ -543,8 +543,6 @@ static void clang_indexSourceFile_Impl(void *UserData) {
// Configure the diagnostics.
IntrusiveRefCntPtr<DiagnosticsEngine>
Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions,
num_command_line_args,
command_line_args,
CaptureDiag,
/*ShouldOwnClient=*/true,
/*ShouldCloneClient=*/false));

View File

@ -60,7 +60,7 @@ TEST(ASTFrontendAction, Sanity) {
invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
CompilerInstance compiler;
compiler.setInvocation(invocation);
compiler.createDiagnostics(0, NULL);
compiler.createDiagnostics();
TestASTFrontendAction test_action;
ASSERT_TRUE(compiler.ExecuteAction(test_action));