Cppcheck
analyzerinfo.h
Go to the documentation of this file.
1 /*
2  * Cppcheck - A tool for static C/C++ code analysis
3  * Copyright (C) 2007-2023 Cppcheck team.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 //---------------------------------------------------------------------------
20 #ifndef analyzerinfoH
21 #define analyzerinfoH
22 //---------------------------------------------------------------------------
23 
24 #include "config.h"
25 
26 #include <cstddef>
27 #include <fstream>
28 #include <list>
29 #include <string>
30 
31 class ErrorMessage;
32 struct FileSettings;
33 
34 /// @addtogroup Core
35 /// @{
36 
37 /**
38  * @brief Analyzer information
39  *
40  * Store various analysis information:
41  * - checksum
42  * - error messages
43  * - whole program analysis data
44  *
45  * The information can be used for various purposes. It allows:
46  * - 'make' - only analyze TUs that are changed and generate full report
47  * - should be possible to add distributed analysis later
48  * - multi-threaded whole program analysis
49  */
51 public:
53 
54  static void writeFilesTxt(const std::string &buildDir, const std::list<std::string> &sourcefiles, const std::string &userDefines, const std::list<FileSettings> &fileSettings);
55 
56  /** Close current TU.analyzerinfo file */
57  void close();
58  bool analyzeFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg, std::size_t hash, std::list<ErrorMessage> &errors);
59  void reportErr(const ErrorMessage &msg);
60  void setFileInfo(const std::string &check, const std::string &fileInfo);
61  static std::string getAnalyzerInfoFile(const std::string &buildDir, const std::string &sourcefile, const std::string &cfg);
62 protected:
63  static std::string getAnalyzerInfoFileFromFilesTxt(std::istream& filesTxt, const std::string &sourcefile, const std::string &cfg);
64 private:
65  std::ofstream mOutputStream;
66  std::string mAnalyzerInfoFile;
67 };
68 
69 /// @}
70 //---------------------------------------------------------------------------
71 #endif // analyzerinfoH
Analyzer information.
Definition: analyzerinfo.h:50
std::string mAnalyzerInfoFile
Definition: analyzerinfo.h:66
std::ofstream mOutputStream
Definition: analyzerinfo.h:65
Wrapper for error messages, provided by reportErr()
Definition: errorlogger.h:48
#define CPPCHECKLIB
Definition: config.h:35
static std::string cfg(const std::vector< std::string > &configs, const std::string &userDefines)
File settings.
Definition: filesettings.h:57