Commit Graph

153 Commits

Author SHA1 Message Date
Dmitry-Me 9d8f67a6ca Improve test coverage for MathLib::calculate() 2020-01-09 18:18:03 +03:00
Rikard Falkeborn 297360920a Keep prefix in string and char literals (#2272)
Keeping the prefix in the token allows cppcheck to print the correct
string and char literals in debug and error messages.

To achieve this, move some of the helper functions from token.cpp to
utils.h so that checks that look at string and char literals can reuse
them. This is a large part of this commit.

Note that the only user visible change is that when string and char
literals are printed in error messages, the prefix is now included.

For example:

	int f() {
		return test.substr( 0 , 4 ) == U"Hello" ? 0 : 1 ;
	};

now prints U"Hello" instead of "Hello" in the error message.
2019-10-16 11:41:33 +02:00
Oliver Stöneberg eac040a00b Various clang-tidy fixes (#2192)
* use range loops

* removed redundant string initializations

* use nullptr

* use proper boolean false

* removed unnecessary continue from end of loop

* removed unnecessary c_str() usage

* use emplace_back()

* removed redundant void arguments
2019-09-25 15:25:19 +02:00
orbitcowboy 4d223a70dc MathLib: Added robustness tests for 'MathLib::divide()'. 2019-05-25 23:06:50 +02:00
Daniel Marjamäki bd7790fd8c Update copyright year 2019-02-09 07:24:06 +01:00
Daniel Marjamäki 8dd641b8be Use OVERRIDE in test 2019-01-12 15:45:25 +01:00
amai2012 19e979315f
Correct detection of Microsoft extensions in MathLib::isValidIntegerSuffix. Remove public overloaded implementation which was not used outside mathlib.cpp. (#1531) 2018-12-20 12:20:31 +01:00
amai2012 378ffed37e Address compiler warning 2018-12-19 14:39:04 +01:00
amai2012 6924522475
Refactor methods for identification of numeric literals. (#1514) 2018-12-10 12:10:26 +01:00
amai2012 a68086c959
Implement hexadecimal float conversion in MathLib::toDoubleNumber ind… (#1506)
* Implement hexadecimal float conversion in MathLib::toDoubleNumber independent of C99/C++17
* Refactor MathLib::isFloatHex and cure some false results
2018-12-06 22:16:16 +01:00
Daniel Marjamäki 2c803a1ead Revert "#6514 Try to support hexadecimal floating numbers in MathLib::toDoubleNumber"
This reverts commit a73decf7e4.
2018-12-01 19:01:51 +01:00
Daniel Marjamäki 501f99ac5a Revert "astyle formatting"
This reverts commit 9289c9a283.
2018-12-01 19:01:40 +01:00
Daniel Marjamäki 9289c9a283 astyle formatting 2018-12-01 13:17:16 +01:00
amai2012 a73decf7e4 #6514 Try to support hexadecimal floating numbers in MathLib::toDoubleNumber 2018-12-01 00:50:26 +01:00
orbitcowboy 2f032d8fa7
Improved const correctness of local variables. (#1396)
* Improved const correctness of local variables.

* Running astyle [ci-skip].

* Removed duplicate 'const'-keyword.
2018-09-24 15:08:16 +02:00
IOBYTE ce50df8047 Fix override warnings. (#1234) 2018-05-15 16:37:40 +02:00
Matthias Krüger f009cfc845 fix some typos found by codespell. 2018-02-04 20:53:43 +01:00
Daniel Marjamäki c4caee6b18 Updated copyright year 2018-01-14 15:37:52 +01:00
PKEuS b684e1f202 Updated AStyle to version 3.0.1 2018-01-08 20:20:33 +01:00
Martin Ettl 53fbfc9fdb test: Various micro optimizations: Replaced std::string() with std::string(). Use std::string::clear() instead of s = and prefer std::string::empty() instead of (s == ) for checking a string is empty. 2018-01-05 22:03:49 +01:00
Daniel Marjamäki f9d8dd9f4d testsuite: don't compare doubles with != 2017-10-10 22:40:49 +02:00
Ayaz Salikhov 28aa939d69 iwyu - include what you use 2017-05-27 04:33:47 +02:00
Daniel Marjamäki adc659f58b Fixed #7897 (MathLib::toDoubleValue: Does not handle character literal) 2017-02-25 21:58:09 +01:00
Matthias Krüger 064a4aa4cc improve constness of functions as per cppchecks suggestions. 2017-01-07 14:31:03 +01:00
Daniel Marjamäki 90ed7634b8 MathLib: fix for octal char literal '\200' 2016-10-16 13:42:20 +02:00
Daniel Marjamäki fee0e4edfa Fixed #7177 (MathLib: Does not handle '\xF6' properly) 2016-08-28 11:37:05 +02:00
PKEuS fc1603eb9b MathLib, ValueType: Support integer suffix "i64" 2016-07-26 13:19:53 +02:00
Simon Martin 40eacb19b1 Ticket #7565: Handle numbers with several C++14 integer separators. 2016-07-01 23:24:28 +02:00
Simon Martin 3095f47a7b Ticket #7137: Properly detect C++14 digit separators. (#802)
Add an optional extended description…
2016-06-04 22:55:55 +02:00
Alexander Mai 4f77a2b044 #7500 buffer overflow: encodeMultiChar lib/mathlib.cpp:343. Improve errors handling 2016-05-17 20:43:32 +02:00
Simon Martin 3af30e728c Ticket #7452: Properly interpret escape sequences in character literals. 2016-05-15 15:48:24 +02:00
Lauri Nurmi 996c9244d8 Update copyright year to 2007-2016. 2016-01-01 15:34:45 +02:00
Alexander Mai 5ddc5c0798 #7187 internal error; unhandled char constant \e. Support \e char literal support by clang,gcc,tcc 2015-12-05 18:53:03 +01:00
Alexander Mai f4aaa76639 Fix compile error with clang 2015-11-28 16:50:12 +01:00
Alexander Mai 78489f4293 MathLib::characterLiteralToLongNumber can encode unicode char literals, though it's incompatible to gcc/clang 2015-11-28 16:37:26 +01:00
Alexander Mai a7ab5ecf08 Fix some compiler in MathLib::characterLiteralToLongNumber + some small refactoring 2015-11-23 20:41:21 +01:00
Alexander Mai b7030fcfa1 Fix compiler error (VS2010) and warning 2015-11-22 16:56:44 +01:00
Alexander Mai 63b7700660 Use clang/gcc-conforming encoding of multicharacter literals 2015-11-22 14:20:36 +01:00
Alexander Mai 9ca6704c81 #7162 Support multicharacter char literals. 2015-11-22 13:31:31 +01:00
Alexander Mai 517922feb6 MathLib::characterLiteralToLongNumber now reports more specific error messages for unsupported unicode literals (see #7162) 2015-11-22 07:38:38 +01:00
Alexander Mai 714579401f #7160 Internal error: Unhandled char constant '\1'. Correct MathLib::toLongNumber. Create new utility function MathLib::characterLiteralToLongNumber 2015-11-21 22:35:58 +01:00
Daniel Marjamäki 79a70c1277 MathLib::toLongNumber: Better handling of '\x12' and '\000' char constants 2015-11-20 18:57:48 +01:00
Daniel Marjamäki 0f9d90d2be Changed Copyrights. Removed my name. 2015-11-18 20:04:50 +01:00
Alexander Mai 7cdeb70efa Fix some glitches from previous commit to TestMathLib 2015-07-26 19:47:27 +02:00
Alexander Mai 7c48bf3ca5 MathLib::isFloat now detects C99 hexadecimal float literals. MathLib::isDecimalFloat was added for C++ and pre-C99 compatibility. 2015-07-26 19:21:53 +02:00
Daniel Marjamäki f3b5857b96 improved testing of calculations in valueflow 2015-07-26 12:00:42 +02:00
Alexander Mai bbec54db8e Implement MathLib::isFloatHex to detect C99 hexadecimal floating pointer literals. Rename MathLib::isHex to MathLib::isIntHex 2015-07-26 08:06:56 +02:00
Daniel Marjamäki b821e996e1 MathLib: Add TEST_MATHLIB_VALUE that is used to test MathLib::value 2015-07-15 17:36:41 +02:00
orbitcowboy dda5e46d1d Fixed typo in comment. No functional changes. 2015-07-15 15:29:35 +02:00
Alexander Mai 56e90f95d9 Corrections for non-Microsoft compilers 2015-06-28 12:34:08 +02:00