From: Daniel Dunbar Date: Thu, 12 Nov 2009 07:28:21 +0000 (+0000) Subject: Move dump-build-information option into DiagnosticOptions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11e729d295378bdc185c8fb87d3326f24d1840d0;p=clang Move dump-build-information option into DiagnosticOptions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86966 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/DiagnosticOptions.h b/include/clang/Frontend/DiagnosticOptions.h index 58673e4dad..39dc48ebfe 100644 --- a/include/clang/Frontend/DiagnosticOptions.h +++ b/include/clang/Frontend/DiagnosticOptions.h @@ -31,6 +31,10 @@ public: /// Column limit for formatting message diagnostics, or 0 if unused. unsigned MessageLength; + /// If non-empty, a file to log extended build information to, for development + /// testing and analysis. + std::string DumpBuildInformation; + public: DiagnosticOptions() { ShowColumn = 1; diff --git a/tools/clang-cc/Options.cpp b/tools/clang-cc/Options.cpp index e2b493148b..7c716406ce 100644 --- a/tools/clang-cc/Options.cpp +++ b/tools/clang-cc/Options.cpp @@ -221,6 +221,11 @@ PhonyDependencyTarget("MP", namespace diagnosticoptions { +static llvm::cl::opt +DumpBuildInformation("dump-build-information", + llvm::cl::value_desc("filename"), + llvm::cl::desc("output a dump of some build information to a file")); + static llvm::cl::opt NoShowColumn("fno-show-column", llvm::cl::desc("Do not include column number on diagnostics")); @@ -659,14 +664,15 @@ void clang::InitializeDependencyOutputOptions(DependencyOutputOptions &Opts) { void clang::InitializeDiagnosticOptions(DiagnosticOptions &Opts) { using namespace diagnosticoptions; - Opts.ShowColumn = !NoShowColumn; - Opts.ShowLocation = !NoShowLocation; + Opts.DumpBuildInformation = DumpBuildInformation; + Opts.MessageLength = MessageLength; Opts.ShowCarets = !NoCaretDiagnostics; + Opts.ShowColors = PrintColorDiagnostic; + Opts.ShowColumn = !NoShowColumn; Opts.ShowFixits = !NoDiagnosticsFixIt; - Opts.ShowSourceRanges = PrintSourceRangeInfo; + Opts.ShowLocation = !NoShowLocation; Opts.ShowOptionNames = PrintDiagnosticOption; - Opts.ShowColors = PrintColorDiagnostic; - Opts.MessageLength = MessageLength; + Opts.ShowSourceRanges = PrintSourceRangeInfo; } void clang::InitializeHeaderSearchOptions(HeaderSearchOptions &Opts, diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index cb00ae3b9e..f2b38401e7 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -341,9 +341,10 @@ RelocatablePCH("relocatable-pch", llvm::cl::desc("Whether to build a relocatable precompiled " "header")); -// Finally, implement the code that groks the options above. +//===----------------------------------------------------------------------===// +// Preprocessor construction +//===----------------------------------------------------------------------===// -// Add the clang headers, which are relative to the clang binary. std::string GetBuiltinIncludePath(const char *Argv0) { llvm::sys::Path P = llvm::sys::Path::GetMainExecutable(Argv0, @@ -363,10 +364,6 @@ std::string GetBuiltinIncludePath(const char *Argv0) { return P.str(); } -//===----------------------------------------------------------------------===// -// Preprocessor construction -//===----------------------------------------------------------------------===// - static Preprocessor * CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo, const PreprocessorOptions &PPOpts, @@ -433,6 +430,7 @@ FixItAtLocations("fixit-at", llvm::cl::value_desc("source-location"), //===----------------------------------------------------------------------===// // ObjC Rewriter Options //===----------------------------------------------------------------------===// + static llvm::cl::opt SilenceRewriteMacroWarning("Wno-rewrite-macros", llvm::cl::init(false), llvm::cl::desc("Silence ObjC rewriting warnings")); @@ -452,23 +450,18 @@ static llvm::cl::opt OptPedanticErrors("pedantic-errors"); static llvm::cl::opt OptNoWarnings("w"); //===----------------------------------------------------------------------===// -// -dump-build-information Stuff +// Dump Build Information //===----------------------------------------------------------------------===// -static llvm::cl::opt -DumpBuildInformation("dump-build-information", - llvm::cl::value_desc("filename"), - llvm::cl::desc("output a dump of some build information to a file")); - static void SetUpBuildDumpLog(const DiagnosticOptions &DiagOpts, unsigned argc, char **argv, llvm::OwningPtr &DiagClient) { std::string ErrorInfo; - llvm::raw_ostream *OS = new llvm::raw_fd_ostream(DumpBuildInformation.c_str(), - ErrorInfo); + llvm::raw_ostream *OS = + new llvm::raw_fd_ostream(DiagOpts.DumpBuildInformation.c_str(), ErrorInfo); if (!ErrorInfo.empty()) { llvm::errs() << "error opening -dump-build-information file '" - << DumpBuildInformation << "', option ignored!\n"; + << DiagOpts.DumpBuildInformation << "', option ignored!\n"; delete OS; return; } @@ -1081,7 +1074,7 @@ static Diagnostic *CreateDiagnosticEngine(const DiagnosticOptions &Opts, DiagClient.reset(new TextDiagnosticPrinter(llvm::errs(), Opts)); } - if (!DumpBuildInformation.empty()) + if (!Opts.DumpBuildInformation.empty()) SetUpBuildDumpLog(Opts, argc, argv, DiagClient); // Configure our handling of diagnostics.