Skip to content

Commit 53227ae

Browse files
committed
hack for clang -fsanitize=integer -fsanitize=nullability
cf danmar#2922
1 parent ad839c2 commit 53227ae

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

cmake/dynamic_analyzer_options.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ endif()
1919

2020
if(ANALYZE_UNDEFINED)
2121
add_compile_options(-fsanitize=undefined)
22+
add_compile_options(-fsanitize=nullability)
23+
add_compile_options(-fsanitize=integer)
2224
add_compile_options(-fno-sanitize-recover=all)
2325
add_compile_options(-fno-omit-frame-pointer)
2426

25-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
27+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fsanitize=integer -fsanitize=nullability")
2628
endif()
2729

2830
if(ANALYZE_DATAFLOW)

externals/simplecpp/simplecpp.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,14 +2203,19 @@ namespace simplecpp {
22032203
continue;
22042204
}
22052205
// get previous subpath
2206-
const std::string::size_type pos1 = path.rfind('/', pos - 1U) + 1U;
2207-
const std::string previousSubPath = path.substr(pos1, pos-pos1);
2206+
std::string::size_type pos1 = path.rfind('/', pos - 1U);
2207+
if (pos1 == std::string::npos) {
2208+
pos1 = 0;
2209+
} else {
2210+
pos1 += 1U;
2211+
}
2212+
const std::string previousSubPath = path.substr(pos1, pos - pos1);
22082213
if (previousSubPath == "..") {
22092214
// don't simplify
22102215
++pos;
22112216
} else {
22122217
// remove previous subpath and ".."
2213-
path.erase(pos1,pos-pos1+4);
2218+
path.erase(pos1, pos - pos1 + 4);
22142219
if (path.empty())
22152220
path = ".";
22162221
// update pos

test/testsamples.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class TestSamples : public TestFixture {
168168
es >> std::oct >> c;
169169
++from;
170170
++from;
171-
myErr.push_back(c);
171+
myErr.push_back(static_cast<char>(c));
172172
} else {
173173
myErr.push_back(*from);
174174
}

0 commit comments

Comments
 (0)