[LLVMdev] Aborting a pass

Bill Wendling wendling at apple.com
Thu Mar 11 13:25:16 PST 2010


On Mar 11, 2010, at 12:49 PM, Trevor Harmon wrote:

> On Mar 1, 2010, at 11:04 AM, Trevor Harmon wrote:
> 
>> What's the proper way to abort a pass if something goes wrong (e.g.,
>> in the pass's constructor)? Do I simply call abort()?
> 
> Calling abort() causes a stack dump to the console, which is good for  
> serious errors, but overkill for most other types of error situations,  
> such as a command-line parameter that the user forgot to add. For  
> these situations, I'm printing an informative error message to errs()  
> and then calling exit(-1). I'm not sure if that's the best approach,  
> but it seems to coax the expected behavior out of LLVM.
> 
You can also use the "llvm_report_error" (et al) commands in llvm/Support/ErrorHandling.h. They will act like exit(), but print error messages.

-bw






More information about the llvm-dev mailing list