This commit is contained in:
parent
cf64ccea22
commit
2a15428096
|
@ -418,6 +418,12 @@ bool CmdLineParser::parseFromArgs(int argc, const char* const argv[])
|
|||
else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0)
|
||||
mSettings.force = true;
|
||||
|
||||
else if (std::strcmp(argv[i], "--fsigned-char") == 0)
|
||||
mSettings.platform.defaultSign = 's';
|
||||
|
||||
else if (std::strcmp(argv[i], "--funsigned-char") == 0)
|
||||
mSettings.platform.defaultSign = 'u';
|
||||
|
||||
// Print help
|
||||
else if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) {
|
||||
mPathNames.clear();
|
||||
|
@ -1191,6 +1197,8 @@ void CmdLineParser::printHelp() const
|
|||
" -f, --force Force checking of all configurations in files. If used\n"
|
||||
" together with '--max-configs=', the last option is the\n"
|
||||
" one that is effective.\n"
|
||||
" --fsigned-char Treat char type as signed.\n"
|
||||
" --funsigned-char Treat char type as unsigned.\n"
|
||||
" -h, --help Print this help.\n"
|
||||
" -I <dir> Give path to search for include files. Give several -I\n"
|
||||
" parameters to give several paths. First given path is\n"
|
||||
|
|
|
@ -332,6 +332,8 @@ void ImportProject::fsParseCommand(FileSettings& fs, const std::string& command)
|
|||
defs += "__PIE__";
|
||||
defs += ";";
|
||||
}
|
||||
// TODO: support -fsigned-char and -funsigned-char?
|
||||
// we can only set it globally but in this context it needs to be treated per file
|
||||
}
|
||||
}
|
||||
fsSetDefines(fs, defs);
|
||||
|
@ -733,6 +735,8 @@ bool ImportProject::importVcxproj(const std::string &filename, std::map<std::str
|
|||
}
|
||||
}
|
||||
}
|
||||
// # TODO: support signedness of char via /J (and potential XML option for it)?
|
||||
// we can only set it globally but in this context it needs to be treated per file
|
||||
|
||||
for (const std::string &c : compileList) {
|
||||
const std::string cfilename = Path::simplifyPath(Path::isAbsolute(c) ? c : Path::getPathFromFilename(filename) + c);
|
||||
|
|
|
@ -126,6 +126,12 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
|
|||
<arg choice="opt">
|
||||
<option>--force</option>
|
||||
</arg>
|
||||
<arg choice="opt">
|
||||
<option>--fsigned-char</option>
|
||||
</arg>
|
||||
<arg choice="opt">
|
||||
<option>--funsigned-char</option>
|
||||
</arg>
|
||||
<arg choice="opt">
|
||||
<option>--help</option>
|
||||
</arg>
|
||||
|
@ -350,6 +356,22 @@ Example: '-UDEBUG'</para>
|
|||
default. If used together with --max-configs=, the last option is the one that is effective.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--fsigned-char</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Treat char type as signed. This overrides previous --platform options and is overridden by following ones.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>--funsigned-char</option>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>Treat char type as unsigned. This overrides previous --platform options and is overridden by following ones.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term>
|
||||
<option>-h</option>
|
||||
|
|
|
@ -31,3 +31,4 @@ Other:
|
|||
- You can suppress warnings in current file using "-file".
|
||||
- You can suppress all warnings where macro is used using "-macro"
|
||||
- fixed CMake build with UBSAN and GCC
|
||||
- Added command-line options "--fsigned-char" and "--funsigned-char" to control the signess of the "char" type. This overrides previously specified "--platform" options and is overrides by following ones.
|
||||
|
|
|
@ -316,6 +316,11 @@ private:
|
|||
#else
|
||||
TEST_CASE(ruleFileNotSupported);
|
||||
#endif
|
||||
TEST_CASE(signedChar);
|
||||
TEST_CASE(signedChar2);
|
||||
TEST_CASE(unsignedChar);
|
||||
TEST_CASE(unsignedChar2);
|
||||
TEST_CASE(signedCharUnsignedChar);
|
||||
|
||||
TEST_CASE(ignorepaths1);
|
||||
TEST_CASE(ignorepaths2);
|
||||
|
@ -2067,6 +2072,51 @@ private:
|
|||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
void signedChar() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--fsigned-char", "file.cpp"};
|
||||
settings->platform.defaultSign = '\0';
|
||||
ASSERT(parser->parseFromArgs(3, argv));
|
||||
ASSERT_EQUALS('s', settings->platform.defaultSign);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
void signedChar2() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--platform=avr8", "--fsigned-char", "file.cpp"};
|
||||
settings->platform.defaultSign = '\0';
|
||||
ASSERT(parser->parseFromArgs(4, argv));
|
||||
ASSERT_EQUALS('s', settings->platform.defaultSign);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
void unsignedChar() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--funsigned-char", "file.cpp"};
|
||||
settings->platform.defaultSign = '\0';
|
||||
ASSERT(parser->parseFromArgs(3, argv));
|
||||
ASSERT_EQUALS('u', settings->platform.defaultSign);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
void unsignedChar2() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--platform=mips32", "--funsigned-char", "file.cpp"};
|
||||
settings->platform.defaultSign = '\0';
|
||||
ASSERT(parser->parseFromArgs(4, argv));
|
||||
ASSERT_EQUALS('u', settings->platform.defaultSign);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
void signedCharUnsignedChar() {
|
||||
REDIRECT;
|
||||
const char * const argv[] = {"cppcheck", "--fsigned-char", "--funsigned-char", "file.cpp"};
|
||||
settings->platform.defaultSign = '\0';
|
||||
ASSERT(parser->parseFromArgs(4, argv));
|
||||
ASSERT_EQUALS('u', settings->platform.defaultSign);
|
||||
ASSERT_EQUALS("", GET_REDIRECT_OUTPUT);
|
||||
}
|
||||
|
||||
#ifdef HAVE_RULES
|
||||
void rule() {
|
||||
REDIRECT;
|
||||
|
|
Loading…
Reference in New Issue