aboutsummaryrefslogtreecommitdiffstats
path: root/mutator_aux.h
blob: 16f4a0f681beb74eb15104c5ee911d261198e872 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*********************************************************************************************************************/
/*first line intentionally left blank*/
/*********************************************************************************************************************/
/*inclusion guard*/
#ifndef MUTATOR_AUX_H
#define MUTATOR_AUX_H
/*********************************************************************************************************************/
/*inclusion directives*/
#include <string>
#include <fstream>
#include "clang/AST/AST.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "tinyxml2/tinyxml2.h"
/*********************************************************************************************************************/
using namespace clang;
using namespace tinyxml2;
/*********************************************************************************************************************/
namespace Devi {
SourceLocation SourceLocationHasMacro (SourceLocation SL, Rewriter &Rewrite, std::string Kind);

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 SaveReport(void);

private:
  XMLDocument XMLReportDoc;
  XMLNode* 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 CloseReport(void);

private:
  std::ofstream JSONRepFile;
};

}

#endif
/*********************************************************************************************************************/
/*last line intentionally left blank.*/