diff options
| author | bloodstalker <thabogre@gmail.com> | 2016-12-02 04:21:43 +0000 | 
|---|---|---|
| committer | bloodstalker <thabogre@gmail.com> | 2016-12-02 04:21:43 +0000 | 
| commit | b0e8a04d7193a223af719157155a269f23b4d01b (patch) | |
| tree | e331a8e879424bf60c066f59078389f3cba11e9d | |
| parent | updated the current implementation status (diff) | |
| download | mutator-b0e8a04d7193a223af719157155a269f23b4d01b.tar.gz mutator-b0e8a04d7193a223af719157155a269f23b4d01b.zip | |
added another overload for member function XMLAdNode to support PPCallbacks.
| -rw-r--r-- | mutator_aux.cpp | 34 | 
1 files 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 <string>  #include <iostream>  #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.*/ | 
