[cfe-dev] an odd bug in CommonOptionsParser

Manuel Klimek klimek at google.com
Mon Mar 24 04:18:10 PDT 2014


On Sat, Mar 22, 2014 at 1:21 PM, VinsonL <lwhvinson1990 at gmail.com> wrote:

> 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 :)


>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/an-odd-bug-in-CommonOptionsParser-tp4038552.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140324/448acb62/attachment.html>


More information about the cfe-dev mailing list