Disable internal checks if NDEBUG is defined (release build)

This commit is contained in:
Thomas Jarosch 2011-10-29 12:47:12 +02:00
parent 6c02de151f
commit ad40586e96
4 changed files with 16 additions and 3 deletions

View File

@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NDEBUG
#include "checkinternal.h"
#include "symboldatabase.h"
#include <string>
@ -23,7 +25,8 @@
using namespace std;
// Register this check class (by creating a static instance of it)
// Register this check class (by creating a static instance of it).
// Disabled in release builds
namespace {
CheckInternal instance;
}
@ -186,3 +189,5 @@ void CheckInternal::missingPercentCharacterError(const Token* tok, const std::st
"Missing percent end character in Token::" + funcname + "() pattern: \"" + pattern + "\""
);
}
#endif // #ifndef NDEBUG

View File

@ -83,9 +83,11 @@ std::string Settings::addEnabled(const std::string &str)
id.insert("performance");
id.insert("portability");
id.insert("information");
id.insert("internal");
id.insert("missingInclude");
id.insert("unusedFunction");
#ifndef NDEBUG
id.insert("internal");
#endif
if (str == "all") {
std::set<std::string>::const_iterator it;

View File

@ -63,7 +63,9 @@ private:
TEST_CASE(enabledPortability);
TEST_CASE(enabledUnusedFunction);
TEST_CASE(enabledMissingInclude);
#ifndef NDEBUG
TEST_CASE(enabledInternal);
#endif
TEST_CASE(errorExitcode);
TEST_CASE(errorExitcodeMissing);
TEST_CASE(errorExitcodeStr);
@ -445,6 +447,7 @@ private:
ASSERT(settings.isEnabled("missingInclude"));
}
#ifndef NDEBUG
void enabledInternal() {
REDIRECT;
const char *argv[] = {"cppcheck", "--enable=internal", "file.cpp"};
@ -453,6 +456,7 @@ private:
ASSERT(parser.ParseFromArgs(3, argv));
ASSERT(settings.isEnabled("internal"));
}
#endif
void errorExitcode() {
REDIRECT;

View File

@ -16,7 +16,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef NDEBUG
#include "tokenize.h"
#include "checkinternal.h"
@ -230,3 +230,5 @@ private:
};
REGISTER_TEST(TestInternal)
#endif // #ifndef NDEBUG