diff options
author | David Blaikie <dblaikie@gmail.com> | 2013-05-15 07:37:26 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2013-05-15 07:37:26 +0000 |
commit | 7247c88d1e41514a41085f83ebf03dd5220e054a (patch) | |
tree | 7672e55dc561fa1fb210fc9b219d010995529f4a /include/clang/AST/Type.h | |
parent | fcec0c991edbb011a1eeb85d8de836502f799aed (diff) | |
download | clang-7247c88d1e41514a41085f83ebf03dd5220e054a.tar.gz |
Use only explicit bool conversion operator
The most common (non-buggy) case are where such objects are used as
return expressions in bool-returning functions or as boolean function
arguments. In those cases I've used (& added if necessary) a named
function to provide the equivalent (or sometimes negative, depending on
convenient wording) test.
DiagnosticBuilder kept its implicit conversion operator owing to the
prevalent use of it in return statements.
One bug was found in ExprConstant.cpp involving a comparison of two
PointerUnions (PointerUnion did not previously have an operator==, so
instead both operands were converted to bool & then compared). A test
is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix
(adding operator== to PointerUnion in LLVM).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/AST/Type.h')
-rw-r--r-- | include/clang/AST/Type.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 39f10d3393..93c287fd18 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -441,7 +441,7 @@ public: bool operator==(Qualifiers Other) const { return Mask == Other.Mask; } bool operator!=(Qualifiers Other) const { return Mask != Other.Mask; } - operator bool() const { return hasQualifiers(); } + LLVM_EXPLICIT operator bool() const { return hasQualifiers(); } Qualifiers &operator+=(Qualifiers R) { addQualifiers(R); |