• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify -w %s
2 
3 struct Trivial {
TrivialTrivial4   Trivial(int x) : value(x) {}
5   int value;
6 };
7 
8 struct NonTrivial : public Trivial {
NonTrivialNonTrivial9   NonTrivial(int x) : Trivial(x) {}
10   ~NonTrivial();
11 };
12 
13 
getTrivial()14 Trivial getTrivial() {
15   return Trivial(42); // no-warning
16 }
17 
getTrivialRef()18 const Trivial &getTrivialRef() {
19   return Trivial(42); // expected-warning {{Address of stack memory associated with temporary object of type 'struct Trivial' returned to caller}}
20 }
21 
22 
getNonTrivial()23 NonTrivial getNonTrivial() {
24   return NonTrivial(42); // no-warning
25 }
26 
getNonTrivialRef()27 const NonTrivial &getNonTrivialRef() {
28   return NonTrivial(42); // expected-warning {{Address of stack memory associated with temporary object of type 'struct NonTrivial' returned to caller}}
29 }
30 
31