clang-static-analyzer

How to find memory leaks with Clang

一世执手 提交于 2021-02-07 05:47:06
问题 I have installed Clang in my machine (ubuntu) in order to find memory leaks in my C code. I wrote a sample code in order to check the working of it which is as follows: /* File: hello.c for leak detection */ #include <stdio.h> #include <stdlib.h> void *x; int main() { x = malloc(2); x = 0; // Memory leak return 0; } I found some options in internet to compile like $ scan-build clang --analyze hello.c and $ scan-build clang -fsanitize=address hello.c But none of them are showing any signs of

How do I use the clang static analyzer with msbuild on Windows?

空扰寡人 提交于 2021-01-27 10:22:35
问题 The binary windows installer for clang includes scan-build but when you run it with msbuild nothing happens. Even if I do something like: "C:\Program Files\LLVM\bin\scan-build.bat" "C:\Program Files\LLVM\bin\clang.exe" test.cpp I get something like: scan-build: Using 'C:\Program Files\LLVM\bin\clang.exe' for static analysis scan-build: Removed Directory '....' scan-build: No Bugs found Where test.cpp is: void DivideByZero(int z){ if (z == 0) { int x = 1 / z; } } int main() { int *i = nullptr;

How do I use the clang static analyzer with msbuild on Windows?

a 夏天 提交于 2021-01-27 10:19:33
问题 The binary windows installer for clang includes scan-build but when you run it with msbuild nothing happens. Even if I do something like: "C:\Program Files\LLVM\bin\scan-build.bat" "C:\Program Files\LLVM\bin\clang.exe" test.cpp I get something like: scan-build: Using 'C:\Program Files\LLVM\bin\clang.exe' for static analysis scan-build: Removed Directory '....' scan-build: No Bugs found Where test.cpp is: void DivideByZero(int z){ if (z == 0) { int x = 1 / z; } } int main() { int *i = nullptr;

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

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

Making new checker visible in the Clang's Static Analyzer

感情迁移 提交于 2020-01-17 06:07:29
问题 I have included the following code in llvm/tools/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td file under let ParentPackage = CoreAlpha in{ ... def SimpleFunc: Checker<"SimpleFunc">, HelpText<"Simple Function Checking">, DescFile<"SimpleFunc.cpp">; But when I am checking its presence after successful compilation by typing the following command, the checker is not visible. clang -cc1 -analyzer-checker-help I don't know what's the reason, hope someone could help me regarding this. 回答1

Making new checker visible in the Clang's Static Analyzer

Deadly 提交于 2020-01-17 06:07:25
问题 I have included the following code in llvm/tools/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td file under let ParentPackage = CoreAlpha in{ ... def SimpleFunc: Checker<"SimpleFunc">, HelpText<"Simple Function Checking">, DescFile<"SimpleFunc.cpp">; But when I am checking its presence after successful compilation by typing the following command, the checker is not visible. clang -cc1 -analyzer-checker-help I don't know what's the reason, hope someone could help me regarding this. 回答1

CLang error (objective C): value stored during initialization is never read

谁说胖子不能爱 提交于 2020-01-15 05:33:13
问题 Foo *oFoo = [[[Foo alloc] init] autorelease]; This is how I was taught to program in Objective C, yet the CLang error checker complains that the initial value was never read. But oFoo is an object with properties. oFoo itself has no single value. The property values are what matter. oFoo.PropertyA = 1; oFoo.PropertyB = @"Hello, World." Should I just ignore this? Is this worth fixing? What is the fix, seeing that "initial value" is meaningless in my context? 回答1: Usually that means: You've