|
22 | 22 | #include "astutils.h" |
23 | 23 | #include "errorlogger.h" |
24 | 24 | #include "errortypes.h" |
| 25 | +#include "keywords.h" |
25 | 26 | #include "library.h" |
26 | 27 | #include "mathlib.h" |
27 | 28 | #include "path.h" |
@@ -1387,6 +1388,7 @@ void SymbolDatabase::createSymbolDatabaseEnums() |
1387 | 1388 |
|
1388 | 1389 | void SymbolDatabase::createSymbolDatabaseIncompleteVars() |
1389 | 1390 | { |
| 1391 | + // TODO: replace with Keywords::getX() |
1390 | 1392 | static const std::unordered_set<std::string> cpp20keywords = { |
1391 | 1393 | "alignas", |
1392 | 1394 | "alignof", |
@@ -1476,6 +1478,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars() |
1476 | 1478 | // Skip goto labels |
1477 | 1479 | if (Token::simpleMatch(tok->previous(), "goto")) |
1478 | 1480 | continue; |
| 1481 | + // TODO: handle all C/C++ standards |
1479 | 1482 | if (cppkeywords.count(tok->str()) > 0) |
1480 | 1483 | continue; |
1481 | 1484 | if (mSettings->standards.cpp >= Standards::CPP20 && cpp20keywords.count(tok->str()) > 0) |
@@ -5999,37 +6002,16 @@ Function * SymbolDatabase::findFunctionInScope(const Token *func, const Scope *n |
5999 | 6002 |
|
6000 | 6003 | //--------------------------------------------------------------------------- |
6001 | 6004 |
|
6002 | | -namespace { |
6003 | | - |
6004 | | -#define C_KEYWORDS \ |
6005 | | - "_Alignas", "_Alignof", "_Atomic", "_Bool", "_Complex", "_Generic", "_Imaginary", "_Noreturn", \ |
6006 | | - "_Static_assert", "_Thread_local", "auto", "break", "case", "char", "const", "continue", "default", \ |
6007 | | - "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "inline", "int", "long", \ |
6008 | | - "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", \ |
6009 | | - "union", "unsigned", "void", "volatile", "while" |
6010 | | - |
6011 | | - const std::unordered_set<std::string> c_keywords = { C_KEYWORDS, "restrict" }; |
6012 | | - const std::unordered_set<std::string> cpp_keywords = { |
6013 | | - C_KEYWORDS, |
6014 | | - "alignas", "alignof", "and", "and_eq", "asm", "bitand", "bitor", "bool", "catch", "char8_t", "char16_t", |
6015 | | - "char32_t", "class", "compl", "concept", "consteval", "constexpr", "constinit", "const_cast", "co_await", |
6016 | | - "co_return", "co_yield", "decltype", |
6017 | | - "delete", "dynamic_cast", "explicit", "export", "false", "friend", |
6018 | | - "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", |
6019 | | - "or", "or_eq", "private", "protected", "public", "reinterpret_cast", |
6020 | | - "requires", "static_assert", |
6021 | | - "static_cast", "template", "this", "thread_local", "throw", |
6022 | | - "true", "try", "typeid", "typename", "using", |
6023 | | - "virtual", "wchar_t", "xor", "xor_eq" |
6024 | | - }; |
6025 | | -} |
6026 | | - |
6027 | 6005 | bool SymbolDatabase::isReservedName(const std::string& iName) const |
6028 | 6006 | { |
6029 | | - if (isCPP()) |
| 6007 | + if (isCPP()) { |
| 6008 | + static const auto& cpp_keywords = Keywords::getAll(Standards::cppstd_t::CPPLatest); |
6030 | 6009 | return cpp_keywords.find(iName) != cpp_keywords.cend(); |
6031 | | - else |
| 6010 | + } |
| 6011 | + else { |
| 6012 | + static const auto& c_keywords = Keywords::getAll(Standards::cstd_t::CLatest); |
6032 | 6013 | return c_keywords.find(iName) != c_keywords.cend(); |
| 6014 | + } |
6033 | 6015 | } |
6034 | 6016 |
|
6035 | 6017 | nonneg int SymbolDatabase::sizeOfType(const Token *type) const |
|
0 commit comments