Driver: Allow Render{Separate,Joined} option flags on JoinedOrSeparate option types.

Also, simplify/fix SeparateArg::render with forced join.

llvm-svn: 99022
This commit is contained in:
Daniel Dunbar 2010-03-20 01:12:00 +00:00
parent aef1db1d71
commit 4ea3aea534
2 changed files with 8 additions and 7 deletions

View File

@ -10,6 +10,7 @@
#include "clang/Driver/Arg.h"
#include "clang/Driver/ArgList.h"
#include "clang/Driver/Option.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang::driver;
@ -155,14 +156,12 @@ SeparateArg::SeparateArg(const Option *Opt, unsigned Index, unsigned _NumValues,
void SeparateArg::render(const ArgList &Args, ArgStringList &Output) const {
if (getOption().hasForceJoinedRender()) {
assert(getNumValues() == 1 && "Cannot force joined render with > 1 args.");
// FIXME: Avoid std::string.
std::string Joined(getOption().getName());
Joined += Args.getArgString(getIndex());
Output.push_back(Args.MakeArgString(Joined.c_str()));
Output.push_back(Args.MakeArgString(llvm::StringRef(getOption().getName()) +
getValue(Args, 0)));
} else {
Output.push_back(Args.getArgString(getIndex()));
for (unsigned i = 0; i < NumValues; ++i)
Output.push_back(Args.getArgString(getIndex() + 1 + i));
Output.push_back(getValue(Args, i));
}
}

View File

@ -167,11 +167,13 @@ Option *OptTable::CreateOption(unsigned id) const {
if (info.Flags & RenderAsInput)
Opt->setNoOptAsInput(true);
if (info.Flags & RenderJoined) {
assert(info.Kind == Option::SeparateClass && "Invalid option.");
assert((info.Kind == Option::JoinedOrSeparateClass ||
info.Kind == Option::SeparateClass) && "Invalid option.");
Opt->setForceJoinedRender(true);
}
if (info.Flags & RenderSeparate) {
assert(info.Kind == Option::JoinedClass && "Invalid option.");
assert((info.Kind == Option::JoinedOrSeparateClass ||
info.Kind == Option::JoinedClass) && "Invalid option.");
Opt->setForceSeparateRender(true);
}
if (info.Flags & Unsupported)