Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/standards.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 9 additions & 1 deletion lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
3 changes: 3 additions & 0 deletions lib/tokenlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/**
Expand Down