r291058 - [Sema] Mark undefined ctors as deleted. NFC.

David Blaikie via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 9 08:34:52 PST 2017


Alternatively could make the bool ctor a template with some SFINAE to
restrict it to only parameters of type bool - thus blocking all conversions
there, if they're particularly problematic.

On Wed, Jan 4, 2017 at 5:32 PM George Burgess IV via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: gbiv
> Date: Wed Jan  4 19:21:21 2017
> New Revision: 291058
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291058&view=rev
> Log:
> [Sema] Mark undefined ctors as deleted. NFC.
>
> Looks like these functions exist just to prevent bad implicit
> conversions. Rather than waiting for the linker to complain about
> undefined references to them, we can mark them as deleted.
>
> Modified:
>     cfe/trunk/include/clang/Sema/Ownership.h
>
> Modified: cfe/trunk/include/clang/Sema/Ownership.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Ownership.h?rev=291058&r1=291057&r2=291058&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Sema/Ownership.h (original)
> +++ cfe/trunk/include/clang/Sema/Ownership.h Wed Jan  4 19:21:21 2017
> @@ -153,8 +153,8 @@ namespace clang {
>      ActionResult(const DiagnosticBuilder &) : Val(PtrTy()), Invalid(true)
> {}
>
>      // These two overloads prevent void* -> bool conversions.
> -    ActionResult(const void *);
> -    ActionResult(volatile void *);
> +    ActionResult(const void *) = delete;
> +    ActionResult(volatile void *) = delete;
>
>      bool isInvalid() const { return Invalid; }
>      bool isUsable() const { return !Invalid && Val; }
> @@ -192,8 +192,8 @@ namespace clang {
>      ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { }
>
>      // These two overloads prevent void* -> bool conversions.
> -    ActionResult(const void *);
> -    ActionResult(volatile void *);
> +    ActionResult(const void *) = delete;
> +    ActionResult(volatile void *) = delete;
>
>      bool isInvalid() const { return PtrWithInvalid & 0x01; }
>      bool isUsable() const { return PtrWithInvalid > 0x01; }
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170109/8a9eda97/attachment.html>


More information about the cfe-commits mailing list