Skip to content

Commit dd91d18

Browse files
committed
Preprocessor: small error() refactoring
1 parent 47264d9 commit dd91d18

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

lib/preprocessor.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,11 @@ static std::string simplecppErrToId(simplecpp::Output::Type type)
920920
}
921921

922922
void Preprocessor::error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, simplecpp::Output::Type type)
923+
{
924+
error(filename, linenr, col, msg, simplecppErrToId(type));
925+
}
926+
927+
void Preprocessor::error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, const std::string& id)
923928
{
924929
std::list<ErrorMessage::FileLocation> locationList;
925930
if (!filename.empty()) {
@@ -933,7 +938,7 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, unsig
933938
mFile0,
934939
Severity::error,
935940
msg,
936-
simplecppErrToId(type),
941+
id,
937942
Certainty::normal));
938943
}
939944

@@ -945,6 +950,7 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
945950

946951
std::list<ErrorMessage::FileLocation> locationList;
947952
if (!filename.empty()) {
953+
// TODO: add relative path handling?
948954
locationList.emplace_back(filename, linenr, col);
949955
}
950956
ErrorMessage errmsg(std::move(locationList), mFile0, Severity::information,

lib/preprocessor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor {
160160
};
161161

162162
void missingInclude(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &header, HeaderTypes headerType);
163+
void error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, const std::string& id);
163164

164165
void addRemarkComments(const simplecpp::TokenList &tokens, std::vector<RemarkComment> &remarkComments) const;
165166

0 commit comments

Comments
 (0)