an odd bug in CommonOptionsParser

I am a new learner in Clang and meet an odd bug.

My code is a simple case:

I am a new learner in Clang and meet an odd bug.

My code is a simple case:

.....
static llvm::cl::OptionCategory MyToolCategory("");
.....
int main(int argc, const char **argv)
{
  CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
  ClangTool Tool(OptionsParser.getCompilations(),
                 OptionsParser.getSourcePathList());
  tooling::MyFactory Factory;
  Tool.run(newFrontendActionFactory(&Factory));
  return 0;
}

but it report an very odd error when compile with clang++(my llvm&clang's
version is 3.4):

==================================================
ToolingTutorial.cpp:74:23: error: no matching constructor for
initialization
of 'clang::tooling::CommonOptionsParser'
  CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
                      ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~

/home/acsa-amd2/Documents/llvm-3.4/tools/clang/include/clang/Tooling/CommonOptionsParser.h:67:3:
note: candidate constructor not
      viable: no known conversion from 'llvm::cl::OptionCategory' to 'const
char *' for 3rd argument
  CommonOptionsParser(int &argc, const char **argv, const char *Overview =
0);
  ^

/home/acsa-amd2/Documents/llvm-3.4/tools/clang/include/clang/Tooling/CommonOptionsParser.h:61:7:
note: candidate constructor
      (the implicit move constructor) not viable: requires 1 argument, but
3
were provided
class CommonOptionsParser {
      ^

/home/acsa-amd2/Documents/llvm-3.4/tools/clang/include/clang/Tooling/CommonOptionsParser.h:61:7:
note: candidate constructor
      (the implicit copy constructor) not viable: requires 1 argument, but
3
were provided
1 error generated.
make: *** [ToolingTutorial.o] Error 1

it makes no sense that the constructor is no match and the compiler mistake
'llvm::cl::OptionCategory' for 'const char *' .

It doesn't. The CommonOptionsParser actually takes a const char* as third
argument, not a llvm::cl::OptionCategory. At least that's what the error
message tells you :slight_smile:

Thanks.I finally recognize what the problem is. It seems Clang-3.5 (have not
release) will add a 3th argument (llvm::cl::OptionCategory) in the
constructor of CommonOptionsParser and now the newest release version 3.4 in
which the constructor still has only two arguments. It surprises me that
there are so many big changes between different versions of Clang :slight_smile: