Questions tagged [clang-static-analyzer]

Use this tag for the Clang Static Analyzer, an open source source code analysis tool which find bugs in C and Objective-C programs. Use this tag also for Xcode Static Analyzer.

The Clang Static Analyzer is an open source (supported by Apple) source code analysis tool which find bugs in C and Objective-C programs.

It can be run either as a standalone tool or within Xcode. The standalone tool is invoked from the command line, and is intended to be run in tandem with a build of a codebase.

The analyzer is 100% open source and is part of the Clang project. Like the rest of Clang, the analyzer is implemented as a C++ library that can be used by other tools and applications.

296 questions
0
votes
1 answer

List Clang-Query Matchers

Is there a way to list all possible matchers in clang-query? The AST matcher reference list is not necessarily the most up-to-date version. Even the list in ASTMatchers.h clang header (clang-6.0.0) does not show what is currently available. For…
0
votes
1 answer

How to taint the command line arguments in Clang Static Analyzer

In Clang Static Analyzer, I have the ability to taint any SVal I am interested in. However, I wonder how could I taint the command line arguments. A simple example here: int main(int argc, char **argv) { memcpy(xxx,argv[0],xxx); } Because there…
OSICracker
  • 11
  • 3
0
votes
1 answer

Matching Function Pointers in Clang-Query

What is the query to match a function pointer, e.g., in the following code: int foo(struct A *a, int b) { return a->x->y(b); } y is the function pointer to match.
0
votes
0 answers

Path conditions from a call to checkBranchCondition

I would like to get the path constraints for each possible branch in a program. Say I have a simple program int x; cin >> x; if (x > 0) { cout << "Path A"; } else { cout << "Path B"; } I would like my checker to be able to determine there…
Albert
  • 1
0
votes
1 answer

Telling Clang Static Analyzer about third-party libraries owning references

I maintain an Objective-C project which uses a C library that implements a garbage-collected scripting environment. In several cases, I need to put a retained Objective-C object in the private field of a scripting object. The Objective-C object is…
Jens Ayton
  • 14,532
  • 3
  • 33
  • 47
0
votes
1 answer

Marking a method as main thread?

With Xcode 9, you can get analyzer warnings if the compiler is able to figure out that you're calling UIKit from a background thread. Is there a way to get these for my own methods? For example: @interface MyObject - (void)doThingOnMainThread…
Steven Fisher
  • 44,462
  • 20
  • 138
  • 192
0
votes
0 answers

scan-build raises an error on sds

I'm using the sds library from redis and run scan-build on it. Then I get two errors, that are very similair. I'll present one of the errors here. sds.c:92:22: warning: Out of bound memory access (accessed memory precedes memory…
iveqy
  • 19,951
  • 1
  • 15
  • 20
0
votes
1 answer

clang-check using arm as a target

I've been trying to use clang-check for static code analysis. My makefile generates a compile_commands.json and so far clang-check works well for x86 platforms, however I'd like to use it for arm platforms too. One of the entries looks like this: { …
Ervadac
  • 936
  • 3
  • 9
  • 26
0
votes
0 answers

clang tools for replace names for large project

I am working on some project which has large number of files, and I want to change some names automatically, for example I have a class named as "Test_http", I want to replace it with some other name in the whole project. I've tried with clang-tidy,…
thisEric
  • 486
  • 7
  • 18
0
votes
0 answers

scan-build doesn't find "variable is used uninitialized"

I am trying to find bugs in reviewed project using scan-build tool. Its output report seems just perfect to send to author of code. Tool finds some good warnings. I also use KDevelop 5.0.3 and it shows me even more warnings. Specifically it reports…
MateuszL
  • 2,751
  • 25
  • 38
0
votes
1 answer

Bypass C errors to generate clang debugging information

TL:DR Can you generate clang debugging information(CFGs, PDGs) when the original source file have DEPENDENCY errors from missing header files that cause compilation issues such as undeclared identifiers and unknown types? The files are…
Quentin Mayo
  • 390
  • 4
  • 11
0
votes
1 answer

How do I run clang's static analyzer from tundra

We use tundra as our build system, and would like to run our builds through clang's static analyzer. The scan-build script that one uses to invoke clang's analyzer works by modifying the CC and CXX environment variables, but this approach doesn't…
Ben Harper
  • 2,350
  • 1
  • 16
  • 15
0
votes
1 answer

Clang AST - isNullPointerConstant()

I'm trying to check if input arguments to a CallExpr is null/nil in Objective C using Clang's AST I saw that there is a method isNullPointerConstant() that seems like it will do what I want…
0
votes
2 answers

Running clang static checker at project level (iOS app) rather than file by file (xcodebuild)

After solving this Omitted code blocks from clang AST for ObjectiveC, I've tried it on a small Objective C .m file along with an appropriate compile_commands.json and it works properly and I get the entire syntax tree. Now I'm trying to see if it's…
Jeremy Kuah
  • 519
  • 1
  • 6
  • 18
0
votes
1 answer

Omitted code blocks from clang AST for ObjectiveC

I was generating AST for Objective C code on a .m file The command is roughly like clang-check -ast-dump /source/file.m &> /output/file.txt It had an error that said Error while trying to load a compilation database: Could not auto-detect…
Jeremy Kuah
  • 519
  • 1
  • 6
  • 18