refactoring: The errmsg is no longer supposed to generate the errorLogger code
This commit is contained in:
parent
170f817a19
commit
3c1c33669e
4
Makefile
4
Makefile
|
@ -234,7 +234,3 @@ test/testunusedprivfunc.o: test/testunusedprivfunc.cpp src/tokenize.h src/settin
|
|||
test/testunusedvar.o: test/testunusedvar.cpp test/testsuite.h src/errorlogger.h src/settings.h src/tokenize.h src/token.h src/checkother.h src/check.h
|
||||
$(CXX) $(CXXFLAGS) -c -o test/testunusedvar.o test/testunusedvar.cpp
|
||||
|
||||
src/errorlogger.h: tools/errmsg
|
||||
tools/errmsg
|
||||
mv errorlogger.h src/
|
||||
|
||||
|
|
|
@ -139,10 +139,6 @@ int main()
|
|||
fout << "\n\t$(CXX) $(CXXFLAGS) -c -o " << objfile(testfiles[i]) << " " << testfiles[i] << "\n\n";
|
||||
}
|
||||
|
||||
fout << "src/errorlogger.h:\ttools/errmsg\n";
|
||||
fout << "\ttools/errmsg\n";
|
||||
fout << "\tmv errorlogger.h src/\n\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
114
tools/errmsg.cpp
114
tools/errmsg.cpp
|
@ -125,120 +125,6 @@ int main()
|
|||
err.push_back(Message("unvalidatedInput", Message::security, "Unvalidated input"));
|
||||
|
||||
|
||||
// Generate code..
|
||||
std::cout << "Generate code.." << std::endl;
|
||||
std::ofstream fout("errorlogger.h");
|
||||
|
||||
fout << "/*\n";
|
||||
fout << " * Cppcheck - A tool for static C/C++ code analysis\n";
|
||||
fout << " * Copyright (C) 2007-2009 Daniel Marjamäki, Reijo Tomperi, Nicolas Le Cam,\n";
|
||||
fout << " * Leandro Penz, Kimmo Varis, Vesa Pikki\n";
|
||||
fout << " *\n";
|
||||
fout << " * This program is free software: you can redistribute it and/or modify\n";
|
||||
fout << " * it under the terms of the GNU General Public License as published by\n";
|
||||
fout << " * the Free Software Foundation, either version 3 of the License, or\n";
|
||||
fout << " * (at your option) any later version.\n";
|
||||
fout << " *\n";
|
||||
fout << " * This program is distributed in the hope that it will be useful,\n";
|
||||
fout << " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
|
||||
fout << " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
|
||||
fout << " * GNU General Public License for more details.\n";
|
||||
fout << " *\n";
|
||||
fout << " * You should have received a copy of the GNU General Public License\n";
|
||||
fout << " * along with this program. If not, see <http://www.gnu.org/licenses/\n";
|
||||
fout << " */\n\n";
|
||||
fout << "// THIS FILE IS GENERATED BY MACHINE, SEE ../tools/errmsg.cpp !\n\n";
|
||||
fout << "#ifndef errorloggerH\n";
|
||||
fout << "#define errorloggerH\n";
|
||||
fout << "#include <list>\n";
|
||||
fout << "#include <string>\n";
|
||||
fout << "#include \"settings.h\"\n";
|
||||
fout << "class Token;\n";
|
||||
fout << "class Tokenizer;\n";
|
||||
fout << "\n";
|
||||
fout << "/**\n";
|
||||
fout << " * This is an interface, which the class responsible of error logging\n";
|
||||
fout << " * should implement.\n";
|
||||
fout << " */\n";
|
||||
fout << "class ErrorLogger\n";
|
||||
fout << "{\n";
|
||||
fout << "public:\n";
|
||||
fout << "\n";
|
||||
fout << " /**\n";
|
||||
fout << " * Wrapper for error messages, provided by reportErr()\n";
|
||||
fout << " */\n";
|
||||
fout << " class ErrorMessage\n";
|
||||
fout << " {\n";
|
||||
fout << " public:\n";
|
||||
fout << " /**\n";
|
||||
fout << " * File name and line number.\n";
|
||||
fout << " */\n";
|
||||
fout << " class FileLocation\n";
|
||||
fout << " {\n";
|
||||
fout << " public:\n";
|
||||
fout << " FileLocation()\n";
|
||||
fout << " {\n";
|
||||
fout << " line = 0;\n";
|
||||
fout << " }\n";
|
||||
fout << " std::string file;\n";
|
||||
fout << " unsigned int line;\n";
|
||||
fout << " };\n";
|
||||
fout << "\n";
|
||||
fout << " ErrorMessage(const std::list<FileLocation> &callStack, const std::string &severity, const std::string &msg, const std::string &id);\n";
|
||||
fout << " ErrorMessage();\n";
|
||||
fout << " std::string toXML() const;\n";
|
||||
fout << " std::string toText() const;\n";
|
||||
fout << " std::string serialize() const;\n";
|
||||
fout << " bool deserialize(const std::string &data);\n";
|
||||
fout << " std::list<FileLocation> _callStack;\n";
|
||||
fout << " std::string _severity;\n";
|
||||
fout << " std::string _msg;\n";
|
||||
fout << " std::string _id;\n";
|
||||
fout << " };\n";
|
||||
fout << "\n";
|
||||
fout << " ErrorLogger() { }\n";
|
||||
fout << " virtual ~ErrorLogger() { }\n";
|
||||
fout << "\n";
|
||||
fout << " /**\n";
|
||||
fout << " * Information about progress is directed here.\n";
|
||||
fout << " * Override this to receive the progress messages.\n";
|
||||
fout << " *\n";
|
||||
fout << " * @param outmsg, E.g. \"Checking main.cpp...\"\n";
|
||||
fout << " */\n";
|
||||
fout << " virtual void reportOut(const std::string &outmsg) = 0;\n";
|
||||
fout << "\n";
|
||||
fout << " /**\n";
|
||||
fout << " * Information about found errors and warnings is directed\n";
|
||||
fout << " * here. Override this to receive the errormessages.\n";
|
||||
fout << " *\n";
|
||||
fout << " * @param msg Location and other information about the found.\n";
|
||||
fout << " * error\n";
|
||||
fout << " */\n";
|
||||
fout << " virtual void reportErr(const ErrorLogger::ErrorMessage &msg) = 0;\n";
|
||||
fout << "\n";
|
||||
fout << " /**\n";
|
||||
fout << " * Information about how many files have been checked\n";
|
||||
fout << " *\n";
|
||||
fout << " * @param index This many files have been checked.\n";
|
||||
fout << " * @param max This many files there are in total.\n";
|
||||
fout << " */\n";
|
||||
fout << " virtual void reportStatus(unsigned int index, unsigned int max) = 0;\n";
|
||||
fout << "\n";
|
||||
|
||||
for (std::list<Message>::const_iterator it = err.begin(); it != err.end(); ++it)
|
||||
it->generateCode(fout);
|
||||
|
||||
fout << "\n";
|
||||
fout << " static std::string callStackToString(const std::list<ErrorLogger::ErrorMessage::FileLocation> &callStack);\n";
|
||||
fout << "\n";
|
||||
fout << "private:\n";
|
||||
fout << " void _writemsg(const Tokenizer *tokenizer, const Token *tok, const char severity[], const std::string &msg, const std::string &id);\n";
|
||||
fout << " void _writemsg(const Tokenizer *tokenizer, const std::list<const Token *> &callstack, const char severity[], const std::string &msg, const std::string &id);\n";
|
||||
fout << " void _writemsg(const std::string &msg, const std::string &id);\n";
|
||||
fout << "};\n";
|
||||
fout << "#endif\n";
|
||||
std::cout << std::endl;
|
||||
|
||||
// Generate documentation..
|
||||
std::cout << "Generate doc.." << std::endl;
|
||||
const unsigned int NUMSUITE = 5;
|
||||
|
|
Loading…
Reference in New Issue