summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2018-08-03 23:19:07 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2018-08-03 23:19:07 +0000
commit09c31b1c999be5e731422e543fccbfa3e7c24a94 (patch)
treeed6c2b7a22a7b8b506509d71dbe656cc520188a4 /clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp
parente5015abf185b6752bd1df09dad5a0d0435ba24a7 (diff)
downloadbcm5719-llvm-09c31b1c999be5e731422e543fccbfa3e7c24a94.tar.gz
bcm5719-llvm-09c31b1c999be5e731422e543fccbfa3e7c24a94.zip
[analyzer] Do not crash in NoStoreFuncVisitor notes if an unexpected region is found.
Just do not generate the note at all in that case. llvm-svn: 338935
Diffstat (limited to 'clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp')
-rw-r--r--clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp b/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp
index 3d7003ead2e..b869f81b6dd 100644
--- a/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp
+++ b/clang/test/Analysis/diagnostics/no-store-func-path-notes.cpp
@@ -333,3 +333,27 @@ int useMaybeInitializeIndirectlyWithPointer() {
return z; // expected-warning{{Undefined or garbage value returned to caller}}
// expected-note@-1{{Undefined or garbage value returned to caller}}
}
+
+////////
+
+struct HasFieldA {
+ int x;
+};
+
+struct HasFieldB {
+ int x;
+};
+
+void maybeInitializeHasField(HasFieldA *b) {
+ if (coin()) // expected-note{{Assuming the condition is false}}
+ // expected-note@-1{{Taking false branch}}
+ ((HasFieldB*)b)->x = 120;
+}
+
+int forceElementRegionApperence() {
+ HasFieldA a;
+ maybeInitializeHasField(&a); // expected-note{{Calling 'maybeInitializeHasField'}}
+ // expected-note@-1{{Returning from 'maybeInitializeHasField'}}
+ return ((HasFieldB*)&a)->x; // expected-warning{{Undefined or garbage value returned to caller}}
+ // expected-note@-1{{Undefined or garbage value returned to caller}}
+}
OpenPOWER on IntegriCloud