LCOV - code coverage report
Current view: top level - cli - main.cpp (source / functions) Hit Total Coverage
Test: lcov.info Lines: 3 3 100.0 %
Date: 2024-04-28 12:00:40 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Cppcheck - A tool for static C/C++ code analysis
       3             :  * Copyright (C) 2007-2024 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             : /**
      21             :  *
      22             :  * @mainpage Cppcheck
      23             :  * @version 2.14.99
      24             :  *
      25             :  * @section overview_sec Overview
      26             :  * Cppcheck is a simple tool for static analysis of C/C++ code.
      27             :  *
      28             :  * When you write a checker you have access to:
      29             :  *  - %Token list - the tokenized code
      30             :  *  - Syntax tree - Syntax tree of each expression
      31             :  *  - %SymbolDatabase - Information about all types/variables/functions/etc
      32             :  *    in the current translation unit
      33             :  *  - Library - Configuration of functions/types
      34             :  *  - Value flow analysis - Data flow analysis that determine possible values for each token
      35             :  *
      36             :  * Use --debug-normal on the command line to see debug output for the token list
      37             :  * and the syntax tree. If both --debug-normal and --verbose is used, the symbol
      38             :  * database is also written.
      39             :  *
      40             :  * The checks are written in C++.
      41             :  *
      42             :  * @section detailed_overview_sec Detailed overview
      43             :  * This happens when you execute cppcheck from the command line:
      44             :  * -# CppCheckExecutor::check this function executes the Cppcheck
      45             :  * -# CmdLineParser::parseFromArgs parse command line arguments
      46             :  *   - The Settings class is used to maintain settings
      47             :  *   - Use FileLister and command line arguments to get files to check
      48             :  * -# ThreadExecutor create more instances of CppCheck if needed
      49             :  * -# CppCheck::check is called for each file. It checks a single file
      50             :  * -# Preprocess the file (through Preprocessor)
      51             :  *   - Comments are removed
      52             :  *   - Macros are expanded
      53             :  * -# Tokenize the file (see Tokenizer)
      54             :  * -# Run the runChecks of all check classes.
      55             :  *
      56             :  * When errors are found, they are reported back to the CppCheckExecutor through the ErrorLogger interface.
      57             :  */
      58             : 
      59             : 
      60             : #include "cppcheckexecutor.h"
      61             : 
      62             : #ifdef NDEBUG
      63             : #include "errortypes.h"
      64             : 
      65             : #include <cstdlib>
      66             : #include <exception>
      67             : #include <iostream>
      68             : #include <string>
      69             : #endif
      70             : 
      71             : /**
      72             :  * Main function of cppcheck
      73             :  *
      74             :  * @param argc Passed to CppCheck::parseFromArgs()
      75             :  * @param argv Passed to CppCheck::parseFromArgs()
      76             :  * @return What CppCheckExecutor::check() returns.
      77             :  */
      78          25 : int main(int argc, char* argv[])
      79             : {
      80             :     // MS Visual C++ memory leak debug tracing
      81             : #if defined(_MSC_VER) && defined(_DEBUG)
      82             :     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
      83             : #endif
      84             : 
      85          50 :     CppCheckExecutor exec;
      86             : 
      87             : // *INDENT-OFF*
      88             : #ifdef NDEBUG
      89             :     try {
      90             : #endif
      91          25 :         return exec.check(argc, argv);
      92             : #ifdef NDEBUG
      93             :     } catch (const InternalError& e) {
      94             :         std::cout << e.errorMessage << std::endl;
      95             :     } catch (const std::exception& error) {
      96             :         std::cout << error.what() << std::endl;
      97             :     } catch (...) {
      98             :         std::cout << "Unknown exception" << std::endl;
      99             :     }
     100             :     return EXIT_FAILURE;
     101             : #endif
     102             : // *INDENT-ON*
     103             : }

Generated by: LCOV version 1.14