-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed object-lifetime visualization for more than one temporary.
- Loading branch information
1 parent
7dd35be
commit caec790
Showing
4 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// cmdlineinsights:-edu-show-lifetime | ||
|
||
template<class T, class U> | ||
struct pair { | ||
T first; | ||
U second; | ||
|
||
pair(T&& t, U&& u) | ||
: first{t} | ||
, second{u} | ||
{} | ||
|
||
pair(const T& t, const U& u) | ||
: first{t} | ||
, second{u} | ||
{} | ||
}; | ||
|
||
// From: https://eel.is/c++draft/class.temporary#6.11 | ||
struct S { | ||
int mi; | ||
const pair<int, int>& failingp; | ||
}; | ||
|
||
int main() | ||
{ | ||
S invalids{1, {2, 3}}; // #A | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/************************************************************************************* | ||
* NOTE: This an educational hand-rolled transformation. Things can be incorrect or * | ||
* buggy. * | ||
*************************************************************************************/ | ||
template<class T, class U> | ||
struct pair | ||
{ | ||
T first; | ||
U second; | ||
inline pair(T && t, U && u) | ||
: first{t} | ||
, second{u} | ||
{ | ||
} | ||
|
||
inline pair(const T & t, const U & u) | ||
: first{t} | ||
, second{u} | ||
{ | ||
} | ||
|
||
}; | ||
|
||
/* First instantiated from: EduLifeTimeTest13.cpp:27 */ | ||
#ifdef INSIGHTS_USE_TEMPLATE | ||
template<> | ||
struct pair<int, int> | ||
{ | ||
int first; | ||
int second; | ||
inline pair(int && t, int && u) | ||
: first{t} | ||
, second{u} | ||
{ | ||
} | ||
|
||
inline pair(const int & t, const int & u); | ||
|
||
}; | ||
|
||
#endif | ||
|
||
struct S | ||
{ | ||
int mi; | ||
const pair<int, int> & failingp; | ||
}; | ||
|
||
|
||
int main() | ||
{ | ||
int __temporary27_18 = 2; | ||
int __temporary27_21 = 3; | ||
const pair<int, int> __temporary27_22 = pair<int, int>{__temporary27_18, __temporary27_21}; | ||
S invalids = {1, __temporary27_22}; | ||
/* __temporary27_21 // lifetime ends here */ | ||
/* __temporary27_18 // lifetime ends here */ | ||
return 0; | ||
/* __temporary27_22 // lifetime ends here */ | ||
/* invalids // lifetime ends here */ | ||
} |