[llvm] r282755 - Generalize ArgList::AddAllArgs more
Douglas Katzman via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 29 12:47:58 PDT 2016
Author: dougk
Date: Thu Sep 29 14:47:58 2016
New Revision: 282755
URL: http://llvm.org/viewvc/llvm-project?rev=282755&view=rev
Log:
Generalize ArgList::AddAllArgs more
Modified:
llvm/trunk/include/llvm/Option/ArgList.h
llvm/trunk/lib/Option/ArgList.cpp
Modified: llvm/trunk/include/llvm/Option/ArgList.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/ArgList.h?rev=282755&r1=282754&r2=282755&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Option/ArgList.h (original)
+++ llvm/trunk/include/llvm/Option/ArgList.h Thu Sep 29 14:47:58 2016
@@ -259,6 +259,10 @@ public:
void AddLastArg(ArgStringList &Output, OptSpecifier Id0,
OptSpecifier Id1) const;
+ /// AddAllArgsExcept - Render all arguments matching any of the given ids
+ /// and not matching any of the excluded ids.
+ void AddAllArgsExcept(ArgStringList &Output, ArrayRef<OptSpecifier> Ids,
+ ArrayRef<OptSpecifier> ExcludeIds) const;
/// AddAllArgs - Render all arguments matching any of the given ids.
void AddAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
Modified: llvm/trunk/lib/Option/ArgList.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/ArgList.cpp?rev=282755&r1=282754&r2=282755&view=diff
==============================================================================
--- llvm/trunk/lib/Option/ArgList.cpp (original)
+++ llvm/trunk/lib/Option/ArgList.cpp Thu Sep 29 14:47:58 2016
@@ -259,19 +259,36 @@ void ArgList::AddLastArg(ArgStringList &
}
}
-void ArgList::AddAllArgs(ArgStringList &Output,
- ArrayRef<OptSpecifier> Ids) const {
+void ArgList::AddAllArgsExcept(ArgStringList &Output,
+ ArrayRef<OptSpecifier> Ids,
+ ArrayRef<OptSpecifier> ExcludeIds) const {
for (const Arg *Arg : Args) {
- for (OptSpecifier Id : Ids) {
+ bool Excluded = false;
+ for (OptSpecifier Id : ExcludeIds) {
if (Arg->getOption().matches(Id)) {
- Arg->claim();
- Arg->render(*this, Output);
+ Excluded = true;
break;
}
}
+ if (!Excluded) {
+ for (OptSpecifier Id : Ids) {
+ if (Arg->getOption().matches(Id)) {
+ Arg->claim();
+ Arg->render(*this, Output);
+ break;
+ }
+ }
+ }
}
}
+/// This is a nicer interface when you don't have a list of Ids to exclude.
+void ArgList::AddAllArgs(ArgStringList &Output,
+ ArrayRef<OptSpecifier> Ids) const {
+ ArrayRef<OptSpecifier> Exclude = None;
+ AddAllArgsExcept(Output, Ids, Exclude);
+}
+
/// This 3-opt variant of AddAllArgs could be eliminated in favor of one
/// that accepts a single specifier, given the above which accepts any number.
void ArgList::AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
More information about the llvm-commits
mailing list