Skip to content

Commit

Permalink
Bug 1322465 part 8 - Use explicit/MOZ_IMPLICIT for the unary construc…
Browse files Browse the repository at this point in the history
…tors in mfbt/. r=Ehsan

MozReview-Commit-ID: 2TpfrAaAIuu

--HG--
extra : rebase_source : 4fb5af1beb94c059cbadfaf27fe3949ae8b85efb
  • Loading branch information
janus926 committed Dec 16, 2016
1 parent e551a0b commit 4e68f1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions build/clang-plugin/tests/TestCustomHeap.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class")))
#ifndef MOZ_HEAP_ALLOCATOR
#define MOZ_HEAP_ALLOCATOR \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wgcc-compat\"") \
__attribute__((annotate("moz_heap_allocator"))) \
_Pragma("GCC diagnostic pop")
#endif

#include <stdlib.h>
#include <memory>
Expand Down
9 changes: 5 additions & 4 deletions mfbt/Char16.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifdef WIN32
# define MOZ_USE_CHAR16_WRAPPER
# include <cstdint>
# include "mozilla/Attributes.h"
/**
* Win32 API extensively uses wchar_t, which is represented by a separated
* builtin type than char16_t per spec. It's not the case for MSVC prior to
Expand All @@ -39,13 +40,13 @@ class char16ptr_t
"char16_t and wchar_t sizes differ");

public:
char16ptr_t(const char16_t* aPtr) : mPtr(aPtr) {}
char16ptr_t(const wchar_t* aPtr) :
MOZ_IMPLICIT char16ptr_t(const char16_t* aPtr) : mPtr(aPtr) {}
MOZ_IMPLICIT char16ptr_t(const wchar_t* aPtr) :
mPtr(reinterpret_cast<const char16_t*>(aPtr))
{}

/* Without this, nullptr assignment would be ambiguous. */
constexpr char16ptr_t(decltype(nullptr)) : mPtr(nullptr) {}
constexpr MOZ_IMPLICIT char16ptr_t(decltype(nullptr)) : mPtr(nullptr) {}

operator const char16_t*() const
{
Expand All @@ -59,7 +60,7 @@ class char16ptr_t
{
return mPtr;
}
operator bool() const
MOZ_IMPLICIT operator bool() const
{
return mPtr != nullptr;
}
Expand Down

0 comments on commit 4e68f1f

Please sign in to comment.