-
-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`CK_NoOp` stands for adding `const` or other qualifiers. Show this conversion, if `--show-all-implicit-casts` is active. This patch enables showing implicit casts for member-function calls as well.
- Loading branch information
1 parent
44d4c44
commit bea5681
Showing
6 changed files
with
105 additions
and
9 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,13 @@ | ||
// cmdlineinsights:--show-all-implicit-casts | ||
|
||
struct A {}; | ||
struct B { | ||
explicit operator A() { return {}; } | ||
}; | ||
|
||
void DangerousFunc(const A&) {} | ||
|
||
int main() | ||
{ | ||
DangerousFunc(static_cast<A>(B{})); | ||
} |
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:--show-all-implicit-casts | ||
|
||
struct A | ||
{ | ||
}; | ||
|
||
|
||
struct B | ||
{ | ||
using retType_5_4 = A; | ||
inline operator retType_5_4 () | ||
{ | ||
return {}; | ||
} | ||
|
||
}; | ||
|
||
|
||
|
||
void DangerousFunc(const A &) | ||
{ | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
DangerousFunc(static_cast<const A>(static_cast<A>(B{}.operator 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,14 @@ | ||
// cmdlineinsights:--show-all-implicit-casts | ||
struct A | ||
{ | ||
bool operator==(const A&) const { return true; } | ||
bool operator!=(const A&) { return true; } | ||
}; | ||
|
||
int main() | ||
{ | ||
A a{}; | ||
|
||
if(a == a) {} // a gets constified as object and parameter | ||
if(a != a) {} // only the parameter gets constified, as != is not const | ||
} |
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,28 @@ | ||
// cmdlineinsights:--show-all-implicit-casts | ||
struct A | ||
{ | ||
inline bool operator==(const A &) const | ||
{ | ||
return true; | ||
} | ||
|
||
inline bool operator!=(const A &) | ||
{ | ||
return true; | ||
} | ||
|
||
}; | ||
|
||
|
||
|
||
int main() | ||
{ | ||
A a = {}; | ||
if(static_cast<const A>(a).operator==(static_cast<const A>(a))) { | ||
} | ||
|
||
if(a.operator!=(static_cast<const A>(a))) { | ||
} | ||
|
||
} | ||
|