blob: e10ea8eaa9cb7869b817842c05e3d8e03440c8b6 (
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
|
#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);
}
}
}
|