-
Notifications
You must be signed in to change notification settings - Fork 379
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Not allowing disabling modeling chekcers in ClangSA
When a Clang Static Analyzer checker is disabled in CodeChecker, clang is invoked with the "analyzer-disable-checker" flag. This allows the user disabling core modeling checkers such as unix.DynamicMemoryModeling. This causes malfunctioning of depending checkers. After this patch, modeling checkers (listed with clang -cc1 -analyzer-checker-help-developer) will not be listed and cannot be disabled through CodeChecker.
- Loading branch information
Showing
3 changed files
with
36 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <stdlib.h> | ||
|
||
//We test this: CodeChecker check -d unix -b "g++ -c silencing.cc" | ||
//since the cplusplus.NewDelete checker depends on unix.Malloc | ||
//unix checkers are not allowed to be disabled (-analyzer-disable-checker) to prevent malfunctioning of depending checkers. | ||
|
||
void checkThatMallocCheckerIsRunning() { | ||
malloc(4); | ||
|
||
//The next warning is shown only with clang version earlier than 13.0.1 as the unix checkers cannot be disabled. | ||
//In later versions the output of core, unix checkers are suppressed with silencing (silence-checkers) | ||
} //Potential memory leak [unix.Malloc] | ||
|
||
#define ZERO_SIZE_PTR ((void *)16) | ||
|
||
void test_delete_ZERO_SIZE_PTR() { | ||
int *Ptr = (int *)ZERO_SIZE_PTR; | ||
// ZERO_SIZE_PTR is specially handled but only for malloc family | ||
// We get the next warning with and without the silencing feature. | ||
delete Ptr; //Argument to 'delete' is a constant address (16), which is not memory allocated by 'new' [cplusplus.NewDelete] | ||
} |