Skip to content
Merged
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ $(libcppdir)/summaries.o: lib/summaries.cpp lib/analyzerinfo.h lib/config.h lib/
$(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/mathlib.h lib/path.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/suppressions.cpp

$(libcppdir)/symboldatabase.o: lib/symboldatabase.cpp lib/astutils.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
$(libcppdir)/symboldatabase.o: lib/symboldatabase.cpp lib/astutils.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/keywords.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/symboldatabase.cpp

$(libcppdir)/templatesimplifier.o: lib/templatesimplifier.cpp lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
Expand Down
1 change: 1 addition & 0 deletions gui/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Highlighter::Highlighter(QTextDocument *parent,
mKeywordFormat.setForeground(mWidgetStyle->keywordColor);
mKeywordFormat.setFontWeight(mWidgetStyle->keywordWeight);
QStringList keywordPatterns;
// TODO: use Keywords::getX()
keywordPatterns << "alignas"
<< "alignof"
<< "asm"
Expand Down
36 changes: 9 additions & 27 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "astutils.h"
#include "errorlogger.h"
#include "errortypes.h"
#include "keywords.h"
#include "library.h"
#include "mathlib.h"
#include "path.h"
Expand Down Expand Up @@ -1387,6 +1388,7 @@ void SymbolDatabase::createSymbolDatabaseEnums()

void SymbolDatabase::createSymbolDatabaseIncompleteVars()
{
// TODO: replace with Keywords::getX()
static const std::unordered_set<std::string> cpp20keywords = {
"alignas",
"alignof",
Expand Down Expand Up @@ -1476,6 +1478,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars()
// Skip goto labels
if (Token::simpleMatch(tok->previous(), "goto"))
continue;
// TODO: handle all C/C++ standards
if (cppkeywords.count(tok->str()) > 0)
continue;
if (mSettings->standards.cpp >= Standards::CPP20 && cpp20keywords.count(tok->str()) > 0)
Expand Down Expand Up @@ -5992,37 +5995,16 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n

//---------------------------------------------------------------------------

namespace {

#define C_KEYWORDS \
"_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", "_Noreturn", \
"_Static_assert", "_Thread_local", "auto", "break", "case", "char", "const", "continue", "default", \
"do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", \
"register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", \
"union", "unsigned", "void", "volatile", "while"

const std::unordered_set<std::string> c_keywords = { C_KEYWORDS, "restrict" };
const std::unordered_set<std::string> cpp_keywords = {
C_KEYWORDS,
"alignas", "alignof", "and", "and_eq", "asm", "bitand", "bitor", "bool", "catch", "char8_t", "char16_t",
"char32_t", "class", "compl", "concept", "consteval", "constexpr", "constinit", "const_cast", "co_await",
"co_return", "co_yield", "decltype",
"delete", "dynamic_cast", "explicit", "export", "false", "friend",
"mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator",
"or", "or_eq", "private", "protected", "public", "reinterpret_cast",
"requires", "static_assert",
"static_cast", "template", "this", "thread_local", "throw",
"true", "try", "typeid", "typename", "using",
"virtual", "wchar_t", "xor", "xor_eq"
};
}

bool SymbolDatabase::isReservedName(const std::string& iName) const
{
if (isCPP())
if (isCPP()) {
static const auto& cpp_keywords = Keywords::getAll(Standards::cppstd_t::CPPLatest);
return cpp_keywords.find(iName) != cpp_keywords.cend();
else
}
else {
static const auto& c_keywords = Keywords::getAll(Standards::cstd_t::CLatest);
return c_keywords.find(iName) != c_keywords.cend();
}
}

nonneg int SymbolDatabase::sizeOfType(const Token *type) const
Expand Down
1 change: 1 addition & 0 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ static const std::unordered_set<std::string> controlFlowKeywords = {
"return"
};

// TODO: replace with Keywords::getX()?
// Another list of keywords
static const std::unordered_set<std::string> baseKeywords = {
"asm",
Expand Down