|
Cppcheck
|
The cppcheck preprocessor. More...
#include <preprocessor.h>
Public Types | |
| enum | HeaderTypes { UserHeader = 1 , SystemHeader } |
| Include file types. More... | |
Public Member Functions | |
| Preprocessor (const Settings &settings, ErrorLogger &errorLogger) | |
| virtual | ~Preprocessor () |
| void | inlineSuppressions (const simplecpp::TokenList &tokens, SuppressionList &suppressions) |
| std::list< Directive > | createDirectives (const simplecpp::TokenList &tokens) const |
| std::set< std::string > | getConfigs (const simplecpp::TokenList &tokens) const |
| void | handleErrors (const simplecpp::OutputList &outputList, bool throwError) |
| bool | loadFiles (const simplecpp::TokenList &rawtokens, std::vector< std::string > &files) |
| void | removeComments () |
| void | setPlatformInfo (simplecpp::TokenList *tokens) const |
| simplecpp::TokenList | preprocess (const simplecpp::TokenList &tokens1, const std::string &cfg, std::vector< std::string > &files, bool throwError=false) |
| std::string | getcode (const simplecpp::TokenList &tokens1, const std::string &cfg, std::vector< std::string > &files, const bool writeLocations) |
| std::size_t | calculateHash (const simplecpp::TokenList &tokens1, const std::string &toolinfo) const |
| Calculate HASH. More... | |
| void | simplifyPragmaAsm (simplecpp::TokenList *tokenList) const |
| void | dump (std::ostream &out) const |
| dump all directives present in source file More... | |
| void | reportOutput (const simplecpp::OutputList &outputList, bool showerror) |
Static Public Member Functions | |
| static void | getErrorMessages (ErrorLogger &errorLogger, const Settings &settings) |
| static bool | hasErrors (const simplecpp::Output &output) |
Static Public Attributes | |
| static char | macroChar = char(1) |
| character that is inserted in expanded macros More... | |
Private Member Functions | |
| void | missingInclude (const std::string &filename, unsigned int linenr, const std::string &header, HeaderTypes headerType) |
| void | error (const std::string &filename, unsigned int linenr, const std::string &msg) |
Static Private Member Functions | |
| static void | simplifyPragmaAsmPrivate (simplecpp::TokenList *tokenList) |
| static bool | hasErrors (const simplecpp::OutputList &outputList) |
Private Attributes | |
| const Settings & | mSettings |
| ErrorLogger & | mErrorLogger |
| std::map< std::string, simplecpp::TokenList * > | mTokenLists |
| list of all directives met while preprocessing file More... | |
| std::string | mFile0 |
| filename for cpp/c file - useful when reporting errors More... | |
| std::list< simplecpp::MacroUsage > | mMacroUsage |
| simplecpp tracking info More... | |
| std::list< simplecpp::IfCond > | mIfCond |
Friends | |
| class | PreprocessorHelper |
| class | TestPreprocessor |
| class | TestUnusedVar |
The cppcheck preprocessor.
The preprocessor has special functionality for extracting the various ifdef configurations that exist in a source file.
Definition at line 71 of file preprocessor.h.
|
explicit |
Definition at line 54 of file preprocessor.cpp.
|
virtual |
Definition at line 57 of file preprocessor.cpp.
References mTokenLists.
| std::size_t Preprocessor::calculateHash | ( | const simplecpp::TokenList & | tokens1, |
| const std::string & | toolinfo | ||
| ) | const |
Calculate HASH.
Using toolinfo, tokens1, filedata.
| tokens1 | Sourcefile tokens |
| toolinfo | Arbitrary extra toolinfo |
Definition at line 936 of file preprocessor.cpp.
References mTokenLists.
Referenced by CppCheck::checkFile().
| std::list< Directive > Preprocessor::createDirectives | ( | const simplecpp::TokenList & | tokens | ) | const |
Definition at line 298 of file preprocessor.cpp.
References emptyString, Directive::linenr, mTokenLists, and Directive::str.
Referenced by CppCheck::checkFile().
| void Preprocessor::dump | ( | std::ostream & | out | ) | const |
dump all directives present in source file
Definition at line 900 of file preprocessor.cpp.
References bool_to_string(), mIfCond, mMacroUsage, and ErrorLogger::toxml().
Referenced by CppCheck::checkFile().
|
private |
Definition at line 855 of file preprocessor.cpp.
References Settings::basePaths, error, Path::fromNativeSeparators(), Path::getRelativePath(), mErrorLogger, mFile0, mSettings, normal, Settings::relativePaths, and ErrorLogger::reportErr().
Referenced by getErrorMessages(), inlineSuppressions(), and reportOutput().
| std::string Preprocessor::getcode | ( | const simplecpp::TokenList & | tokens1, |
| const std::string & | cfg, | ||
| std::vector< std::string > & | files, | ||
| const bool | writeLocations | ||
| ) |
Definition at line 797 of file preprocessor.cpp.
References cfg(), macroChar, and preprocess().
Referenced by CppCheck::checkFile().
| std::set< std::string > Preprocessor::getConfigs | ( | const simplecpp::TokenList & | tokens | ) | const |
Definition at line 626 of file preprocessor.cpp.
References Settings::configurationExcluded(), mSettings, mTokenLists, Settings::userDefines, and Settings::userUndefs.
Referenced by CppCheck::checkFile().
|
static |
Definition at line 892 of file preprocessor.cpp.
References emptyString, error(), missingInclude(), SystemHeader, and UserHeader.
Referenced by CppCheck::getErrorMessages().
| void Preprocessor::handleErrors | ( | const simplecpp::OutputList & | outputList, |
| bool | throwError | ||
| ) |
Definition at line 726 of file preprocessor.cpp.
References Settings::force, mSettings, reportOutput(), and Settings::userDefines.
Referenced by loadFiles(), and preprocess().
|
static |
Definition at line 700 of file preprocessor.cpp.
Referenced by loadFiles().
|
staticprivate |
Definition at line 718 of file preprocessor.cpp.
| void Preprocessor::inlineSuppressions | ( | const simplecpp::TokenList & | tokens, |
| SuppressionList & | suppressions | ||
| ) |
Definition at line 283 of file preprocessor.cpp.
References addInlineSuppressions(), error(), Settings::inlineSuppressions, mSettings, and mTokenLists.
Referenced by CppCheck::checkFile().
| bool Preprocessor::loadFiles | ( | const simplecpp::TokenList & | rawtokens, |
| std::vector< std::string > & | files | ||
| ) |
Definition at line 740 of file preprocessor.cpp.
References createDUI(), emptyString, handleErrors(), hasErrors(), mSettings, and mTokenLists.
Referenced by CppCheck::checkFile().
|
private |
Definition at line 874 of file preprocessor.cpp.
References Settings::checks, information, SimpleEnableGroup< T >::isEnabled(), mErrorLogger, mFile0, missingInclude, mSettings, normal, ErrorLogger::reportErr(), and SystemHeader.
Referenced by getErrorMessages(), and reportOutput().
| simplecpp::TokenList Preprocessor::preprocess | ( | const simplecpp::TokenList & | tokens1, |
| const std::string & | cfg, | ||
| std::vector< std::string > & | files, | ||
| bool | throwError = false |
||
| ) |
Definition at line 778 of file preprocessor.cpp.
References cfg(), createDUI(), handleErrors(), mIfCond, mMacroUsage, mSettings, and mTokenLists.
Referenced by CppCheck::checkFile(), and getcode().
| void Preprocessor::removeComments | ( | ) |
Definition at line 750 of file preprocessor.cpp.
References mTokenLists.
Referenced by CppCheck::checkFile().
| void Preprocessor::reportOutput | ( | const simplecpp::OutputList & | outputList, |
| bool | showerror | ||
| ) |
Definition at line 824 of file preprocessor.cpp.
References emptyString, error(), missingInclude(), startsWith(), SystemHeader, and UserHeader.
Referenced by handleErrors().
| void Preprocessor::setPlatformInfo | ( | simplecpp::TokenList * | tokens | ) | const |
Definition at line 758 of file preprocessor.cpp.
References mSettings, Settings::platform, Platform::sizeof_bool, Platform::sizeof_double, Platform::sizeof_float, Platform::sizeof_int, Platform::sizeof_long, Platform::sizeof_long_double, Platform::sizeof_long_long, Platform::sizeof_pointer, and Platform::sizeof_short.
Referenced by CppCheck::checkFile().
| void Preprocessor::simplifyPragmaAsm | ( | simplecpp::TokenList * | tokenList | ) | const |
Definition at line 952 of file preprocessor.cpp.
References mTokenLists, and simplifyPragmaAsmPrivate().
Referenced by CppCheck::checkFile().
|
staticprivate |
Definition at line 960 of file preprocessor.cpp.
References sameline().
Referenced by simplifyPragmaAsm().
|
friend |
Definition at line 73 of file preprocessor.h.
|
friend |
Definition at line 74 of file preprocessor.h.
|
friend |
Definition at line 75 of file preprocessor.h.
|
static |
character that is inserted in expanded macros
Definition at line 88 of file preprocessor.h.
Referenced by CppCheck::checkFile(), and getcode().
|
private |
Definition at line 142 of file preprocessor.h.
Referenced by error(), and missingInclude().
|
private |
filename for cpp/c file - useful when reporting errors
Definition at line 149 of file preprocessor.h.
Referenced by error(), and missingInclude().
|
private |
Definition at line 153 of file preprocessor.h.
Referenced by dump(), and preprocess().
|
private |
simplecpp tracking info
Definition at line 152 of file preprocessor.h.
Referenced by dump(), and preprocess().
|
private |
Definition at line 141 of file preprocessor.h.
Referenced by error(), getConfigs(), handleErrors(), inlineSuppressions(), loadFiles(), missingInclude(), preprocess(), and setPlatformInfo().
|
private |
list of all directives met while preprocessing file
Definition at line 146 of file preprocessor.h.
Referenced by calculateHash(), createDirectives(), getConfigs(), inlineSuppressions(), loadFiles(), preprocess(), removeComments(), simplifyPragmaAsm(), and ~Preprocessor().