[cfe-commits] r59555 - /cfe/trunk/include/clang/Basic/Diagnostic.h
Chris Lattner
sabre at nondot.org
Tue Nov 18 13:53:03 PST 2008
Author: lattner
Date: Tue Nov 18 15:53:02 2008
New Revision: 59555
URL: http://llvm.org/viewvc/llvm-project?rev=59555&view=rev
Log:
Allow diagnostics to be used in bool context, like:
return Diag(...);
when the function returns bool. This always evaluates to true.
Modified:
cfe/trunk/include/clang/Basic/Diagnostic.h
Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=59555&r1=59554&r2=59555&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue Nov 18 15:53:02 2008
@@ -243,6 +243,11 @@
const Diagnostic *getDiags() const { return DiagObj; }
unsigned getID() const { return DiagID; }
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; }
More information about the cfe-commits
mailing list