]> granicus.if.org Git - clang/commitdiff
Driver: Add default for ArgList::hasFlag and simplify implementation.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 7 Apr 2009 21:08:57 +0000 (21:08 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 7 Apr 2009 21:08:57 +0000 (21:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68549 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/ArgList.h
lib/Driver/ArgList.cpp

index a0b925279cf39fe8030ea28a224458fd6d3dc275..7e0427d9b5dd16c606a66d0f1735deb4f7a97f16 100644 (file)
@@ -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.
index 69cb85b7fc34e81bafc9df671b8318ad3895fa67..78236730248b0db1a43de4430552918786f57958 100644 (file)
@@ -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;
 }