Merge pull request #253 Keep inline functions for GCov code coverage

Keep inline functions for GCov code coverage
This commit is contained in:
Sébastien Rombauts 2020-01-04 22:18:57 +01:00 committed by GitHub
commit 0fd0746863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 22 deletions

View File

@ -50,7 +50,7 @@ else (MSVC)
option(SQLITECPP_USE_GCOV "USE GCov instrumentation." OFF) option(SQLITECPP_USE_GCOV "USE GCov instrumentation." OFF)
if (SQLITECPP_USE_GCOV) if (SQLITECPP_USE_GCOV)
message (STATUS "Using GCov instrumentation") message (STATUS "Using GCov instrumentation")
add_compile_options (-coverage) # NOTE -fkeep-inline-functions would be useful but not working with current Google test and GCC 4.8 add_compile_options (-coverage)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage")
endif () endif ()
endif (CMAKE_COMPILER_IS_GNUCXX) endif (CMAKE_COMPILER_IS_GNUCXX)
@ -198,6 +198,23 @@ if (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Cla
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fPIC") set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fPIC")
endif (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) endif (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
option(SQLITECPP_USE_ASAN "Use Address Sanitizer." OFF)
if (SQLITECPP_USE_ASAN)
if ((CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 6) OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
message (STATUS "Using Address Sanitizer")
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
endif ()
endif ()
endif (SQLITECPP_USE_ASAN)
if (SQLITECPP_USE_GCOV)
# Prevent the compiler from removing the unused inline functions so that they get tracked as "non-covered"
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fkeep-inline-functions -fkeep-static-functions")
endif ()
# Allow the library to be installed via "make install" and found with "find_package" # Allow the library to be installed via "make install" and found with "find_package"
include(GNUInstallDirs) include(GNUInstallDirs)
install(TARGETS SQLiteCpp install(TARGETS SQLiteCpp
@ -227,18 +244,6 @@ install(FILES
## Build provided copy of SQLite3 C library ## ## Build provided copy of SQLite3 C library ##
option(SQLITECPP_USE_ASAN "Use Address Sanitizer." OFF)
if (SQLITECPP_USE_ASAN)
if ((CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 6) OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
message (STATUS "Using Address Sanitizer")
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
endif ()
endif ()
endif (SQLITECPP_USE_ASAN)
option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON) option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON)
if (SQLITECPP_INTERNAL_SQLITE) if (SQLITECPP_INTERNAL_SQLITE)
# build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package # build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package

View File

@ -18,3 +18,7 @@ cmake --build .
# Build and run unit-tests (ie 'make test') # Build and run unit-tests (ie 'make test')
ctest --output-on-failure ctest --output-on-failure
# And with Valgrind
#valgrind --leak-check=full --error-exitcode=1 ./SQLiteCpp_example1
#valgrind --leak-check=full --error-exitcode=1 ./SQLiteCpp_tests

View File

@ -609,7 +609,7 @@ public:
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
/// Return the UTF-8 SQL Query. /// Return the UTF-8 SQL Query.
inline const std::string& getQuery() const const std::string& getQuery() const
{ {
return mQuery; return mQuery;
} }
@ -618,17 +618,17 @@ public:
std::string getExpandedSQL(); std::string getExpandedSQL();
/// Return the number of columns in the result set returned by the prepared statement /// Return the number of columns in the result set returned by the prepared statement
inline int getColumnCount() const int getColumnCount() const
{ {
return mColumnCount; return mColumnCount;
} }
/// true when a row has been fetched with executeStep() /// true when a row has been fetched with executeStep()
inline bool hasRow() const bool hasRow() const
{ {
return mbHasRow; return mbHasRow;
} }
/// true when the last executeStep() had no more row to fetch /// true when the last executeStep() had no more row to fetch
inline bool isDone() const bool isDone() const
{ {
return mbDone; return mbDone;
} }
@ -667,13 +667,13 @@ private:
~Ptr(); ~Ptr();
/// Inline cast operator returning the pointer to SQLite Database Connection Handle /// Inline cast operator returning the pointer to SQLite Database Connection Handle
inline operator sqlite3*() const operator sqlite3*() const
{ {
return mpSQLite; return mpSQLite;
} }
/// Inline cast operator returning the pointer to SQLite Statement Object /// Inline cast operator returning the pointer to SQLite Statement Object
inline operator sqlite3_stmt*() const operator sqlite3_stmt*() const
{ {
return mpStmt; return mpStmt;
} }
@ -696,7 +696,7 @@ private:
* *
* @param[in] aRet SQLite return code to test against the SQLITE_OK expected value * @param[in] aRet SQLite return code to test against the SQLITE_OK expected value
*/ */
inline void check(const int aRet) const void check(const int aRet) const
{ {
if (SQLite::OK != aRet) if (SQLite::OK != aRet)
{ {
@ -707,7 +707,7 @@ private:
/** /**
* @brief Check if there is a row of result returned by executeStep(), else throw a SQLite::Exception. * @brief Check if there is a row of result returned by executeStep(), else throw a SQLite::Exception.
*/ */
inline void checkRow() const void checkRow() const
{ {
if (false == mbHasRow) if (false == mbHasRow)
{ {
@ -718,7 +718,7 @@ private:
/** /**
* @brief Check if there is a Column index is in the range of columns in the result. * @brief Check if there is a Column index is in the range of columns in the result.
*/ */
inline void checkIndex(const int aIndex) const void checkIndex(const int aIndex) const
{ {
if ((aIndex < 0) || (aIndex >= mColumnCount)) if ((aIndex < 0) || (aIndex >= mColumnCount))
{ {