Skip to content

Commit b78787f

Browse files
authored
CppCheck: made some methods private / moved analyseClangTidy() calls into CppCheck (danmar#7504)
1 parent 88ef81e commit b78787f

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

cli/processexecutor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,9 @@ unsigned int ProcessExecutor::check()
336336

337337
if (iFileSettings != mFileSettings.end()) {
338338
resultOfCheck = fileChecker.check(*iFileSettings);
339-
if (mSettings.clangTidy)
340-
fileChecker.analyseClangTidy(*iFileSettings);
341339
} else {
342340
// Read file from a file
343341
resultOfCheck = fileChecker.check(*iFile);
344-
// TODO: call analyseClangTidy()?
345342
}
346343

347344
pipewriter.writeSuppr(mSuppressions.nomsg);

cli/singleexecutor.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ unsigned int SingleExecutor::check()
6565
++c;
6666
if (!mSettings.quiet)
6767
reportStatus(c, mFileSettings.size(), c, mFileSettings.size());
68-
if (mSettings.clangTidy)
69-
mCppcheck.analyseClangTidy(fs);
7068
}
7169

7270
if (mCppcheck.analyseWholeProgram())

cli/threadexecutor.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,9 @@ class ThreadData
119119
if (fs) {
120120
// file settings..
121121
result = fileChecker.check(*fs);
122-
if (mSettings.clangTidy)
123-
fileChecker.analyseClangTidy(*fs);
124122
} else {
125123
// Read file from a file
126124
result = fileChecker.check(*file);
127-
// TODO: call analyseClangTidy()?
128125
}
129126
for (const auto& suppr : mSuppressions.nomsg.getSuppressions()) {
130127
// need to transfer all inline suppressions because these are used later on

lib/cppcheck.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,10 +774,15 @@ unsigned int CppCheck::check(const FileWithDetails &file)
774774
(void)mSuppressions.nomsg.isSuppressed(SuppressionList::ErrorMessage::fromErrorMessage(msg, {}), true);
775775
}
776776

777+
unsigned int returnValue;
777778
if (mSettings.clang)
778-
return checkClang(file);
779+
returnValue = checkClang(file);
780+
else
781+
returnValue = checkFile(file, "");
782+
783+
// TODO: call analyseClangTidy()
779784

780-
return checkFile(file, "");
785+
return returnValue;
781786
}
782787

783788
unsigned int CppCheck::check(const FileWithDetails &file, const std::string &content)
@@ -827,6 +832,8 @@ unsigned int CppCheck::check(const FileSettings &fs)
827832
temp.mFileInfo.pop_back();
828833
}
829834
// TODO: propagate back more data?
835+
if (mSettings.clangTidy)
836+
analyseClangTidy(fs); // TODO: returnValue
830837
return returnValue;
831838
}
832839

@@ -1927,6 +1934,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings)
19271934
const std::string args = "-quiet -checks=*,-clang-analyzer-*,-llvm* \"" + fileSettings.filename() + "\" -- " + allIncludes + allDefines;
19281935
std::string output;
19291936
if (const int exitcode = mExecuteCommand(exe, split(args), "2>&1", output)) {
1937+
// TODO: needs to be a proper error
19301938
std::cerr << "Failed to execute '" << exe << "' (exitcode: " << std::to_string(exitcode) << ")" << std::endl;
19311939
return;
19321940
}

lib/cppcheck.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ namespace simplecpp { class TokenList; }
5555
* Usage: See check() for more info.
5656
*/
5757
class CPPCHECKLIB CppCheck {
58+
friend class TestCppcheck;
59+
5860
public:
5961
using ExecuteCmdFn = std::function<int (std::string,std::vector<std::string>,std::string,std::string&)>;
6062

@@ -123,7 +125,6 @@ class CPPCHECKLIB CppCheck {
123125
static void getErrorMessages(ErrorLogger &errorlogger);
124126

125127
void tooManyConfigsError(const std::string &file, int numberOfConfigurations);
126-
void purgedConfigurationMessage(const std::string &file, const std::string& configuration);
127128

128129
/** Analyse whole program, run this after all TUs has been scanned.
129130
* This is deprecated and the plan is to remove this when
@@ -132,15 +133,15 @@ class CPPCHECKLIB CppCheck {
132133
*/
133134
bool analyseWholeProgram();
134135

135-
/** Analyze all files using clang-tidy */
136-
void analyseClangTidy(const FileSettings &fileSettings);
137-
138136
/** analyse whole program use .analyzeinfo files or ctuinfo string */
139137
unsigned int analyseWholeProgram(const std::string &buildDir, const std::list<FileWithDetails> &files, const std::list<FileSettings>& fileSettings, const std::string& ctuInfo);
140138

141139
static void resetTimerResults();
142140
static void printTimerResults(SHOWTIME_MODES mode);
143141

142+
private:
143+
void purgedConfigurationMessage(const std::string &file, const std::string& configuration);
144+
144145
bool isPremiumCodingStandardId(const std::string& id) const;
145146

146147
/**
@@ -150,7 +151,9 @@ class CPPCHECKLIB CppCheck {
150151

151152
std::string getLibraryDumpData() const;
152153

153-
private:
154+
/** Analyze all files using clang-tidy */
155+
void analyseClangTidy(const FileSettings &fileSettings);
156+
154157
#ifdef HAVE_RULES
155158
/** Are there "simple" rules */
156159
bool hasRule(const std::string &tokenlist) const;

0 commit comments

Comments
 (0)