Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions cli/cppcheckexecutorsig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)

const Signalmap_t::const_iterator it=listofsignals.find(signo);
const char * const signame = (it==listofsignals.end()) ? "unknown" : it->second.c_str();
bool printCallstack=true; // try to print a callstack?
bool lowMem=false; // was low-memory condition detected? Be careful then! Avoid allocating much more memory then.
bool unexpectedSignal=true; // unexpected indicates program failure
bool terminate=true; // exit process/thread
Expand Down Expand Up @@ -241,7 +240,6 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
unexpectedSignal=false; // legal usage: interrupt application via CTRL-C
fputs("cppcheck received signal ", output);
fputs(signame, output);
printCallstack=true;
fputs(".\n", output);
break;
case SIGSEGV:
Expand Down Expand Up @@ -277,11 +275,9 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
fputs(".\n", output);
break;
}
if (printCallstack) {
#ifdef USE_UNIX_BACKTRACE_SUPPORT
print_stacktrace(output, true, -1, lowMem);
print_stacktrace(output, true, -1, lowMem);
#endif
}
if (unexpectedSignal) {
fputs("\nPlease report this to the cppcheck developers!\n", output);
}
Expand Down
2 changes: 1 addition & 1 deletion cli/processexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ProcessExecutor::~ProcessExecutor()

class PipeWriter : public ErrorLogger {
public:
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_VERIFICATION='4', CHILD_END='5'};
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'};

explicit PipeWriter(int pipe) : mWpipe(pipe) {}

Expand Down
3 changes: 0 additions & 3 deletions gui/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#define SETTINGS_WINDOW_MAXIMIZED "Window maximized"
#define SETTINGS_WINDOW_WIDTH "Window width"
#define SETTINGS_WINDOW_HEIGHT "Window height"
#define SETTINGS_LOG_VIEW_WIDTH "Log/View width"
#define SETTINGS_LOG_VIEW_HEIGHT "Log/View height"
#define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state"
#define SETTINGS_CHECK_DIALOG_WIDTH "Check dialog width"
#define SETTINGS_CHECK_DIALOG_HEIGHT "Check dialog height"
Expand Down Expand Up @@ -101,7 +99,6 @@
#define SETTINGS_LAST_PROJECT_PATH "Last project path"
#define SETTINGS_LAST_RESULT_PATH "Last result path"
#define SETTINGS_LAST_SOURCE_PATH "Last source path"
#define SETTINGS_LAST_INCLUDE_PATH "Last include path"
#define SETTINGS_LAST_APP_PATH "Last application path"

#define SETTINGS_LAST_ANALYZE_FILES_FILTER "Last analyze files filter"
Expand Down
1 change: 0 additions & 1 deletion gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
#include <QtNetwork/QNetworkReply>
#include <QTemporaryFile>

static const QString OnlineHelpURL("https://cppcheck.sourceforge.io/manual.html");
static const QString compile_commands_json("compile_commands.json");

static QString fromNativePath(const QString& p) {
Expand Down
6 changes: 4 additions & 2 deletions gui/projectfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,11 @@ class ProjectFile : public QObject {
QStringList getCheckUnknownFunctionReturn() const {
return mCheckUnknownFunctionReturn;
}
void setCheckUnknownFunctionReturn(const QStringList &s) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the code which uses it is commented out. It's the one I added the TODO to.

/*
void setCheckUnknownFunctionReturn(const QStringList &s) {
mCheckUnknownFunctionReturn = s;
}
}
*/

/** Use Clang parser */
bool clangParser;
Expand Down
1 change: 1 addition & 0 deletions gui/projectfiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
mUI->mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
setSuppressions(projectFile->getSuppressions());

// TODO
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not remove the comment block?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I didn't look into why it is commented.

// Human knowledge..
/*
mUI->mListUnknownFunctionReturn->clear();
Expand Down
8 changes: 0 additions & 8 deletions gui/resultstree.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,6 @@ protected slots:
*/
void startApplication(QStandardItem *target, int application = -1);

/**
* @brief Helper function to copy filename/full path to the clipboard
*
* @param target Error tree item to open
* @param fullPath Are we copying full path or only filename?
*/
void copyPathToClipboard(QStandardItem *target, bool fullPath);

/**
* @brief Helper function returning the filename/full path of the error tree item \a target.
*
Expand Down
17 changes: 9 additions & 8 deletions gui/translationhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool TranslationHandler::setLanguage(const QString &code)
failure = true;
} else {
// Make sure there is a translator
if (!mTranslator && !failure)
if (!mTranslator)
mTranslator = new QTranslator(this);

//Load the new language
Expand All @@ -106,18 +106,19 @@ bool TranslationHandler::setLanguage(const QString &code)
else
translationFile = appPath + "/" + mTranslations[index].mFilename + ".qm";

if (!mTranslator->load(translationFile) && !failure) {
if (!mTranslator->load(translationFile)) {
failure = true;
//If it failed, lets check if the default file exists
if (!QFile::exists(translationFile)) {
error = QObject::tr("Language file %1 not found!");
error = error.arg(translationFile);
failure = true;
}

//If file exists, there's something wrong with it
error = QObject::tr("Failed to load translation for language %1 from file %2");
error = error.arg(mTranslations[index].mName);
error = error.arg(translationFile);
else {
//If file exists, there's something wrong with it
error = QObject::tr("Failed to load translation for language %1 from file %2");
error = error.arg(mTranslations[index].mName);
error = error.arg(translationFile);
}
}
}

Expand Down
1 change: 0 additions & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ static const struct CWE CWE571(571U); // Expression is Always True
static const struct CWE CWE672(672U); // Operation on a Resource after Expiration or Release
static const struct CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
static const struct CWE CWE683(683U); // Function Call With Incorrect Order of Arguments
static const struct CWE CWE686(686U); // Function Call With Incorrect Argument Type
static const struct CWE CWE704(704U); // Incorrect Type Conversion or Cast
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
static const struct CWE CWE768(768U); // Incorrect Short Circuit Evaluation
Expand Down
5 changes: 0 additions & 5 deletions lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,6 @@ static std::string getContainerName(const Token *containerToken)
return ret;
}

enum OperandPosition {
Left,
Right
};

static bool isVector(const Token* tok)
{
if (!tok)
Expand Down
1 change: 0 additions & 1 deletion lib/checkuninitvar.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class CPPCHECKLIB CheckUninitVar : public Check {
private:
std::set<const Token*> mUninitDiags;
Check::FileInfo* getFileInfo() const;
bool isUnsafeFunction(const Scope* scope, int argnr, const Token** tok) const;

void getErrorMessages(ErrorLogger* errorLogger, const Settings* settings) const override
{
Expand Down
6 changes: 1 addition & 5 deletions lib/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ enum class Color {
FgGreen = 32,
FgBlue = 34,
FgMagenta = 35,
FgDefault = 39,
BgRed = 41,
BgGreen = 42,
BgBlue = 44,
BgDefault = 49
FgDefault = 39
};
CPPCHECKLIB std::ostream& operator<<(std::ostream& os, const Color& c);

Expand Down
4 changes: 0 additions & 4 deletions lib/cppcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@ class CPPCHECKLIB CppCheck : ErrorLogger {
void tooManyConfigsError(const std::string &file, const int numberOfConfigurations);
void purgedConfigurationMessage(const std::string &file, const std::string& configuration);

void dontSimplify() {
mSimplify = false;
}

/** Analyse whole program, run this after all TUs has been scanned.
* This is deprecated and the plan is to remove this when
* .analyzeinfo is good enough.
Expand Down
4 changes: 1 addition & 3 deletions lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct OnExit {

struct ForwardTraversal {
enum class Progress { Continue, Break, Skip };
enum class Terminate { None, Bail, Escape, Modified, Inconclusive, Conditional };
enum class Terminate { None, Bail, Inconclusive };
ForwardTraversal(const ValuePtr<Analyzer>& analyzer, const Settings& settings)
: analyzer(analyzer), settings(settings), actions(Analyzer::Action::None), analyzeOnly(false), analyzeTerminate(false)
{}
Expand Down Expand Up @@ -333,8 +333,6 @@ struct ForwardTraversal {

enum class Status {
None,
Escaped,
Modified,
Inconclusive,
};

Expand Down
11 changes: 1 addition & 10 deletions lib/library.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class CPPCHECKLIB Library {
};
struct RangeItemRecordTypeItem {
std::string name;
int templateParameter;
int templateParameter; // TODO: use this
};
std::string startPattern, startPattern2, endPattern, itEndPattern;
std::map<std::string, Function> functions;
Expand Down Expand Up @@ -403,15 +403,6 @@ class CPPCHECKLIB Library {
return arg ? arg->valid : emptyString;
}

struct InvalidArgValue {
enum class Type {le, lt, eq, ge, gt, range} type;
std::string op1;
std::string op2;
bool isInt() const {
return MathLib::isInt(op1);
}
};

const ArgumentChecks::IteratorInfo *getArgIteratorInfo(const Token *ftok, int argnr) const {
const ArgumentChecks *arg = getarg(ftok, argnr);
return arg && arg->iteratorInfo.it ? &arg->iteratorInfo : nullptr;
Expand Down
7 changes: 1 addition & 6 deletions lib/preprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ class CPPCHECKLIB Preprocessor {
* Include file types.
*/
enum HeaderTypes {
NoHeader = 0,
UserHeader,
UserHeader = 1,
SystemHeader
};

Expand Down Expand Up @@ -173,10 +172,6 @@ class CPPCHECKLIB Preprocessor {

static void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings);

void setFile0(const std::string &f) {
mFile0 = f;
}

/**
* dump all directives present in source file
*/
Expand Down
2 changes: 0 additions & 2 deletions lib/programmemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ bool conditionIsTrue(const Token* condition, ProgramMemory pm, const Settings* s
*/
ProgramMemory getProgramMemory(const Token* tok, const Token* expr, const ValueFlow::Value& value, const Settings* settings);

ProgramMemory getProgramMemory(const Token *tok, const ProgramMemory::Map& vars);

ValueFlow::Value evaluateLibraryFunction(const std::unordered_map<nonneg int, ValueFlow::Value>& args,
const std::string& returnValue,
const Settings* settings);
Expand Down
6 changes: 0 additions & 6 deletions lib/reverseanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,12 +388,6 @@ struct ReverseTraversal {
}
};

void valueFlowGenericReverse(Token* start, const ValuePtr<Analyzer>& a, const Settings& settings)
{
ReverseTraversal rt{a, settings};
rt.traverse(start);
}

void valueFlowGenericReverse(Token* start, const Token* end, const ValuePtr<Analyzer>& a, const Settings& settings)
{
ReverseTraversal rt{a, settings};
Expand Down
1 change: 0 additions & 1 deletion lib/reverseanalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Token;
template<class T>
class ValuePtr;

void valueFlowGenericReverse(Token* start, const ValuePtr<Analyzer>& a, const Settings& settings);
void valueFlowGenericReverse(Token* start, const Token* end, const ValuePtr<Analyzer>& a, const Settings& settings);

#endif
6 changes: 0 additions & 6 deletions lib/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ class SimpleEnableGroup {
void fill() {
mFlags = 0xFFFFFFFF;
}
void setEnabledAll(bool enabled) {
if (enabled)
fill();
else
clear();
}
bool isEnabled(T flag) const {
return (mFlags & (1U << (uint32_t)flag)) != 0;
}
Expand Down
7 changes: 0 additions & 7 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4452,13 +4452,6 @@ Scope::Scope(const SymbolDatabase *check_, const Token *classDef_, const Scope *
className = nameTok->str();
}

bool Scope::hasDefaultConstructor() const
{
return numConstructors > 0 && std::any_of(functionList.begin(), functionList.end(), [](const Function& func) {
return func.type == Function::eConstructor && func.argCount() == 0;
});
}

AccessControl Scope::defaultAccess() const
{
switch (type) {
Expand Down
2 changes: 0 additions & 2 deletions lib/symboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -1177,8 +1177,6 @@ class CPPCHECKLIB Scope {
functionMap.insert(make_pair(back->tokenDef->str(), back));
}

bool hasDefaultConstructor() const;

AccessControl defaultAccess() const;

/**
Expand Down
4 changes: 0 additions & 4 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2516,10 +2516,6 @@ Token* findTypeEnd(Token* tok)
return tok;
}

const Token* findTypeEnd(const Token* tok) {
return findTypeEnd(const_cast<Token*>(tok));
}

Token* findLambdaEndScope(Token* tok)
{
if (!Token::simpleMatch(tok, "["))
Expand Down
1 change: 0 additions & 1 deletion lib/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,6 @@ class CPPCHECKLIB Token {
};

Token* findTypeEnd(Token* tok);
const Token* findTypeEnd(const Token* tok);
Token* findLambdaEndScope(Token* tok);
const Token* findLambdaEndScope(const Token* tok);

Expand Down
13 changes: 0 additions & 13 deletions lib/tokenize.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ class CPPCHECKLIB Tokenizer {
nonneg int sizeOfType(const std::string& type) const;

void simplifyDebug();
/**
* Try to determine if function parameter is passed by value by looking
* at the function declaration.
* @param fpar token for function parameter in the function call
* @return true if the parameter is passed by value. if unsure, false is returned
*/
bool isFunctionParameterPassedByValue(const Token *fpar) const;

/** Simplify assignment where rhs is a block : "x=({123;});" => "{x=123;}" */
void simplifyAssignmentBlock();
Expand Down Expand Up @@ -548,12 +541,6 @@ class CPPCHECKLIB Tokenizer {
*/
void simplifyCPPAttribute();

/**
* Replace strlen(str)
* @return true if any replacement took place, false else
* */
bool simplifyStrlen();

/**
* Convert namespace aliases
*/
Expand Down
2 changes: 1 addition & 1 deletion test/cfg/boost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void valid_code(boost::function<void(void)> &pf_print_hello)
pf_print_hello = boost::bind(print_hello);
}

void ignoredReturnValue(char * buf)
void ignoredReturnValue()
{
// cppcheck-suppress ignoredReturnValue
boost::math::round(1.5);
Expand Down
16 changes: 0 additions & 16 deletions test/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,6 @@ class givenACodeSampleToTokenize {
};


class SimpleSuppressor : public ErrorLogger {
public:
SimpleSuppressor(Settings &settings, ErrorLogger *next)
: settings(settings), next(next) {}
void reportOut(const std::string &outmsg, Color /*c*/ = Color::Reset) override {
next->reportOut(outmsg);
}
void reportErr(const ErrorMessage &msg) override {
if (!msg.callStack.empty() && !settings.nomsg.isSuppressed(msg))
next->reportErr(msg);
}
private:
Settings &settings;
ErrorLogger *next;
};

class ScopedFile {
public:
ScopedFile(std::string name, const std::string &content, std::string path = "");
Expand Down