]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp
Merge ^/head r321307 through r321350.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / lib / AST / StmtProfile.cpp
1 //===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the Stmt::Profile method, which builds a unique bit
11 // representation that identifies a statement/expression.
12 //
13 //===----------------------------------------------------------------------===//
14 #include "clang/AST/ASTContext.h"
15 #include "clang/AST/DeclCXX.h"
16 #include "clang/AST/DeclObjC.h"
17 #include "clang/AST/DeclTemplate.h"
18 #include "clang/AST/Expr.h"
19 #include "clang/AST/ExprCXX.h"
20 #include "clang/AST/ExprObjC.h"
21 #include "clang/AST/ExprOpenMP.h"
22 #include "clang/AST/ODRHash.h"
23 #include "clang/AST/StmtVisitor.h"
24 #include "llvm/ADT/FoldingSet.h"
25 using namespace clang;
26
27 namespace {
28   class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
29   protected:
30     llvm::FoldingSetNodeID &ID;
31     bool Canonical;
32
33   public:
34     StmtProfiler(llvm::FoldingSetNodeID &ID, bool Canonical)
35         : ID(ID), Canonical(Canonical) {}
36
37     virtual ~StmtProfiler() {}
38
39     void VisitStmt(const Stmt *S);
40
41 #define STMT(Node, Base) void Visit##Node(const Node *S);
42 #include "clang/AST/StmtNodes.inc"
43
44     /// \brief Visit a declaration that is referenced within an expression
45     /// or statement.
46     virtual void VisitDecl(const Decl *D) = 0;
47
48     /// \brief Visit a type that is referenced within an expression or
49     /// statement.
50     virtual void VisitType(QualType T) = 0;
51
52     /// \brief Visit a name that occurs within an expression or statement.
53     virtual void VisitName(DeclarationName Name) = 0;
54
55     /// \brief Visit identifiers that are not in Decl's or Type's.
56     virtual void VisitIdentifierInfo(IdentifierInfo *II) = 0;
57
58     /// \brief Visit a nested-name-specifier that occurs within an expression
59     /// or statement.
60     virtual void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) = 0;
61
62     /// \brief Visit a template name that occurs within an expression or
63     /// statement.
64     virtual void VisitTemplateName(TemplateName Name) = 0;
65
66     /// \brief Visit template arguments that occur within an expression or
67     /// statement.
68     void VisitTemplateArguments(const TemplateArgumentLoc *Args,
69                                 unsigned NumArgs);
70
71     /// \brief Visit a single template argument.
72     void VisitTemplateArgument(const TemplateArgument &Arg);
73   };
74
75   class StmtProfilerWithPointers : public StmtProfiler {
76     const ASTContext &Context;
77
78   public:
79     StmtProfilerWithPointers(llvm::FoldingSetNodeID &ID,
80                              const ASTContext &Context, bool Canonical)
81         : StmtProfiler(ID, Canonical), Context(Context) {}
82   private:
83     void VisitDecl(const Decl *D) override {
84       ID.AddInteger(D ? D->getKind() : 0);
85
86       if (Canonical && D) {
87         if (const NonTypeTemplateParmDecl *NTTP =
88                 dyn_cast<NonTypeTemplateParmDecl>(D)) {
89           ID.AddInteger(NTTP->getDepth());
90           ID.AddInteger(NTTP->getIndex());
91           ID.AddBoolean(NTTP->isParameterPack());
92           VisitType(NTTP->getType());
93           return;
94         }
95
96         if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
97           // The Itanium C++ ABI uses the type, scope depth, and scope
98           // index of a parameter when mangling expressions that involve
99           // function parameters, so we will use the parameter's type for
100           // establishing function parameter identity. That way, our
101           // definition of "equivalent" (per C++ [temp.over.link]) is at
102           // least as strong as the definition of "equivalent" used for
103           // name mangling.
104           VisitType(Parm->getType());
105           ID.AddInteger(Parm->getFunctionScopeDepth());
106           ID.AddInteger(Parm->getFunctionScopeIndex());
107           return;
108         }
109
110         if (const TemplateTypeParmDecl *TTP =
111                 dyn_cast<TemplateTypeParmDecl>(D)) {
112           ID.AddInteger(TTP->getDepth());
113           ID.AddInteger(TTP->getIndex());
114           ID.AddBoolean(TTP->isParameterPack());
115           return;
116         }
117
118         if (const TemplateTemplateParmDecl *TTP =
119                 dyn_cast<TemplateTemplateParmDecl>(D)) {
120           ID.AddInteger(TTP->getDepth());
121           ID.AddInteger(TTP->getIndex());
122           ID.AddBoolean(TTP->isParameterPack());
123           return;
124         }
125       }
126
127       ID.AddPointer(D ? D->getCanonicalDecl() : nullptr);
128     }
129
130     void VisitType(QualType T) override {
131       if (Canonical && !T.isNull())
132         T = Context.getCanonicalType(T);
133
134       ID.AddPointer(T.getAsOpaquePtr());
135     }
136
137     void VisitName(DeclarationName Name) override {
138       ID.AddPointer(Name.getAsOpaquePtr());
139     }
140
141     void VisitIdentifierInfo(IdentifierInfo *II) override {
142       ID.AddPointer(II);
143     }
144
145     void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
146       if (Canonical)
147         NNS = Context.getCanonicalNestedNameSpecifier(NNS);
148       ID.AddPointer(NNS);
149     }
150
151     void VisitTemplateName(TemplateName Name) override {
152       if (Canonical)
153         Name = Context.getCanonicalTemplateName(Name);
154
155       Name.Profile(ID);
156     }
157   };
158
159   class StmtProfilerWithoutPointers : public StmtProfiler {
160     ODRHash &Hash;
161   public:
162     StmtProfilerWithoutPointers(llvm::FoldingSetNodeID &ID, ODRHash &Hash)
163         : StmtProfiler(ID, false), Hash(Hash) {}
164
165   private:
166     void VisitType(QualType T) override {
167       Hash.AddQualType(T);
168     }
169
170     void VisitName(DeclarationName Name) override {
171       Hash.AddDeclarationName(Name);
172     }
173     void VisitIdentifierInfo(IdentifierInfo *II) override {
174       ID.AddBoolean(II);
175       if (II) {
176         Hash.AddIdentifierInfo(II);
177       }
178     }
179     void VisitDecl(const Decl *D) override {
180       ID.AddBoolean(D);
181       if (D) {
182         Hash.AddDecl(D);
183       }
184     }
185     void VisitTemplateName(TemplateName Name) override {
186       Hash.AddTemplateName(Name);
187     }
188     void VisitNestedNameSpecifier(NestedNameSpecifier *NNS) override {
189       ID.AddBoolean(NNS);
190       if (NNS) {
191         Hash.AddNestedNameSpecifier(NNS);
192       }
193     }
194   };
195 }
196
197 void StmtProfiler::VisitStmt(const Stmt *S) {
198   assert(S && "Requires non-null Stmt pointer");
199   ID.AddInteger(S->getStmtClass());
200   for (const Stmt *SubStmt : S->children()) {
201     if (SubStmt)
202       Visit(SubStmt);
203     else
204       ID.AddInteger(0);
205   }
206 }
207
208 void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
209   VisitStmt(S);
210   for (const auto *D : S->decls())
211     VisitDecl(D);
212 }
213
214 void StmtProfiler::VisitNullStmt(const NullStmt *S) {
215   VisitStmt(S);
216 }
217
218 void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
219   VisitStmt(S);
220 }
221
222 void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
223   VisitStmt(S);
224 }
225
226 void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
227   VisitStmt(S);
228 }
229
230 void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
231   VisitStmt(S);
232   VisitDecl(S->getDecl());
233 }
234
235 void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
236   VisitStmt(S);
237   // TODO: maybe visit attributes?
238 }
239
240 void StmtProfiler::VisitIfStmt(const IfStmt *S) {
241   VisitStmt(S);
242   VisitDecl(S->getConditionVariable());
243 }
244
245 void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
246   VisitStmt(S);
247   VisitDecl(S->getConditionVariable());
248 }
249
250 void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
251   VisitStmt(S);
252   VisitDecl(S->getConditionVariable());
253 }
254
255 void StmtProfiler::VisitDoStmt(const DoStmt *S) {
256   VisitStmt(S);
257 }
258
259 void StmtProfiler::VisitForStmt(const ForStmt *S) {
260   VisitStmt(S);
261 }
262
263 void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
264   VisitStmt(S);
265   VisitDecl(S->getLabel());
266 }
267
268 void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
269   VisitStmt(S);
270 }
271
272 void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
273   VisitStmt(S);
274 }
275
276 void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
277   VisitStmt(S);
278 }
279
280 void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
281   VisitStmt(S);
282 }
283
284 void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
285   VisitStmt(S);
286   ID.AddBoolean(S->isVolatile());
287   ID.AddBoolean(S->isSimple());
288   VisitStringLiteral(S->getAsmString());
289   ID.AddInteger(S->getNumOutputs());
290   for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
291     ID.AddString(S->getOutputName(I));
292     VisitStringLiteral(S->getOutputConstraintLiteral(I));
293   }
294   ID.AddInteger(S->getNumInputs());
295   for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
296     ID.AddString(S->getInputName(I));
297     VisitStringLiteral(S->getInputConstraintLiteral(I));
298   }
299   ID.AddInteger(S->getNumClobbers());
300   for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
301     VisitStringLiteral(S->getClobberStringLiteral(I));
302 }
303
304 void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
305   // FIXME: Implement MS style inline asm statement profiler.
306   VisitStmt(S);
307 }
308
309 void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
310   VisitStmt(S);
311   VisitType(S->getCaughtType());
312 }
313
314 void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
315   VisitStmt(S);
316 }
317
318 void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
319   VisitStmt(S);
320 }
321
322 void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
323   VisitStmt(S);
324   ID.AddBoolean(S->isIfExists());
325   VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
326   VisitName(S->getNameInfo().getName());
327 }
328
329 void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
330   VisitStmt(S);
331 }
332
333 void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
334   VisitStmt(S);
335 }
336
337 void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
338   VisitStmt(S);
339 }
340
341 void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
342   VisitStmt(S);
343 }
344
345 void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
346   VisitStmt(S);
347 }
348
349 void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
350   VisitStmt(S);
351 }
352
353 void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
354   VisitStmt(S);
355   ID.AddBoolean(S->hasEllipsis());
356   if (S->getCatchParamDecl())
357     VisitType(S->getCatchParamDecl()->getType());
358 }
359
360 void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
361   VisitStmt(S);
362 }
363
364 void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
365   VisitStmt(S);
366 }
367
368 void
369 StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
370   VisitStmt(S);
371 }
372
373 void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
374   VisitStmt(S);
375 }
376
377 void
378 StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
379   VisitStmt(S);
380 }
381
382 namespace {
383 class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
384   StmtProfiler *Profiler;
385   /// \brief Process clauses with list of variables.
386   template <typename T>
387   void VisitOMPClauseList(T *Node);
388
389 public:
390   OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
391 #define OPENMP_CLAUSE(Name, Class)                                             \
392   void Visit##Class(const Class *C);
393 #include "clang/Basic/OpenMPKinds.def"
394   void VistOMPClauseWithPreInit(const OMPClauseWithPreInit *C);
395   void VistOMPClauseWithPostUpdate(const OMPClauseWithPostUpdate *C);
396 };
397
398 void OMPClauseProfiler::VistOMPClauseWithPreInit(
399     const OMPClauseWithPreInit *C) {
400   if (auto *S = C->getPreInitStmt())
401     Profiler->VisitStmt(S);
402 }
403
404 void OMPClauseProfiler::VistOMPClauseWithPostUpdate(
405     const OMPClauseWithPostUpdate *C) {
406   VistOMPClauseWithPreInit(C);
407   if (auto *E = C->getPostUpdateExpr())
408     Profiler->VisitStmt(E);
409 }
410
411 void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
412   VistOMPClauseWithPreInit(C);
413   if (C->getCondition())
414     Profiler->VisitStmt(C->getCondition());
415 }
416
417 void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
418   if (C->getCondition())
419     Profiler->VisitStmt(C->getCondition());
420 }
421
422 void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
423   VistOMPClauseWithPreInit(C);
424   if (C->getNumThreads())
425     Profiler->VisitStmt(C->getNumThreads());
426 }
427
428 void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
429   if (C->getSafelen())
430     Profiler->VisitStmt(C->getSafelen());
431 }
432
433 void OMPClauseProfiler::VisitOMPSimdlenClause(const OMPSimdlenClause *C) {
434   if (C->getSimdlen())
435     Profiler->VisitStmt(C->getSimdlen());
436 }
437
438 void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
439   if (C->getNumForLoops())
440     Profiler->VisitStmt(C->getNumForLoops());
441 }
442
443 void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
444
445 void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
446
447 void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
448   VistOMPClauseWithPreInit(C);
449   if (auto *S = C->getChunkSize())
450     Profiler->VisitStmt(S);
451 }
452
453 void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
454   if (auto *Num = C->getNumForLoops())
455     Profiler->VisitStmt(Num);
456 }
457
458 void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
459
460 void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
461
462 void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
463
464 void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
465
466 void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
467
468 void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
469
470 void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
471
472 void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
473
474 void OMPClauseProfiler::VisitOMPThreadsClause(const OMPThreadsClause *) {}
475
476 void OMPClauseProfiler::VisitOMPSIMDClause(const OMPSIMDClause *) {}
477
478 void OMPClauseProfiler::VisitOMPNogroupClause(const OMPNogroupClause *) {}
479
480 template<typename T>
481 void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
482   for (auto *E : Node->varlists()) {
483     if (E)
484       Profiler->VisitStmt(E);
485   }
486 }
487
488 void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
489   VisitOMPClauseList(C);
490   for (auto *E : C->private_copies()) {
491     if (E)
492       Profiler->VisitStmt(E);
493   }
494 }
495 void
496 OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
497   VisitOMPClauseList(C);
498   VistOMPClauseWithPreInit(C);
499   for (auto *E : C->private_copies()) {
500     if (E)
501       Profiler->VisitStmt(E);
502   }
503   for (auto *E : C->inits()) {
504     if (E)
505       Profiler->VisitStmt(E);
506   }
507 }
508 void
509 OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
510   VisitOMPClauseList(C);
511   VistOMPClauseWithPostUpdate(C);
512   for (auto *E : C->source_exprs()) {
513     if (E)
514       Profiler->VisitStmt(E);
515   }
516   for (auto *E : C->destination_exprs()) {
517     if (E)
518       Profiler->VisitStmt(E);
519   }
520   for (auto *E : C->assignment_ops()) {
521     if (E)
522       Profiler->VisitStmt(E);
523   }
524 }
525 void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
526   VisitOMPClauseList(C);
527 }
528 void OMPClauseProfiler::VisitOMPReductionClause(
529                                          const OMPReductionClause *C) {
530   Profiler->VisitNestedNameSpecifier(
531       C->getQualifierLoc().getNestedNameSpecifier());
532   Profiler->VisitName(C->getNameInfo().getName());
533   VisitOMPClauseList(C);
534   VistOMPClauseWithPostUpdate(C);
535   for (auto *E : C->privates()) {
536     if (E)
537       Profiler->VisitStmt(E);
538   }
539   for (auto *E : C->lhs_exprs()) {
540     if (E)
541       Profiler->VisitStmt(E);
542   }
543   for (auto *E : C->rhs_exprs()) {
544     if (E)
545       Profiler->VisitStmt(E);
546   }
547   for (auto *E : C->reduction_ops()) {
548     if (E)
549       Profiler->VisitStmt(E);
550   }
551 }
552 void OMPClauseProfiler::VisitOMPTaskReductionClause(
553     const OMPTaskReductionClause *C) {
554   Profiler->VisitNestedNameSpecifier(
555       C->getQualifierLoc().getNestedNameSpecifier());
556   Profiler->VisitName(C->getNameInfo().getName());
557   VisitOMPClauseList(C);
558   VistOMPClauseWithPostUpdate(C);
559   for (auto *E : C->privates()) {
560     if (E)
561       Profiler->VisitStmt(E);
562   }
563   for (auto *E : C->lhs_exprs()) {
564     if (E)
565       Profiler->VisitStmt(E);
566   }
567   for (auto *E : C->rhs_exprs()) {
568     if (E)
569       Profiler->VisitStmt(E);
570   }
571   for (auto *E : C->reduction_ops()) {
572     if (E)
573       Profiler->VisitStmt(E);
574   }
575 }
576 void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
577   VisitOMPClauseList(C);
578   VistOMPClauseWithPostUpdate(C);
579   for (auto *E : C->privates()) {
580     if (E)
581       Profiler->VisitStmt(E);
582   }
583   for (auto *E : C->inits()) {
584     if (E)
585       Profiler->VisitStmt(E);
586   }
587   for (auto *E : C->updates()) {
588     if (E)
589       Profiler->VisitStmt(E);
590   }
591   for (auto *E : C->finals()) {
592     if (E)
593       Profiler->VisitStmt(E);
594   }
595   if (C->getStep())
596     Profiler->VisitStmt(C->getStep());
597   if (C->getCalcStep())
598     Profiler->VisitStmt(C->getCalcStep());
599 }
600 void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
601   VisitOMPClauseList(C);
602   if (C->getAlignment())
603     Profiler->VisitStmt(C->getAlignment());
604 }
605 void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
606   VisitOMPClauseList(C);
607   for (auto *E : C->source_exprs()) {
608     if (E)
609       Profiler->VisitStmt(E);
610   }
611   for (auto *E : C->destination_exprs()) {
612     if (E)
613       Profiler->VisitStmt(E);
614   }
615   for (auto *E : C->assignment_ops()) {
616     if (E)
617       Profiler->VisitStmt(E);
618   }
619 }
620 void
621 OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
622   VisitOMPClauseList(C);
623   for (auto *E : C->source_exprs()) {
624     if (E)
625       Profiler->VisitStmt(E);
626   }
627   for (auto *E : C->destination_exprs()) {
628     if (E)
629       Profiler->VisitStmt(E);
630   }
631   for (auto *E : C->assignment_ops()) {
632     if (E)
633       Profiler->VisitStmt(E);
634   }
635 }
636 void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
637   VisitOMPClauseList(C);
638 }
639 void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
640   VisitOMPClauseList(C);
641 }
642 void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
643   if (C->getDevice())
644     Profiler->VisitStmt(C->getDevice());
645 }
646 void OMPClauseProfiler::VisitOMPMapClause(const OMPMapClause *C) {
647   VisitOMPClauseList(C);
648 }
649 void OMPClauseProfiler::VisitOMPNumTeamsClause(const OMPNumTeamsClause *C) {
650   VistOMPClauseWithPreInit(C);
651   if (C->getNumTeams())
652     Profiler->VisitStmt(C->getNumTeams());
653 }
654 void OMPClauseProfiler::VisitOMPThreadLimitClause(
655     const OMPThreadLimitClause *C) {
656   VistOMPClauseWithPreInit(C);
657   if (C->getThreadLimit())
658     Profiler->VisitStmt(C->getThreadLimit());
659 }
660 void OMPClauseProfiler::VisitOMPPriorityClause(const OMPPriorityClause *C) {
661   if (C->getPriority())
662     Profiler->VisitStmt(C->getPriority());
663 }
664 void OMPClauseProfiler::VisitOMPGrainsizeClause(const OMPGrainsizeClause *C) {
665   if (C->getGrainsize())
666     Profiler->VisitStmt(C->getGrainsize());
667 }
668 void OMPClauseProfiler::VisitOMPNumTasksClause(const OMPNumTasksClause *C) {
669   if (C->getNumTasks())
670     Profiler->VisitStmt(C->getNumTasks());
671 }
672 void OMPClauseProfiler::VisitOMPHintClause(const OMPHintClause *C) {
673   if (C->getHint())
674     Profiler->VisitStmt(C->getHint());
675 }
676 void OMPClauseProfiler::VisitOMPToClause(const OMPToClause *C) {
677   VisitOMPClauseList(C);
678 }
679 void OMPClauseProfiler::VisitOMPFromClause(const OMPFromClause *C) {
680   VisitOMPClauseList(C);
681 }
682 void OMPClauseProfiler::VisitOMPUseDevicePtrClause(
683     const OMPUseDevicePtrClause *C) {
684   VisitOMPClauseList(C);
685 }
686 void OMPClauseProfiler::VisitOMPIsDevicePtrClause(
687     const OMPIsDevicePtrClause *C) {
688   VisitOMPClauseList(C);
689 }
690 }
691
692 void
693 StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
694   VisitStmt(S);
695   OMPClauseProfiler P(this);
696   ArrayRef<OMPClause *> Clauses = S->clauses();
697   for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
698        I != E; ++I)
699     if (*I)
700       P.Visit(*I);
701 }
702
703 void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
704   VisitOMPExecutableDirective(S);
705 }
706
707 void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
708   VisitOMPExecutableDirective(S);
709 }
710
711 void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
712   VisitOMPLoopDirective(S);
713 }
714
715 void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
716   VisitOMPLoopDirective(S);
717 }
718
719 void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
720   VisitOMPLoopDirective(S);
721 }
722
723 void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
724   VisitOMPExecutableDirective(S);
725 }
726
727 void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
728   VisitOMPExecutableDirective(S);
729 }
730
731 void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
732   VisitOMPExecutableDirective(S);
733 }
734
735 void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
736   VisitOMPExecutableDirective(S);
737 }
738
739 void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
740   VisitOMPExecutableDirective(S);
741   VisitName(S->getDirectiveName().getName());
742 }
743
744 void
745 StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
746   VisitOMPLoopDirective(S);
747 }
748
749 void StmtProfiler::VisitOMPParallelForSimdDirective(
750     const OMPParallelForSimdDirective *S) {
751   VisitOMPLoopDirective(S);
752 }
753
754 void StmtProfiler::VisitOMPParallelSectionsDirective(
755     const OMPParallelSectionsDirective *S) {
756   VisitOMPExecutableDirective(S);
757 }
758
759 void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
760   VisitOMPExecutableDirective(S);
761 }
762
763 void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
764   VisitOMPExecutableDirective(S);
765 }
766
767 void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
768   VisitOMPExecutableDirective(S);
769 }
770
771 void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
772   VisitOMPExecutableDirective(S);
773 }
774
775 void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
776   VisitOMPExecutableDirective(S);
777 }
778
779 void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
780   VisitOMPExecutableDirective(S);
781 }
782
783 void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
784   VisitOMPExecutableDirective(S);
785 }
786
787 void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
788   VisitOMPExecutableDirective(S);
789 }
790
791 void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
792   VisitOMPExecutableDirective(S);
793 }
794
795 void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
796   VisitOMPExecutableDirective(S);
797 }
798
799 void StmtProfiler::VisitOMPTargetEnterDataDirective(
800     const OMPTargetEnterDataDirective *S) {
801   VisitOMPExecutableDirective(S);
802 }
803
804 void StmtProfiler::VisitOMPTargetExitDataDirective(
805     const OMPTargetExitDataDirective *S) {
806   VisitOMPExecutableDirective(S);
807 }
808
809 void StmtProfiler::VisitOMPTargetParallelDirective(
810     const OMPTargetParallelDirective *S) {
811   VisitOMPExecutableDirective(S);
812 }
813
814 void StmtProfiler::VisitOMPTargetParallelForDirective(
815     const OMPTargetParallelForDirective *S) {
816   VisitOMPExecutableDirective(S);
817 }
818
819 void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
820   VisitOMPExecutableDirective(S);
821 }
822
823 void StmtProfiler::VisitOMPCancellationPointDirective(
824     const OMPCancellationPointDirective *S) {
825   VisitOMPExecutableDirective(S);
826 }
827
828 void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
829   VisitOMPExecutableDirective(S);
830 }
831
832 void StmtProfiler::VisitOMPTaskLoopDirective(const OMPTaskLoopDirective *S) {
833   VisitOMPLoopDirective(S);
834 }
835
836 void StmtProfiler::VisitOMPTaskLoopSimdDirective(
837     const OMPTaskLoopSimdDirective *S) {
838   VisitOMPLoopDirective(S);
839 }
840
841 void StmtProfiler::VisitOMPDistributeDirective(
842     const OMPDistributeDirective *S) {
843   VisitOMPLoopDirective(S);
844 }
845
846 void OMPClauseProfiler::VisitOMPDistScheduleClause(
847     const OMPDistScheduleClause *C) {
848   VistOMPClauseWithPreInit(C);
849   if (auto *S = C->getChunkSize())
850     Profiler->VisitStmt(S);
851 }
852
853 void OMPClauseProfiler::VisitOMPDefaultmapClause(const OMPDefaultmapClause *) {}
854
855 void StmtProfiler::VisitOMPTargetUpdateDirective(
856     const OMPTargetUpdateDirective *S) {
857   VisitOMPExecutableDirective(S);
858 }
859
860 void StmtProfiler::VisitOMPDistributeParallelForDirective(
861     const OMPDistributeParallelForDirective *S) {
862   VisitOMPLoopDirective(S);
863 }
864
865 void StmtProfiler::VisitOMPDistributeParallelForSimdDirective(
866     const OMPDistributeParallelForSimdDirective *S) {
867   VisitOMPLoopDirective(S);
868 }
869
870 void StmtProfiler::VisitOMPDistributeSimdDirective(
871     const OMPDistributeSimdDirective *S) {
872   VisitOMPLoopDirective(S);
873 }
874
875 void StmtProfiler::VisitOMPTargetParallelForSimdDirective(
876     const OMPTargetParallelForSimdDirective *S) {
877   VisitOMPLoopDirective(S);
878 }
879
880 void StmtProfiler::VisitOMPTargetSimdDirective(
881     const OMPTargetSimdDirective *S) {
882   VisitOMPLoopDirective(S);
883 }
884
885 void StmtProfiler::VisitOMPTeamsDistributeDirective(
886     const OMPTeamsDistributeDirective *S) {
887   VisitOMPLoopDirective(S);
888 }
889
890 void StmtProfiler::VisitOMPTeamsDistributeSimdDirective(
891     const OMPTeamsDistributeSimdDirective *S) {
892   VisitOMPLoopDirective(S);
893 }
894
895 void StmtProfiler::VisitOMPTeamsDistributeParallelForSimdDirective(
896     const OMPTeamsDistributeParallelForSimdDirective *S) {
897   VisitOMPLoopDirective(S);
898 }
899
900 void StmtProfiler::VisitOMPTeamsDistributeParallelForDirective(
901     const OMPTeamsDistributeParallelForDirective *S) {
902   VisitOMPLoopDirective(S);
903 }
904
905 void StmtProfiler::VisitOMPTargetTeamsDirective(
906     const OMPTargetTeamsDirective *S) {
907   VisitOMPExecutableDirective(S);
908 }
909
910 void StmtProfiler::VisitOMPTargetTeamsDistributeDirective(
911     const OMPTargetTeamsDistributeDirective *S) {
912   VisitOMPLoopDirective(S);
913 }
914
915 void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForDirective(
916     const OMPTargetTeamsDistributeParallelForDirective *S) {
917   VisitOMPLoopDirective(S);
918 }
919
920 void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
921     const OMPTargetTeamsDistributeParallelForSimdDirective *S) {
922   VisitOMPLoopDirective(S);
923 }
924
925 void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
926     const OMPTargetTeamsDistributeSimdDirective *S) {
927   VisitOMPLoopDirective(S);
928 }
929
930 void StmtProfiler::VisitExpr(const Expr *S) {
931   VisitStmt(S);
932 }
933
934 void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
935   VisitExpr(S);
936   if (!Canonical)
937     VisitNestedNameSpecifier(S->getQualifier());
938   VisitDecl(S->getDecl());
939   if (!Canonical)
940     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
941 }
942
943 void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
944   VisitExpr(S);
945   ID.AddInteger(S->getIdentType());
946 }
947
948 void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
949   VisitExpr(S);
950   S->getValue().Profile(ID);
951   ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
952 }
953
954 void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
955   VisitExpr(S);
956   ID.AddInteger(S->getKind());
957   ID.AddInteger(S->getValue());
958 }
959
960 void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
961   VisitExpr(S);
962   S->getValue().Profile(ID);
963   ID.AddBoolean(S->isExact());
964   ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
965 }
966
967 void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
968   VisitExpr(S);
969 }
970
971 void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
972   VisitExpr(S);
973   ID.AddString(S->getBytes());
974   ID.AddInteger(S->getKind());
975 }
976
977 void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
978   VisitExpr(S);
979 }
980
981 void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
982   VisitExpr(S);
983 }
984
985 void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
986   VisitExpr(S);
987   ID.AddInteger(S->getOpcode());
988 }
989
990 void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
991   VisitType(S->getTypeSourceInfo()->getType());
992   unsigned n = S->getNumComponents();
993   for (unsigned i = 0; i < n; ++i) {
994     const OffsetOfNode &ON = S->getComponent(i);
995     ID.AddInteger(ON.getKind());
996     switch (ON.getKind()) {
997     case OffsetOfNode::Array:
998       // Expressions handled below.
999       break;
1000
1001     case OffsetOfNode::Field:
1002       VisitDecl(ON.getField());
1003       break;
1004
1005     case OffsetOfNode::Identifier:
1006       VisitIdentifierInfo(ON.getFieldName());
1007       break;
1008
1009     case OffsetOfNode::Base:
1010       // These nodes are implicit, and therefore don't need profiling.
1011       break;
1012     }
1013   }
1014
1015   VisitExpr(S);
1016 }
1017
1018 void
1019 StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
1020   VisitExpr(S);
1021   ID.AddInteger(S->getKind());
1022   if (S->isArgumentType())
1023     VisitType(S->getArgumentType());
1024 }
1025
1026 void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
1027   VisitExpr(S);
1028 }
1029
1030 void StmtProfiler::VisitOMPArraySectionExpr(const OMPArraySectionExpr *S) {
1031   VisitExpr(S);
1032 }
1033
1034 void StmtProfiler::VisitCallExpr(const CallExpr *S) {
1035   VisitExpr(S);
1036 }
1037
1038 void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
1039   VisitExpr(S);
1040   VisitDecl(S->getMemberDecl());
1041   if (!Canonical)
1042     VisitNestedNameSpecifier(S->getQualifier());
1043   ID.AddBoolean(S->isArrow());
1044 }
1045
1046 void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
1047   VisitExpr(S);
1048   ID.AddBoolean(S->isFileScope());
1049 }
1050
1051 void StmtProfiler::VisitCastExpr(const CastExpr *S) {
1052   VisitExpr(S);
1053 }
1054
1055 void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
1056   VisitCastExpr(S);
1057   ID.AddInteger(S->getValueKind());
1058 }
1059
1060 void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
1061   VisitCastExpr(S);
1062   VisitType(S->getTypeAsWritten());
1063 }
1064
1065 void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
1066   VisitExplicitCastExpr(S);
1067 }
1068
1069 void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
1070   VisitExpr(S);
1071   ID.AddInteger(S->getOpcode());
1072 }
1073
1074 void
1075 StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
1076   VisitBinaryOperator(S);
1077 }
1078
1079 void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
1080   VisitExpr(S);
1081 }
1082
1083 void StmtProfiler::VisitBinaryConditionalOperator(
1084     const BinaryConditionalOperator *S) {
1085   VisitExpr(S);
1086 }
1087
1088 void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
1089   VisitExpr(S);
1090   VisitDecl(S->getLabel());
1091 }
1092
1093 void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
1094   VisitExpr(S);
1095 }
1096
1097 void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
1098   VisitExpr(S);
1099 }
1100
1101 void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
1102   VisitExpr(S);
1103 }
1104
1105 void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
1106   VisitExpr(S);
1107 }
1108
1109 void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
1110   VisitExpr(S);
1111 }
1112
1113 void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
1114   VisitExpr(S);
1115 }
1116
1117 void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
1118   if (S->getSyntacticForm()) {
1119     VisitInitListExpr(S->getSyntacticForm());
1120     return;
1121   }
1122
1123   VisitExpr(S);
1124 }
1125
1126 void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
1127   VisitExpr(S);
1128   ID.AddBoolean(S->usesGNUSyntax());
1129   for (const DesignatedInitExpr::Designator &D : S->designators()) {
1130     if (D.isFieldDesignator()) {
1131       ID.AddInteger(0);
1132       VisitName(D.getFieldName());
1133       continue;
1134     }
1135
1136     if (D.isArrayDesignator()) {
1137       ID.AddInteger(1);
1138     } else {
1139       assert(D.isArrayRangeDesignator());
1140       ID.AddInteger(2);
1141     }
1142     ID.AddInteger(D.getFirstExprIndex());
1143   }
1144 }
1145
1146 // Seems that if VisitInitListExpr() only works on the syntactic form of an
1147 // InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
1148 void StmtProfiler::VisitDesignatedInitUpdateExpr(
1149     const DesignatedInitUpdateExpr *S) {
1150   llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
1151                    "initializer");
1152 }
1153
1154 void StmtProfiler::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *S) {
1155   VisitExpr(S);
1156 }
1157
1158 void StmtProfiler::VisitArrayInitIndexExpr(const ArrayInitIndexExpr *S) {
1159   VisitExpr(S);
1160 }
1161
1162 void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
1163   llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
1164 }
1165
1166 void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
1167   VisitExpr(S);
1168 }
1169
1170 void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
1171   VisitExpr(S);
1172   VisitName(&S->getAccessor());
1173 }
1174
1175 void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
1176   VisitExpr(S);
1177   VisitDecl(S->getBlockDecl());
1178 }
1179
1180 void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
1181   VisitExpr(S);
1182   for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
1183     QualType T = S->getAssocType(i);
1184     if (T.isNull())
1185       ID.AddPointer(nullptr);
1186     else
1187       VisitType(T);
1188     VisitExpr(S->getAssocExpr(i));
1189   }
1190 }
1191
1192 void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
1193   VisitExpr(S);
1194   for (PseudoObjectExpr::const_semantics_iterator
1195          i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
1196     // Normally, we would not profile the source expressions of OVEs.
1197     if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
1198       Visit(OVE->getSourceExpr());
1199 }
1200
1201 void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
1202   VisitExpr(S);
1203   ID.AddInteger(S->getOp());
1204 }
1205
1206 static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
1207                                           UnaryOperatorKind &UnaryOp,
1208                                           BinaryOperatorKind &BinaryOp) {
1209   switch (S->getOperator()) {
1210   case OO_None:
1211   case OO_New:
1212   case OO_Delete:
1213   case OO_Array_New:
1214   case OO_Array_Delete:
1215   case OO_Arrow:
1216   case OO_Call:
1217   case OO_Conditional:
1218   case OO_Coawait:
1219   case NUM_OVERLOADED_OPERATORS:
1220     llvm_unreachable("Invalid operator call kind");
1221       
1222   case OO_Plus:
1223     if (S->getNumArgs() == 1) {
1224       UnaryOp = UO_Plus;
1225       return Stmt::UnaryOperatorClass;
1226     }
1227     
1228     BinaryOp = BO_Add;
1229     return Stmt::BinaryOperatorClass;
1230       
1231   case OO_Minus:
1232     if (S->getNumArgs() == 1) {
1233       UnaryOp = UO_Minus;
1234       return Stmt::UnaryOperatorClass;
1235     }
1236     
1237     BinaryOp = BO_Sub;
1238     return Stmt::BinaryOperatorClass;
1239
1240   case OO_Star:
1241     if (S->getNumArgs() == 1) {
1242       UnaryOp = UO_Deref;
1243       return Stmt::UnaryOperatorClass;
1244     }
1245     
1246     BinaryOp = BO_Mul;
1247     return Stmt::BinaryOperatorClass;
1248
1249   case OO_Slash:
1250     BinaryOp = BO_Div;
1251     return Stmt::BinaryOperatorClass;
1252       
1253   case OO_Percent:
1254     BinaryOp = BO_Rem;
1255     return Stmt::BinaryOperatorClass;
1256
1257   case OO_Caret:
1258     BinaryOp = BO_Xor;
1259     return Stmt::BinaryOperatorClass;
1260
1261   case OO_Amp:
1262     if (S->getNumArgs() == 1) {
1263       UnaryOp = UO_AddrOf;
1264       return Stmt::UnaryOperatorClass;
1265     }
1266     
1267     BinaryOp = BO_And;
1268     return Stmt::BinaryOperatorClass;
1269       
1270   case OO_Pipe:
1271     BinaryOp = BO_Or;
1272     return Stmt::BinaryOperatorClass;
1273
1274   case OO_Tilde:
1275     UnaryOp = UO_Not;
1276     return Stmt::UnaryOperatorClass;
1277
1278   case OO_Exclaim:
1279     UnaryOp = UO_LNot;
1280     return Stmt::UnaryOperatorClass;
1281
1282   case OO_Equal:
1283     BinaryOp = BO_Assign;
1284     return Stmt::BinaryOperatorClass;
1285
1286   case OO_Less:
1287     BinaryOp = BO_LT;
1288     return Stmt::BinaryOperatorClass;
1289
1290   case OO_Greater:
1291     BinaryOp = BO_GT;
1292     return Stmt::BinaryOperatorClass;
1293       
1294   case OO_PlusEqual:
1295     BinaryOp = BO_AddAssign;
1296     return Stmt::CompoundAssignOperatorClass;
1297
1298   case OO_MinusEqual:
1299     BinaryOp = BO_SubAssign;
1300     return Stmt::CompoundAssignOperatorClass;
1301
1302   case OO_StarEqual:
1303     BinaryOp = BO_MulAssign;
1304     return Stmt::CompoundAssignOperatorClass;
1305
1306   case OO_SlashEqual:
1307     BinaryOp = BO_DivAssign;
1308     return Stmt::CompoundAssignOperatorClass;
1309
1310   case OO_PercentEqual:
1311     BinaryOp = BO_RemAssign;
1312     return Stmt::CompoundAssignOperatorClass;
1313
1314   case OO_CaretEqual:
1315     BinaryOp = BO_XorAssign;
1316     return Stmt::CompoundAssignOperatorClass;
1317     
1318   case OO_AmpEqual:
1319     BinaryOp = BO_AndAssign;
1320     return Stmt::CompoundAssignOperatorClass;
1321     
1322   case OO_PipeEqual:
1323     BinaryOp = BO_OrAssign;
1324     return Stmt::CompoundAssignOperatorClass;
1325       
1326   case OO_LessLess:
1327     BinaryOp = BO_Shl;
1328     return Stmt::BinaryOperatorClass;
1329     
1330   case OO_GreaterGreater:
1331     BinaryOp = BO_Shr;
1332     return Stmt::BinaryOperatorClass;
1333
1334   case OO_LessLessEqual:
1335     BinaryOp = BO_ShlAssign;
1336     return Stmt::CompoundAssignOperatorClass;
1337     
1338   case OO_GreaterGreaterEqual:
1339     BinaryOp = BO_ShrAssign;
1340     return Stmt::CompoundAssignOperatorClass;
1341
1342   case OO_EqualEqual:
1343     BinaryOp = BO_EQ;
1344     return Stmt::BinaryOperatorClass;
1345     
1346   case OO_ExclaimEqual:
1347     BinaryOp = BO_NE;
1348     return Stmt::BinaryOperatorClass;
1349       
1350   case OO_LessEqual:
1351     BinaryOp = BO_LE;
1352     return Stmt::BinaryOperatorClass;
1353     
1354   case OO_GreaterEqual:
1355     BinaryOp = BO_GE;
1356     return Stmt::BinaryOperatorClass;
1357       
1358   case OO_AmpAmp:
1359     BinaryOp = BO_LAnd;
1360     return Stmt::BinaryOperatorClass;
1361     
1362   case OO_PipePipe:
1363     BinaryOp = BO_LOr;
1364     return Stmt::BinaryOperatorClass;
1365
1366   case OO_PlusPlus:
1367     UnaryOp = S->getNumArgs() == 1? UO_PreInc 
1368                                   : UO_PostInc;
1369     return Stmt::UnaryOperatorClass;
1370
1371   case OO_MinusMinus:
1372     UnaryOp = S->getNumArgs() == 1? UO_PreDec
1373                                   : UO_PostDec;
1374     return Stmt::UnaryOperatorClass;
1375
1376   case OO_Comma:
1377     BinaryOp = BO_Comma;
1378     return Stmt::BinaryOperatorClass;
1379
1380   case OO_ArrowStar:
1381     BinaryOp = BO_PtrMemI;
1382     return Stmt::BinaryOperatorClass;
1383       
1384   case OO_Subscript:
1385     return Stmt::ArraySubscriptExprClass;
1386   }
1387   
1388   llvm_unreachable("Invalid overloaded operator expression");
1389 }
1390
1391 void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
1392   if (S->isTypeDependent()) {
1393     // Type-dependent operator calls are profiled like their underlying
1394     // syntactic operator.
1395     //
1396     // An operator call to operator-> is always implicit, so just skip it. The
1397     // enclosing MemberExpr will profile the actual member access.
1398     if (S->getOperator() == OO_Arrow)
1399       return Visit(S->getArg(0));
1400
1401     UnaryOperatorKind UnaryOp = UO_Extension;
1402     BinaryOperatorKind BinaryOp = BO_Comma;
1403     Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
1404
1405     ID.AddInteger(SC);
1406     for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1407       Visit(S->getArg(I));
1408     if (SC == Stmt::UnaryOperatorClass)
1409       ID.AddInteger(UnaryOp);
1410     else if (SC == Stmt::BinaryOperatorClass || 
1411              SC == Stmt::CompoundAssignOperatorClass)
1412       ID.AddInteger(BinaryOp);
1413     else
1414       assert(SC == Stmt::ArraySubscriptExprClass);
1415
1416     return;
1417   }
1418
1419   VisitCallExpr(S);
1420   ID.AddInteger(S->getOperator());
1421 }
1422
1423 void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
1424   VisitCallExpr(S);
1425 }
1426
1427 void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
1428   VisitCallExpr(S);
1429 }
1430
1431 void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
1432   VisitExpr(S);
1433 }
1434
1435 void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
1436   VisitExplicitCastExpr(S);
1437 }
1438
1439 void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
1440   VisitCXXNamedCastExpr(S);
1441 }
1442
1443 void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
1444   VisitCXXNamedCastExpr(S);
1445 }
1446
1447 void
1448 StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
1449   VisitCXXNamedCastExpr(S);
1450 }
1451
1452 void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
1453   VisitCXXNamedCastExpr(S);
1454 }
1455
1456 void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1457   VisitCallExpr(S);
1458 }
1459
1460 void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
1461   VisitExpr(S);
1462   ID.AddBoolean(S->getValue());
1463 }
1464
1465 void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
1466   VisitExpr(S);
1467 }
1468
1469 void StmtProfiler::VisitCXXStdInitializerListExpr(
1470     const CXXStdInitializerListExpr *S) {
1471   VisitExpr(S);
1472 }
1473
1474 void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
1475   VisitExpr(S);
1476   if (S->isTypeOperand())
1477     VisitType(S->getTypeOperandSourceInfo()->getType());
1478 }
1479
1480 void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
1481   VisitExpr(S);
1482   if (S->isTypeOperand())
1483     VisitType(S->getTypeOperandSourceInfo()->getType());
1484 }
1485
1486 void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1487   VisitExpr(S);
1488   VisitDecl(S->getPropertyDecl());
1489 }
1490
1491 void StmtProfiler::VisitMSPropertySubscriptExpr(
1492     const MSPropertySubscriptExpr *S) {
1493   VisitExpr(S);
1494 }
1495
1496 void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
1497   VisitExpr(S);
1498   ID.AddBoolean(S->isImplicit());
1499 }
1500
1501 void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
1502   VisitExpr(S);
1503 }
1504
1505 void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
1506   VisitExpr(S);
1507   VisitDecl(S->getParam());
1508 }
1509
1510 void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1511   VisitExpr(S);
1512   VisitDecl(S->getField());
1513 }
1514
1515 void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
1516   VisitExpr(S);
1517   VisitDecl(
1518          const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1519 }
1520
1521 void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
1522   VisitExpr(S);
1523   VisitDecl(S->getConstructor());
1524   ID.AddBoolean(S->isElidable());
1525 }
1526
1527 void StmtProfiler::VisitCXXInheritedCtorInitExpr(
1528     const CXXInheritedCtorInitExpr *S) {
1529   VisitExpr(S);
1530   VisitDecl(S->getConstructor());
1531 }
1532
1533 void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
1534   VisitExplicitCastExpr(S);
1535 }
1536
1537 void
1538 StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
1539   VisitCXXConstructExpr(S);
1540 }
1541
1542 void
1543 StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1544   VisitExpr(S);
1545   for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1546                                  CEnd = S->explicit_capture_end();
1547        C != CEnd; ++C) {
1548     ID.AddInteger(C->getCaptureKind());
1549     switch (C->getCaptureKind()) {
1550     case LCK_StarThis:
1551     case LCK_This:
1552       break;
1553     case LCK_ByRef:
1554     case LCK_ByCopy:
1555       VisitDecl(C->getCapturedVar());
1556       ID.AddBoolean(C->isPackExpansion());
1557       break;
1558     case LCK_VLAType:
1559       llvm_unreachable("VLA type in explicit captures.");
1560     }
1561   }
1562   // Note: If we actually needed to be able to match lambda
1563   // expressions, we would have to consider parameters and return type
1564   // here, among other things.
1565   VisitStmt(S->getBody());
1566 }
1567
1568 void
1569 StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
1570   VisitExpr(S);
1571 }
1572
1573 void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
1574   VisitExpr(S);
1575   ID.AddBoolean(S->isGlobalDelete());
1576   ID.AddBoolean(S->isArrayForm());
1577   VisitDecl(S->getOperatorDelete());
1578 }
1579
1580 void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
1581   VisitExpr(S);
1582   VisitType(S->getAllocatedType());
1583   VisitDecl(S->getOperatorNew());
1584   VisitDecl(S->getOperatorDelete());
1585   ID.AddBoolean(S->isArray());
1586   ID.AddInteger(S->getNumPlacementArgs());
1587   ID.AddBoolean(S->isGlobalNew());
1588   ID.AddBoolean(S->isParenTypeId());
1589   ID.AddInteger(S->getInitializationStyle());
1590 }
1591
1592 void
1593 StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
1594   VisitExpr(S);
1595   ID.AddBoolean(S->isArrow());
1596   VisitNestedNameSpecifier(S->getQualifier());
1597   ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
1598   if (S->getScopeTypeInfo())
1599     VisitType(S->getScopeTypeInfo()->getType());
1600   ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
1601   if (S->getDestroyedTypeInfo())
1602     VisitType(S->getDestroyedType());
1603   else
1604     VisitIdentifierInfo(S->getDestroyedTypeIdentifier());
1605 }
1606
1607 void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
1608   VisitExpr(S);
1609   VisitNestedNameSpecifier(S->getQualifier());
1610   VisitName(S->getName());
1611   ID.AddBoolean(S->hasExplicitTemplateArgs());
1612   if (S->hasExplicitTemplateArgs())
1613     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1614 }
1615
1616 void
1617 StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
1618   VisitOverloadExpr(S);
1619 }
1620
1621 void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1622   VisitExpr(S);
1623   ID.AddInteger(S->getTrait());
1624   ID.AddInteger(S->getNumArgs());
1625   for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1626     VisitType(S->getArg(I)->getType());
1627 }
1628
1629 void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
1630   VisitExpr(S);
1631   ID.AddInteger(S->getTrait());
1632   VisitType(S->getQueriedType());
1633 }
1634
1635 void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
1636   VisitExpr(S);
1637   ID.AddInteger(S->getTrait());
1638   VisitExpr(S->getQueriedExpression());
1639 }
1640
1641 void StmtProfiler::VisitDependentScopeDeclRefExpr(
1642     const DependentScopeDeclRefExpr *S) {
1643   VisitExpr(S);
1644   VisitName(S->getDeclName());
1645   VisitNestedNameSpecifier(S->getQualifier());
1646   ID.AddBoolean(S->hasExplicitTemplateArgs());
1647   if (S->hasExplicitTemplateArgs())
1648     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1649 }
1650
1651 void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
1652   VisitExpr(S);
1653 }
1654
1655 void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1656     const CXXUnresolvedConstructExpr *S) {
1657   VisitExpr(S);
1658   VisitType(S->getTypeAsWritten());
1659 }
1660
1661 void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1662     const CXXDependentScopeMemberExpr *S) {
1663   ID.AddBoolean(S->isImplicitAccess());
1664   if (!S->isImplicitAccess()) {
1665     VisitExpr(S);
1666     ID.AddBoolean(S->isArrow());
1667   }
1668   VisitNestedNameSpecifier(S->getQualifier());
1669   VisitName(S->getMember());
1670   ID.AddBoolean(S->hasExplicitTemplateArgs());
1671   if (S->hasExplicitTemplateArgs())
1672     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1673 }
1674
1675 void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
1676   ID.AddBoolean(S->isImplicitAccess());
1677   if (!S->isImplicitAccess()) {
1678     VisitExpr(S);
1679     ID.AddBoolean(S->isArrow());
1680   }
1681   VisitNestedNameSpecifier(S->getQualifier());
1682   VisitName(S->getMemberName());
1683   ID.AddBoolean(S->hasExplicitTemplateArgs());
1684   if (S->hasExplicitTemplateArgs())
1685     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1686 }
1687
1688 void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
1689   VisitExpr(S);
1690 }
1691
1692 void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
1693   VisitExpr(S);
1694 }
1695
1696 void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
1697   VisitExpr(S);
1698   VisitDecl(S->getPack());
1699   if (S->isPartiallySubstituted()) {
1700     auto Args = S->getPartialArguments();
1701     ID.AddInteger(Args.size());
1702     for (const auto &TA : Args)
1703       VisitTemplateArgument(TA);
1704   } else {
1705     ID.AddInteger(0);
1706   }
1707 }
1708
1709 void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
1710     const SubstNonTypeTemplateParmPackExpr *S) {
1711   VisitExpr(S);
1712   VisitDecl(S->getParameterPack());
1713   VisitTemplateArgument(S->getArgumentPack());
1714 }
1715
1716 void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1717     const SubstNonTypeTemplateParmExpr *E) {
1718   // Profile exactly as the replacement expression.
1719   Visit(E->getReplacement());
1720 }
1721
1722 void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1723   VisitExpr(S);
1724   VisitDecl(S->getParameterPack());
1725   ID.AddInteger(S->getNumExpansions());
1726   for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1727     VisitDecl(*I);
1728 }
1729
1730 void StmtProfiler::VisitMaterializeTemporaryExpr(
1731                                            const MaterializeTemporaryExpr *S) {
1732   VisitExpr(S);
1733 }
1734
1735 void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1736   VisitExpr(S);
1737   ID.AddInteger(S->getOperator());
1738 }
1739
1740 void StmtProfiler::VisitCoroutineBodyStmt(const CoroutineBodyStmt *S) {
1741   VisitStmt(S);
1742 }
1743
1744 void StmtProfiler::VisitCoreturnStmt(const CoreturnStmt *S) {
1745   VisitStmt(S);
1746 }
1747
1748 void StmtProfiler::VisitCoawaitExpr(const CoawaitExpr *S) {
1749   VisitExpr(S);
1750 }
1751
1752 void StmtProfiler::VisitDependentCoawaitExpr(const DependentCoawaitExpr *S) {
1753   VisitExpr(S);
1754 }
1755
1756 void StmtProfiler::VisitCoyieldExpr(const CoyieldExpr *S) {
1757   VisitExpr(S);
1758 }
1759
1760 void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
1761   VisitExpr(E);  
1762 }
1763
1764 void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1765   VisitExpr(E);
1766 }
1767
1768 void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
1769   VisitExpr(S);
1770 }
1771
1772 void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
1773   VisitExpr(E);
1774 }
1775
1776 void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1777   VisitExpr(E);
1778 }
1779
1780 void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1781   VisitExpr(E);
1782 }
1783
1784 void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
1785   VisitExpr(S);
1786   VisitType(S->getEncodedType());
1787 }
1788
1789 void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
1790   VisitExpr(S);
1791   VisitName(S->getSelector());
1792 }
1793
1794 void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
1795   VisitExpr(S);
1796   VisitDecl(S->getProtocol());
1797 }
1798
1799 void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
1800   VisitExpr(S);
1801   VisitDecl(S->getDecl());
1802   ID.AddBoolean(S->isArrow());
1803   ID.AddBoolean(S->isFreeIvar());
1804 }
1805
1806 void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
1807   VisitExpr(S);
1808   if (S->isImplicitProperty()) {
1809     VisitDecl(S->getImplicitPropertyGetter());
1810     VisitDecl(S->getImplicitPropertySetter());
1811   } else {
1812     VisitDecl(S->getExplicitProperty());
1813   }
1814   if (S->isSuperReceiver()) {
1815     ID.AddBoolean(S->isSuperReceiver());
1816     VisitType(S->getSuperReceiverType());
1817   }
1818 }
1819
1820 void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1821   VisitExpr(S);
1822   VisitDecl(S->getAtIndexMethodDecl());
1823   VisitDecl(S->setAtIndexMethodDecl());
1824 }
1825
1826 void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
1827   VisitExpr(S);
1828   VisitName(S->getSelector());
1829   VisitDecl(S->getMethodDecl());
1830 }
1831
1832 void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
1833   VisitExpr(S);
1834   ID.AddBoolean(S->isArrow());
1835 }
1836
1837 void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1838   VisitExpr(S);
1839   ID.AddBoolean(S->getValue());
1840 }
1841
1842 void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1843     const ObjCIndirectCopyRestoreExpr *S) {
1844   VisitExpr(S);
1845   ID.AddBoolean(S->shouldCopy());
1846 }
1847
1848 void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
1849   VisitExplicitCastExpr(S);
1850   ID.AddBoolean(S->getBridgeKind());
1851 }
1852
1853 void StmtProfiler::VisitObjCAvailabilityCheckExpr(
1854     const ObjCAvailabilityCheckExpr *S) {
1855   VisitExpr(S);
1856 }
1857
1858 void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
1859                                           unsigned NumArgs) {
1860   ID.AddInteger(NumArgs);
1861   for (unsigned I = 0; I != NumArgs; ++I)
1862     VisitTemplateArgument(Args[I].getArgument());
1863 }
1864
1865 void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1866   // Mostly repetitive with TemplateArgument::Profile!
1867   ID.AddInteger(Arg.getKind());
1868   switch (Arg.getKind()) {
1869   case TemplateArgument::Null:
1870     break;
1871
1872   case TemplateArgument::Type:
1873     VisitType(Arg.getAsType());
1874     break;
1875
1876   case TemplateArgument::Template:
1877   case TemplateArgument::TemplateExpansion:
1878     VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
1879     break;
1880       
1881   case TemplateArgument::Declaration:
1882     VisitDecl(Arg.getAsDecl());
1883     break;
1884
1885   case TemplateArgument::NullPtr:
1886     VisitType(Arg.getNullPtrType());
1887     break;
1888
1889   case TemplateArgument::Integral:
1890     Arg.getAsIntegral().Profile(ID);
1891     VisitType(Arg.getIntegralType());
1892     break;
1893
1894   case TemplateArgument::Expression:
1895     Visit(Arg.getAsExpr());
1896     break;
1897
1898   case TemplateArgument::Pack:
1899     for (const auto &P : Arg.pack_elements())
1900       VisitTemplateArgument(P);
1901     break;
1902   }
1903 }
1904
1905 void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
1906                    bool Canonical) const {
1907   StmtProfilerWithPointers Profiler(ID, Context, Canonical);
1908   Profiler.Visit(this);
1909 }
1910
1911 void Stmt::ProcessODRHash(llvm::FoldingSetNodeID &ID,
1912                           class ODRHash &Hash) const {
1913   StmtProfilerWithoutPointers Profiler(ID, Hash);
1914   Profiler.Visit(this);
1915 }