From d47afb96a3f988e6d21a92fe4dfe875ab227c7c0 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Sun, 20 Jan 2013 01:58:28 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172945 91177308-0d34-0410-b5e6-96231b3b80d8 --- examples/clang-interpreter/main.cpp | 2 +- include/clang/Basic/DiagnosticOptions.h | 4 --- include/clang/Driver/CC1Options.td | 3 -- include/clang/Frontend/CompilerInstance.h | 10 ++---- include/clang/Tooling/Tooling.h | 3 +- lib/Frontend/ASTUnit.cpp | 7 ++-- lib/Frontend/CompilerInstance.cpp | 35 ++----------------- lib/Frontend/CompilerInvocation.cpp | 1 - .../CreateInvocationFromCommandLine.cpp | 4 +-- lib/Tooling/Tooling.cpp | 9 ++--- tools/diagtool/ShowEnabledWarnings.cpp | 3 +- tools/driver/cc1_main.cpp | 2 +- tools/libclang/CIndex.cpp | 4 +-- tools/libclang/Indexing.cpp | 2 -- unittests/Frontend/FrontendActionTest.cpp | 2 +- 15 files changed, 17 insertions(+), 74 deletions(-) diff --git a/examples/clang-interpreter/main.cpp b/examples/clang-interpreter/main.cpp index 4d4654ead7..3d0d6409d9 100644 --- a/examples/clang-interpreter/main.cpp +++ b/examples/clang-interpreter/main.cpp @@ -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(CCArgs.data())); + Clang.createDiagnostics(); if (!Clang.hasDiagnostics()) return 1; diff --git a/include/clang/Basic/DiagnosticOptions.h b/include/clang/Basic/DiagnosticOptions.h index 2b80e9b9ea..1a68d95765 100644 --- a/include/clang/Basic/DiagnosticOptions.h +++ b/include/clang/Basic/DiagnosticOptions.h @@ -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; diff --git a/include/clang/Driver/CC1Options.td b/include/clang/Driver/CC1Options.td index af06f2ee91..d485303350 100644 --- a/include/clang/Driver/CC1Options.td +++ b/include/clang/Driver/CC1Options.td @@ -215,9 +215,6 @@ def header_include_file : Separate<["-"], "header-include-file">, // Diagnostic Options //===----------------------------------------------------------------------===// -def dump_build_information : Separate<["-"], "dump-build-information">, - MetaVarName<"">, - 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">, diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h index 2d6a8702dc..492a3c57cd 100644 --- a/include/clang/Frontend/CompilerInstance.h +++ b/include/clang/Frontend/CompilerInstance.h @@ -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 - createDiagnostics(DiagnosticOptions *Opts, int Argc, - const char* const *Argv, + createDiagnostics(DiagnosticOptions *Opts, DiagnosticConsumer *Client = 0, bool ShouldOwnClient = true, bool ShouldCloneClient = true, diff --git a/include/clang/Tooling/Tooling.h b/include/clang/Tooling/Tooling.h index 6d92442457..27e5a0af25 100644 --- a/include/clang/Tooling/Tooling.h +++ b/include/clang/Tooling/Tooling.h @@ -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 CommandLine; OwningPtr ToolAction; diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index a958fd93d6..9ab3a8faba 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -656,8 +656,7 @@ void ASTUnit::ConfigureDiags(IntrusiveRefCntPtr &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 StoredDiagnostics; diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index 8ceb9f72fd..9941eae8d4 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -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 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 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); diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index 2c02c423c1..9329b3bc1b 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -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; diff --git a/lib/Frontend/CreateInvocationFromCommandLine.cpp b/lib/Frontend/CreateInvocationFromCommandLine.cpp index 1ce23f737e..e25eb4322c 100644 --- a/lib/Frontend/CreateInvocationFromCommandLine.cpp +++ b/lib/Frontend/CreateInvocationFromCommandLine.cpp @@ -34,9 +34,7 @@ clang::createInvocationFromCommandLine(ArrayRef 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 Args; diff --git a/lib/Tooling/Tooling.cpp b/lib/Tooling/Tooling.cpp index ac378a9984..a9e7b84808 100644 --- a/lib/Tooling/Tooling.cpp +++ b/lib/Tooling/Tooling.cpp @@ -179,15 +179,13 @@ bool ToolInvocation::run() { } OwningPtr 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 ScopedToolAction(ToolAction.take()); // Create the compilers actual diagnostics engine. - Compiler.createDiagnostics(CC1Args.size(), - const_cast(CC1Args.data())); + Compiler.createDiagnostics(); if (!Compiler.hasDiagnostics()) return false; diff --git a/tools/diagtool/ShowEnabledWarnings.cpp b/tools/diagtool/ShowEnabledWarnings.cpp index abd69fd0af..bcc7520c1b 100644 --- a/tools/diagtool/ShowEnabledWarnings.cpp +++ b/tools/diagtool/ShowEnabledWarnings.cpp @@ -71,8 +71,7 @@ createDiagnostics(unsigned int argc, char **argv) { // Build the diagnostics parser IntrusiveRefCntPtr FinalDiags = - CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts(), - argc, argv); + CompilerInstance::createDiagnostics(&Invocation->getDiagnosticOpts()); if (!FinalDiags) return NULL; diff --git a/tools/driver/cc1_main.cpp b/tools/driver/cc1_main.cpp index 6e1920022f..f54c87898c 100644 --- a/tools/driver/cc1_main.cpp +++ b/tools/driver/cc1_main.cpp @@ -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(ArgBegin)); + Clang->createDiagnostics(); if (!Clang->hasDiagnostics()) return 1; diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 7d999b86fb..f8c6f69096 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -2587,9 +2587,7 @@ static void clang_parseTranslationUnit_Impl(void *UserData) { // Configure the diagnostics. IntrusiveRefCntPtr - 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 Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions, - num_command_line_args, - command_line_args, CaptureDiag, /*ShouldOwnClient=*/true, /*ShouldCloneClient=*/false)); diff --git a/unittests/Frontend/FrontendActionTest.cpp b/unittests/Frontend/FrontendActionTest.cpp index e70c3b85e0..bcb340d668 100644 --- a/unittests/Frontend/FrontendActionTest.cpp +++ b/unittests/Frontend/FrontendActionTest.cpp @@ -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)); -- 2.40.0