static-analysis

Why do linters pick on useless escape character?

旧街凉风 提交于 2020-07-16 10:39:07
问题 Escaping non-special characters in strings, template literals, and regular expressions doesn't have any effect Source: https://eslint.org/docs/rules/no-useless-escape But clearly this is wrong: There's nothing to "fix" here; we all know this is a perfectly valid sequence of characters. Joking aside what's the rationale behind this? If even ESLint acknowledges that there's no harm then why bother? It may be useless if you only look at the end result (I know that the \ character won't be

How can I display a compiler warning upon function invocation?

蓝咒 提交于 2020-06-27 14:46:08
问题 I've got a function I want to export in my module so people can use it. However, in ≈95% of cases, using it is a bad idea. /// Check whether foo is a metasyntactic variable. /// /// **Using this function is a mistake.** This function is slow, /// since checking widgets is an extremely expensive operation. /// You should be keeping track of what's what, and ideally will /// never need to use this function. /// /// If you _do_ need to use this function, please consider a refactor. pub fn test

Clang Static Analyzer doesn't find the most basic problems

点点圈 提交于 2020-04-10 07:56:46
问题 I wanted to try out the clang static analyzer. I'm on Windows and built clang with Visual Studio. It seems to work, but at the same time it seems to be extremely useless. I made an example file example.c int main(void) { int h = 0; return 1/h; } Calling scan-build gcc -c example.c finds no error. example.c int main(void) { int h; return 1/h; } Calling scan-build gcc -c example.c finds no error. example.c int main(void) { return 1/0; } Calling scan-build gcc -c example.c finds no error. If

scan-build make does not detect any bugs

China☆狼群 提交于 2020-04-06 02:27:45
问题 I have a very simple .c file, with some obvious bugs inside it. #include <stdio.h> struct S { int x; }; void f(struct S s){ } void test() { struct S s; f(s); // warn } int test2(int x){ return 5/(x-x); // warn } int main(){ test(); test2(532); printf("Hej\r\r"); } I am trying to use the clang's static code analyzer tool (scan-build) to detect errors. When I run the tool directly on the files, as for example using the following command: scan-build g++ -o 1 1.c I do get the intended output,

scan-build make does not detect any bugs

会有一股神秘感。 提交于 2020-04-06 02:25:51
问题 I have a very simple .c file, with some obvious bugs inside it. #include <stdio.h> struct S { int x; }; void f(struct S s){ } void test() { struct S s; f(s); // warn } int test2(int x){ return 5/(x-x); // warn } int main(){ test(); test2(532); printf("Hej\r\r"); } I am trying to use the clang's static code analyzer tool (scan-build) to detect errors. When I run the tool directly on the files, as for example using the following command: scan-build g++ -o 1 1.c I do get the intended output,

scan-build make does not detect any bugs

谁说胖子不能爱 提交于 2020-04-06 02:25:04
问题 I have a very simple .c file, with some obvious bugs inside it. #include <stdio.h> struct S { int x; }; void f(struct S s){ } void test() { struct S s; f(s); // warn } int test2(int x){ return 5/(x-x); // warn } int main(){ test(); test2(532); printf("Hej\r\r"); } I am trying to use the clang's static code analyzer tool (scan-build) to detect errors. When I run the tool directly on the files, as for example using the following command: scan-build g++ -o 1 1.c I do get the intended output,

How-to use Clang Static Analyzer on Windows?

你离开我真会死。 提交于 2020-04-05 06:45:15
问题 I'm currently trying to integrate the Clang Static Analyzer v9.0.1 into my CMake v3.16.5 build system using the Microsoft Visual C++ Compiler (MSVC) v19.25.28610.4 on a Windows v10.0.18363.720 operating system. Everything is build for the architecture x86_64. LLVM and Clang have been build from source. After some reading on the World Wide Web (WWW), there seems to be multiple ways to use the Clang Static Analyzer. Sadly the documentation is horrible and there seems to be some special quirks

How-to use Clang Static Analyzer on Windows?

眉间皱痕 提交于 2020-04-05 06:44:50
问题 I'm currently trying to integrate the Clang Static Analyzer v9.0.1 into my CMake v3.16.5 build system using the Microsoft Visual C++ Compiler (MSVC) v19.25.28610.4 on a Windows v10.0.18363.720 operating system. Everything is build for the architecture x86_64. LLVM and Clang have been build from source. After some reading on the World Wide Web (WWW), there seems to be multiple ways to use the Clang Static Analyzer. Sadly the documentation is horrible and there seems to be some special quirks