diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index 60eb88951d2..f22e999ac98 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -643,7 +643,7 @@ unsigned int CppCheck::checkFile(const std::string& filename, const std::string if (mUnusedFunctionsCheck && mSettings.useSingleJob() && mSettings.buildDir.empty()) { // this is not a real source file - we just want to tokenize it. treat it as C anyways as the language needs to be determined. Tokenizer tokenizer(mSettings, *this); - tokenizer.list.setLang(Standards::Language::C); + tokenizer.list.setLang(Standards::Language::Markup); if (fileStream) { tokenizer.list.createTokens(*fileStream, filename); } diff --git a/lib/standards.h b/lib/standards.h index 34d1882a067..478333b7267 100644 --- a/lib/standards.h +++ b/lib/standards.h @@ -34,7 +34,7 @@ * This struct contains all possible standards that cppcheck recognize. */ struct Standards { - enum Language { None, C, CPP }; + enum Language { None, C, CPP, Markup }; /** C code standard */ enum cstd_t { C89, C99, C11, C17, C23, CLatest = C23 } c = CLatest; diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index fae6e123fbf..9acb2df1d46 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -2190,10 +2190,18 @@ bool TokenList::isCPP() const return mLang == Standards::Language::CPP; } +bool TokenList::isMarkup() const +{ + return mLang == Standards::Language::Markup; +} + void TokenList::setLang(Standards::Language lang) { ASSERT_LANG(lang != Standards::Language::None); - ASSERT_LANG(mLang == Standards::Language::None); + //ASSERT_LANG(mLang == Standards::Language::None); + /* OL: We should have an ability to change between languages when we have markup inside c++ project + * which we treat as C + */ mLang = lang; } diff --git a/lib/tokenlist.h b/lib/tokenlist.h index c03cf3b6382..5f8f999b034 100644 --- a/lib/tokenlist.h +++ b/lib/tokenlist.h @@ -68,6 +68,9 @@ class CPPCHECKLIB TokenList { /** @return true if the code is C++ */ bool isCPP() const; + /** @return true if the code is a Markup language */ + bool isMarkup() const; + void setLang(Standards::Language lang); /**