Szelethus updated this revision to Diff 198180. Szelethus added a comment. Add a `TODO:`, since we actually don't emit a warning when we should -- I'm afraid that this won't be an easy fix though, similarly to ``__vector_size__``: D61246#inline-543357 <https://reviews.llvm.org/D61246#inline-543357>.
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61569/new/ https://reviews.llvm.org/D61569 Files: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h test/Analysis/cxx-uninitialized-object.cpp Index: test/Analysis/cxx-uninitialized-object.cpp =================================================================== --- test/Analysis/cxx-uninitialized-object.cpp +++ test/Analysis/cxx-uninitialized-object.cpp @@ -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 @@ 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; +} Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h =================================================================== --- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h +++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h @@ -323,9 +323,8 @@ /// 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) {
Index: test/Analysis/cxx-uninitialized-object.cpp =================================================================== --- test/Analysis/cxx-uninitialized-object.cpp +++ test/Analysis/cxx-uninitialized-object.cpp @@ -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 @@ 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; +} Index: lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h =================================================================== --- lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h +++ lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h @@ -323,9 +323,8 @@ /// 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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits