-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
123 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
void foo(std::string); | ||
|
||
int main() | ||
{ | ||
std::string s = "test"; | ||
foo(std::move(s)); | ||
|
||
std::cout << s << std::endl; | ||
} |
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,9 @@ | ||
void foo(std::string); | ||
|
||
int main() | ||
{ | ||
std::string s = "test"; | ||
foo(s); | ||
|
||
std::cout << s << std::endl; | ||
} |
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,9 @@ | ||
samples\accessMoved\bad.cpp:8:18: warning: Access of moved variable 's'. [accessMoved] | ||
std::cout << s << std::endl; | ||
^ | ||
samples\accessMoved\bad.cpp:6:9: note: Calling std::move(s) | ||
foo(std::move(s)); | ||
^ | ||
samples\accessMoved\bad.cpp:8:18: note: Access of moved variable 's'. | ||
std::cout << s << std::endl; | ||
^ |
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,11 @@ | ||
static void f(bool b) | ||
{ | ||
if (b) {} | ||
else if (!b) {} | ||
} | ||
|
||
int main() | ||
{ | ||
f(true); | ||
return 0; | ||
} |
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,11 @@ | ||
static void f(bool b) | ||
{ | ||
if (b) {} | ||
else {} | ||
} | ||
|
||
int main() | ||
{ | ||
f(true); | ||
return 0; | ||
} |
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,9 @@ | ||
samples\multiCondition\bad.c:4:14: style: Expression is always true because 'else if' condition is opposite to previous condition at line 3. [multiCondition] | ||
else if (!b) {} | ||
^ | ||
samples\multiCondition\bad.c:3:9: note: first condition | ||
if (b) {} | ||
^ | ||
samples\multiCondition\bad.c:4:14: note: else if condition is opposite to first condition | ||
else if (!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,11 @@ | ||
class C | ||
{ | ||
public: | ||
explicit C(std::string s) | ||
: _s(s) | ||
{ | ||
} | ||
void foo(); | ||
private: | ||
std::string _s; | ||
}; |
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,11 @@ | ||
class C | ||
{ | ||
public: | ||
explicit C(std::string s) | ||
: _s(std::move(s)) | ||
{ | ||
} | ||
void foo(); | ||
private: | ||
std::string _s; | ||
}; |
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,3 @@ | ||
samples\passedByValue_1\bad.cpp:4:28: performance: Function parameter 's' should be passed by const reference. [passedByValue] | ||
explicit C(std::string s) | ||
^ |
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,10 @@ | ||
bool foo(std::string s) | ||
{ | ||
return s.empty(); | ||
} | ||
|
||
int main() | ||
{ | ||
std::string s; | ||
foo(s); | ||
} |
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,10 @@ | ||
bool foo(const std::string& s) | ||
{ | ||
return s.empty(); | ||
} | ||
|
||
int main() | ||
{ | ||
std::string s; | ||
foo(s); | ||
} |
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,3 @@ | ||
samples\passedByValue_2\bad.cpp:1:22: performance: Function parameter 's' should be passed by const reference. [passedByValue] | ||
bool foo(std::string s) | ||
^ |
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,7 @@ | ||
void foo(const std::string&, const std::string&); | ||
|
||
int main() | ||
{ | ||
std::string s1 = "test1", s2 = "test2"; | ||
foo(s1, s1); | ||
} |
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,7 @@ | ||
void foo(const std::string&, const std::string&); | ||
|
||
int main() | ||
{ | ||
std::string s1 = "test1", s2 = "test2"; | ||
foo(s1, s2); | ||
} |
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,3 @@ | ||
samples\unreadVariable\bad.cpp:5:34: style: Variable 's2' is assigned a value that is never used. [unreadVariable] | ||
std::string s1 = "test1", s2 = "test2"; | ||
^ |