aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2017-03-16 21:49:35 +0000
committerbloodstalker <thabogre@gmail.com>2017-03-16 21:49:35 +0000
commitc94f449a1409156704306added527f3cd9b374a8 (patch)
tree20681691fb13f89c12b124656c395a7e58186535
parentthe XML and JSON report classes are here now (diff)
downloadmutator-c94f449a1409156704306added527f3cd9b374a8.tar.gz
mutator-c94f449a1409156704306added527f3cd9b374a8.zip
the XML and JSON report classes are here now
-rw-r--r--mutator_report.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/mutator_report.h b/mutator_report.h
new file mode 100644
index 0000000..e621bcd
--- /dev/null
+++ b/mutator_report.h
@@ -0,0 +1,97 @@
+
+/***************************************************Project Mutator****************************************************/
+//-*-c++-*-
+/*********************************************************************************************************************/
+/*first line intentionally left blank*/
+/*Copyright (C) 2017 Farzad Sadeghi
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.*/
+/*********************************************************************************************************************/
+/*inclusion guard*/
+#ifndef MUTATOR_REPORT_H
+#define MUTATOR_REPORT_H
+/*********************************************************************************************************************/
+/*inclusion directives*/
+#include <string>
+#include <fstream>
+#include "clang/AST/AST.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+#include "tinyxml2/tinyxml2.h"
+/*********************************************************************************************************************/
+using namespace clang;
+using namespace tinyxml2;
+/*********************************************************************************************************************/
+namespace Devi {
+/*********************************************************************************************************************/
+/*@DEVI- for both report classes, if the program gets terminated, since the destructor does not close
+the report files, what happens to them is implementation-defined in case of let's say an exit, but since
+we erase the files everytime a new instance of mutator-lvl0 is called, we are fine. or so i think.*/
+/*@DEVI- in case of a crash, the XML report will only hold the base node, while the JSON report will
+contain all the reports up until the crash. tinyxml2 writes the nodes to file on SaveFile which is
+called in SaveReport so that's why.*/
+class XMLReport
+{
+public:
+ XMLReport();
+
+ void XMLCreateReport(void);
+ void XMLAddNode(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description);
+ /*overloaded for rule checks that announce the result on onendoftranslation instead of run
+ since they dont have access to matchresult or astcontext.*/
+ void XMLAddNode(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description);
+ /*another overload to support the xml output for PPCallbacks.*/
+ void XMLAddNode(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description);
+
+ void XMLAddNode(std::string FilePath, std::string MisraRule, std::string Description);
+
+ void XMLAddNode(unsigned Line, unsigned Column, std::string FileName, std::string MisraRule, std::string Description);
+
+ void SaveReport(void);
+
+private:
+ XMLDocument XMLReportDoc;
+ XMLElement* RootPointer;
+};
+/*********************************************************************************************************************/
+class JSONReport
+{
+public:
+ JSONReport();
+
+ void JSONCreateReport(void);
+ void JSONAddElement(ASTContext* ASTC, SourceLocation SL, std::string MisraRule, std::string Description);
+ /*overload for checks that announce the result in onendoftranslation unit.*/
+ void JSONAddElement(FullSourceLoc FSL, SourceLocation SL, std::string MisraRule, std::string Description);
+ /*overload for PPCallbacks.*/
+ void JSONAddElement(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description);
+
+ void JSONAddElement(std::string FilePath, std::string MisraRule, std::string Description);
+
+ void JSONAddElement(unsigned Line, unsigned Column, std::string FileName, std::string MisraRule, std::string Description);
+
+ void CloseReport(void);
+
+private:
+ std::ofstream JSONRepFile;
+};
+/*********************************************************************************************************************/
+/*end of namespace Devi*/
+}
+#endif
+/*********************************************************************************************************************/
+/*last line intentionally left blank.*/
+