Clang Tooling: Run multiple tools with different args

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang Tooling: Run multiple tools with different args

madil90
Hi,
   I have to run multiple tools in the same code using different set of arguments for each (different source files). Seperately both tools work fine. But when I run them both, the source path list in the second tool contains all the source paths passed to the first tool too. How can I clear the source path list? e.g.

CommonOptionsParser parser(size,Args);
ClangTool tool(parser.getCompilations(),parser.getSourcePathList());   // source is test.cpp

CommonOptionsParser parser1(size1,Args1);
ClangTool tool2(parser1.getCompilations(),parser.getSourcePathList());
// source is test.cpp and test1.cpp in the above while Args1 contain only test1.cpp

    Is there a way to reset the whole toolig structure and run a completely new tool on a new set of arguments in the same code? (I don't wanna make 4 tools and run them seperately).

Regards,
Adil
             
Reply | Threaded
Open this post in threaded view
|

Re: Clang Tooling: Run multiple tools with different args

Manuel Klimek
On Tue, Feb 12, 2013 at 5:34 PM, madil90 <[hidden email]> wrote:
Hi,
   I have to run multiple tools in the same code using different set of
arguments for each (different source files). Seperately both tools work
fine. But when I run them both, the source path list in the second tool
contains all the source paths passed to the first tool too. How can I clear
the source path list? e.g.

CommonOptionsParser parser(size,Args);
ClangTool tool(parser.getCompilations(),parser.getSourcePathList());   //
source is test.cpp

CommonOptionsParser parser1(size1,Args1);
ClangTool tool2(parser1.getCompilations(),parser.getSourcePathList());
// source is test.cpp and test1.cpp in the above while Args1 contain only
test1.cpp

    Is there a way to reset the whole toolig structure and run a completely
new tool on a new set of arguments in the same code? (I don't wanna make 4
tools and run them seperately).

Yes, don't use CommonOptionsParser. It is mainly a convenience class to make writing tools easy. If you want two tools with two different argument lists, parse them yourself and hand them to the ClangTool constructors...

Cheers,
/Manuel
 

Regards,
Adil




--
View this message in context: http://clang-developers.42468.n3.nabble.com/Clang-Tooling-Run-multiple-tools-with-different-args-tp4030423.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang Tooling: Run multiple tools with different args

madil90
To parse the command line arguments myself, I used some code from the CommonOptionsParsers constrcutor. I don't understand the sourcePaths population though. How is this list used and how is this populated? I searched through the LLVM source code and found no usage of sourcePaths anywhere? Can you provide a little more detail on how llvm command line parser and the clang parser (options after "--") work?


On Wed, Feb 13, 2013 at 5:15 PM, Manuel Klimek <[hidden email]> wrote:
On Tue, Feb 12, 2013 at 5:34 PM, madil90 <[hidden email]> wrote:
Hi,
   I have to run multiple tools in the same code using different set of
arguments for each (different source files). Seperately both tools work
fine. But when I run them both, the source path list in the second tool
contains all the source paths passed to the first tool too. How can I clear
the source path list? e.g.

CommonOptionsParser parser(size,Args);
ClangTool tool(parser.getCompilations(),parser.getSourcePathList());   //
source is test.cpp

CommonOptionsParser parser1(size1,Args1);
ClangTool tool2(parser1.getCompilations(),parser.getSourcePathList());
// source is test.cpp and test1.cpp in the above while Args1 contain only
test1.cpp

    Is there a way to reset the whole toolig structure and run a completely
new tool on a new set of arguments in the same code? (I don't wanna make 4
tools and run them seperately).

Yes, don't use CommonOptionsParser. It is mainly a convenience class to make writing tools easy. If you want two tools with two different argument lists, parse them yourself and hand them to the ClangTool constructors...

Cheers,
/Manuel
 

Regards,
Adil




--
View this message in context: http://clang-developers.42468.n3.nabble.com/Clang-Tooling-Run-multiple-tools-with-different-args-tp4030423.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




--
Mohammad Adil
LUMS SSE

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang Tooling: Run multiple tools with different args

Manuel Klimek
On Wed, Feb 13, 2013 at 1:26 PM, Mohammad Adil <[hidden email]> wrote:
To parse the command line arguments myself, I used some code from the CommonOptionsParsers constrcutor. I don't understand the sourcePaths population though. How is this list used and how is this populated? I searched through the LLVM source code and found no usage of sourcePaths anywhere? Can you provide a little more detail on how llvm command line parser and the clang parser (options after "--") work?

This has generally nothing to do with the command line parsing.

You need to give the ClangTool a CompilationDatabase. The CommonOptionsParser happens to implement a strategy where it:
a) tries to load a FixedCompilationDatabase when you specify args after -- on the command line
b) tries to auto-detect the compilation database from the path specified via -p
c) tries to auto-detect the compilation database from the first source file specified on the command line

Cheers,
/Manuel
 


On Wed, Feb 13, 2013 at 5:15 PM, Manuel Klimek <[hidden email]> wrote:
On Tue, Feb 12, 2013 at 5:34 PM, madil90 <[hidden email]> wrote:
Hi,
   I have to run multiple tools in the same code using different set of
arguments for each (different source files). Seperately both tools work
fine. But when I run them both, the source path list in the second tool
contains all the source paths passed to the first tool too. How can I clear
the source path list? e.g.

CommonOptionsParser parser(size,Args);
ClangTool tool(parser.getCompilations(),parser.getSourcePathList());   //
source is test.cpp

CommonOptionsParser parser1(size1,Args1);
ClangTool tool2(parser1.getCompilations(),parser.getSourcePathList());
// source is test.cpp and test1.cpp in the above while Args1 contain only
test1.cpp

    Is there a way to reset the whole toolig structure and run a completely
new tool on a new set of arguments in the same code? (I don't wanna make 4
tools and run them seperately).

Yes, don't use CommonOptionsParser. It is mainly a convenience class to make writing tools easy. If you want two tools with two different argument lists, parse them yourself and hand them to the ClangTool constructors...

Cheers,
/Manuel
 

Regards,
Adil




--
View this message in context: http://clang-developers.42468.n3.nabble.com/Clang-Tooling-Run-multiple-tools-with-different-args-tp4030423.html
Sent from the Clang Developers mailing list archive at Nabble.com.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




--
Mohammad Adil
LUMS SSE


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev