[PATCH] D62899: [analyzer][UninitializedObjectChecker] Mark uninitialized regions as interesting.
Kristóf Umann via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 5 04:28:22 PDT 2019
Szelethus created this revision.
Szelethus added reviewers: NoQ, xazax.hun, dcoughlin, baloghadamsoftware, rnkovacs.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, Charusso, gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, szepet, whisperity.
Repository:
rC Clang
https://reviews.llvm.org/D62899
Files:
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
Index: clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
===================================================================
--- clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
+++ clang/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
// RUN: -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
// RUN: -analyzer-config optin.cplusplus.UninitializedObject:IgnoreGuardedFields=true \
+// RUN: -analyzer-output=text \
// RUN: -std=c++11 -verify %s
//===----------------------------------------------------------------------===//
@@ -158,15 +159,16 @@
public:
UnguardedFieldThroughMethodTest(Kind K) : K(K) {
- switch (K) {
+ switch (K) { // expected-note{{Control jumps to 'case A:' at line}}
case V:
Volume = 0;
break;
case A:
- Area = 0; // expected-warning {{1 uninitialized field}}
- break;
+ Area = 0;
+ break; // expected-note{{Execution jumps to the end of the function}}
}
- }
+ } // expected-warning{{1 uninitialized field}}
+ // expected-note at -1{{1 uninitialized field}}
void operator-() {
assert(K == Kind::A);
@@ -180,6 +182,7 @@
void fUnguardedFieldThroughMethodTest() {
UnguardedFieldThroughMethodTest T1(UnguardedFieldThroughMethodTest::Kind::A);
+ // expected-note at -1{{Calling constructor for 'UnguardedFieldThroughMethodTest'}}
}
class UnguardedPublicFieldsTest {
@@ -196,15 +199,16 @@
public:
UnguardedPublicFieldsTest(Kind K) : K(K) {
- switch (K) {
+ switch (K) { // expected-note{{Control jumps to 'case A:' at line}}
case V:
Volume = 0;
break;
case A:
- Area = 0; // expected-warning {{1 uninitialized field}}
- break;
+ Area = 0;
+ break; // expected-note{{Execution jumps to the end of the function}}
}
- }
+ } // expected-warning {{1 uninitialized field}}
+ // expected-note at -1{{1 uninitialized field}}
void operator-() {
assert(K == Kind::A);
@@ -219,6 +223,7 @@
void fUnguardedPublicFieldsTest() {
UnguardedPublicFieldsTest T1(UnguardedPublicFieldsTest::Kind::A);
+ // expected-note at -1{{Calling constructor for 'UnguardedPublicFieldsTest'}}
}
//===----------------------------------------------------------------------===//
Index: clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
@@ -209,6 +209,7 @@
Report->addNote(Pair.second,
PathDiagnosticLocation::create(Pair.first->getDecl(),
Context.getSourceManager()));
+ Report->markInteresting(Pair.first);
}
Context.emitReport(std::move(Report));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62899.203120.patch
Type: text/x-patch
Size: 3056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190605/d5eea419/attachment.bin>
More information about the cfe-commits
mailing list