Commit Graph

18265 Commits

Author SHA1 Message Date
firewave 01ceb9bae7 fixed issue 8661: Misleading error message when compilation database is not recognized 2018-07-25 16:26:25 +02:00
Daniel Marjamäki 58c91c4645 Revert "Refactoring endsWith utility function"
This reverts commit d300d1f61b.
2018-07-25 16:14:43 +02:00
orbitcowboy f27baf0956 cli: stop processing in case an invalid or non-existant rule-file is provided. 2018-07-25 08:25:18 +02:00
Daniel Marjamäki f9a5a114bb astyle formatting
[ci skip]
2018-07-25 07:44:06 +02:00
Daniel Marjamäki d300d1f61b Refactoring endsWith utility function 2018-07-25 07:43:50 +02:00
Paul Fultz II 9895ea5ff2 Fix issue 470: Condition is always true or false on logical operators (#1294)
* Fix issue 470: Condition is always true or false on logical operators

* Dont warn on literals

* Compute logical operators using valueflow

* Fix FP when using literals

* Always warn on subconditions that are always true

* Use percent matches first

* Add test for logical operators

* Check if parent is null
2018-07-23 08:51:59 +02:00
Oliver Stöneberg 373039f034 Minor Cleanups (#1321)
* added CLion project folder to .gitignore

* adjusted project name in CMakeLists.txt

* avoid warning when compiling "Debug" with Visual Studio via CMake

There was a GCC-style compiler flag in the common flags in compileroptions.cmake which caused the following warning:
cl : Command line warning D9002 : ignoring unknown option '-O0'

* compileroptions.cmake: restored original formatting
2018-07-23 08:34:41 +02:00
lordylike 12e58c8521 fix ticket 8570: passedByValue with member initializer list and std::move (#1316)
* fix ticket 8570

allow member initializer list variables that are moved to be non-const

* review feedback

* replace tabs with spaces in test code
2018-07-22 15:01:18 +02:00
Daniel Marjamäki 77b653bf94 Clarify warnings when char literals are converted to bool in conditions 2018-07-21 18:40:06 +02:00
Sebastian f862cf603f
posix.cfg: Add some pthread_mutex_* functions. (#1320)
References:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html
http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html
2018-07-21 17:52:12 +02:00
Sebastian a44b4ba441
.gitignore: Ignore dump files created by Cppcheck. (#1319) 2018-07-21 17:51:15 +02:00
Daniel Marjamäki 417670d947 Clarify code with continue 2018-07-20 21:44:23 +02:00
Timothy318 2ae6a84274 Update doxyfile (#1314) 2018-07-20 21:28:28 +02:00
rikardfalkeborn 30a8d953e3 Move sqrt{,f,l} argument checks to cfg file (#1313) 2018-07-20 20:56:39 +02:00
Sebastian 788ad0fc1f
Travis: Parallelize naming.py calls. (#1317)
naming.py is called parallel (4 times at a time) for all *.cpp.dump files directly in gui/ and lib/.
@matthiaskrgr had the idea for it: e46c499f5a (commitcomment-29717495)
Files in gui/test are now ignored already when creating the .dump files.
According to the Travis log output these changes speed up the Travis build up to three minutes.
2018-07-19 08:43:23 +02:00
Sebastian 4ef452132c
posix.cfg,gnu.cfg: Add (get|set)hostname functions. (#1315)
Reference for POSIX gethostname:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html
Reference for sethostname:
http://man7.org/linux/man-pages/man2/gethostname.2.html
2018-07-18 09:40:06 +02:00
Matthias Krüger e46c499f5a travis: when checking variable naming convention, run cppcheck with 2 threads instead of one. 2018-07-16 10:52:40 +02:00
Matthias Krüger 0b308dd095 run dmake 2018-07-16 10:48:49 +02:00
Daniel Marjamäki 7c4820e047 Rename Library::isargvalid() 2018-07-15 23:05:48 +02:00
rikardfalkeborn 491ee577c6 Support floats in valid config (#1297)
* Add tests for invalid ranges

* Refactor loadLibErrors

This reduces the amount of code slightly and will simplify adding
more tests.

* Handle empty valid field

Before this change, the sequence <valid></valid> in a config file would
result in a segmentation fault. Now an empty field results in the error
message:

cppcheck: Failed to load library configuration file 'mycfg.cfg'. Bad attribute value '""'

* Add support for valid for floating point arguments

Previously, it was not possible to add valid ranges to floating point
arguments since it only handled integers. This made ranges not work well
for floating point arguments since arguments were cast to integers
before the ranges were handled.

Fix this by using doubles instead of integers if the argument is a float.
Add some tests for this and make sure errors are printed with enough
precision (somewhat arbitrarily chosen).

Note that it is still only possible to add integer ranges (i.e. -1:1).

* Add support for floats in configuration valid range

Now that it is possible to handle decimal arguments, there is no reason
to not allow non-integer ranges. Take care to not allow broken
configurations.

* Move check to within if-clause

* Move asin{,f,l} and acos{,f,l} input checks to config file
2018-07-15 22:47:56 +02:00
Olivier Croquette b05ae44edb Fix link error when building with MinGW about __imp_PathFileExistsA (#1310)
Following error occurs when building with MinGW 7.2.0 and Ninja on Windows:

  cli/CMakeFiles/cli_objs.dir/filelister.cpp.obj: In function `MyIsDirectory':
  cppcheck-1.84\build/../cli/filelister.cpp:49: undefined reference to `__imp_PathIsDirectoryA'
  cli/CMakeFiles/cli_objs.dir/filelister.cpp.obj: In function `MyFileExists':
  cppcheck-1.84\build/../cli/filelister.cpp:67: undefined reference to `__imp_PathFileExistsA'
  collect2.exe: error: ld returned 1 exit status

This is the corresponding code in filelister.cpp:

  #ifdef _WIN32

  // snip

  static BOOL MyIsDirectory(const std::string& path)
  {
  #ifdef __BORLANDC__
      return (GetFileAttributes(path.c_str()) & FILE_ATTRIBUTE_DIRECTORY);
  #else
  // See http://msdn.microsoft.com/en-us/library/bb773621(VS.85).aspx
      return PathIsDirectoryA(path.c_str());
  #endif
  }

  static BOOL MyFileExists(const std::string& path)
  {
  #ifdef __BORLANDC__
      DWORD fa = GetFileAttributes(path.c_str());
      BOOL result = FALSE;
      if (fa != INVALID_FILE_ATTRIBUTES && !(fa & FILE_ATTRIBUTE_DIRECTORY))
	  result = TRUE;
  #else
      const BOOL result = PathFileExistsA(path.c_str());
  #endif
      return result;
  }

The else blocks assume that Shlwapi.lib is available on Windows except with Borland,
so the patch set ensures that the library is linked on the same condition.
2018-07-15 22:26:02 +02:00
rikardfalkeborn 0e639ea7c9 runtest.sh: Bugfix cfg dir when run in test/cfg (#1311)
Commit 5cc8da2db4 introduced syntax checking of xml-files. This broke
running the file directly in the test/cfg folder since it assumed the
config files to check were located in cfg in the current working
directory. Fix this by adding a variable that holds the correct path.
2018-07-15 22:24:31 +02:00
Daniel Marjamäki 39857220ce Refactoring: Use range for loops 2018-07-15 15:08:35 +02:00
Daniel Marjamäki cc5f00c252 Refactoring; use range for loops 2018-07-15 15:03:08 +02:00
Daniel Marjamäki 518dd8bfa3 Refactoring: Use range for loops 2018-07-15 14:51:33 +02:00
Daniel Marjamäki 1c4fb47582 astyle formatting
[ci skip]
2018-07-15 14:45:33 +02:00
Daniel Marjamäki faea8e1c02 Refactoring: Use range for loops 2018-07-15 14:45:15 +02:00
Paul Fultz II 5d1fdf7958 Fix issue 7904: Handle double nots in isSameExpression (#1305)
* Fix issue 7904: Handle double nots in isSameExpression

* Skip checking double nots in assignments

* Use ast to check for double not
2018-07-15 11:30:02 +02:00
Daniel Marjamäki 60485df762 Refactoring; Use range for loops 2018-07-14 22:49:31 +02:00
Daniel Marjamäki 991300ac54 Clarify code with Token::isUnaryOp() 2018-07-14 22:36:08 +02:00
Daniel Marjamäki 1e824330c0 Refactoring: Use range for loops 2018-07-14 22:26:22 +02:00
Daniel Marjamäki 0f3cc56c59 Refactoring: Use range for loops 2018-07-14 13:19:41 +02:00
Daniel Marjamäki d603a811bb Clarify code with Token::hasKnownValue() 2018-07-14 13:09:53 +02:00
Daniel Marjamäki d00e522856 Clarify the code with Token::isUnaryOp and Token::isBinaryOp 2018-07-14 13:01:24 +02:00
Daniel Marjamäki c9a2071420 Refactoring: Use range for loop 2018-07-14 12:28:57 +02:00
Daniel Marjamäki 0c84475aac Clarify code with Token::isUnaryOp() 2018-07-14 10:26:22 +02:00
Daniel Marjamäki 449c48f6a7 Refactoring: Use range for loops 2018-07-14 10:23:41 +02:00
Daniel Marjamäki c7b787888a Refactoring: Use range for loops 2018-07-14 10:09:12 +02:00
Daniel Marjamäki 7dda8e2a2d Refactoring: Use range for loops 2018-07-14 10:02:32 +02:00
Daniel Marjamäki eeda082a2f Refactoring: use range for loops 2018-07-14 09:54:52 +02:00
Daniel Marjamäki bb36adb432 Refactoring; Use range for loops 2018-07-14 09:49:03 +02:00
Daniel Marjamäki c60763bc14 Refactoring; Use range for loop 2018-07-14 08:18:10 +02:00
Daniel Marjamäki 5b1d96b346 Clarify code with Token::isUnaryOp() 2018-07-14 08:04:08 +02:00
Daniel Marjamäki 4429ee55c3 Refactoring; Use range for loop 2018-07-14 07:55:18 +02:00
Daniel Marjamäki 1dd647ae84 Refactoring; Use range for loop 2018-07-14 07:49:04 +02:00
Daniel Marjamäki d759015d99 Refactoring; Use range for loops 2018-07-13 23:51:22 +02:00
Daniel Marjamäki 594e07acaa Refactoring; Use range for loop 2018-07-13 23:45:34 +02:00
Daniel Marjamäki 58ac8a9982 Refactoring; Use range for loops 2018-07-13 23:43:03 +02:00
Daniel Marjamäki ed76f06ca7 Refactoring; use range for loop 2018-07-13 23:32:49 +02:00
Daniel Marjamäki b2403c36cd Refactoring; Use Token::isUnaryOp() to clarify code 2018-07-13 23:17:24 +02:00