forked from mirrors/gecko-dev
		
	 34a6c4ff8f
			
		
	
	
		34a6c4ff8f
		
	
	
	
	
		
			
			Differential Revision: https://phabricator.services.mozilla.com/D3980 --HG-- rename : tools/clang-tidy/test/misc-bool-pointer-implicit-conversion.cpp => tools/clang-tidy/test/bugprone-bool-pointer-implicit-conversion.cpp rename : tools/clang-tidy/test/misc-forward-declaration-namespace.cpp => tools/clang-tidy/test/bugprone-forward-declaration-namespace.cpp rename : tools/clang-tidy/test/misc-macro-repeated-side-effects.cpp => tools/clang-tidy/test/bugprone-macro-repeated-side-effects.cpp rename : tools/clang-tidy/test/misc-string-constructor.cpp => tools/clang-tidy/test/bugprone-string-constructor.cpp rename : tools/clang-tidy/test/misc-string-integer-assignment.cpp => tools/clang-tidy/test/bugprone-string-integer-assignment.cpp rename : tools/clang-tidy/test/misc-suspicious-missing-comma.cpp => tools/clang-tidy/test/bugprone-suspicious-missing-comma.cpp rename : tools/clang-tidy/test/misc-swapped-arguments.cpp => tools/clang-tidy/test/bugprone-swapped-arguments.cpp rename : tools/clang-tidy/test/misc-unused-raii.cpp => tools/clang-tidy/test/bugprone-unused-raii.cpp extra : moz-landing-system : lando
		
			
				
	
	
		
			28 lines
		
	
	
	
		
			589 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
	
		
			589 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // https://clang.llvm.org/extra/clang-tidy/checks/bugprone-string-integer-assignment.html
 | |
| 
 | |
| #include "structures.h"
 | |
| 
 | |
| void test_int()
 | |
| {
 | |
|   // Numeric types can be implicitly casted to character types.
 | |
|   std::string s;
 | |
|   int x = 5965;
 | |
|   s = 6; // warning
 | |
|   s = x; // warning
 | |
| }
 | |
| 
 | |
| void test_conversion()
 | |
| {
 | |
|   // Use the appropriate conversion functions or character literals.
 | |
|   std::string s;
 | |
|   int x = 5965;
 | |
|   s = '6'; // OK
 | |
|   s = std::to_string(x); // OK
 | |
| }
 | |
| 
 | |
| void test_cast()
 | |
| {
 | |
|   // In order to suppress false positives, use an explicit cast.
 | |
|   std::string s;
 | |
|   s = static_cast<char>(6); // OK
 | |
| }
 |