我认为问题在于opt
已经解析了它自己的参数,并且已经将位码文件作为位置参数进行处理,因此具有多个位置参数会产生不明确性。
该文档解释了API,就像它在独立应用程序中使用一样。因此,举例来说,如果你做这样的事情:
int main(int argc, char *argv[]) {
cl::list<std::string> Files(cl::Positional, cl::OneOrMore);
cl::list<std::string> Files2(cl::Positional, cl::OneOrMore);
cl::list<std::string> Libraries("l", cl::ZeroOrMore);
cl::ParseCommandLineOptions(argc, argv);
for(auto &e : Libraries) outs() << e << "\n";
outs() << "....\n";
for(auto &e : Files) outs() << e << "\n";
outs() << "....\n";
for(auto &e : Files2) outs() << e << "\n";
outs() << "....\n";
}
你得到的东西是这样的:
$ foo -l one two three four five six
one
....
two
three
four
five
....
six
....
现在,如果你身边两个位置参数的定义交换,甚至可以改变的cl::OneOrMore
Files2
选项cl::ZeroOrMore
,你会得到一个错误
$ option: error - option can never match, because another positional argument will match an unbounded number of values, and this option does not require a value!
个人而言,当我使用opt
我放弃了positiontal ARG ument选项,做这样的事情:
cl::list<std::string> Lists("lists", cl::desc("Specify names"), cl::OneOrMore);
,让我做到这一点:
opt -load ./fooPass.so -foo -o out.bc -lists one ./in.bc -lists two
并遍历std::string
列表以同样的方式获得:
one
two
S标志不是传递的选项,它是一个选项,使其自己使其输出LLVM程序集。 – Shuzheng
我该如何做第一件作品(定位)? – Shuzheng
你能解释'-mapiWM'选项吗? – hailinzeng