[llvm-commits] [LLVMdev] [PATCH] Allow per-thread re-direction of outs()/errs()

Hal Finkel hfinkel at anl.gov
Sun Jun 3 16:15:58 PDT 2012


On Sun, 03 Jun 2012 12:12:06 -0700
Chris Lattner <clattner at apple.com> wrote:

> 
> On Jun 2, 2012, at 11:01 AM, Mikael Lyngvig wrote:
> 
> > If I may add my two cents: 
> > 
> > I am planning to use LLVM as the backend for a compiler I am
> > working on.  And I wholeheartedly agree with Justin that it is a
> > problem, if LLVM is allowed to freely write to stdout and stderr as
> > it is a component which can be used in all sorts of code, be it a
> > GUI IDE, a CLI driver, or whatever.
> 
> LLVM should not be doing this.
> 
> > Also, I have a number of times wondered about the somewhat unusual
> > use of error strings in LLVM (that you pass in a string, which can
> > be assigned a descriptive error message).  Better would be, IMHO,
> > to provide an interface along the lines of this:
> > 
> > class ErrorHandler
> > {
> > public:
> >         virtual void Report(ErrorKind kind, uint code, const
> > Position &position, const unichar *text, ...) = 0; };
> > 
> > And then let the client, i.e. the frontend, derive from it and
> > handle all the output in whichever way it wants to.  The above
> > example is probably too complex for LLVM, but that's what I use in
> > my compiler.  ErrorKind is ErrorKind_Fatal, ErrorKind_Error, etc.
> > Position is simply a filename, a line number, and a character
> > position.  unichar is either char or wchar_t, depending on the
> > build mode and target environment.
> 
> You're right, this would be better.  We have even already have it :)
> 
>   llvm/Support/ErrorHandling.h

This seems to only handle fatal errors. If that's correct, it will
probably need to be extended to handle non-fatal errors, warnings,
suggestions, notes, etc.

 -Hal

> 
> -Chris
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



-- 
Hal Finkel
Postdoctoral Appointee
Leadership Computing Facility
Argonne National Laboratory



More information about the llvm-commits mailing list