[PATCH] Header dependencies support for modularize

Thompson, John John_Thompson at playstation.sony.com
Wed Aug 21 08:18:32 PDT 2013


One option would be to let my previous ArgumentsAdjuster patch through.  If you look at my modularize patch, you'll see that it's not a pretty solution having to know all the clang options that take arguments, as I have to know which options take arguments in order not to mistake an option argument for a file name.  I can't use the file name extension because the input could be a C++ header with no extension.  It seems this might be useful to others as well.

Or, you could just approve my modularize patch.


From: Manuel Klimek [mailto:klimek at google.com]
Sent: Wednesday, August 21, 2013 6:16 AM
To: Kim Gräsman
Cc: Thompson, John; Sean Silva; cfe-commits at cs.uiuc.edu
Subject: Re: [PATCH] Header dependencies support for modularize

On Wed, Aug 21, 2013 at 3:06 PM, Kim Gräsman <kim.grasman at gmail.com<mailto:kim.grasman at gmail.com>> wrote:

On Wed, Aug 21, 2013 at 2:48 PM, Thompson, John
<John_Thompson at playstation.sony.com<mailto:John_Thompson at playstation.sony.com>> wrote:
> This would seem to have a prerequisite that ClangTooling have a OptTable
> somewhere, but there doesn't seem to be a connection.
> Now let's suppose I get past that hurdle, either by creating one myself and
> somehow coercing it to parse the arguments given to ArgumentsAdjuster, how
> do I use libOption to walk the arguments and figure out which command-line
> argument is the source file?
> Ideally, tooling should have a mechanism to tell me what the source file or
> files are for each command line in the compilation database.  I had a much
> simpler version, but it required I modify ArgumentsAdjuster to be given the
> source file, which the caller had handy, but I couldn't get that change
> through.
> Could someone associated with tooling lend a hand and tell me how to get the
> input file from the command lines in the compilation database?
I can't help, but I'm struggling with the same thing right now.

Our tool is originally designed to act as a replacement for clang in
Make build systems, so it accepts the same command-line (plus some
additional, escaped options)

I've wanted to add compilation database support, but the way tooling
is wired it seems I need to extract compilation db and source paths
from the command-line and pass them to ClangTool::ClangTool. The
compilation db is (sort of) handled by FixedCompilationDatabase, but
it seems the source paths are assumed to be tool arguments, not Clang

Use a clang plugin if you want to run as part of a build. The code that has your main logic is basically the same, and you can use ASTMatchers and other stuff from tooling in your clang plugin just fine.

See: http://clang.llvm.org/docs/Tooling.html


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130821/6246f7ee/attachment.html>

More information about the cfe-commits mailing list