summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2016-05-17 16:02:38 +0200
committerFrancisco Jerez <[email protected]>2016-07-11 20:20:47 -0700
commitc2a167ad73f91f4e9f94a45aba65a01e198fd41f (patch)
tree3367316eaa9885949a4da30410779525471fedf0 /src
parentc513cfa747bdb9ac3059ab4e436cd7083c50aed0 (diff)
clover/llvm: Factor out compiler option tokenization.
Reviewed-by: Serge Martin <[email protected]> Tested-by: Jan Vesely <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/clover/llvm/invocation.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp
index 7cfd4481e2d..155ba066f5c 100644
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
@@ -96,6 +96,18 @@ namespace {
}
}
+ inline std::vector<std::string>
+ tokenize(const std::string &s) {
+ std::vector<std::string> ss;
+ std::istringstream iss(s);
+ std::string t;
+
+ while (getline(iss, t, ' '))
+ ss.push_back(t);
+
+ return ss;
+ }
+
struct target {
target(const std::string &s) :
cpu(s.begin(), s.begin() + s.find_first_of("-")),
@@ -117,18 +129,7 @@ namespace {
std::string log;
llvm::raw_string_ostream s_log(log);
- // Parse the compiler options:
- std::vector<std::string> opts_array;
- std::istringstream ss(opts);
-
- while (!ss.eof()) {
- std::string opt;
- getline(ss, opt, ' ');
- opts_array.push_back(opt);
- }
-
- opts_array.push_back(name);
-
+ const std::vector<std::string> opts_array = tokenize(opts + " " + name);
std::vector<const char *> opts_carray;
for (unsigned i = 0; i < opts_array.size(); i++) {
opts_carray.push_back(opts_array.at(i).c_str());