Cppcheck
Signals | Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CheckThread Class Reference

Thread to run cppcheck. More...

#include <checkthread.h>

Inheritance diagram for CheckThread:

Signals

void done ()
 cpp checking is done More...
 
void fileChecked (const QString &file)
 

Public Member Functions

 CheckThread (ThreadResult &result)
 
void check (const Settings &settings)
 Set settings for cppcheck. More...
 
void analyseWholeProgram (const QStringList &files)
 Run whole program analysis. More...
 
void setAddonsAndTools (const QStringList &addonsAndTools)
 
void setClangIncludePaths (const QStringList &s)
 
void setSuppressions (const QList< SuppressionList::Suppression > &s)
 
void run () override
 method that is run in a thread More...
 
void stop ()
 

Static Public Member Functions

static QString clangCmd ()
 Determine command to run clang. More...
 
static QString clangTidyCmd ()
 Determine command to run clang-tidy. More...
 
static int executeCommand (std::string exe, std::vector< std::string > args, std::string redirect, std::string &output)
 

Protected Types

enum  State { Running , Stopping , Stopped , Ready }
 States for the check thread. More...
 

Protected Attributes

std::atomic< StatemState {Ready}
 Thread's current execution state. More...
 
ThreadResultmResult
 
CppCheck mCppcheck
 Cppcheck itself. More...
 

Private Member Functions

void runAddonsAndTools (const FileSettings *fileSettings, const QString &fileName)
 
void parseClangErrors (const QString &tool, const QString &file0, QString err)
 
bool isSuppressed (const SuppressionList::ErrorMessage &errorMessage) const
 

Private Attributes

QStringList mFiles
 
bool mAnalyseWholeProgram {}
 
QStringList mAddonsAndTools
 
QStringList mClangIncludePaths
 
QList< SuppressionList::SuppressionmSuppressions
 

Detailed Description

Thread to run cppcheck.

Definition at line 47 of file checkthread.h.

Member Enumeration Documentation

◆ State

enum CheckThread::State
protected

States for the check thread.

Whole purpose of these states is to allow stopping of the checking. When stopping we say for the thread (Stopping) that stop when current check has been completed. Thread must be stopped cleanly, just terminating thread likely causes unpredictable side-effects.

Enumerator
Running 

The thread is checking.

Stopping 

The thread will stop after current work.

Stopped 

The thread has been stopped.

Ready 

The thread is ready.

Definition at line 118 of file checkthread.h.

Constructor & Destructor Documentation

◆ CheckThread()

CheckThread::CheckThread ( ThreadResult result)
explicit

Definition at line 87 of file checkthread.cpp.

Member Function Documentation

◆ analyseWholeProgram()

void CheckThread::analyseWholeProgram ( const QStringList &  files)

Run whole program analysis.

Parameters
filesAll files

Definition at line 99 of file checkthread.cpp.

References mAnalyseWholeProgram, and mFiles.

◆ check()

void CheckThread::check ( const Settings settings)

Set settings for cppcheck.

Parameters
settingssettings for cppcheck

Definition at line 92 of file checkthread.cpp.

References mCppcheck, mFiles, and CppCheck::settings().

◆ clangCmd()

QString CheckThread::clangCmd ( )
static

Determine command to run clang.

Returns
Command to run clang, empty if it is not found

Definition at line 420 of file checkthread.cpp.

References SETTINGS_CLANG_PATH.

Referenced by runAddonsAndTools().

◆ clangTidyCmd()

QString CheckThread::clangTidyCmd ( )
static

Determine command to run clang-tidy.

Returns
Command to run clang-tidy, empty if it is not found

Definition at line 445 of file checkthread.cpp.

References SETTINGS_CLANG_PATH.

Referenced by ProjectFileDialog::loadFromProjectFile(), and runAddonsAndTools().

◆ done

void CheckThread::done ( )
signal

cpp checking is done

Referenced by ThreadHandler::removeThreads(), run(), and ThreadHandler::setThreadCount().

◆ executeCommand()

int CheckThread::executeCommand ( std::string  exe,
std::vector< std::string >  args,
std::string  redirect,
std::string &  output 
)
static

Definition at line 60 of file checkthread.cpp.

References startsWith().

Referenced by MainWindow::getCppcheckSettings().

◆ fileChecked

void CheckThread::fileChecked ( const QString &  file)
signal

◆ isSuppressed()

bool CheckThread::isSuppressed ( const SuppressionList::ErrorMessage errorMessage) const
private

Definition at line 413 of file checkthread.cpp.

References mSuppressions.

Referenced by parseClangErrors().

◆ parseClangErrors()

void CheckThread::parseClangErrors ( const QString &  tool,
const QString &  file0,
QString  err 
)
private

◆ run()

void CheckThread::run ( )
override

method that is run in a thread

Definition at line 107 of file checkthread.cpp.

References CppCheck::analyseWholeProgram(), Settings::buildDir, done(), mAnalyseWholeProgram, mCppcheck, mFiles, mState, Running, and CppCheck::settings().

◆ runAddonsAndTools()

void CheckThread::runAddonsAndTools ( const FileSettings fileSettings,
const QString &  fileName 
)
private

◆ setAddonsAndTools()

void CheckThread::setAddonsAndTools ( const QStringList &  addonsAndTools)
inline

Definition at line 65 of file checkthread.h.

References mAddonsAndTools.

◆ setClangIncludePaths()

void CheckThread::setClangIncludePaths ( const QStringList &  s)
inline

Definition at line 69 of file checkthread.h.

References mClangIncludePaths.

◆ setSuppressions()

void CheckThread::setSuppressions ( const QList< SuppressionList::Suppression > &  s)
inline

Definition at line 73 of file checkthread.h.

References mSuppressions.

◆ stop()

void CheckThread::stop ( )

Definition at line 308 of file checkthread.cpp.

References mState, Stopping, and Settings::terminate().

Member Data Documentation

◆ mAddonsAndTools

QStringList CheckThread::mAddonsAndTools
private

Definition at line 145 of file checkthread.h.

Referenced by runAddonsAndTools(), and setAddonsAndTools().

◆ mAnalyseWholeProgram

bool CheckThread::mAnalyseWholeProgram {}
private

Definition at line 144 of file checkthread.h.

Referenced by analyseWholeProgram(), and run().

◆ mClangIncludePaths

QStringList CheckThread::mClangIncludePaths
private

Definition at line 146 of file checkthread.h.

Referenced by runAddonsAndTools(), and setClangIncludePaths().

◆ mCppcheck

CppCheck CheckThread::mCppcheck
protected

Cppcheck itself.

Definition at line 134 of file checkthread.h.

Referenced by check(), run(), and runAddonsAndTools().

◆ mFiles

QStringList CheckThread::mFiles
private

Definition at line 143 of file checkthread.h.

Referenced by analyseWholeProgram(), check(), and run().

◆ mResult

ThreadResult& CheckThread::mResult
protected

Definition at line 130 of file checkthread.h.

Referenced by parseClangErrors().

◆ mState

std::atomic<State> CheckThread::mState {Ready}
protected

Thread's current execution state.

Can be changed from outside

Definition at line 128 of file checkthread.h.

Referenced by run(), and stop().

◆ mSuppressions

QList<SuppressionList::Suppression> CheckThread::mSuppressions
private

Definition at line 147 of file checkthread.h.

Referenced by isSuppressed(), and setSuppressions().


The documentation for this class was generated from the following files: