[llvm-commits] [dragonegg] r154169 - in /dragonegg/trunk: README src/Backend.cpp

Duncan Sands baldrick at free.fr
Fri Apr 6 02:05:37 PDT 2012


Author: baldrick
Date: Fri Apr  6 04:05:37 2012
New Revision: 154169

URL: http://llvm.org/viewvc/llvm-project?rev=154169&view=rev
Log:
Make it possible to pass multiple space separated options in one hit.

Modified:
    dragonegg/trunk/README
    dragonegg/trunk/src/Backend.cpp

Modified: dragonegg/trunk/README
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/README?rev=154169&r1=154168&r2=154169&view=diff
==============================================================================
--- dragonegg/trunk/README (original)
+++ dragonegg/trunk/README Fri Apr  6 04:05:37 2012
@@ -121,6 +121,6 @@
   clash with the LLVM output.  This option causes GCC output to be written to
   a file instead.  Good for seeing which GCC output we've failed to turn off.
 
--fplugin-arg-dragonegg-llvm-option=option
-  Pass a command line option through to LLVM.  If you want to pass an option
-  that contains equals signs then you need to use colons (':') instead of '='.
+-fplugin-arg-dragonegg-llvm-option=options
+  Pass command line options through to LLVM.  If you want to pass an option that
+  contains equals signs then you need to use colons (':') instead of '='.

Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=154169&r1=154168&r2=154169&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Fri Apr  6 04:05:37 2012
@@ -2102,13 +2102,31 @@
           continue;
         }
         std::string value(argv[i].value);
-        // Turn ':' into '=' everywhere.  This is because '=' is useful for
-        // passing settings to LLVM but GCC doesn't allow it.
+        // Split the value at spaces, making it possible to pass several options
+        // in one 'llvm-option' value.  Turn ':' into '=' everywhere because '='
+        // is useful for passing settings to LLVM but GCC doesn't allow it.
+        std::string::iterator first = value.begin(); // Start of next sub-option
         for (std::string::iterator I = value.begin(), E = value.end(); I != E;
-             ++I)
-          if (*I == ':')
+             ++I) {
+          char C = *I;
+          if (C == ':') {
+            // Turn colons into equals signs, otherwise there is no way to use
+            // an option that needs an equals sign.
             *I = '=';
-        ArgStrings.push_back(value);
+          } else if (C == ' ') {
+            // A space - split the string.
+            std::string option(first, I);
+            // Don't bother with empty options (multiple spaces cause these).
+            if (option != "")
+              ArgStrings.push_back(option);
+            first = I;
+            ++first;
+          }
+        }
+        // Add the last option. If there were no spaces then this is everything.
+        std::string option(first, value.end());
+        if (option != "")
+          ArgStrings.push_back(option);
         continue;
       }
 





More information about the llvm-commits mailing list