Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
35956659
Commit
35956659
authored
Jan 29, 2014
by
kosak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GTEST_MOVE macro, to support mocking methods with move-only return types.
Add GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
parent
7d1051ce
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
2 deletions
+28
-2
gtest-port.h
include/gtest/internal/gtest-port.h
+25
-2
gtest-printers.cc
src/gtest-printers.cc
+3
-0
No files found.
include/gtest/internal/gtest-port.h
View file @
35956659
...
@@ -198,6 +198,10 @@
...
@@ -198,6 +198,10 @@
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used.
//
//
// C++11 feature wrappers:
//
// GTEST_MOVE_ - portability wrapper for std::move.
//
// Synchronization:
// Synchronization:
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
// Mutex, MutexLock, ThreadLocal, GetThreadCount()
// - synchronization primitives.
// - synchronization primitives.
...
@@ -264,6 +268,7 @@
...
@@ -264,6 +268,7 @@
#include <iostream> // NOLINT
#include <iostream> // NOLINT
#include <sstream> // NOLINT
#include <sstream> // NOLINT
#include <string> // NOLINT
#include <string> // NOLINT
#include <utility>
#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com"
#define GTEST_FLAG_PREFIX_ "gtest_"
#define GTEST_FLAG_PREFIX_ "gtest_"
...
@@ -823,6 +828,12 @@ using ::std::tuple_size;
...
@@ -823,6 +828,12 @@ using ::std::tuple_size;
# define GTEST_MUST_USE_RESULT_
# define GTEST_MUST_USE_RESULT_
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC
#if GTEST_LANG_CXX11
# define GTEST_MOVE_(x) ::std::move(x) // NOLINT
#else
# define GTEST_MOVE_(x) x
#endif
// Determine whether the compiler supports Microsoft's Structured Exception
// Determine whether the compiler supports Microsoft's Structured Exception
// Handling. This is supported by several Windows compilers but generally
// Handling. This is supported by several Windows compilers but generally
// does not exist on any other system.
// does not exist on any other system.
...
@@ -875,10 +886,22 @@ using ::std::tuple_size;
...
@@ -875,10 +886,22 @@ using ::std::tuple_size;
__attribute__((no_sanitize_memory))
__attribute__((no_sanitize_memory))
# else
# else
# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
# endif
# endif
// __has_feature(memory_sanitizer)
#else
#else
# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
# define GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
#endif
#endif // __clang__
// A function level attribute to disable AddressSanitizer instrumentation.
#if defined(__clang__)
# if __has_feature(address_sanitizer)
# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_ \
__attribute__((no_sanitize_address))
# else
# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
# endif // __has_feature(address_sanitizer)
#else
# define GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
#endif // __clang__
namespace
testing
{
namespace
testing
{
...
...
src/gtest-printers.cc
View file @
35956659
...
@@ -57,6 +57,7 @@ using ::std::ostream;
...
@@ -57,6 +57,7 @@ using ::std::ostream;
// Prints a segment of bytes in the given object.
// Prints a segment of bytes in the given object.
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
void
PrintByteSegmentInObjectTo
(
const
unsigned
char
*
obj_bytes
,
size_t
start
,
void
PrintByteSegmentInObjectTo
(
const
unsigned
char
*
obj_bytes
,
size_t
start
,
size_t
count
,
ostream
*
os
)
{
size_t
count
,
ostream
*
os
)
{
char
text
[
5
]
=
""
;
char
text
[
5
]
=
""
;
...
@@ -254,6 +255,7 @@ void PrintTo(wchar_t wc, ostream* os) {
...
@@ -254,6 +255,7 @@ void PrintTo(wchar_t wc, ostream* os) {
// and may not be NUL-terminated.
// and may not be NUL-terminated.
template
<
typename
CharType
>
template
<
typename
CharType
>
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
static
void
PrintCharsAsStringTo
(
static
void
PrintCharsAsStringTo
(
const
CharType
*
begin
,
size_t
len
,
ostream
*
os
)
{
const
CharType
*
begin
,
size_t
len
,
ostream
*
os
)
{
const
char
*
const
kQuoteBegin
=
sizeof
(
CharType
)
==
1
?
"
\"
"
:
"L
\"
"
;
const
char
*
const
kQuoteBegin
=
sizeof
(
CharType
)
==
1
?
"
\"
"
:
"L
\"
"
;
...
@@ -276,6 +278,7 @@ static void PrintCharsAsStringTo(
...
@@ -276,6 +278,7 @@ static void PrintCharsAsStringTo(
// 'begin'. CharType must be either char or wchar_t.
// 'begin'. CharType must be either char or wchar_t.
template
<
typename
CharType
>
template
<
typename
CharType
>
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_MEMORY_
GTEST_ATTRIBUTE_NO_SANITIZE_ADDRESS_
static
void
UniversalPrintCharArray
(
static
void
UniversalPrintCharArray
(
const
CharType
*
begin
,
size_t
len
,
ostream
*
os
)
{
const
CharType
*
begin
,
size_t
len
,
ostream
*
os
)
{
// The code
// The code
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment