aboutsummaryrefslogtreecommitdiffstats
path: root/mutator_aux.cpp
diff options
context:
space:
mode:
authorbloodstalker <thabogre@gmail.com>2016-11-04 05:11:43 +0000
committerbloodstalker <thabogre@gmail.com>2016-11-04 05:11:43 +0000
commiteb08e2691b9645883e4f48f0aebf050c3dd65ffb (patch)
tree5d8237ecdaa0250940bee0f81d4680d5bf876201 /mutator_aux.cpp
parentwip-now all run methods sourcelocations handle macros properly-added some mor... (diff)
downloadmutator-eb08e2691b9645883e4f48f0aebf050c3dd65ffb.tar.gz
mutator-eb08e2691b9645883e4f48f0aebf050c3dd65ffb.zip
the new file will hold the auxillary code.
Diffstat (limited to '')
-rw-r--r--mutator_aux.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/mutator_aux.cpp b/mutator_aux.cpp
new file mode 100644
index 0000000..e10ea8e
--- /dev/null
+++ b/mutator_aux.cpp
@@ -0,0 +1,41 @@
+
+#include <string>
+#include <iostream>
+#include "clang/AST/AST.h"
+#include "mutator_aux.h"
+#include "clang/Rewrite/Core/Rewriter.h"
+
+using namespace clang;
+
+namespace Devi {
+/*a simple function that checks the sourcelocations for a macro expansion. returns the sourcelocation without
+macro expansion address.*/
+SourceLocation SourceLocationHasMacro (SourceLocation SL, Rewriter &Rewrite, std::string Kind)
+{
+ /*does the sourcelocation include a macro expansion?*/
+ if ( SL.isMacroID() )
+ {
+ /*get the expansion range which is startloc and endloc*/
+ std::pair <SourceLocation, SourceLocation> expansionRange = Rewrite.getSourceMgr().getImmediateExpansionRange(SL);
+
+ if (Kind == "start")
+ {
+ /*get the startloc.*/
+ return (expansionRange.first);
+ }
+ else if (Kind == "end")
+ {
+ return (expansionRange.second);
+ }
+ else
+ {
+ std::cout << "the third argument of Devi::SourceLocationHasMacro is invalid." << std::endl;
+ }
+
+ }
+ else
+ {
+ return (SL);
+ }
+}
+} \ No newline at end of file