Skip to content

Commit 6402a97

Browse files
committed
[analyzer] Checker for uninitialized C++ objects
This checker analyzes C++ constructor calls, and reports uninitialized fields. Due to the nature of this problem (uninitialized fields after an object construction), this checker doesn't search for bugs, but rather is a tool to enforce a specific programming model where every field needs to be initialized. This checker lands in alpha for now, and a number of followup patches will be made to reduce false negatives and to make it easier for the user to understand what rules the checker relies on, eg. whether a derived class' constructor is responsible for initializing inherited data members or whether it should be handled in the base class' constructor. Differential Revision: https://reviews.llvm.org/D45532 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@334935 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 07caa7f commit 6402a97

7 files changed

+3224
-0
lines changed

include/clang/StaticAnalyzer/Checkers/Checkers.td

+4
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ def MisusedMovedObjectChecker: Checker<"MisusedMovedObject">,
319319
"object will be reported">,
320320
DescFile<"MisusedMovedObjectChecker.cpp">;
321321

322+
def UninitializedObjectChecker: Checker<"UninitializedObject">,
323+
HelpText<"Reports uninitialized fields after object construction">,
324+
DescFile<"UninitializedObjectChecker.cpp">;
325+
322326
} // end: "alpha.cplusplus"
323327

324328

lib/StaticAnalyzer/Checkers/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ add_clang_library(clangStaticAnalyzerCheckers
9292
UndefResultChecker.cpp
9393
UndefinedArraySubscriptChecker.cpp
9494
UndefinedAssignmentChecker.cpp
95+
UninitializedObjectChecker.cpp
9596
UnixAPIChecker.cpp
9697
UnreachableCodeChecker.cpp
9798
VforkChecker.cpp

0 commit comments

Comments
 (0)