aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-11-18 21:53:02 +0000
committerChris Lattner <sabre@nondot.org>2008-11-18 21:53:02 +0000
commit95d1ba492c3191f49392e53acbf878e39fc8ba0a (patch)
treeccba6d441ab10506741836ed83ebca79014adb84
parent204b2fed909b1eabea7aeb6caadd7cff718edee5 (diff)
Allow diagnostics to be used in bool context, like:
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
-rw-r--r--include/clang/Basic/Diagnostic.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/include/clang/Basic/Diagnostic.h b/include/clang/Basic/Diagnostic.h
index fb3e5953da..3edf990d24 100644
--- a/include/clang/Basic/Diagnostic.h
+++ b/include/clang/Basic/Diagnostic.h
@@ -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; }