blob: 922dd2a20d59c2598101412e518bda29f9030a3b (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
class Stmt {
code Code = [{
addData(S->getStmtClass());
// This ensures that non-macro-generated code isn't identical to
// macro-generated code.
addData(data_collection::getMacroStack(S->getBeginLoc(), Context));
addData(data_collection::getMacroStack(S->getEndLoc(), Context));
}];
}
class Expr {
code Code = [{
addData(S->getType());
}];
}
//--- Builtin functionality ----------------------------------------------//
class ArrayTypeTraitExpr {
code Code = [{
addData(S->getTrait());
}];
}
class ExpressionTraitExpr {
code Code = [{
addData(S->getTrait());
}];
}
class PredefinedExpr {
code Code = [{
addData(S->getIdentKind());
}];
}
class TypeTraitExpr {
code Code = [{
addData(S->getTrait());
for (unsigned i = 0; i < S->getNumArgs(); ++i)
addData(S->getArg(i)->getType());
}];
}
//--- Calls --------------------------------------------------------------//
class CallExpr {
code Code = [{
// Function pointers don't have a callee and we just skip hashing it.
if (const FunctionDecl *D = S->getDirectCallee()) {
// If the function is a template specialization, we also need to handle
// the template arguments as they are not included in the qualified name.
if (auto Args = D->getTemplateSpecializationArgs()) {
std::string ArgString;
// Print all template arguments into ArgString
llvm::raw_string_ostream OS(ArgString);
for (unsigned i = 0; i < Args->size(); ++i) {
Args->get(i).print(Context.getLangOpts(), OS, /*IncludeType*/ true);
// Add a padding character so that 'foo<X, XX>()' != 'foo<XX, X>()'.
OS << '\n';
}
OS.flush();
addData(ArgString);
}
addData(D->getQualifiedNameAsString());
}
}];
}
//--- Value references ---------------------------------------------------//
class DeclRefExpr {
code Code = [{
addData(S->getDecl()->getQualifiedNameAsString());
}];
}
class MemberExpr {
code Code = [{
addData(S->getMemberDecl()->getName());
}];
}
//--- Literals -----------------------------------------------------------//
class IntegerLiteral {
code Code = [{
addData(llvm::hash_value(S->getValue()));
}];
}
class FloatingLiteral {
code Code = [{
addData(llvm::hash_value(S->getValue()));
}];
}
class StringLiteral {
code Code = [{
addData(S->getString());
}];
}
class CXXBoolLiteralExpr {
code Code = [{
addData(S->getValue());
}];
}
class CharacterLiteral {
code Code = [{
addData(S->getValue());
}];
}
//--- Exceptions ---------------------------------------------------------//
class CXXCatchStmt {
code Code = [{
addData(S->getCaughtType());
}];
}
//--- C++ OOP Stmts ------------------------------------------------------//
class CXXDeleteExpr {
code Code = [{
addData(S->isArrayFormAsWritten()); addData(S->isGlobalDelete());
}];
}
//--- Casts --------------------------------------------------------------//
class ObjCBridgedCastExpr {
code Code = [{
addData(S->getBridgeKind());
}];
}
//--- Miscellaneous Exprs ------------------------------------------------//
class BinaryOperator {
code Code = [{
addData(S->getOpcode());
}];
}
class UnaryOperator {
code Code = [{
addData(S->getOpcode());
}];
}
//--- Control flow -------------------------------------------------------//
class GotoStmt {
code Code = [{
addData(S->getLabel()->getName());
}];
}
class IndirectGotoStmt {
code Code = [{
if (S->getConstantTarget())
addData(S->getConstantTarget()->getName());
}];
}
class LabelStmt {
code Code = [{
addData(S->getDecl()->getName());
}];
}
class MSDependentExistsStmt {
code Code = [{
addData(S->isIfExists());
}];
}
class AddrLabelExpr {
code Code = [{
addData(S->getLabel()->getName());
}];
}
//--- Objective-C --------------------------------------------------------//
class ObjCIndirectCopyRestoreExpr {
code Code = [{
addData(S->shouldCopy());
}];
}
class ObjCPropertyRefExpr {
code Code = [{
addData(S->isSuperReceiver()); addData(S->isImplicitProperty());
}];
}
class ObjCAtCatchStmt {
code Code = [{
addData(S->hasEllipsis());
}];
}
//--- Miscellaneous Stmts ------------------------------------------------//
class CXXFoldExpr {
code Code = [{
addData(S->isRightFold()); addData(S->getOperator());
}];
}
class GenericSelectionExpr {
code Code = [{
for (const GenericSelectionExpr::ConstAssociation Assoc : S->associations()) {
addData(Assoc.getType());
}
}];
}
class LambdaExpr {
code Code = [{
for (const LambdaCapture &C : S->captures()) {
addData(C.isPackExpansion());
addData(C.getCaptureKind());
if (C.capturesVariable())
addData(C.getCapturedVar()->getType());
}
addData(S->isGenericLambda());
addData(S->isMutable());
}];
}
class DeclStmt {
code Code = [{
auto numDecls = std::distance(S->decl_begin(), S->decl_end());
addData(static_cast<unsigned>(numDecls));
for (const Decl *D : S->decls()) {
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
addData(VD->getType());
}
}
}];
}
class AsmStmt {
code Code = [{
addData(S->isSimple());
addData(S->isVolatile());
addData(S->generateAsmString(Context));
for (unsigned i = 0; i < S->getNumInputs(); ++i) {
addData(S->getInputConstraint(i));
}
for (unsigned i = 0; i < S->getNumOutputs(); ++i) {
addData(S->getOutputConstraint(i));
}
for (unsigned i = 0; i < S->getNumClobbers(); ++i) {
addData(S->getClobber(i));
}
}];
}
class AttributedStmt {
code Code = [{
for (const Attr *A : S->getAttrs()) {
addData(std::string(A->getSpelling()));
}
}];
}
|