Token: add isRestrict flag
This commit is contained in:
parent
e2c35abde5
commit
03c9253962
|
@ -651,6 +651,13 @@ public:
|
|||
setFlag(fIsInline, b);
|
||||
}
|
||||
|
||||
bool isRestrict() const {
|
||||
return getFlag(fIsRestrict);
|
||||
}
|
||||
void isRestrict(bool b) {
|
||||
setFlag(fIsRestrict, b);
|
||||
}
|
||||
|
||||
bool isRemovedVoidParameter() const {
|
||||
return getFlag(fIsRemovedVoidParameter);
|
||||
}
|
||||
|
@ -1277,6 +1284,7 @@ private:
|
|||
fIsSimplifedScope = (1ULL << 34), // scope added when simplifying e.g. if (int i = ...; ...)
|
||||
fIsRemovedVoidParameter = (1ULL << 35), // A void function parameter has been removed
|
||||
fIsIncompleteConstant = (1ULL << 36),
|
||||
fIsRestrict = (1ULL << 37), // Is this a restrict pointer type
|
||||
};
|
||||
|
||||
Token::Type mTokType;
|
||||
|
|
|
@ -5498,6 +5498,8 @@ void Tokenizer::dump(std::ostream &out) const
|
|||
out << " isImplicitInt=\"true\"";
|
||||
if (tok->isComplex())
|
||||
out << " isComplex=\"true\"";
|
||||
if (tok->isRestrict())
|
||||
out << " isRestrict=\"true\"";
|
||||
if (tok->link())
|
||||
out << " link=\"" << tok->link() << '\"';
|
||||
if (tok->varId() > 0)
|
||||
|
@ -11249,11 +11251,14 @@ void Tokenizer::simplifyKeyword()
|
|||
if (keywords.find(tok->str()) != keywords.end()) {
|
||||
// Don't remove struct members
|
||||
if (!Token::simpleMatch(tok->previous(), ".")) {
|
||||
if (tok->str().find("inline") != std::string::npos) {
|
||||
Token *temp = tok->next();
|
||||
while (temp != nullptr && Token::Match(temp, "%name%")) {
|
||||
temp->isInline(true);
|
||||
temp = temp->next();
|
||||
const bool isinline = (tok->str().find("inline") != std::string::npos);
|
||||
const bool isrestrict = (tok->str().find("restrict") != std::string::npos);
|
||||
if (isinline || isrestrict) {
|
||||
for (Token *temp = tok->next(); Token::Match(temp, "%name%"); temp = temp->next()) {
|
||||
if (isinline)
|
||||
temp->isInline(true);
|
||||
if (isrestrict)
|
||||
temp->isRestrict(true);
|
||||
}
|
||||
}
|
||||
tok->deleteThis(); // Simplify..
|
||||
|
@ -11271,8 +11276,12 @@ void Tokenizer::simplifyKeyword()
|
|||
tok->deleteNext();
|
||||
|
||||
if (c99) {
|
||||
while (tok->str() == "restrict")
|
||||
if (tok->str() == "restrict") {
|
||||
for (Token *temp = tok->next(); Token::Match(temp, "%name%"); temp = temp->next()) {
|
||||
temp->isRestrict(true);
|
||||
}
|
||||
tok->deleteThis();
|
||||
}
|
||||
|
||||
if (mSettings->standards.c >= Standards::C11) {
|
||||
while (tok->str() == "_Atomic")
|
||||
|
|
Loading…
Reference in New Issue