Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
942bb460
Commit
942bb460
authored
Jan 24, 2017
by
Milo Yip
Committed by
GitHub
Jan 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #827 from lichray/fix-signed
Treat signed-unsigned conversions as errors.
parents
265fb6ee
3cc77d5d
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
37 additions
and
35 deletions
+37
-35
CMakeLists.txt
CMakeLists.txt
+2
-0
CMakeLists.txt
example/CMakeLists.txt
+2
-3
encodedstream.h
include/rapidjson/encodedstream.h
+1
-1
encodings.h
include/rapidjson/encodings.h
+3
-3
dtoa.h
include/rapidjson/internal/dtoa.h
+4
-4
ieee754.h
include/rapidjson/internal/ieee754.h
+2
-2
regex.h
include/rapidjson/internal/regex.h
+2
-2
strtod.h
include/rapidjson/internal/strtod.h
+7
-7
istreamwrapper.h
include/rapidjson/istreamwrapper.h
+1
-1
pointer.h
include/rapidjson/pointer.h
+3
-3
schema.h
include/rapidjson/schema.h
+1
-1
writer.h
include/rapidjson/writer.h
+1
-1
CMakeLists.txt
test/perftest/CMakeLists.txt
+2
-0
CMakeLists.txt
test/unittest/CMakeLists.txt
+3
-4
encodingstest.cpp
test/unittest/encodingstest.cpp
+1
-1
itoatest.cpp
test/unittest/itoatest.cpp
+2
-2
No files found.
CMakeLists.txt
View file @
942bb460
...
...
@@ -57,6 +57,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native"
)
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Werror"
)
set
(
EXTRA_CXX_FLAGS -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wsign-conversion
)
if
(
RAPIDJSON_BUILD_CXX11
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS
"4.7.0"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++0x"
)
...
...
@@ -86,6 +87,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native"
)
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wall -Wextra -Werror -Wno-missing-field-initializers"
)
set
(
EXTRA_CXX_FLAGS -Weffc++ -Wswitch-default -Wfloat-equal -Wconversion -Wimplicit-fallthrough -Weverything
)
if
(
RAPIDJSON_BUILD_CXX11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
endif
()
...
...
example/CMakeLists.txt
View file @
942bb460
...
...
@@ -24,11 +24,10 @@ set(EXAMPLES
include_directories
(
"../include/"
)
add_definitions
(
-D__STDC_FORMAT_MACROS
)
set_property
(
DIRECTORY PROPERTY COMPILE_OPTIONS
${
EXTRA_CXX_FLAGS
}
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-pthread -Werror -Wall -Wextra -Weffc++ -Wswitch-default"
)
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-pthread"
)
endif
()
foreach
(
example
${
EXAMPLES
}
)
...
...
include/rapidjson/encodedstream.h
View file @
942bb460
...
...
@@ -200,7 +200,7 @@ private:
// xx xx xx xx UTF-8
if
(
!
hasBOM_
)
{
unsigned
pattern
=
(
c
[
0
]
?
1
:
0
)
|
(
c
[
1
]
?
2
:
0
)
|
(
c
[
2
]
?
4
:
0
)
|
(
c
[
3
]
?
8
:
0
);
int
pattern
=
(
c
[
0
]
?
1
:
0
)
|
(
c
[
1
]
?
2
:
0
)
|
(
c
[
2
]
?
4
:
0
)
|
(
c
[
3
]
?
8
:
0
);
switch
(
pattern
)
{
case
0x08
:
type_
=
kUTF32BE
;
break
;
case
0x0A
:
type_
=
kUTF16BE
;
break
;
...
...
include/rapidjson/encodings.h
View file @
942bb460
...
...
@@ -157,7 +157,7 @@ struct UTF8 {
if
(
type
>=
32
)
{
*
codepoint
=
0
;
}
else
{
*
codepoint
=
(
0xFF
>>
type
)
&
static_cast
<
unsigned
char
>
(
c
);
*
codepoint
=
(
0xFF
u
>>
type
)
&
static_cast
<
unsigned
char
>
(
c
);
}
bool
result
=
true
;
switch
(
type
)
{
...
...
@@ -283,7 +283,7 @@ struct UTF16 {
RAPIDJSON_ASSERT
(
codepoint
<=
0x10FFFF
);
unsigned
v
=
codepoint
-
0x10000
;
os
.
Put
(
static_cast
<
typename
OutputStream
::
Ch
>
((
v
>>
10
)
|
0xD800
));
os
.
Put
(
(
v
&
0x3FF
)
|
0xDC00
);
os
.
Put
(
static_cast
<
typename
OutputStream
::
Ch
>
((
v
&
0x3FF
)
|
0xDC00
)
);
}
}
...
...
@@ -299,7 +299,7 @@ struct UTF16 {
RAPIDJSON_ASSERT
(
codepoint
<=
0x10FFFF
);
unsigned
v
=
codepoint
-
0x10000
;
PutUnsafe
(
os
,
static_cast
<
typename
OutputStream
::
Ch
>
((
v
>>
10
)
|
0xD800
));
PutUnsafe
(
os
,
(
v
&
0x3FF
)
|
0xDC00
);
PutUnsafe
(
os
,
static_cast
<
typename
OutputStream
::
Ch
>
((
v
&
0x3FF
)
|
0xDC00
)
);
}
}
...
...
include/rapidjson/internal/dtoa.h
View file @
942bb460
...
...
@@ -41,7 +41,7 @@ inline void GrisuRound(char* buffer, int len, uint64_t delta, uint64_t rest, uin
}
}
inline
unsigned
CountDecimalDigit32
(
uint32_t
n
)
{
inline
int
CountDecimalDigit32
(
uint32_t
n
)
{
// Simple pure C++ implementation was faster than __builtin_clz version in this situation.
if
(
n
<
10
)
return
1
;
if
(
n
<
100
)
return
2
;
...
...
@@ -63,7 +63,7 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
const
DiyFp
wp_w
=
Mp
-
W
;
uint32_t
p1
=
static_cast
<
uint32_t
>
(
Mp
.
f
>>
-
one
.
e
);
uint64_t
p2
=
Mp
.
f
&
(
one
.
f
-
1
);
unsigned
kappa
=
CountDecimalDigit32
(
p1
);
// kappa in [0, 9]
int
kappa
=
CountDecimalDigit32
(
p1
);
// kappa in [0, 9]
*
len
=
0
;
while
(
kappa
>
0
)
{
...
...
@@ -102,8 +102,8 @@ inline void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buff
kappa
--
;
if
(
p2
<
delta
)
{
*
K
+=
kappa
;
int
index
=
-
static_cast
<
int
>
(
kappa
)
;
GrisuRound
(
buffer
,
*
len
,
delta
,
p2
,
one
.
f
,
wp_w
.
f
*
(
index
<
9
?
kPow10
[
-
static_cast
<
int
>
(
kappa
)
]
:
0
));
int
index
=
-
kappa
;
GrisuRound
(
buffer
,
*
len
,
delta
,
p2
,
one
.
f
,
wp_w
.
f
*
(
index
<
9
?
kPow10
[
index
]
:
0
));
return
;
}
}
...
...
include/rapidjson/internal/ieee754.h
View file @
942bb460
...
...
@@ -48,13 +48,13 @@ public:
int
IntegerExponent
()
const
{
return
(
IsNormal
()
?
Exponent
()
:
kDenormalExponent
)
-
kSignificandSize
;
}
uint64_t
ToBias
()
const
{
return
(
u_
&
kSignMask
)
?
~
u_
+
1
:
u_
|
kSignMask
;
}
static
unsigned
EffectiveSignificandSize
(
int
order
)
{
static
int
EffectiveSignificandSize
(
int
order
)
{
if
(
order
>=
-
1021
)
return
53
;
else
if
(
order
<=
-
1074
)
return
0
;
else
return
static_cast
<
unsigned
>
(
order
)
+
1074
;
return
order
+
1074
;
}
private
:
...
...
include/rapidjson/internal/regex.h
View file @
942bb460
...
...
@@ -688,8 +688,8 @@ private:
bool
matched
=
AddState
(
l
,
s
.
out
);
return
AddState
(
l
,
s
.
out1
)
||
matched
;
}
else
if
(
!
(
stateSet_
[
index
>>
5
]
&
(
1
<<
(
index
&
31
))))
{
stateSet_
[
index
>>
5
]
|=
(
1
<<
(
index
&
31
));
else
if
(
!
(
stateSet_
[
index
>>
5
]
&
(
1
u
<<
(
index
&
31
))))
{
stateSet_
[
index
>>
5
]
|=
(
1
u
<<
(
index
&
31
));
*
l
.
template
PushUnsafe
<
SizeType
>
()
=
index
;
}
return
s
.
out
==
kRegexInvalidState
;
// by using PushUnsafe() above, we can ensure s is not validated due to reallocation.
...
...
include/rapidjson/internal/strtod.h
View file @
942bb460
...
...
@@ -140,8 +140,8 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit
significand
++
;
size_t
remaining
=
length
-
i
;
const
unsigned
kUlpShift
=
3
;
const
unsigned
kUlp
=
1
<<
kUlpShift
;
const
int
kUlpShift
=
3
;
const
int
kUlp
=
1
<<
kUlpShift
;
int64_t
error
=
(
remaining
==
0
)
?
0
:
kUlp
/
2
;
DiyFp
v
(
significand
,
0
);
...
...
@@ -177,17 +177,17 @@ inline bool StrtodDiyFp(const char* decimals, size_t length, size_t decimalPosit
v
=
v
.
Normalize
();
error
<<=
oldExp
-
v
.
e
;
const
unsigned
effectiveSignificandSize
=
Double
::
EffectiveSignificandSize
(
64
+
v
.
e
);
unsigned
precisionSize
=
64
-
effectiveSignificandSize
;
const
int
effectiveSignificandSize
=
Double
::
EffectiveSignificandSize
(
64
+
v
.
e
);
int
precisionSize
=
64
-
effectiveSignificandSize
;
if
(
precisionSize
+
kUlpShift
>=
64
)
{
unsigned
scaleExp
=
(
precisionSize
+
kUlpShift
)
-
63
;
int
scaleExp
=
(
precisionSize
+
kUlpShift
)
-
63
;
v
.
f
>>=
scaleExp
;
v
.
e
+=
scaleExp
;
error
=
(
error
>>
scaleExp
)
+
1
+
static_cast
<
int
>
(
kUlp
)
;
error
=
(
error
>>
scaleExp
)
+
1
+
kUlp
;
precisionSize
-=
scaleExp
;
}
DiyFp
rounded
(
v
.
f
>>
precisionSize
,
v
.
e
+
static_cast
<
int
>
(
precisionSize
)
);
DiyFp
rounded
(
v
.
f
>>
precisionSize
,
v
.
e
+
precisionSize
);
const
uint64_t
precisionBits
=
(
v
.
f
&
((
uint64_t
(
1
)
<<
precisionSize
)
-
1
))
*
kUlp
;
const
uint64_t
halfWay
=
(
uint64_t
(
1
)
<<
(
precisionSize
-
1
))
*
kUlp
;
if
(
precisionBits
>=
halfWay
+
static_cast
<
unsigned
>
(
error
))
{
...
...
include/rapidjson/istreamwrapper.h
View file @
942bb460
...
...
@@ -54,7 +54,7 @@ public:
Ch
Peek
()
const
{
typename
StreamType
::
int_type
c
=
stream_
.
peek
();
return
RAPIDJSON_LIKELY
(
c
!=
StreamType
::
traits_type
::
eof
())
?
static_cast
<
Ch
>
(
c
)
:
'\0'
;
return
RAPIDJSON_LIKELY
(
c
!=
StreamType
::
traits_type
::
eof
())
?
static_cast
<
Ch
>
(
c
)
:
static_cast
<
Ch
>
(
'\0'
)
;
}
Ch
Take
()
{
...
...
include/rapidjson/pointer.h
View file @
942bb460
...
...
@@ -274,7 +274,7 @@ public:
else
{
Ch
name
[
21
];
for
(
size_t
i
=
0
;
i
<=
length
;
i
++
)
name
[
i
]
=
buffer
[
i
]
;
name
[
i
]
=
static_cast
<
Ch
>
(
buffer
[
i
])
;
Token
token
=
{
name
,
length
,
index
};
return
Append
(
token
,
allocator
);
}
...
...
@@ -1029,8 +1029,8 @@ private:
unsigned
char
u
=
static_cast
<
unsigned
char
>
(
c
);
static
const
char
hexDigits
[
16
]
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
os_
.
Put
(
'%'
);
os_
.
Put
(
hexDigits
[
u
>>
4
]
);
os_
.
Put
(
hexDigits
[
u
&
15
]
);
os_
.
Put
(
static_cast
<
typename
OutputStream
::
Ch
>
(
hexDigits
[
u
>>
4
])
);
os_
.
Put
(
static_cast
<
typename
OutputStream
::
Ch
>
(
hexDigits
[
u
&
15
])
);
}
private
:
OutputStream
&
os_
;
...
...
include/rapidjson/schema.h
View file @
942bb460
...
...
@@ -1263,7 +1263,7 @@ struct TokenHelper {
char
buffer
[
21
];
size_t
length
=
static_cast
<
size_t
>
((
sizeof
(
SizeType
)
==
4
?
u32toa
(
index
,
buffer
)
:
u64toa
(
index
,
buffer
))
-
buffer
);
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
*
documentStack
.
template
Push
<
Ch
>
()
=
buffer
[
i
]
;
*
documentStack
.
template
Push
<
Ch
>
()
=
static_cast
<
Ch
>
(
buffer
[
i
])
;
}
};
...
...
include/rapidjson/writer.h
View file @
942bb460
...
...
@@ -352,7 +352,7 @@ protected:
char
*
end
=
internal
::
dtoa
(
d
,
buffer
,
maxDecimalPlaces_
);
PutReserve
(
*
os_
,
static_cast
<
size_t
>
(
end
-
buffer
));
for
(
char
*
p
=
buffer
;
p
!=
end
;
++
p
)
PutUnsafe
(
*
os_
,
static_cast
<
typename
TargetEncoding
::
Ch
>
(
*
p
));
PutUnsafe
(
*
os_
,
static_cast
<
typename
OutputStream
::
Ch
>
(
*
p
));
return
true
;
}
...
...
test/perftest/CMakeLists.txt
View file @
942bb460
...
...
@@ -19,6 +19,8 @@ if(CCACHE_FOUND)
endif
()
endif
(
CCACHE_FOUND
)
set_property
(
DIRECTORY PROPERTY COMPILE_OPTIONS
${
EXTRA_CXX_FLAGS
}
)
IF
(
NOT
(
CMAKE_BUILD_TYPE STREQUAL
"Debug"
))
add_test
(
NAME perftest
COMMAND
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/perftest
...
...
test/unittest/CMakeLists.txt
View file @
942bb460
...
...
@@ -36,10 +36,9 @@ if(CCACHE_FOUND)
endif
()
endif
(
CCACHE_FOUND
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"GNU"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal"
)
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror -Wall -Wextra -Weffc++ -Wswitch-default -Wfloat-equal -Wimplicit-fallthrough -Weverything"
)
set_property
(
DIRECTORY PROPERTY COMPILE_OPTIONS
${
EXTRA_CXX_FLAGS
}
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
# If the user is running a newer version of Clang that includes the
# -Wdouble-promotion, we will ignore that warning.
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.7
)
...
...
test/unittest/encodingstest.cpp
View file @
942bb460
...
...
@@ -267,7 +267,7 @@ static unsigned inline decode(unsigned* state, unsigned* codep, unsigned byte) {
*
codep
=
(
*
state
!=
UTF8_ACCEPT
)
?
(
byte
&
0x3fu
)
|
(
*
codep
<<
6
)
:
(
0xff
>>
type
)
&
(
byte
);
(
0xff
u
>>
type
)
&
(
byte
);
*
state
=
utf8d
[
256
+
*
state
+
type
];
return
*
state
;
...
...
test/unittest/itoatest.cpp
View file @
942bb460
...
...
@@ -74,7 +74,7 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) {
VerifyValue
<
T
>
(
std
::
numeric_limits
<
T
>::
max
(),
f
,
g
);
// 2^n - 1, 2^n, 10^n - 1, 10^n until overflow
for
(
uint32_
t
power
=
2
;
power
<=
10
;
power
+=
8
)
{
for
(
in
t
power
=
2
;
power
<=
10
;
power
+=
8
)
{
T
i
=
1
,
last
;
do
{
VerifyValue
<
T
>
(
i
-
1
,
f
,
g
);
...
...
@@ -86,7 +86,7 @@ static void Verify(void(*f)(T, char*), char* (*g)(T, char*)) {
last
=
i
;
if
(
i
>
static_cast
<
T
>
(
std
::
numeric_limits
<
T
>::
max
()
/
static_cast
<
T
>
(
power
)))
break
;
i
*=
power
;
i
*=
static_cast
<
T
>
(
power
)
;
}
while
(
last
<
i
);
}
}
...
...
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