Allow diagnostics to be used in bool context, like:

return Diag(...);

when the function returns bool.  This always evaluates to true.

llvm-svn: 59555
This commit is contained in:
Chris Lattner 2008-11-18 21:53:02 +00:00
parent e05c4dfc42
commit a7fc74fdc1
1 changed files with 5 additions and 0 deletions

View File

@ -244,6 +244,11 @@ public:
unsigned getID() const { return DiagID; } unsigned getID() const { return DiagID; }
const FullSourceLoc &getLocation() const { return Loc; } const FullSourceLoc &getLocation() const { return Loc; }
/// Operator bool: conversion of DiagnosticInfo to bool always returns true.
/// This allows is to be used in boolean error contexts like:
/// return Diag(...);
operator bool() const { return true; }
unsigned getNumArgs() const { return DiagObj->NumDiagArgs; } unsigned getNumArgs() const { return DiagObj->NumDiagArgs; }
/// getArgStr - Return the provided argument string specified by Idx. /// getArgStr - Return the provided argument string specified by Idx.