@@ -80,12 +80,13 @@ void TokenList::deallocateTokens()
8080
8181void TokenList::determineCppC ()
8282{
83- if (!mSettings ) {
84- mIsC = Path::isC (getSourceFilePath ());
85- mIsCpp = Path::isCPP (getSourceFilePath ());
83+ if (mSettings && (mSettings ->enforcedLang != Settings::Language::None)) {
84+ mLang = mSettings ->enforcedLang ;
8685 } else {
87- mIsC = mSettings ->enforcedLang == Settings::Language::C || (mSettings ->enforcedLang == Settings::Language::None && Path::isC (getSourceFilePath ()));
88- mIsCpp = mSettings ->enforcedLang == Settings::Language::CPP || (mSettings ->enforcedLang == Settings::Language::None && Path::isCPP (getSourceFilePath ()));
86+ if (Path::isC (getSourceFilePath ()))
87+ mLang = Settings::Language::C;
88+ else if (Path::isCPP (getSourceFilePath ()))
89+ mLang = Settings::Language::CPP;
8990 }
9091}
9192
@@ -1854,7 +1855,7 @@ void TokenList::simplifyPlatformTypes()
18541855 if (!mSettings )
18551856 return ;
18561857
1857- const bool isCPP11 = mIsCpp && (mSettings ->standards .cpp >= Standards::CPP11);
1858+ const bool isCPP11 = isCPP () && (mSettings ->standards .cpp >= Standards::CPP11);
18581859
18591860 enum { isLongLong, isLong, isInt } type;
18601861
@@ -1996,7 +1997,7 @@ void TokenList::simplifyStdType()
19961997 continue ;
19971998 }
19981999
1999- if (Token::Match (tok, " char|short|int|long|unsigned|signed|double|float" ) || (mIsC && (mSettings ->standards .c >= Standards::C99) && Token::Match (tok, " complex|_Complex" ))) {
2000+ if (Token::Match (tok, " char|short|int|long|unsigned|signed|double|float" ) || (isC () && (mSettings ->standards .c >= Standards::C99) && Token::Match (tok, " complex|_Complex" ))) {
20002001 bool isFloat= false ;
20012002 bool isSigned = false ;
20022003 bool isUnsigned = false ;
@@ -2019,7 +2020,7 @@ void TokenList::simplifyStdType()
20192020 else if (Token::Match (tok2, " float|double" )) {
20202021 isFloat = true ;
20212022 typeSpec = tok2;
2022- } else if (mIsC && (mSettings ->standards .c >= Standards::C99) && Token::Match (tok2, " complex|_Complex" ))
2023+ } else if (isC () && (mSettings ->standards .c >= Standards::C99) && Token::Match (tok2, " complex|_Complex" ))
20232024 isComplex = !isFloat || tok2->str () == " _Complex" || Token::Match (tok2->next (), " *|&|%name%" ); // Ensure that "complex" is not the variables name
20242025 else if (Token::Match (tok2, " char|int" )) {
20252026 if (!typeSpec)
@@ -2057,7 +2058,7 @@ void TokenList::simplifyStdType()
20572058
20582059bool TokenList::isKeyword (const std::string &str) const
20592060{
2060- if (mIsCpp ) {
2061+ if (isCPP () ) {
20612062 // TODO: integrate into keywords?
20622063 // types and literals are not handled as keywords
20632064 static const std::unordered_set<std::string> cpp_types = {" bool" , " false" , " true" };
0 commit comments