@@ -850,17 +850,6 @@ unsigned int CppCheck::check(const FileSettings &fs)
850
850
return returnValue;
851
851
}
852
852
853
- unsigned int CppCheck::checkBuffer (const FileWithDetails &file, const std::string &cfgname, int fileIndex, const uint8_t * data, std::size_t size)
854
- {
855
- return checkInternal (file, cfgname, fileIndex,
856
- [&file, data, size](std::vector<std::string>& files) {
857
- return simplecpp::TokenList{data, size, files, file.spath ()};
858
- },
859
- [&file, data, size](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
860
- return simplecpp::TokenList{data, size, files, file.spath (), outputList};
861
- });
862
- }
863
-
864
853
std::size_t CppCheck::calculateHash (const Preprocessor& preprocessor, const simplecpp::TokenList& tokens, const std::string& filePath) const
865
854
{
866
855
std::ostringstream toolinfo;
@@ -882,18 +871,23 @@ std::size_t CppCheck::calculateHash(const Preprocessor& preprocessor, const simp
882
871
return preprocessor.calculateHash (tokens, toolinfo.str ());
883
872
}
884
873
874
+ unsigned int CppCheck::checkBuffer (const FileWithDetails &file, const std::string &cfgname, int fileIndex, const uint8_t * data, std::size_t size)
875
+ {
876
+ const auto f = [&file, data, size](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
877
+ return simplecpp::TokenList{data, size, files, file.spath (), outputList};
878
+ };
879
+ return checkInternal (file, cfgname, fileIndex, f);
880
+ }
881
+
885
882
unsigned int CppCheck::checkFile (const FileWithDetails& file, const std::string &cfgname, int fileIndex)
886
883
{
887
- return checkInternal (file, cfgname, fileIndex,
888
- [&file](std::vector<std::string>& files) {
889
- return simplecpp::TokenList{file.spath (), files};
890
- },
891
- [&file](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
884
+ const auto f = [&file](std::vector<std::string>& files, simplecpp::OutputList* outputList) {
892
885
return simplecpp::TokenList{file.spath (), files, outputList};
893
- });
886
+ };
887
+ return checkInternal (file, cfgname, fileIndex, f);
894
888
}
895
889
896
- unsigned int CppCheck::checkInternal (const FileWithDetails& file, const std::string &cfgname, int fileIndex, const CreateTokensFn& createTokens, const CreateTokenListFn& createTokenList)
890
+ unsigned int CppCheck::checkInternal (const FileWithDetails& file, const std::string &cfgname, int fileIndex, const CreateTokenListFn& createTokenList)
897
891
{
898
892
// TODO: move to constructor when CppCheck no longer owns the settings
899
893
if (mSettings .checks .isEnabled (Checks::unusedFunction) && !mUnusedFunctionsCheck )
@@ -945,7 +939,7 @@ unsigned int CppCheck::checkInternal(const FileWithDetails& file, const std::str
945
939
// markup files are special and do not adhere to the enforced language
946
940
TokenList tokenlist{mSettings , Standards::Language::C};
947
941
std::vector<std::string> files;
948
- simplecpp::TokenList tokens = createTokens (files);
942
+ simplecpp::TokenList tokens = createTokenList (files, nullptr );
949
943
if (analyzerInformation) {
950
944
const Preprocessor preprocessor (mSettings , mErrorLogger , file.lang ());
951
945
hash = calculateHash (preprocessor, tokens);
0 commit comments