Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
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
json
Commits
a6bd798b
Unverified
Commit
a6bd798b
authored
Sep 10, 2019
by
Niels Lohmann
Committed by
GitHub
Sep 10, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1728 from t-b/fix-clang-sanitizer-invocation
Fix clang sanitizer invocation
parents
eab68e77
6d701b29
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
13 deletions
+23
-13
.travis.yml
.travis.yml
+7
-4
to_json.hpp
include/nlohmann/detail/conversions/to_json.hpp
+4
-1
input_adapters.hpp
include/nlohmann/detail/input/input_adapters.hpp
+2
-2
json.hpp
single_include/nlohmann/json.hpp
+6
-3
CMakeLists.txt
test/CMakeLists.txt
+3
-3
UBSAN.supp
test/src/UBSAN.supp
+1
-0
No files found.
.travis.yml
View file @
a6bd798b
...
@@ -43,12 +43,15 @@ matrix:
...
@@ -43,12 +43,15 @@ matrix:
-
os
:
linux
-
os
:
linux
compiler
:
clang
compiler
:
clang
env
:
env
:
-
COMPILER=clang++-
5.0
-
COMPILER=clang++-
7
-
CMAKE_OPTIONS=-DJSON_Sanitizer=ON
-
CMAKE_OPTIONS=-DJSON_Sanitizer=ON
-
UBSAN_OPTIONS=print_stacktrace=1,suppressions=$(pwd)/test/src/UBSAN.supp
addons
:
addons
:
apt
:
apt
:
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
llvm-toolchain-trusty-5.0'
]
sources
:
[
'
ubuntu-toolchain-r-test'
,
'
llvm-toolchain-trusty-7'
]
packages
:
[
'
g++-6'
,
'
clang-5.0'
,
'
ninja-build'
]
packages
:
[
'
g++-6'
,
'
clang-7'
,
'
ninja-build'
]
before_script
:
-
export PATH=$PATH:/usr/lib/llvm-7/bin
# cppcheck
# cppcheck
-
os
:
linux
-
os
:
linux
...
@@ -330,7 +333,7 @@ script:
...
@@ -330,7 +333,7 @@ script:
# compile and execute unit tests
# compile and execute unit tests
-
mkdir -p build && cd build
-
mkdir -p build && cd build
-
cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release
-
cmake .. ${CMAKE_OPTIONS} -DJSON_MultipleHeaders=${MULTIPLE_HEADERS} -GNinja && cmake --build . --config Release
-
ctest -C Release -V -j
-
ctest -C Release -
-timeout 2700 -
V -j
-
cd ..
-
cd ..
# check if homebrew works (only checks develop branch)
# check if homebrew works (only checks develop branch)
...
...
include/nlohmann/detail/conversions/to_json.hpp
View file @
a6bd798b
...
@@ -154,7 +154,10 @@ struct external_constructor<value_t::array>
...
@@ -154,7 +154,10 @@ struct external_constructor<value_t::array>
j
.
m_type
=
value_t
::
array
;
j
.
m_type
=
value_t
::
array
;
j
.
m_value
=
value_t
::
array
;
j
.
m_value
=
value_t
::
array
;
j
.
m_value
.
array
->
resize
(
arr
.
size
());
j
.
m_value
.
array
->
resize
(
arr
.
size
());
std
::
copy
(
std
::
begin
(
arr
),
std
::
end
(
arr
),
j
.
m_value
.
array
->
begin
());
if
(
arr
.
size
()
>
0
)
{
std
::
copy
(
std
::
begin
(
arr
),
std
::
end
(
arr
),
j
.
m_value
.
array
->
begin
());
}
j
.
assert_invariant
();
j
.
assert_invariant
();
}
}
};
};
...
...
include/nlohmann/detail/input/input_adapters.hpp
View file @
a6bd798b
...
@@ -131,9 +131,8 @@ class input_stream_adapter : public input_adapter_protocol
...
@@ -131,9 +131,8 @@ class input_stream_adapter : public input_adapter_protocol
class
input_buffer_adapter
:
public
input_adapter_protocol
class
input_buffer_adapter
:
public
input_adapter_protocol
{
{
public
:
public
:
JSON_HEDLEY_NON_NULL
(
2
)
input_buffer_adapter
(
const
char
*
b
,
const
std
::
size_t
l
)
noexcept
input_buffer_adapter
(
const
char
*
b
,
const
std
::
size_t
l
)
noexcept
:
cursor
(
b
),
limit
(
b
+
l
)
:
cursor
(
b
),
limit
(
b
==
nullptr
?
nullptr
:
(
b
+
l
)
)
{}
{}
// delete because of pointer members
// delete because of pointer members
...
@@ -147,6 +146,7 @@ class input_buffer_adapter : public input_adapter_protocol
...
@@ -147,6 +146,7 @@ class input_buffer_adapter : public input_adapter_protocol
{
{
if
(
JSON_HEDLEY_LIKELY
(
cursor
<
limit
))
if
(
JSON_HEDLEY_LIKELY
(
cursor
<
limit
))
{
{
assert
(
cursor
!=
nullptr
and
limit
!=
nullptr
);
return
std
::
char_traits
<
char
>::
to_int_type
(
*
(
cursor
++
));
return
std
::
char_traits
<
char
>::
to_int_type
(
*
(
cursor
++
));
}
}
...
...
single_include/nlohmann/json.hpp
View file @
a6bd798b
...
@@ -3489,7 +3489,10 @@ struct external_constructor<value_t::array>
...
@@ -3489,7 +3489,10 @@ struct external_constructor<value_t::array>
j
.
m_type
=
value_t
::
array
;
j
.
m_type
=
value_t
::
array
;
j
.
m_value
=
value_t
::
array
;
j
.
m_value
=
value_t
::
array
;
j
.
m_value
.
array
->
resize
(
arr
.
size
());
j
.
m_value
.
array
->
resize
(
arr
.
size
());
std
::
copy
(
std
::
begin
(
arr
),
std
::
end
(
arr
),
j
.
m_value
.
array
->
begin
());
if
(
arr
.
size
()
>
0
)
{
std
::
copy
(
std
::
begin
(
arr
),
std
::
end
(
arr
),
j
.
m_value
.
array
->
begin
());
}
j
.
assert_invariant
();
j
.
assert_invariant
();
}
}
};
};
...
@@ -3882,9 +3885,8 @@ class input_stream_adapter : public input_adapter_protocol
...
@@ -3882,9 +3885,8 @@ class input_stream_adapter : public input_adapter_protocol
class
input_buffer_adapter
:
public
input_adapter_protocol
class
input_buffer_adapter
:
public
input_adapter_protocol
{
{
public
:
public
:
JSON_HEDLEY_NON_NULL
(
2
)
input_buffer_adapter
(
const
char
*
b
,
const
std
::
size_t
l
)
noexcept
input_buffer_adapter
(
const
char
*
b
,
const
std
::
size_t
l
)
noexcept
:
cursor
(
b
),
limit
(
b
+
l
)
:
cursor
(
b
),
limit
(
b
==
nullptr
?
nullptr
:
(
b
+
l
)
)
{}
{}
// delete because of pointer members
// delete because of pointer members
...
@@ -3898,6 +3900,7 @@ class input_buffer_adapter : public input_adapter_protocol
...
@@ -3898,6 +3900,7 @@ class input_buffer_adapter : public input_adapter_protocol
{
{
if
(
JSON_HEDLEY_LIKELY
(
cursor
<
limit
))
if
(
JSON_HEDLEY_LIKELY
(
cursor
<
limit
))
{
{
assert
(
cursor
!=
nullptr
and
limit
!=
nullptr
);
return
std
::
char_traits
<
char
>::
to_int_type
(
*
(
cursor
++
));
return
std
::
char_traits
<
char
>::
to_int_type
(
*
(
cursor
++
));
}
}
...
...
test/CMakeLists.txt
View file @
a6bd798b
...
@@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF)
...
@@ -6,7 +6,7 @@ option(JSON_Coverage "Build test suite with coverage information" OFF)
if
(
JSON_Sanitizer
)
if
(
JSON_Sanitizer
)
message
(
STATUS
"Building test suite with Clang sanitizer"
)
message
(
STATUS
"Building test suite with Clang sanitizer"
)
if
(
NOT MSVC
)
if
(
NOT MSVC
)
set
(
CMAKE_CXX_FLAGS
"-g -O
2 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer
"
)
set
(
CMAKE_CXX_FLAGS
"-g -O
0 -fsanitize=address -fsanitize=undefined -fsanitize=integer -fsanitize=nullability -fno-omit-frame-pointer -fno-sanitize-recover=all -fsanitize-recover=unsigned-integer-overflow
"
)
endif
()
endif
()
endif
()
endif
()
...
@@ -71,7 +71,7 @@ set_target_properties(doctest_main PROPERTIES
...
@@ -71,7 +71,7 @@ set_target_properties(doctest_main PROPERTIES
COMPILE_DEFINITIONS
"$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_DEFINITIONS
"$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>"
COMPILE_OPTIONS
"$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
COMPILE_OPTIONS
"$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
)
)
if
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.8.0"
)
if
(
${
CMAKE_VERSION
}
VERSION_LESS
"3.8.0"
)
target_compile_features
(
doctest_main PUBLIC cxx_range_for
)
target_compile_features
(
doctest_main PUBLIC cxx_range_for
)
else
()
else
()
target_compile_features
(
doctest_main PUBLIC cxx_std_11
)
target_compile_features
(
doctest_main PUBLIC cxx_std_11
)
...
@@ -92,7 +92,7 @@ if(MSVC)
...
@@ -92,7 +92,7 @@ if(MSVC)
# Disable warning C4566: character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252)
# Disable warning C4566: character represented by universal-character-name '\uFF01' cannot be represented in the current code page (1252)
# Disable warning C4996: 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::operator <<': was declared deprecated
# Disable warning C4996: 'nlohmann::basic_json<std::map,std::vector,std::string,bool,int64_t,uint64_t,double,std::allocator,nlohmann::adl_serializer>::operator <<': was declared deprecated
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/wd4389 /wd4309 /wd4566 /wd4996"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/wd4389 /wd4309 /wd4566 /wd4996"
)
# https://github.com/nlohmann/json/issues/1114
# https://github.com/nlohmann/json/issues/1114
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/bigobj"
)
set
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/bigobj"
)
endif
()
endif
()
...
...
test/src/UBSAN.supp
0 → 100644
View file @
a6bd798b
unsigned-integer-overflow:stl_bvector.h
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