@@ -753,18 +753,10 @@ bool Preprocessor::hasErrors(const simplecpp::Output &output)
753753 return false ;
754754}
755755
756- bool Preprocessor::hasErrors (const simplecpp::OutputList &outputList)
757- {
758- const auto it = std::find_if (outputList.cbegin (), outputList.cend (), [](const simplecpp::Output &output) {
759- return hasErrors (output);
760- });
761- return it != outputList.cend ();
762- }
763-
764- void Preprocessor::handleErrors (const simplecpp::OutputList& outputList, bool throwError)
756+ bool Preprocessor::handleErrors (const simplecpp::OutputList& outputList, bool throwError)
765757{
766758 const bool showerror = (!mSettings .userDefines .empty () && !mSettings .force );
767- reportOutput (outputList, showerror);
759+ const bool hasError = reportOutput (outputList, showerror);
768760 if (throwError) {
769761 const auto it = std::find_if (outputList.cbegin (), outputList.cend (), [](const simplecpp::Output &output){
770762 return hasErrors (output);
@@ -773,6 +765,7 @@ void Preprocessor::handleErrors(const simplecpp::OutputList& outputList, bool th
773765 throw *it;
774766 }
775767 }
768+ return hasError;
776769}
777770
778771bool Preprocessor::loadFiles (std::vector<std::string> &files)
@@ -781,8 +774,7 @@ bool Preprocessor::loadFiles(std::vector<std::string> &files)
781774
782775 simplecpp::OutputList outputList;
783776 mFileCache = simplecpp::load (mTokens , files, dui, &outputList);
784- handleErrors (outputList, false );
785- return !hasErrors (outputList);
777+ return !handleErrors (outputList, false );
786778}
787779
788780void Preprocessor::removeComments ()
@@ -825,7 +817,7 @@ simplecpp::TokenList Preprocessor::preprocess(const std::string &cfg, std::vecto
825817 mMacroUsage = std::move (macroUsage);
826818 mIfCond = std::move (ifCond);
827819
828- handleErrors (outputList, throwError);
820+ ( void ) handleErrors (outputList, throwError);
829821
830822 tokens2.removeComments ();
831823
@@ -859,11 +851,14 @@ std::string Preprocessor::getcode(const std::string &cfg, std::vector<std::strin
859851 return ret.str ();
860852}
861853
862- void Preprocessor::reportOutput (const simplecpp::OutputList &outputList, bool showerror)
854+ bool Preprocessor::reportOutput (const simplecpp::OutputList &outputList, bool showerror)
863855{
856+ bool hasError = false ;
857+
864858 for (const simplecpp::Output &out : outputList) {
865859 switch (out.type ) {
866860 case simplecpp::Output::ERROR:
861+ hasError = true ;
867862 if (!startsWith (out.msg ," #error" ) || showerror)
868863 error (out.location .file (), out.location .line , out.msg );
869864 break ;
@@ -880,15 +875,19 @@ void Preprocessor::reportOutput(const simplecpp::OutputList &outputList, bool sh
880875 case simplecpp::Output::INCLUDE_NESTED_TOO_DEEPLY:
881876 case simplecpp::Output::SYNTAX_ERROR:
882877 case simplecpp::Output::UNHANDLED_CHAR_ERROR:
878+ hasError = true ;
883879 error (out.location .file (), out.location .line , out.msg );
884880 break ;
885881 case simplecpp::Output::EXPLICIT_INCLUDE_NOT_FOUND:
886882 case simplecpp::Output::FILE_NOT_FOUND:
887883 case simplecpp::Output::DUI_ERROR:
884+ hasError = true ;
888885 error (" " , 0 , out.msg );
889886 break ;
890887 }
891888 }
889+
890+ return hasError;
892891}
893892
894893void Preprocessor::error (const std::string &filename, unsigned int linenr, const std::string &msg)
0 commit comments