aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-04-07 21:08:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-04-07 21:08:57 +0000
commit9af6668984f1594459a58c381d95272aa7ca7663 (patch)
tree99e56a00adbbb1b640752434ee21b0150789c486
parent5c27f2bfd2e19429dd9206f9b019e11d4a570acf (diff)
Driver: Add default for ArgList::hasFlag and simplify implementation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68549 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Driver/ArgList.h2
-rw-r--r--lib/Driver/ArgList.cpp8
2 files changed, 3 insertions, 7 deletions
diff --git a/include/clang/Driver/ArgList.h b/include/clang/Driver/ArgList.h
index a0b925279c..7e0427d9b5 100644
--- a/include/clang/Driver/ArgList.h
+++ b/include/clang/Driver/ArgList.h
@@ -91,7 +91,7 @@ namespace driver {
/// negation is present, and \arg Default if neither option is
/// given. If both the option and its negation are present, the
/// last one wins.
- bool hasFlag(options::ID Pos, options::ID Neg, bool Default) const;
+ bool hasFlag(options::ID Pos, options::ID Neg, bool Default=true) const;
/// AddLastArg - Render only the last argument match \arg Id0, if
/// present.
diff --git a/lib/Driver/ArgList.cpp b/lib/Driver/ArgList.cpp
index 69cb85b7fc..7823673024 100644
--- a/lib/Driver/ArgList.cpp
+++ b/lib/Driver/ArgList.cpp
@@ -50,12 +50,8 @@ Arg *ArgList::getLastArg(options::ID Id0, options::ID Id1, bool Claim) const {
}
bool ArgList::hasFlag(options::ID Pos, options::ID Neg, bool Default) const {
- Arg *PosA = getLastArg(Pos);
- Arg *NegA = getLastArg(Neg);
- if (PosA && NegA)
- return NegA->getIndex() < PosA->getIndex();
- if (PosA) return true;
- if (NegA) return false;
+ if (Arg *A = getLastArg(Pos, Neg))
+ return A->getOption().matches(Pos);
return Default;
}