diff options
author | Hans Wennborg <hans@hanshq.net> | 2013-07-27 00:23:45 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2013-07-27 00:23:45 +0000 |
commit | 6ddc6901ef18ee4463cb4981d3a520ce3f8e2c36 (patch) | |
tree | 80b8822e9c06afc9fa83c6ab1563bf9e5aaeec53 /clang/lib/Driver/Driver.cpp | |
parent | 568cb2783345a972dabb7290ff38db8e522d0ec7 (diff) | |
download | bcm5719-llvm-6ddc6901ef18ee4463cb4981d3a520ce3f8e2c36.tar.gz bcm5719-llvm-6ddc6901ef18ee4463cb4981d3a520ce3f8e2c36.zip |
clang-cl: add support for the /? and /help options
This establishes a new Flag in Options.td, which can be assigned to
options that should be made available in clang's cl.exe compatible
mode, and updates the Driver to make use of the flag.
(The whitespace change to CMakeLists forces the build to re-run CMake
and pick up the include dependency on the new .td file. This makes the
build work if someone moves backwards in commit history after this change.)
Differential Revision: http://llvm-reviews.chandlerc.com/D1215
llvm-svn: 187280
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 028ba623c4f..c105fa86f9f 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -20,6 +20,7 @@ #include "clang/Driver/ToolChain.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/Option/Arg.h" @@ -108,9 +109,17 @@ void Driver::ParseDriverMode(ArrayRef<const char *> Args) { InputArgList *Driver::ParseArgStrings(ArrayRef<const char *> ArgList) { llvm::PrettyStackTraceString CrashInfo("Command line argument parsing"); + + unsigned IncludedFlagsBitmask; + unsigned ExcludedFlagsBitmask; + llvm::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) = + getIncludeExcludeOptionFlagMasks(); + unsigned MissingArgIndex, MissingArgCount; InputArgList *Args = getOpts().ParseArgs(ArgList.begin(), ArgList.end(), - MissingArgIndex, MissingArgCount); + MissingArgIndex, MissingArgCount, + IncludedFlagsBitmask, + ExcludedFlagsBitmask); // Check for missing argument error. if (MissingArgCount) @@ -607,9 +616,17 @@ void Driver::PrintOptions(const ArgList &Args) const { } void Driver::PrintHelp(bool ShowHidden) const { - getOpts().PrintHelp( - llvm::outs(), Name.c_str(), DriverTitle.c_str(), /*Include*/ 0, - /*Exclude*/ options::NoDriverOption | (ShowHidden ? 0 : HelpHidden)); + unsigned IncludedFlagsBitmask; + unsigned ExcludedFlagsBitmask; + llvm::tie(IncludedFlagsBitmask, ExcludedFlagsBitmask) = + getIncludeExcludeOptionFlagMasks(); + + ExcludedFlagsBitmask |= options::NoDriverOption; + if (!ShowHidden) + ExcludedFlagsBitmask |= HelpHidden; + + getOpts().PrintHelp(llvm::outs(), Name.c_str(), DriverTitle.c_str(), + IncludedFlagsBitmask, ExcludedFlagsBitmask); } void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const { @@ -1856,3 +1873,18 @@ bool Driver::GetReleaseVersion(const char *Str, unsigned &Major, HadExtra = true; return true; } + +std::pair<unsigned, unsigned> Driver::getIncludeExcludeOptionFlagMasks() const { + unsigned IncludedFlagsBitmask = 0; + unsigned ExcludedFlagsBitmask = 0; + + if (Mode == CLMode) { + // Only allow CL options. + // FIXME: Also allow "core" Clang options. + IncludedFlagsBitmask = options::CLOption; + } else { + ExcludedFlagsBitmask |= options::CLOption; + } + + return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask); +} |