Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous bugfixes #23

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
cmake_minimum_required(VERSION 3.0.2)
project("sparta")

include(CTest)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})
include(Commons)

Expand All @@ -25,7 +26,7 @@ add_library(sparta INTERFACE)

target_include_directories(sparta INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(sparta INTERFACE ${Boost_LIBRARIES})
Expand Down Expand Up @@ -53,17 +54,6 @@ export(TARGETS sparta FILE sparta_target.cmake)
###################################################
# test
###################################################
file(GLOB test "test/*.cpp")

include(CTest)
# ${test} contains all paths to the test cpps
foreach(testfile ${test})
# ${testfile} is in the format of test/SomeTest.cpp
string(REPLACE ".cpp" "_test" no_ext_name ${testfile})
# ${no_ext_name} is in the format of test/SomeTest_test
get_filename_component(test_bin ${no_ext_name} NAME)
# ${test_bin} is in the format of SomeTest_test
add_executable(${test_bin} ${testfile})
target_link_libraries(${test_bin} PRIVATE sparta gmock_main)
add_test(NAME ${testfile} COMMAND ${test_bin})
endforeach()
if (BUILD_TESTING)
add_subdirectory(test)
endif()
4 changes: 4 additions & 0 deletions include/sparta/PowersetAbstractDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <type_traits>

#include <sparta/AbstractDomain.h>
#include <sparta/Exceptions.h>

namespace sparta {
namespace pad_impl {
Expand Down Expand Up @@ -235,6 +236,9 @@ class PowersetAbstractDomain
return this->get_value()->contains(e);
}
}
SPARTA_ASSERT(false && "unknown AbstractValueKind");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to include:

#include <sparta/Exceptions.h>

Otherwise we are getting the error:

xxx/sparta/PowersetAbstractDomain.h:238:5: error: use of undeclared identifier 'assert'
    SPARTA_ASSERT(false && "unknown AbstractValueKind");
    ^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

// Return false to suppress -Wreturn-type warning reported by gcc
return false;
Comment on lines +239 to +241
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to see if a different compiler that understands the switch case always returns would give a warning here mentioning that this is dead code
We will see what our CI says.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang 16 does not raise any warnings here with -Wall -Wextra, although I have not tried MSVC.

}

friend std::ostream& operator<<(std::ostream& o, const Derived& s) {
Expand Down
3 changes: 3 additions & 0 deletions include/sparta/SmallSortedSetAbstractDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ class SmallSortedSetAbstractDomain final
return this->get_value()->contains(e);
}
}
SPARTA_ASSERT(false && "unknown AbstractValueKind");
// Return false to suppress -Wreturn-type warning reported by gcc
return false;
}

friend std::ostream& operator<<(std::ostream& out,
Expand Down
17 changes: 17 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

file(GLOB test "*.cpp")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add our license header

# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


foreach(testfile ${test})
# ${testfile} is in the format of SomeTest.cpp
string(REPLACE ".cpp" "_test" no_ext_name ${testfile})
# ${no_ext_name} is in the format of SomeTest_test
get_filename_component(test_bin ${no_ext_name} NAME)
# ${test_bin} is in the format of SomeTest_test
add_executable(${test_bin} ${testfile})
target_link_libraries(${test_bin} PRIVATE sparta gmock_main)
add_test(NAME ${testfile} COMMAND ${test_bin})
endforeach()
Loading