瀏覽代碼

[analyzer][MallocChecker][NFC] Document and reorganize some functions

This patch merely reorganizes some things, and features no functional change.

In detail:

* Provided documentation, or moved existing documentation in more obvious
places.
* Added dividers. (the //===----------===// thing).
* Moved getAllocationFamily, printAllocDeallocName, printExpectedAllocName and
printExpectedDeallocName in the global namespace on top of the file where
AllocationFamily is declared, as they are very strongly related.
* Moved isReleased and MallocUpdateRefState near RefState's definition for the
same reason.
* Realloc modeling was very poor in terms of variable and structure naming, as
well as documentation, so I renamed some of them and added much needed docs.
* Moved function IdentifierInfos to a separate struct, and moved isMemFunction,
isCMemFunction adn isStandardNewDelete inside it. This makes the patch affect
quite a lot of lines, should I extract it to a separate one?
* Moved MallocBugVisitor out of MallocChecker.
* Preferred switches to long else-if branches in some places.
* Neatly organized some RUN: lines.

Differential Revision: https://reviews.llvm.org/D54823


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349281 91177308-0d34-0410-b5e6-96231b3b80d8
Kristof Umann 6 年之前
父節點
當前提交
97361a20a7
共有 3 個文件被更改,包括 535 次插入270 次删除
  1. 524 268
      lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  2. 5 1
      test/Analysis/malloc-annotations.c
  3. 6 1
      test/Analysis/malloc.c

文件差異過大導致無法顯示
+ 524 - 268
lib/StaticAnalyzer/Checkers/MallocChecker.cpp


+ 5 - 1
test/Analysis/malloc-annotations.c

@@ -1,4 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc -analyzer-store=region -verify -analyzer-config unix.Malloc:Optimistic=true %s
+// RUN: %clang_analyze_cc1 -analyzer-store=region -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.deadcode.UnreachableCode \
+// RUN:   -analyzer-checker=alpha.core.CastSize,unix.Malloc \
+// RUN:   -analyzer-config unix.Malloc:Optimistic=true
 typedef __typeof(sizeof(int)) size_t;
 typedef __typeof(sizeof(int)) size_t;
 void *malloc(size_t);
 void *malloc(size_t);
 void free(void *);
 void free(void *);

+ 6 - 1
test/Analysis/malloc.c

@@ -1,4 +1,9 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.deadcode.UnreachableCode,alpha.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-store=region -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.deadcode.UnreachableCode \
+// RUN:   -analyzer-checker=alpha.core.CastSize \
+// RUN:   -analyzer-checker=unix.Malloc \
+// RUN:   -analyzer-checker=debug.ExprInspection
 
 
 #include "Inputs/system-header-simulator.h"
 #include "Inputs/system-header-simulator.h"
 
 

部分文件因文件數量過多而無法顯示