[cfe-commits] r99022 - in /cfe/trunk/lib/Driver: Arg.cpp OptTable.cpp

Daniel Dunbar daniel at zuster.org
Fri Mar 19 18:12:00 PDT 2010


Author: ddunbar
Date: Fri Mar 19 20:12:00 2010
New Revision: 99022

URL: http://llvm.org/viewvc/llvm-project?rev=99022&view=rev
Log:
Driver: Allow Render{Separate,Joined} option flags on JoinedOrSeparate option types.

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

Modified:
    cfe/trunk/lib/Driver/Arg.cpp
    cfe/trunk/lib/Driver/OptTable.cpp

Modified: cfe/trunk/lib/Driver/Arg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Arg.cpp?rev=99022&r1=99021&r2=99022&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Arg.cpp (original)
+++ cfe/trunk/lib/Driver/Arg.cpp Fri Mar 19 20:12:00 2010
@@ -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 @@
 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));
   }
 }
 

Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=99022&r1=99021&r2=99022&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Fri Mar 19 20:12:00 2010
@@ -167,11 +167,13 @@
   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)





More information about the cfe-commits mailing list