r359998 - [analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as primitive.
Kristof Umann via cfe-commits
cfe-commits at lists.llvm.org
Sun May 5 12:42:33 PDT 2019
Author: szelethus
Date: Sun May 5 12:42:33 2019
New Revision: 359998
URL: http://llvm.org/viewvc/llvm-project?rev=359998&view=rev
Log:
[analyzer][UninitializedObjectChecker] PR41741: Regard all scalar types as primitive.
https://bugs.llvm.org/show_bug.cgi?id=41741
Pretty much the same as D61246 and D61106, this time for __complex__ types. Upon
further investigation, I realized that we should regard all types
Type::isScalarType returns true for as primitive, so I merged
isMemberPointerType(), isBlockPointerType() and isAnyComplexType()` into that
instead.
I also stumbled across yet another bug,
https://bugs.llvm.org/show_bug.cgi?id=41753, but it seems to be unrelated to
this checker.
Differential Revision: https://reviews.llvm.org/D61569
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h?rev=359998&r1=359997&r2=359998&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h Sun May 5 12:42:33 2019
@@ -323,9 +323,8 @@ private:
/// needs to be analyzed as much as checking whether their value is undefined.
inline bool isPrimitiveType(const QualType &T) {
return T->isBuiltinType() || T->isEnumeralType() ||
- T->isMemberPointerType() || T->isBlockPointerType() ||
T->isFunctionType() || T->isAtomicType() ||
- T->isVectorType();
+ T->isVectorType() || T->isScalarType();
}
inline bool isDereferencableType(const QualType &T) {
Modified: cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp?rev=359998&r1=359997&r2=359998&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp (original)
+++ cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp Sun May 5 12:42:33 2019
@@ -1,11 +1,15 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN: %clang_analyze_cc1 -std=c++14 -verify %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=optin.cplusplus.UninitializedObject \
// RUN: -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
-// RUN: -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN: -std=c++14 -verify %s
+// RUN: -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
-// RUN: -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
-// RUN: -std=c++14 -verify %s
+// RUN: %clang_analyze_cc1 -std=c++14 -verify %s \
+// RUN: -analyzer-checker=core \
+// RUN: -analyzer-checker=optin.cplusplus.UninitializedObject \
+// RUN: -analyzer-config \
+// RUN: optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true
//===----------------------------------------------------------------------===//
// Default constructor test.
@@ -1156,3 +1160,28 @@ void __vector_size__LongTest() {
VectorSizeLong v;
v.x[0] = 0;
}
+
+struct ComplexUninitTest {
+ ComplexUninitTest() {}
+ __complex__ float x;
+ __complex__ int y;
+};
+
+// FIXME: Currently this causes (unrelated to this checker) an assertion
+// failure.
+//
+//struct ComplexInitTest {
+// ComplexInitTest() {
+// x = {1.0f, 1.0f};
+// y = {1, 1};
+// }
+// __complex__ float x;
+// __complex__ int y;
+//};
+
+void fComplexTest() {
+// ComplexInitTest x;
+
+ // TODO: we should emit a warning for x2.x and x2.y.
+ ComplexUninitTest x2;
+}
More information about the cfe-commits
mailing list