[cfe-dev] [PATCH] Fix clang test failures on MIPS

Manuel Klimek klimek at google.com
Fri May 4 08:39:15 PDT 2012

On Fri, May 4, 2012 at 5:21 PM, Simon Atanasyan <satanasyan at mips.com> wrote:
> On Fri, May 4, 2012 at 12:30 AM, Manuel Klimek <klimek at google.com> wrote:
>> On Thu, May 3, 2012 at 10:16 PM, Chandler Carruth <chandlerc at google.com> wrote:
>>> My understanding is that the tooling library wishes to only run a single
>>> compilation job, and is failing to properly set up the driver/invocation for
>>> that, leaving the external assembler job also in the pipeline. I'm not of
>>> the exact location of this code, but I think Manuel has seen related
>>> problems recently anyways.
>> Yep, we need to add a hook to adjust the compile command lines for
>> running a single syntax only job.
>> My idea was to add a hook that by default does that syntax only
>> modification and allow users to specify different hooks in case they
>> know what they're doing ...
> Just want to be sure that I understand you properly before start
> coding. Does the solution below conform your original idea?
> 1. Add virtual function processCommandLine(StringRef FilePath,
> std::vector<std::string> &CommandLine) to the ClangTool class. This
> function adds/removes/replaces command line arguments if necessary.
> 2. Call this function from ClangTool::run() method before
> ToolInvocation instance creation to adjust command line.
> 3. Create class ClangSyntaxCheckTool. It inherits class ClangTool and
> overrides processCommandLine() method. The new method adds
> "-fsyntax-only" argument to the command line.
> 3. Use ClangSyntaxCheckTool instead of ClangTool in the clang-check.

I actually thought that preparing the command line for syntax checking
would be the default, as all tools I've written so far need it, and
the only one I've seen using something different was Nick when he was
playing around with mapreducing code generation.

I haven't put too much thought into the interface yet, but I'd imagine
something along the lines of
class ArgumentAdjuster {
  vector<std::string> Adjust(const vector<std::string> &Arguments) = 0;

class ClangSyntaxOnlyAdjuster : public ArgumentAdjuster { ... };

Then, for people who have command lines that are for gcc for some reasons:
class GccToClangAdjuster : public ArgumentAdjuster { ... };

Then we can install a ClangSyntaxOnlyAdjuster per default and add a
method to ClangTool:
void setArgumentAdjuster(ArgumentAdjuster *Adjuster);

I think the argument adjusting is orthogonal to the tool, so I'd
rather avoid inheritance on the ClangTool level.


More information about the cfe-dev mailing list