51 friend class TestSimplifyTemplate;
52 friend class TestSimplifyTypedef;
53 friend class TestTokenizer;
79 bool isScopeNoReturn(
const Token *endScopeToken,
bool *unknown =
nullptr)
const;
81 bool simplifyTokens1(
const std::string &configuration);
98 bool simplifyTokenList1(
const char FileName[]);
105 void simplifyHeadersAndUnusedTemplates();
110 void removeExtraTemplateKeywords();
116 void splitTemplateRightAngleBrackets(
bool check);
125 nonneg int sizeOfType(
const std::string& type)
const;
135 void arraySizeAfterValueFlow();
139 void simplifyLabelsCaseDefault();
143 void simplifyCaseRange();
146 void removeMacrosInGlobalScope();
148 void addSemicolonAfterUnknownMacro();
157 void removeMacroInClassDef();
160 void sizeofAddParentheses();
166 void simplifyVarDecl(
const bool only_k_r_fpar);
167 void simplifyVarDecl(
Token * tokBegin,
const Token *
const tokEnd,
const bool only_k_r_fpar);
173 void simplifyInitVar();
182 void simplifyStaticConst();
188 void simplifyVariableMultipleAssign();
197 bool simplifyCAlternativeTokens();
202 bool simplifyAddBraces();
210 Token * simplifyAddBracesToCommand(
Token * tok);
218 Token * simplifyAddBracesPair(
Token *tok,
bool commandWithCondition);
221 void simplifyUsingToTypedef();
231 void simplifyTypedef();
232 void simplifyTypedefCpp();
236 void simplifyTypedefLHS();
240 static bool isMemberFunction(
const Token *openParen);
244 bool simplifyUsing();
245 void simplifyUsingError(
const Token* usingStart,
const Token* usingEnd);
248 void simplifyEmptyNamespaces();
254 void simplifyIfSwitchForInit();
259 void removeRedundantSemicolons();
276 bool simplifyRedundantParentheses();
282 void simplifyFunctionParameters();
293 void simplifyTemplates();
295 void simplifyDoublePlusAndDoubleMinus();
297 void simplifyRedundantConsecutiveBraces();
299 void simplifyArrayAccessSyntax();
301 void simplifyParameterVoid();
303 void fillTypeSizes();
305 void combineOperators();
307 void combineStringAndCharLiterals();
309 void concatenateNegativeNumberAndAnyPositive();
311 void simplifyExternC();
313 void simplifyRoundCurlyParentheses();
315 void simplifyTypeIntrinsics();
319 void checkForEnumsWithTypedef();
321 void findComplicatedSyntaxErrorsInTemplates();
347 void simplifyPointerToStandardType();
350 void simplifyFunctionPointers();
382 NORETURN void syntaxErrorC(
const Token *tok,
const std::string &what)
const;
387 void unhandledCharLiteral(
const Token *tok,
const std::string& msg)
const;
392 void unhandled_macro_class_x_y(
const Token *tok)
const;
395 void checkConfiguration()
const;
396 void macroWithSemicolonError(
const Token *tok,
const std::string ¯oName)
const;
401 void validateC()
const;
407 void validate()
const;
410 void reportUnknownMacros()
const;
541 bool duplicateTypedef(
Token *&tokPtr,
const Token *name,
const Token *typeDef)
const;
543 void unsupportedTypedef(
const Token *tok)
const;
545 static void setVarIdClassFunction(
const std::string &classname,
546 Token *
const startToken,
547 const Token *
const endToken,
548 const std::map<std::string, nonneg int> &varlist,
549 std::map<
nonneg int, std::map<std::string, nonneg int>>& structMembers,
564 return mSymbolDatabase;
573 void printDebugOutput(
int simplification)
const;
575 void dump(std::ostream &out)
const;
605 static bool isOneNumber(
const std::string &s);
613 static const Token * startOfExecutableScope(
const Token * tok);
619 void calculateScopes();
630 const Token *processFunc(
const Token *tok2,
bool inOperator)
const;
631 Token *processFunc(
Token *tok2,
bool inOperator);
This is an interface, which the class responsible of error logging should implement.
This is just a container for general settings so that we don't need to pass individual values to func...
Simplify templates from the preprocessed and partially simplified code.
const Token * front() const
get first token of list
The token list that the TokenList generates is a linked-list of this class.
The main purpose is to tokenize the source code.
void simplifyOverloadedOperators()
simplify overloaded operators: 'obj(123)' => 'obj .
void simplifyMicrosoftStringFunctions()
Convert Microsoft string functions _tcscpy -> strcpy.
std::string mConfiguration
E.g.
void simplifyBitfields()
Simplify bitfields - the field width is removed as we don't use it.
nonneg int newVarId()
Get new variable id.
bool isPacked(const Token *bodyStart) const
void reportError(const std::list< const Token * > &callstack, Severity severity, const std::string &id, const std::string &msg, bool inconclusive=false) const
const Settings & getSettings() const
const Token * tokens() const
void simplifyAttribute()
Remove __attribute__ ((?))
static const Token * findSQLBlockEnd(const Token *tokSQLStart)
Find end of SQL (or PL/SQL) block.
void simplifyNamespaceAliases()
Convert namespace aliases.
static bool isGarbageExpr(const Token *start, const Token *end, bool allowSemicolon)
Detect garbage expression.
nonneg int varIdCount() const
Get variable count.
void removeUnnecessaryQualification()
Remove unnecessary member qualification.
void createSymbolDatabase()
void prepareTernaryOpForAST()
Prepare ternary operators with parentheses so that the AST can be created.
static std::string simplifyString(const std::string &source)
Modify strings in the token list by replacing hex and oct values.
void simplifyFunctionTryCatch()
Simplify function level try blocks: Convert "void f() try {} catch (int) {}" to "void f() { try {} ca...
std::list< Directive > mDirectives
ErrorLogger & mErrorLogger
errorlogger
void simplifyCppcheckAttribute()
Remove __cppcheck__ ((?))
Token * getAttributeFuncTok(Token *tok, bool gccattr) const
Get function token for a attribute.
void findGarbageCode() const
Detect garbage code and call syntaxError() if found.
Tokenizer & operator=(const Tokenizer &)=delete
Disable assignment operator.
void simplifyMicrosoftMemoryFunctions()
Convert Microsoft memory functions CopyMemory(dst, src, len) -> memcpy(dst, src, len) FillMemory(dst,...
void setDirectives(std::list< Directive > directives)
void simplifyAssignmentBlock()
Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}".
std::map< std::string, int > mTypeSize
sizeof information for known types
TokenList list
Token list: stores all tokens.
void simplifyNamespaceStd()
Add std:: in front of std classes, when using namespace std; was given.
void simplifyKeyword()
Remove keywords "volatile", "inline", "register", and "restrict".
bool isC() const
Is the code C.
const SymbolDatabase * getSymbolDatabase() const
const Settings & mSettings
settings
static bool operatorEnd(const Token *tok)
void simplifyDeclspec()
Remove __declspec()
void setTimerResults(TimerResults *tr)
void simplifySpaceshipOperator()
Simplify c++20 spaceship operator.
void printUnknownTypes() const
Output list of unknown types.
void simplifyBorland()
Remove Borland code.
TemplateSimplifier *const mTemplateSimplifier
void simplifyCallingConvention()
Remove calling convention.
void setPodTypes()
Set pod types.
void reportError(const Token *tok, const Severity severity, const std::string &id, const std::string &msg, bool inconclusive=false) const
report error message
void simplifyAsm()
Remove __asm.
void simplifyAt()
Simplify @… (compiler extension)
bool isCPP() const
Is the code CPP.
bool hasIfdef(const Token *start, const Token *end) const
void simplifyStructDecl()
Struct simplification "struct S { } s;" => "struct S { }; S s;".
Tokenizer(const Tokenizer &)=delete
Disable copy constructor.
void simplifyAsm2()
asm heuristics, Put ^{} statements in asm()
void simplifyOperatorName()
Collapse operator name tokens into single token operator = => operator=.
std::vector< TypedefInfo > mTypedefInfo
void simplifyCoroutines()
Simplify coroutines - just put parentheses around arguments for co_* keywords so they can be handled ...
void simplifyNestedNamespace()
Convert C++17 style nested namespace to older style.
void simplifyCPPAttribute()
Remove [[attribute]] (C++11, C23) from TokenList.
static const std::string emptyString
Severity
enum class for severity.
A preprocessor directive Each preprocessor directive (#include, #define, #undef, #if,...
bool endsWith(const std::string &str, char c)