-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make single-argument string constructors explicit #2707
Conversation
TimeBaseStoreType is not the same as TimeBase
Cast to the TimeBaseStore type with a known size
Remove unnecessary const casting
Existing code was correct but somewhat terse and obscure Refactor and add comments for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Remove explicit from char* constructor The autocoder depends on the implicit constructor
|
||
TaskString(const char* src) : StringBase() { *this = src; } | ||
explicit TaskString(const char* src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
TaskString(const StringBase& src) : StringBase() { *this = src; } | ||
explicit TaskString(const StringBase& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
TaskString() : StringBase() { *this = ""; } | ||
|
||
TaskString(const TaskString& src) : StringBase() { *this = src; } | ||
explicit TaskString(const TaskString& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
ObjectName(const char* src) : StringBase() { *this = src; } | ||
explicit ObjectName(const char* src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
ObjectName(const StringBase& src) : StringBase() { *this = src; } | ||
explicit ObjectName(const StringBase& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
FileNameString(const char* src) : StringBase() { *this = src; } | ||
explicit FileNameString(const char* src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
FileNameString(const StringBase& src) : StringBase() { *this = src; } | ||
explicit FileNameString(const StringBase& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
}; | ||
|
||
FileNameString() : StringBase() { *this = ""; } | ||
|
||
FileNameString(const FileNameString& src) : StringBase() { *this = src; } | ||
explicit FileNameString(const FileNameString& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
}; | ||
|
||
String() : StringBase() { *this = ""; } | ||
|
||
String(const String& src) : StringBase() { *this = src; } | ||
explicit String(const String& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
|
||
String(const StringBase& src) : StringBase() { *this = src; } | ||
explicit String(const StringBase& src) : StringBase() { *this = src; } |
Check notice
Code scanning / CodeQL
More than one statement per line Note
This PR makes single-argument string constructors explicit, where possible with the current code generation. Explicit single-argument constructors are recommended (including by the static analysis in this repo) because they avoid unwanted implicit conversions.
Note the following:
char *
constructor ofFw::String
, we can't make the single-argument constructors explicit until we close this issue: Revise generated C++ that relies on implicit string constructors fpp#421.