[cfe-commits] r66757 - in /cfe/trunk: include/clang/Driver/Option.h lib/Driver/Option.cpp
Daniel Dunbar
daniel at zuster.org
Wed Mar 11 18:34:20 PDT 2009
Author: ddunbar
Date: Wed Mar 11 20:34:20 2009
New Revision: 66757
URL: http://llvm.org/viewvc/llvm-project?rev=66757&view=rev
Log:
Driver: Add Option::getId and Option::matches taking an option
identifier; we will want to use the latter in situations where we just
want to check for a match, but not load options unnecessarily.
Modified:
cfe/trunk/include/clang/Driver/Option.h
cfe/trunk/lib/Driver/Option.cpp
Modified: cfe/trunk/include/clang/Driver/Option.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=66757&r1=66756&r2=66757&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Wed Mar 11 20:34:20 2009
@@ -88,6 +88,7 @@
public:
virtual ~Option();
+ options::ID getId() const { return ID; }
OptionClass getKind() const { return Kind; }
const char *getName() const { return Name; }
const OptionGroup *getGroup() const { return Group; }
@@ -124,6 +125,7 @@
/// matches - Predicate for whether this option is part of the
/// given option (which may be a group).
bool matches(const Option *Opt) const;
+ bool matches(options::ID Id) const;
/// accept - Potentially accept the current argument, returning a
/// new Arg instance, or 0 if the option does not accept this
Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=66757&r1=66756&r2=66757&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Wed Mar 11 20:34:20 2009
@@ -86,6 +86,22 @@
return false;
}
+bool Option::matches(options::ID Id) const {
+ // FIXME: Decide what to do here; we should either pull out the
+ // handling of alias on the option for Id from the other matches, or
+ // find some other solution (which hopefully doesn't require using
+ // the option table).
+ if (Alias)
+ return Alias->matches(Id);
+
+ if (ID == Id)
+ return true;
+
+ if (Group)
+ return Group->matches(Id);
+ return false;
+}
+
OptionGroup::OptionGroup(options::ID ID, const char *Name,
const OptionGroup *Group)
: Option(Option::GroupClass, ID, Name, Group, 0) {
More information about the cfe-commits
mailing list