[cfe-commits] r90422 - in /cfe/trunk: include/clang/Driver/CC1Options.td include/clang/Frontend/FrontendOptions.h lib/Frontend/CompilerInvocation.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Wed Dec 2 23:01:58 PST 2009
Author: ddunbar
Date: Thu Dec 3 01:01:58 2009
New Revision: 90422
URL: http://llvm.org/viewvc/llvm-project?rev=90422&view=rev
Log:
clang-cc: Honor -help and -version when using new style option parsing.
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Frontend/FrontendOptions.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=90422&r1=90421&r2=90422&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Thu Dec 3 01:01:58 2009
@@ -201,6 +201,9 @@
HelpText<"Disable freeing of memory on exit">;
def empty_input_only : Flag<"-empty-input-only">,
HelpText<"Force running on an empty input file">;
+def help : Flag<"-help">,
+ HelpText<"Print this help text">;
+def _help : Flag<"--help">, Alias<help>;
def x : Separate<"-x">, HelpText<"Input language type">;
def cxx_inheritance_view : Separate<"-cxx-inheritance-view">,
MetaVarName<"<class name>">,
@@ -212,6 +215,9 @@
HelpText<"Load the named plugin (dynamic shared object)">;
def plugin : Separate<"-plugin">,
HelpText<"Use the named plugin action (use \"help\" to list available options)">;
+def version : Flag<"-version">,
+ HelpText<"Print the compiler version">;
+def _version : Flag<"--version">, Alias<version>;
def Action_Group : OptionGroup<"<action group>">;
let Group = Action_Group in {
Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=90422&r1=90421&r2=90422&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
+++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Dec 3 01:01:58 2009
@@ -77,12 +77,14 @@
unsigned RelocatablePCH : 1; ///< When generating PCH files,
/// instruct the PCH writer to create
/// relocatable PCH files.
+ unsigned ShowHelp : 1; ///< Show the -help text.
unsigned ShowMacrosInCodeCompletion : 1; ///< Show macros in code completion
/// results.
unsigned ShowStats : 1; ///< Show frontend performance
/// metrics and statistics.
unsigned ShowTimers : 1; ///< Show timers for individual
/// actions.
+ unsigned ShowVersion : 1; ///< Show the -version text.
/// The input files and their types.
std::vector<std::pair<InputKind, std::string> > Inputs;
@@ -116,9 +118,11 @@
ProgramAction = frontend::ParseSyntaxOnly;
ActionName = "";
RelocatablePCH = 0;
+ ShowHelp = 0;
ShowMacrosInCodeCompletion = 0;
ShowStats = 0;
ShowTimers = 0;
+ ShowVersion = 0;
}
/// getInputKindForExtension - Return the appropriate input kind for a file
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=90422&r1=90421&r2=90422&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Dec 3 01:01:58 2009
@@ -296,12 +296,16 @@
Res.push_back("-empty-input-only");
if (Opts.RelocatablePCH)
Res.push_back("-relocatable-pch");
+ if (Opts.ShowHelp)
+ Res.push_back("-help");
if (Opts.ShowMacrosInCodeCompletion)
Res.push_back("-code-completion-macros");
if (Opts.ShowStats)
Res.push_back("-print-stats");
if (Opts.ShowTimers)
Res.push_back("-ftime-report");
+ if (Opts.ShowVersion)
+ Res.push_back("-version");
bool NeedLang = false;
for (unsigned i = 0, e = Opts.Inputs.size(); i != e; ++i)
@@ -888,9 +892,11 @@
Opts.OutputFile = getLastArgValue(Args, OPT_o);
Opts.Plugins = getAllArgValues(Args, OPT_load);
Opts.RelocatablePCH = Args.hasArg(OPT_relocatable_pch);
+ Opts.ShowHelp = Args.hasArg(OPT_help);
Opts.ShowMacrosInCodeCompletion = Args.hasArg(OPT_code_completion_macros);
Opts.ShowStats = Args.hasArg(OPT_print_stats);
Opts.ShowTimers = Args.hasArg(OPT_ftime_report);
+ Opts.ShowVersion = Args.hasArg(OPT_version);
Opts.ViewClassInheritance = getLastArgValue(Args, OPT_cxx_inheritance_view);
FrontendOptions::InputKind DashX = FrontendOptions::IK_None;
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=90422&r1=90421&r2=90422&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Thu Dec 3 01:01:58 2009
@@ -311,6 +311,22 @@
(void*)(intptr_t) GetBuiltinIncludePath,
Diags);
+ // Honor -help.
+ if (Clang.getInvocation().getFrontendOpts().ShowHelp) {
+ llvm::OwningPtr<driver::OptTable> Opts(driver::createCC1OptTable());
+ Opts->PrintHelp(llvm::outs(), "clang-cc",
+ "LLVM 'Clang' Compiler: http://clang.llvm.org");
+ return 0;
+ }
+
+ // Honor -version.
+ //
+ // FIXME: Use a better -version message?
+ if (Clang.getInvocation().getFrontendOpts().ShowVersion) {
+ llvm::cl::PrintVersionMessage();
+ return 0;
+ }
+
// Create the actual diagnostics engine.
Clang.createDiagnostics(argc, argv);
if (!Clang.hasDiagnostics())
More information about the cfe-commits
mailing list