HomePhabricator

Add a DiagnosticManager replace error streams in the expression parser.

Description

Add a DiagnosticManager replace error streams in the expression parser.

We want to do a better job presenting errors that occur when evaluating
expressions. Key to this effort is getting away from a model where all
errors are spat out onto a stream where the client has to take or leave
all of them.

To this end, this patch adds a new class, DiagnosticManager, which
contains errors produced by the compiler or by LLDB as an expression
is created. The DiagnosticManager can dump itself to a log as well as
to a string. Clients will (in the future) be able to filter out the
errors they're interested in by ID or present subsets of these errors
to the user.

This patch is not intended to change the *users* of errors - only to
thread DiagnosticManagers to all the places where streams are used. I
also attempt to standardize our use of errors a bit, removing trailing
newlines and making clients omit 'error:', 'warning:' etc. and instead
pass the Severity flag.

The patch is testsuite-neutral, with modifications to one part of the
MI tests because it relied on "error: error:" being erroneously
printed. This patch fixes the MI variable handling and the testcase.

rdar://problem/22864976

Details

Committed
spyffeMar 18 2016, 5:03 PM
Parents
rL263858: Delete the custom implementation of signal() on Windows.
Branches
Unknown
Tags
Unknown

Event Timeline

Hello,

looks like this CL broke Windows build bot - http://lab.llvm.org:8011/builders/lldb-windows7-android/builds/4882.
Could you take a look?

spyffe added a subscriber: spyffe.Mar 21 2016, 11:09 AM

Oleksiy,

I’m looking at this but it’s not clear to me what the errors are referring to.
First of all, it appears that the compiler is having problems with attribute ((format (printf, 2, 3))), but it’s used elsewhere in LLDB also – for example, CommandReturnObject.h. Do you have any clue what VS is complaining about here?
Second, this error

c:\lldbSlave\lldb-win7-android\llvm\tools\lldb\source\Expression\DiagnosticManager.cpp(67): error C2556: 'size_t lldb_private::DiagnosticManager::Printf(lldb_private::DiagnosticSeverity,const char *,...)': overloaded function differs only by return type from 'int lldb_private::DiagnosticManager::Printf(lldb_private::DiagnosticSeverity,const char *,...)'
c:\lldbSlave\lldb-win7-android\llvm\tools\lldb\include\lldb/Expression/DiagnosticManager.h(73): note: see declaration of 'lldb_private::DiagnosticManager::Printf'

is a little difficult to understand, because DiagnosticManager.h:73 reads

size_t
Printf(DiagnosticSeverity severity, const char *format, ...) __attribute__((format(printf, 3, 4)));

How did the compiler decide size_t == int? I suspect it has something to do with the attribute part.

In a pinch, it would be possible to #ifdef WINDOWS or something like that, but if there’s a Right Way™ to do this, I’d love to.

Sean