]> granicus.if.org Git - clang/commitdiff
Allow diagnostics to be used in bool context, like:
authorChris Lattner <sabre@nondot.org>
Tue, 18 Nov 2008 21:53:02 +0000 (21:53 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Nov 2008 21:53:02 +0000 (21:53 +0000)
return Diag(...);

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59555 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Diagnostic.h

index fb3e5953dabe9c9f7f21a3457fab10f0f8a64e19..3edf990d24e1eacc2068049e6fb5b21bbc0d496a 100644 (file)
@@ -243,6 +243,11 @@ public:
   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; }