summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2013-04-24 18:01:26 +0000
committerChad Rosier <mcrosier@apple.com>2013-04-24 18:01:26 +0000
commitcba3b88da55c24b95181c71e658d6f7eae8ffc3d (patch)
tree05c5cc3d140669e2b4dd1cb1941b6a54c024ccb4
parentcc111b2bc9f2dd707cda656ce9ba5511a3e734c6 (diff)
downloadbcm5719-llvm-cba3b88da55c24b95181c71e658d6f7eae8ffc3d.tar.gz
bcm5719-llvm-cba3b88da55c24b95181c71e658d6f7eae8ffc3d.zip
[driver] Add a hasFlag API that accepts a positive alias.
Part of rdar://13622687 llvm-svn: 180203
-rw-r--r--clang/include/clang/Driver/ArgList.h9
-rw-r--r--clang/lib/Driver/ArgList.cpp7
2 files changed, 15 insertions, 1 deletions
diff --git a/clang/include/clang/Driver/ArgList.h b/clang/include/clang/Driver/ArgList.h
index 3967dcc21d1..362cf9c0801 100644
--- a/clang/include/clang/Driver/ArgList.h
+++ b/clang/include/clang/Driver/ArgList.h
@@ -237,7 +237,14 @@ namespace driver {
/// true if the option is present, false if the negation is present, and
/// \p Default if neither option is given. If both the option and its
/// negation are present, the last one wins.
- bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default=true) const;
+ bool hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default = true) const;
+
+ /// hasFlag - Given an option \p Pos, an alias \p PosAlias and its negative
+ /// form \p Neg, return true if the option or its alias is present, false if
+ /// the negation is present, and \p Default if none of the options are
+ /// given. If multiple options are present, the last one wins.
+ bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
+ bool Default = true) const;
/// AddLastArg - Render only the last argument match \p Id0, if present.
void AddLastArg(ArgStringList &Output, OptSpecifier Id0) const;
diff --git a/clang/lib/Driver/ArgList.cpp b/clang/lib/Driver/ArgList.cpp
index 6c57b622b8d..6fde8360b6c 100644
--- a/clang/lib/Driver/ArgList.cpp
+++ b/clang/lib/Driver/ArgList.cpp
@@ -206,6 +206,13 @@ bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier Neg, bool Default) const {
return Default;
}
+bool ArgList::hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg,
+ bool Default) const {
+ if (Arg *A = getLastArg(Pos, PosAlias, Neg))
+ return A->getOption().matches(Pos) || A->getOption().matches(PosAlias);
+ return Default;
+}
+
StringRef ArgList::getLastArgValue(OptSpecifier Id,
StringRef Default) const {
if (Arg *A = getLastArg(Id))
OpenPOWER on IntegriCloud