Merge pull request #753 from Dmitry-Me/mergePatterns
Merge overlapping patterns
This commit is contained in:
commit
1bbb82ab2b
|
@ -5609,20 +5609,33 @@ void Tokenizer::simplifyPlatformTypes()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
|
// pre-check to reduce unneeded match calls
|
||||||
|
if (!Token::Match(tok, "std| ::| %type%"))
|
||||||
|
continue;
|
||||||
|
bool isUnsigned;
|
||||||
|
if (Token::Match(tok, "std| ::| size_t|uintptr_t|uintmax_t"))
|
||||||
|
isUnsigned = true;
|
||||||
|
else if (Token::Match(tok, "std| ::| ssize_t|ptrdiff_t|intptr_t|intmax_t"))
|
||||||
|
isUnsigned = false;
|
||||||
|
else
|
||||||
|
continue;
|
||||||
|
|
||||||
bool inStd = false;
|
bool inStd = false;
|
||||||
if (Token::Match(tok, "std :: size_t|ssize_t|ptrdiff_t|intptr_t|uintptr_t")) {
|
if (tok->str() == "::") {
|
||||||
|
tok->deleteThis();
|
||||||
|
} else if (tok->str() == "std") {
|
||||||
|
if (tok->next()->str() != "::")
|
||||||
|
continue;
|
||||||
inStd = true;
|
inStd = true;
|
||||||
tok->deleteNext();
|
tok->deleteNext();
|
||||||
tok->deleteThis();
|
tok->deleteThis();
|
||||||
} else if (Token::Match(tok, ":: size_t|ssize_t|ptrdiff_t|intptr_t|uintptr_t")) {
|
|
||||||
tok->deleteThis();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "size_t|uintptr_t|uintmax_t")) {
|
|
||||||
if (inStd)
|
if (inStd)
|
||||||
tok->originalName("std::" + tok->str());
|
tok->originalName("std::" + tok->str());
|
||||||
else
|
else
|
||||||
tok->originalName(tok->str());
|
tok->originalName(tok->str());
|
||||||
|
if (isUnsigned)
|
||||||
tok->isUnsigned(true);
|
tok->isUnsigned(true);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -5637,24 +5650,6 @@ void Tokenizer::simplifyPlatformTypes()
|
||||||
tok->str("int");
|
tok->str("int");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, "ssize_t|ptrdiff_t|intptr_t|intmax_t")) {
|
|
||||||
if (inStd)
|
|
||||||
tok->originalName("std::" + tok->str());
|
|
||||||
else
|
|
||||||
tok->originalName(tok->str());
|
|
||||||
switch (type) {
|
|
||||||
case isLongLong:
|
|
||||||
tok->isLong(true);
|
|
||||||
tok->str("long");
|
|
||||||
break;
|
|
||||||
case isLong :
|
|
||||||
tok->str("long");
|
|
||||||
break;
|
|
||||||
case isInt:
|
|
||||||
tok->str("int");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_settings->isWindowsPlatform()) {
|
if (_settings->isWindowsPlatform()) {
|
||||||
|
|
Loading…
Reference in New Issue