Skip to content

Commit 657b7c5

Browse files
committed
Preprocessor: small error() refactoring
1 parent 843ce7c commit 657b7c5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/preprocessor.cpp

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

916916
void Preprocessor::error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, simplecpp::Output::Type type)
917+
{
918+
error(filename, linenr, col, msg, simplecppErrToId(type));
919+
}
920+
921+
void Preprocessor::error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, const std::string& id)
917922
{
918923
std::list<ErrorMessage::FileLocation> locationList;
919924
if (!filename.empty()) {
@@ -927,7 +932,7 @@ void Preprocessor::error(const std::string &filename, unsigned int linenr, unsig
927932
mFile0,
928933
Severity::error,
929934
msg,
930-
simplecppErrToId(type),
935+
id,
931936
Certainty::normal));
932937
}
933938

@@ -939,6 +944,7 @@ void Preprocessor::missingInclude(const std::string &filename, unsigned int line
939944

940945
std::list<ErrorMessage::FileLocation> locationList;
941946
if (!filename.empty()) {
947+
// TODO: add relative path handling?
942948
locationList.emplace_back(filename, linenr, col);
943949
}
944950
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
@@ -159,6 +159,7 @@ class CPPCHECKLIB WARN_UNUSED Preprocessor {
159159
};
160160

161161
void missingInclude(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &header, HeaderTypes headerType);
162+
void error(const std::string &filename, unsigned int linenr, unsigned int col, const std::string &msg, const std::string& id);
162163

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

0 commit comments

Comments
 (0)