mirror of
				https://github.com/mozilla/gecko-dev.git
				synced 2025-10-31 16:28:05 +02:00 
			
		
		
		
	 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
		
			
				
	
	
		
			17 lines
		
	
	
	
		
			702 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			17 lines
		
	
	
	
		
			702 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| // https://clang.llvm.org/extra/clang-tidy/checks/bugprone-string-constructor.html
 | ||
| 
 | ||
| #include "structures.h"
 | ||
| 
 | ||
| void test()
 | ||
| {
 | ||
|   // A common mistake is to swap parameters to the ‘fill’ string-constructor.
 | ||
|   std::string str('x', 50); // should be str(50, 'x')
 | ||
| 
 | ||
|   // Calling the string-literal constructor with a length bigger than the
 | ||
|   // literal is suspicious and adds extra random characters to the string.
 | ||
|   std::string("test", 200);   // Will include random characters after "test".
 | ||
| 
 | ||
|   // Creating an empty string from constructors with parameters is considered
 | ||
|   // suspicious. The programmer should use the empty constructor instead.
 | ||
|   std::string("test", 0);   // Creation of an empty string.
 | ||
| }
 |