Visual Studio parsable error output from clang-cl

Hi guys,

I'm working on an extension for visual studio 2013 that will let me compile with clang-cl and I want to have the output from clang fully integrated into the output pane and error list. The errors I'm getting from clang-cl look like this:

C:\Users\Kim\Documents\Visual Studio 2013\Projects\ConsoleApplication8\ConsoleApplication8\Source.cpp(5,2) : error: use of undeclared identifier 'ohno'

While the regular VS error format looks like this:
>c:\users\kim\documents\visual studio 2013\projects\consoleapplication8\project1\source.cpp(6): error C2065: 'safsa' : undeclared identifier

And the clang error line is not parsed for the error list correctly with ParseOutputStringForTaskItem:

             while ((line = compileProcess.StandardError.ReadLine()) != null)
             {
                 line = line + "\n";
                 uint[] priority = new uint[1];
                 string[] file = new string[1];
                 uint[] line_number = new uint[1];
                 string[] msg = new string[1];
                 int[] found = new int[1];

                 launchpad.ParseOutputStringForTaskItem(line, priority, file, line_number, msg, found);

                     OutputPane.OutputTaskItemString(line, (Microsoft.VisualStudio.Shell.Interop.VSTASKPRIORITY)priority[0], VSTASKCATEGORY.CAT_BUILDCOMPILE,
                       "Error", (int)Microsoft.VisualStudio.Shell.Interop._vstaskbitmap.BMP_SQUIGGLE, file[0], line_number[0], msg[0]);

             }

             OutputPane.FlushToTaskList();

I get output in the output pane fine (and I can click the message to goto source location) but nothing in the error list.

I figure that clang-cl outputs visual studio compatible error messages by default but I just wanted to check with the experts. Maybe someone here has already got this working.

Thanks,
Kim

In article <53657C53.5040609@gmail.com>,
    Kim <soldoutseashell@gmail.com> writes:

I figure that clang-cl outputs visual studio compatible error messages
by default but I just wanted to check with the experts. Maybe someone
here has already got this working.

This problem has also surfaced with unit test libraries that try to
output assertion messages in a format compatible with the error pane
in VS.

It's actually worse than you think.

What was detected as a matching expression has changed in different
editions of Visual Studio. I believe the last time this stopped
working with unit test frameworks it was because the matcher became
sensitive to spaces around the :'s, but its been a while and I don't
recall the details.

So, how to fix this in clang-cl? Well, I suppose you could introduce
command line arguments to affect the formatting of the messages to be
compatible with a particular edition of VS. An alternate solution is
to wrap the execution of clang-cl and massage the message output to be
compatible.

Hi Kim,

Hi guys,

I'm working on an extension for visual studio 2013 that will let me compile
with clang-cl and I want to have the output from clang fully integrated into
the output pane and error list. The errors I'm getting from clang-cl look
like this:

Would your extension be doing anything different from e.g. the
"LLVM-vs2013" toolset that gets installed by the llvm toolchain
installer from http://llvm.org/builds/? Because improvements to that
are welcome :slight_smile:

C:\Users\Kim\Documents\Visual Studio
2013\Projects\ConsoleApplication8\ConsoleApplication8\Source.cpp(5,2) :
error: use of undeclared identifier 'ohno'

While the regular VS error format looks like this:

c:\users\kim\documents\visual studio
2013\projects\consoleapplication8\project1\source.cpp(6): error C2065:
'safsa' : undeclared identifier

And the clang error line is not parsed for the error list correctly with
ParseOutputStringForTaskItem

Do you have any idea of what the critical difference is between the
output formats?

[..]

I figure that clang-cl outputs visual studio compatible error messages by
default but I just wanted to check with the experts. Maybe someone here has
already got this working.

It tries to be compatible, but it's probably not perfect. If you know
how to make the output more compatible, that would be great.

Thanks,
Hans