aboutsummaryrefslogtreecommitdiff
path: root/tools/llvmc/plugins/Base/Hooks.cpp
blob: 661a914489db8f07d5f3a3a5781d36b77807ede8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <string>
#include <vector>

namespace hooks {
typedef std::vector<std::string> StrVec;

/// ConvertToMAttr - Convert -m* and -mno-* to -mattr=+*,-*
std::string ConvertToMAttr(const StrVec& Opts) {
  std::string out("-mattr=");

  bool firstIter = true;
  for (StrVec::const_iterator B = Opts.begin(), E = Opts.end(); B!=E; ++B) {
    const std::string& Arg = *B;

    if (firstIter)
      firstIter = false;
    else
      out += ",";

    if (Arg.find("no-") == 0 && Arg[3] != 0) {
      out += '-';
      out += Arg.c_str() + 3;
    }
    else {
      out += '+';
      out += Arg;
    }
  }

  return out;
}

}