From b0e8a04d7193a223af719157155a269f23b4d01b Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Fri, 2 Dec 2016 07:51:43 +0330 Subject: added another overload for member function XMLAdNode to support PPCallbacks. --- mutator_aux.cpp | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/mutator_aux.cpp b/mutator_aux.cpp index 190451b..9d0e4f3 100644 --- a/mutator_aux.cpp +++ b/mutator_aux.cpp @@ -1,14 +1,18 @@ +/*first line intentionally left blank.*/ +/*********************************************************************************************************************/ +/*inclusion directives*/ +#include "mutator_aux.h" #include #include #include "clang/AST/AST.h" -#include "mutator_aux.h" +#include "clang/Basic/SourceManager.h" #include "clang/Rewrite/Core/Rewriter.h" #include "tinyxml2/tinyxml2.h" - +/*********************************************************************************************************************/ using namespace clang; using namespace tinyxml2; - +/*********************************************************************************************************************/ namespace Devi { /*a simple function that checks the sourcelocations for a macro expansion. returns the sourcelocation without macro expansion address.*/ @@ -48,7 +52,7 @@ XMLReport::XMLReport() RootPointer = XMLReportDoc.NewElement("Report"); } -void XMLReport::XMLCreateReport(void) +void XMLReport::XMLCreateReport() { XMLReportDoc.InsertFirstChild(RootPointer); @@ -92,6 +96,24 @@ void XMLReport::XMLAddNode(FullSourceLoc FullSrcLoc, SourceLocation SL, std::str RootPointer->InsertEndChild(MisraElement); } +void XMLReport::XMLAddNode(const SourceManager &SM, SourceLocation SL, std::string MisraRule, std::string Description) +{ + SL = SM.getSpellingLoc(SL); + + unsigned LineNumber = SM.getSpellingLineNumber(SL); + unsigned ColumnNumber = SM.getSpellingColumnNumber(SL); + + std::string FileNameString = SM.getFilename(SL).str(); + + XMLElement* MisraElement = XMLReportDoc.NewElement("MisraDiag"); + MisraElement->SetText(Description.c_str()); + MisraElement->SetAttribute("Misra-C:2004Rule", MisraRule.c_str()); + MisraElement->SetAttribute("FileName", FileNameString.c_str()); + MisraElement->SetAttribute("SpellingLineNumber", LineNumber); + MisraElement->SetAttribute("SpellingColumnNumber", ColumnNumber); + RootPointer->InsertEndChild(MisraElement); +} + void XMLReport::SaveReport(void) { XMLError XMLErrorResult = XMLReportDoc.SaveFile("/home/bloodstalker/devi/hell2/test/misrareport.xml"); @@ -102,4 +124,6 @@ void XMLReport::SaveReport(void) } } /*********************************************************************************************************************/ -} \ No newline at end of file +} +/*********************************************************************************************************************/ +/*last line intentionally left blank.*/ -- cgit v1.2.3