summaryrefslogtreecommitdiff
path: root/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2013-07-27 00:23:45 +0000
committerHans Wennborg <hans@hanshq.net>2013-07-27 00:23:45 +0000
commit6981330cc231e4e2ccbd38679209e04b776483eb (patch)
treefcf65a915b83e8af6e4b48425fa607fb5074f1cb /lib/Driver/Driver.cpp
parent2437c8642da2728aab47262ffb74dfa796a1cf35 (diff)
downloadclang-6981330cc231e4e2ccbd38679209e04b776483eb.tar.gz
clang-6981330cc231e4e2ccbd38679209e04b776483eb.tar.bz2
clang-6981330cc231e4e2ccbd38679209e04b776483eb.tar.xz
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187280 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r--lib/Driver/Driver.cpp40
1 files changed, 36 insertions, 4 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp
index 028ba623c4..c105fa86f9 100644
--- a/lib/Driver/Driver.cpp
+++ b/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);
+}