Can clangtool handle "-I"?

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

Can clangtool handle "-I"?

Hubert Tong via cfe-dev
I'm writing a tool using AST matcher, and I need to pass the path of the clang built-in heads to my tool (or it will error me that "'stddef.h' file not found"), so I add `-I/path/to/the/headers` to my tool, but the program said that "Unknown command line argument '-I/usr/lib/llvm-6.0/lib/clang/6.0.0/include'."

So is there any built-in OptionCategory that can handle "-I" parameters?


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can clangtool handle "-I"?

Hubert Tong via cfe-dev
On 04/08/2020 09:23, Yafei Liu via cfe-dev wrote:
> I'm writing a tool using AST matcher, and I need to pass the path of the
> clang built-in heads to my tool (or it will error me that "'stddef.h'
> file not found"), so I add `-I/path/to/the/headers` to my tool, but the
> program said that "Unknown command line argument
> '-I/usr/lib/llvm-6.0/lib/clang/6.0.0/include'."

-I/usr/lib/llvm-6.0/lib/clang/6.0.0/include is not a command-line
argument, it is two:

"-I" and "/usr/lib/llvm-6.0/lib/clang/6.0.0/include"

I believe it should work if you pass it as the two arguments.  The shell
will normally do this splitting for you.

David

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can clangtool handle "-I"?

Hubert Tong via cfe-dev
In reply to this post by Hubert Tong via cfe-dev
Try using --extra-arg-before=-I'/path/to/clang/include' when run your tool
 
Use CommonOptionsParser to access given flag:
 
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList());


04.08.2020, 11:24, "Yafei Liu via cfe-dev" <[hidden email]>:
I'm writing a tool using AST matcher, and I need to pass the path of the clang built-in heads to my tool (or it will error me that "'stddef.h' file not found"), so I add `-I/path/to/the/headers` to my tool, but the program said that "Unknown command line argument '-I/usr/lib/llvm-6.0/lib/clang/6.0.0/include'."

So is there any built-in OptionCategory that can handle "-I" parameters?

,

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can clangtool handle "-I"?

Hubert Tong via cfe-dev
Hi Samins, that works for me, thank you.

On Tue, Aug 4, 2020 at 6:55 PM samins KAlex <[hidden email]> wrote:
Try using --extra-arg-before=-I'/path/to/clang/include' when run your tool
 
Use CommonOptionsParser to access given flag:
 
CommonOptionsParser OptionsParser(argc, argv, MyToolCategory);
ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList());


04.08.2020, 11:24, "Yafei Liu via cfe-dev" <[hidden email]>:
I'm writing a tool using AST matcher, and I need to pass the path of the clang built-in heads to my tool (or it will error me that "'stddef.h' file not found"), so I add `-I/path/to/the/headers` to my tool, but the program said that "Unknown command line argument '-I/usr/lib/llvm-6.0/lib/clang/6.0.0/include'."

So is there any built-in OptionCategory that can handle "-I" parameters?

,

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can clangtool handle "-I"?

Hubert Tong via cfe-dev
In reply to this post by Hubert Tong via cfe-dev
If you are using the `clang::tooling::CommonOptionsParser` to handle
the command line, then you can pass `-I` using either `extra-arg` or
after the `--`
`clang-tool -tool -specific -args -extra-arg=-I/usr/...` or
`clang-tool -tool -specific -args -- -I/usr/...`.

~Nathan James

On Tue, 2020-08-04 at 16:23 +0800, Yafei Liu via cfe-dev wrote:

> I'm writing a tool using AST matcher, and I need to pass the path of
> the clang built-in heads to my tool (or it will error me that
> "'stddef.h' file not found"), so I add `-I/path/to/the/headers` to my
> tool, but the program said that "Unknown command line argument '-
> I/usr/lib/llvm-6.0/lib/clang/6.0.0/include'."
>
> So is there any built-in OptionCategory that can handle "-I"
> parameters?
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Can clangtool handle "-I"?

Hubert Tong via cfe-dev
In reply to this post by Hubert Tong via cfe-dev
If you are using the `clang::tooling::CommonOptionsParser` to handle
the command line, then you can pass `-I` using either `extra-arg` or
after the `--`
`clang-tool -tool -specific -args -extra-arg=-I/usr/...` or
`clang-tool -tool -specific -args -- -I/usr/...`.

~Nathan James

On Tue, 2020-08-04 at 16:23 +0800, Yafei Liu via cfe-dev wrote:

> I'm writing a tool using AST matcher, and I need to pass the path of
> the clang built-in heads to my tool (or it will error me that
> "'stddef.h' file not found"), so I add `-I/path/to/the/headers` to my
> tool, but the program said that "Unknown command line argument '-
> I/usr/lib/llvm-6.0/lib/clang/6.0.0/include'."
>
> So is there any built-in OptionCategory that can handle "-I"
> parameters?
>
> _______________________________________________
> cfe-dev mailing list
> [hidden email]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev