Skip to content

Commit

Permalink
Fix scan-build (#269)
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Aug 21, 2019
1 parent 56af147 commit 8869432
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
5 changes: 2 additions & 3 deletions .semaphore/semaphore.yml
Expand Up @@ -72,9 +72,8 @@ blocks:
commands:
- cd test
- scan-build -k make CXX=clang++ CCC_CXX=clang++ showcxxversion
- scan-build -k make CXX=clang++ CCC_CXX=clang++ DEFS=-DIUTEST_HAS_CXX_HDR_VARIANT=0 $PARALLELS | tee log.txt
- |-
grep -e "scan-build: [0-9]* bugs found" log.txt >/dev/null || true && false
- scan-build -k --status-bugs make CXX=clang++ CCC_CXX=clang++ DEFS=-DIUTEST_HAS_CXX_HDR_VARIANT=0 syntax_tests $PARALLELS
# - scan-build -k --status-bugs make CXX=clang++ CCC_CXX=clang++ DEFS=-DIUTEST_HAS_CXX_HDR_VARIANT=0 $PARALLELS
- name: sample-run
commands:
- cd projects/make
Expand Down
2 changes: 1 addition & 1 deletion include/internal/iutest_console.hpp
Expand Up @@ -166,7 +166,7 @@ class iuConsole
iuLogger* pInstance;
};

static LoggerInstanceVariable& GetLoggerInstanceVariable() { static LoggerInstanceVariable v; return v; }
static LoggerInstanceVariable& GetLoggerInstanceVariable() { static LoggerInstanceVariable sLogger; return sLogger; }
static iuLogger* GetLogger() { return GetLoggerInstanceVariable().pInstance; }
};

Expand Down
11 changes: 10 additions & 1 deletion include/internal/iutest_internal.hpp
Expand Up @@ -20,6 +20,10 @@
#include "../iutest_pred.hpp"
#include "../iutest_package.hpp"

#if defined(__clang_analyzer__)
# include <assert.h>
#endif

//======================================================================
// define
/**
Expand Down Expand Up @@ -457,12 +461,17 @@
* @brief IUTEST_ANALYSIS_ASSUME_ を通す
*/
#if IUTEST_HAS_ANALYSIS_ASSUME
# define IUTEST_ANALYSIS_ASSUME_DELEGATE IUTEST_ANALYSIS_ASSUME
#elif defined(__clang_analyzer__)
# define IUTEST_ANALYSIS_ASSUME_DELEGATE assert
#endif

#if defined(IUTEST_ANALYSIS_ASSUME_DELEGATE)
#define IUTEST_THROUGH_ANALYSIS_ASSUME_(expr, todo) \
IUTEST_AMBIGUOUS_ELSE_BLOCKER_ \
if( bool b = true ) { \
IUTEST_UNUSED_VAR(b); \
IUTEST_ANALYSIS_ASSUME(expr); \
IUTEST_ANALYSIS_ASSUME_DELEGATE(expr); \
goto IUTEST_PP_CAT(iutest_label_analysis_assume, __LINE__); \
} else \
IUTEST_PP_CAT(iutest_label_analysis_assume, __LINE__): \
Expand Down
2 changes: 1 addition & 1 deletion include/iutest_env.hpp
Expand Up @@ -324,7 +324,7 @@ class TestEnv
::std::string m_locale_ctype;
};

static Variable& get_vars() { static Variable v; return v; }
static Variable& get_vars() { static Variable sVars; return sVars; }

public:
static detail::iuRandom& genrand() { return get_vars().m_genrand; } //!< 乱数生成器
Expand Down
5 changes: 3 additions & 2 deletions include/iutest_matcher.hpp
Expand Up @@ -983,8 +983,9 @@ class ElementsAreArrayMatcher : public IMatcher

Ite it_a=actual_begin;
typename ::std::vector<T>::iterator it_e=m_expected.begin();
for( int i=0; it_e != m_expected.end(); ++it_e, ++it_a, ++i )
for( int i=0; it_a != actual_end && it_e != m_expected.end(); ++it_e, ++it_a, ++i )
{
(void)i;
if( *it_a != *it_e )
{
return AssertionFailure() << WhichIs();
Expand Down Expand Up @@ -2334,7 +2335,7 @@ detail::ElementsAreArrayMatcher<T> ElementsAreArray(const T* a, int count)

/**
* @brief Make ElementsAreArrayForward matcher
* @details argument はの各要素が a の要素とマッチする
* @details argument の各要素が a の要素とマッチする
*/
template<typename Container>
detail::ElementsAreArrayMatcher< typename Container::value_type > ElementsAreArrayForward(const Container& container)
Expand Down
3 changes: 2 additions & 1 deletion test/compatibility_tests.cpp
Expand Up @@ -6,7 +6,7 @@
*
* @author t.shirayanagi
* @par copyright
* Copyright (C) 2012-2016, Takazumi Shirayanagi\n
* Copyright (C) 2012-2019, Takazumi Shirayanagi\n
* This software is released under the new BSD License,
* see LICENSE
*/
Expand Down Expand Up @@ -89,6 +89,7 @@ IUTEST(Compatibility, TestResult)
const ::iutest::TestInfo* testinfo = ::iutest::UnitTest::GetInstance()->current_test_info();
IUTEST_ASSERT_NOTNULL(testinfo);
const ::iutest::TestResult* result = testinfo->result();
IUTEST_ASSERT_NOTNULL(result);

(void)result->total_part_count();
(void)result->test_property_count();
Expand Down

0 comments on commit 8869432

Please sign in to comment.