blob: 0318330abbd00629111f49252c38d38ee1838063 [file] [log] [blame]
Douglas Gregor5c193b92009-07-28 00:33:38 +00001//===---- 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
Douglas Gregor32615a12009-07-28 16:39:25 +000011// representation that identifies a statement/expression.
Douglas Gregor5c193b92009-07-28 00:33:38 +000012//
13//===----------------------------------------------------------------------===//
14#include "clang/AST/ASTContext.h"
Douglas Gregora7095092009-07-28 14:44:31 +000015#include "clang/AST/DeclCXX.h"
16#include "clang/AST/DeclObjC.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000017#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/StmtVisitor.h"
22#include "llvm/ADT/FoldingSet.h"
Douglas Gregor5c193b92009-07-28 00:33:38 +000023using namespace clang;
24
25namespace {
Chandler Carruth631abd92011-06-16 06:47:06 +000026 class StmtProfiler : public ConstStmtVisitor<StmtProfiler> {
Douglas Gregor5c193b92009-07-28 00:33:38 +000027 llvm::FoldingSetNodeID &ID;
Jay Foad39c79802011-01-12 09:06:06 +000028 const ASTContext &Context;
Douglas Gregor5c193b92009-07-28 00:33:38 +000029 bool Canonical;
Mike Stump11289f42009-09-09 15:08:12 +000030
Douglas Gregor5c193b92009-07-28 00:33:38 +000031 public:
Jay Foad39c79802011-01-12 09:06:06 +000032 StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Mike Stump11289f42009-09-09 15:08:12 +000033 bool Canonical)
Douglas Gregor5c193b92009-07-28 00:33:38 +000034 : ID(ID), Context(Context), Canonical(Canonical) { }
Mike Stump11289f42009-09-09 15:08:12 +000035
Chandler Carruth631abd92011-06-16 06:47:06 +000036 void VisitStmt(const Stmt *S);
Mike Stump11289f42009-09-09 15:08:12 +000037
Chandler Carruth631abd92011-06-16 06:47:06 +000038#define STMT(Node, Base) void Visit##Node(const Node *S);
Alexis Hunt656bb312010-05-05 15:24:00 +000039#include "clang/AST/StmtNodes.inc"
Mike Stump11289f42009-09-09 15:08:12 +000040
Douglas Gregor5c193b92009-07-28 00:33:38 +000041 /// \brief Visit a declaration that is referenced within an expression
42 /// or statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000043 void VisitDecl(const Decl *D);
Mike Stump11289f42009-09-09 15:08:12 +000044
45 /// \brief Visit a type that is referenced within an expression or
Douglas Gregor5c193b92009-07-28 00:33:38 +000046 /// statement.
47 void VisitType(QualType T);
Mike Stump11289f42009-09-09 15:08:12 +000048
Douglas Gregor5c193b92009-07-28 00:33:38 +000049 /// \brief Visit a name that occurs within an expression or statement.
50 void VisitName(DeclarationName Name);
Mike Stump11289f42009-09-09 15:08:12 +000051
Douglas Gregor5c193b92009-07-28 00:33:38 +000052 /// \brief Visit a nested-name-specifier that occurs within an expression
53 /// or statement.
54 void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
Mike Stump11289f42009-09-09 15:08:12 +000055
Douglas Gregor5c193b92009-07-28 00:33:38 +000056 /// \brief Visit a template name that occurs within an expression or
57 /// statement.
58 void VisitTemplateName(TemplateName Name);
Mike Stump11289f42009-09-09 15:08:12 +000059
Douglas Gregor5c193b92009-07-28 00:33:38 +000060 /// \brief Visit template arguments that occur within an expression or
61 /// statement.
Chandler Carruth631abd92011-06-16 06:47:06 +000062 void VisitTemplateArguments(const TemplateArgumentLoc *Args,
63 unsigned NumArgs);
John McCall0ad16662009-10-29 08:12:44 +000064
65 /// \brief Visit a single template argument.
66 void VisitTemplateArgument(const TemplateArgument &Arg);
Douglas Gregor5c193b92009-07-28 00:33:38 +000067 };
Alexander Kornienkoab9db512015-06-22 23:07:51 +000068}
Douglas Gregor5c193b92009-07-28 00:33:38 +000069
Chandler Carruth631abd92011-06-16 06:47:06 +000070void StmtProfiler::VisitStmt(const Stmt *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +000071 ID.AddInteger(S->getStmtClass());
Benjamin Kramer642f1732015-07-02 21:03:14 +000072 for (const Stmt *SubStmt : S->children()) {
73 if (SubStmt)
74 Visit(SubStmt);
Peter Collingbournecdb9f302012-03-01 16:34:31 +000075 else
76 ID.AddInteger(0);
77 }
Douglas Gregor5c193b92009-07-28 00:33:38 +000078}
79
Chandler Carruth631abd92011-06-16 06:47:06 +000080void StmtProfiler::VisitDeclStmt(const DeclStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000081 VisitStmt(S);
Aaron Ballman535bbcc2014-03-14 17:01:24 +000082 for (const auto *D : S->decls())
83 VisitDecl(D);
Douglas Gregor44882592009-07-28 15:27:13 +000084}
85
Chandler Carruth631abd92011-06-16 06:47:06 +000086void StmtProfiler::VisitNullStmt(const NullStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000087 VisitStmt(S);
88}
89
Chandler Carruth631abd92011-06-16 06:47:06 +000090void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000091 VisitStmt(S);
92}
93
Chandler Carruth631abd92011-06-16 06:47:06 +000094void StmtProfiler::VisitSwitchCase(const SwitchCase *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000095 VisitStmt(S);
96}
97
Chandler Carruth631abd92011-06-16 06:47:06 +000098void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +000099 VisitStmt(S);
100}
101
Chandler Carruth631abd92011-06-16 06:47:06 +0000102void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000103 VisitStmt(S);
104}
105
Chandler Carruth631abd92011-06-16 06:47:06 +0000106void StmtProfiler::VisitLabelStmt(const LabelStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000107 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000108 VisitDecl(S->getDecl());
Douglas Gregor44882592009-07-28 15:27:13 +0000109}
110
Richard Smithc202b282012-04-14 00:33:13 +0000111void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) {
112 VisitStmt(S);
113 // TODO: maybe visit attributes?
114}
115
Chandler Carruth631abd92011-06-16 06:47:06 +0000116void StmtProfiler::VisitIfStmt(const IfStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000117 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000118 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000119}
120
Chandler Carruth631abd92011-06-16 06:47:06 +0000121void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000122 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000123 VisitDecl(S->getConditionVariable());
Douglas Gregor00044172009-07-29 16:09:57 +0000124}
125
Chandler Carruth631abd92011-06-16 06:47:06 +0000126void StmtProfiler::VisitWhileStmt(const WhileStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000127 VisitStmt(S);
Douglas Gregor7bab5ff2009-11-25 00:27:52 +0000128 VisitDecl(S->getConditionVariable());
Douglas Gregor44882592009-07-28 15:27:13 +0000129}
130
Chandler Carruth631abd92011-06-16 06:47:06 +0000131void StmtProfiler::VisitDoStmt(const DoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000132 VisitStmt(S);
133}
134
Chandler Carruth631abd92011-06-16 06:47:06 +0000135void StmtProfiler::VisitForStmt(const ForStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000136 VisitStmt(S);
137}
138
Chandler Carruth631abd92011-06-16 06:47:06 +0000139void StmtProfiler::VisitGotoStmt(const GotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000140 VisitStmt(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000141 VisitDecl(S->getLabel());
Douglas Gregor44882592009-07-28 15:27:13 +0000142}
143
Chandler Carruth631abd92011-06-16 06:47:06 +0000144void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000145 VisitStmt(S);
146}
147
Chandler Carruth631abd92011-06-16 06:47:06 +0000148void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000149 VisitStmt(S);
150}
151
Chandler Carruth631abd92011-06-16 06:47:06 +0000152void StmtProfiler::VisitBreakStmt(const BreakStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000153 VisitStmt(S);
154}
155
Chandler Carruth631abd92011-06-16 06:47:06 +0000156void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000157 VisitStmt(S);
158}
159
Chad Rosierde70e0e2012-08-25 00:11:56 +0000160void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000161 VisitStmt(S);
162 ID.AddBoolean(S->isVolatile());
163 ID.AddBoolean(S->isSimple());
164 VisitStringLiteral(S->getAsmString());
165 ID.AddInteger(S->getNumOutputs());
166 for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
167 ID.AddString(S->getOutputName(I));
168 VisitStringLiteral(S->getOutputConstraintLiteral(I));
169 }
170 ID.AddInteger(S->getNumInputs());
171 for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
172 ID.AddString(S->getInputName(I));
173 VisitStringLiteral(S->getInputConstraintLiteral(I));
174 }
175 ID.AddInteger(S->getNumClobbers());
176 for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
Chad Rosierd9fb09a2012-08-27 23:28:41 +0000177 VisitStringLiteral(S->getClobberStringLiteral(I));
Douglas Gregor44882592009-07-28 15:27:13 +0000178}
179
Chad Rosier32503022012-06-11 20:47:18 +0000180void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) {
181 // FIXME: Implement MS style inline asm statement profiler.
182 VisitStmt(S);
183}
184
Chandler Carruth631abd92011-06-16 06:47:06 +0000185void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000186 VisitStmt(S);
187 VisitType(S->getCaughtType());
188}
189
Chandler Carruth631abd92011-06-16 06:47:06 +0000190void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000191 VisitStmt(S);
192}
193
Chandler Carruth631abd92011-06-16 06:47:06 +0000194void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) {
Richard Smith02e85f32011-04-14 22:09:26 +0000195 VisitStmt(S);
196}
197
Douglas Gregordeb4a2be2011-10-25 01:33:02 +0000198void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) {
199 VisitStmt(S);
200 ID.AddBoolean(S->isIfExists());
201 VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier());
202 VisitName(S->getNameInfo().getName());
203}
204
Chandler Carruth631abd92011-06-16 06:47:06 +0000205void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000206 VisitStmt(S);
207}
208
Chandler Carruth631abd92011-06-16 06:47:06 +0000209void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000210 VisitStmt(S);
211}
212
Chandler Carruth631abd92011-06-16 06:47:06 +0000213void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) {
John Wiegley1c0675e2011-04-28 01:08:34 +0000214 VisitStmt(S);
215}
216
Nico Weber9b982072014-07-07 00:12:30 +0000217void StmtProfiler::VisitSEHLeaveStmt(const SEHLeaveStmt *S) {
218 VisitStmt(S);
219}
220
Tareq A. Siraj24110cc2013-04-16 18:53:08 +0000221void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) {
222 VisitStmt(S);
223}
224
Chandler Carruth631abd92011-06-16 06:47:06 +0000225void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000226 VisitStmt(S);
227}
228
Chandler Carruth631abd92011-06-16 06:47:06 +0000229void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000230 VisitStmt(S);
231 ID.AddBoolean(S->hasEllipsis());
232 if (S->getCatchParamDecl())
233 VisitType(S->getCatchParamDecl()->getType());
234}
235
Chandler Carruth631abd92011-06-16 06:47:06 +0000236void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000237 VisitStmt(S);
238}
239
Chandler Carruth631abd92011-06-16 06:47:06 +0000240void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000241 VisitStmt(S);
242}
243
Chandler Carruth631abd92011-06-16 06:47:06 +0000244void
245StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000246 VisitStmt(S);
247}
248
Chandler Carruth631abd92011-06-16 06:47:06 +0000249void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) {
Douglas Gregor44882592009-07-28 15:27:13 +0000250 VisitStmt(S);
251}
252
Chandler Carruth631abd92011-06-16 06:47:06 +0000253void
254StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) {
John McCall31168b02011-06-15 23:02:42 +0000255 VisitStmt(S);
256}
257
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000258namespace {
259class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> {
260 StmtProfiler *Profiler;
Alexey Bataev756c1962013-09-24 03:17:45 +0000261 /// \brief Process clauses with list of variables.
262 template <typename T>
263 void VisitOMPClauseList(T *Node);
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000264public:
265 OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { }
266#define OPENMP_CLAUSE(Name, Class) \
267 void Visit##Class(const Class *C);
268#include "clang/Basic/OpenMPKinds.def"
269};
270
Alexey Bataevaadd52e2014-02-13 05:29:23 +0000271void OMPClauseProfiler::VisitOMPIfClause(const OMPIfClause *C) {
272 if (C->getCondition())
273 Profiler->VisitStmt(C->getCondition());
274}
275
Alexey Bataev3778b602014-07-17 07:32:53 +0000276void OMPClauseProfiler::VisitOMPFinalClause(const OMPFinalClause *C) {
277 if (C->getCondition())
278 Profiler->VisitStmt(C->getCondition());
279}
280
Alexey Bataev568a8332014-03-06 06:15:19 +0000281void OMPClauseProfiler::VisitOMPNumThreadsClause(const OMPNumThreadsClause *C) {
282 if (C->getNumThreads())
283 Profiler->VisitStmt(C->getNumThreads());
284}
285
Alexey Bataev62c87d22014-03-21 04:51:18 +0000286void OMPClauseProfiler::VisitOMPSafelenClause(const OMPSafelenClause *C) {
287 if (C->getSafelen())
288 Profiler->VisitStmt(C->getSafelen());
289}
290
Alexander Musman8bd31e62014-05-27 15:12:19 +0000291void OMPClauseProfiler::VisitOMPCollapseClause(const OMPCollapseClause *C) {
292 if (C->getNumForLoops())
293 Profiler->VisitStmt(C->getNumForLoops());
294}
295
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000296void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { }
Alexey Bataev756c1962013-09-24 03:17:45 +0000297
Alexey Bataevbcbadb62014-05-06 06:04:14 +0000298void OMPClauseProfiler::VisitOMPProcBindClause(const OMPProcBindClause *C) { }
299
Alexey Bataev56dafe82014-06-20 07:16:17 +0000300void OMPClauseProfiler::VisitOMPScheduleClause(const OMPScheduleClause *C) {
Alexey Bataev040d5402015-05-12 08:35:28 +0000301 if (C->getChunkSize()) {
Alexey Bataev56dafe82014-06-20 07:16:17 +0000302 Profiler->VisitStmt(C->getChunkSize());
Alexey Bataev040d5402015-05-12 08:35:28 +0000303 if (C->getHelperChunkSize()) {
304 Profiler->VisitStmt(C->getChunkSize());
305 }
306 }
Alexey Bataev56dafe82014-06-20 07:16:17 +0000307}
308
Alexey Bataev10e775f2015-07-30 11:36:16 +0000309void OMPClauseProfiler::VisitOMPOrderedClause(const OMPOrderedClause *C) {
310 if (auto *Num = C->getNumForLoops())
311 Profiler->VisitStmt(Num);
312}
Alexey Bataev142e1fc2014-06-20 09:44:06 +0000313
Alexey Bataev236070f2014-06-20 11:19:47 +0000314void OMPClauseProfiler::VisitOMPNowaitClause(const OMPNowaitClause *) {}
315
Alexey Bataev7aea99a2014-07-17 12:19:31 +0000316void OMPClauseProfiler::VisitOMPUntiedClause(const OMPUntiedClause *) {}
317
Alexey Bataev74ba3a52014-07-17 12:47:03 +0000318void OMPClauseProfiler::VisitOMPMergeableClause(const OMPMergeableClause *) {}
319
Alexey Bataevf98b00c2014-07-23 02:27:21 +0000320void OMPClauseProfiler::VisitOMPReadClause(const OMPReadClause *) {}
321
Alexey Bataevdea47612014-07-23 07:46:59 +0000322void OMPClauseProfiler::VisitOMPWriteClause(const OMPWriteClause *) {}
323
Alexey Bataev67a4f222014-07-23 10:25:33 +0000324void OMPClauseProfiler::VisitOMPUpdateClause(const OMPUpdateClause *) {}
325
Alexey Bataev459dec02014-07-24 06:46:57 +0000326void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}
327
Alexey Bataev82bad8b2014-07-24 08:55:34 +0000328void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
329
Alexey Bataev756c1962013-09-24 03:17:45 +0000330template<typename T>
331void OMPClauseProfiler::VisitOMPClauseList(T *Node) {
Alexey Bataev03b340a2014-10-21 03:16:40 +0000332 for (auto *E : Node->varlists()) {
333 Profiler->VisitStmt(E);
334 }
Alexey Bataev756c1962013-09-24 03:17:45 +0000335}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000336
337void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000338 VisitOMPClauseList(C);
Alexey Bataev03b340a2014-10-21 03:16:40 +0000339 for (auto *E : C->private_copies()) {
340 Profiler->VisitStmt(E);
341 }
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000342}
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000343void
344OMPClauseProfiler::VisitOMPFirstprivateClause(const OMPFirstprivateClause *C) {
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000345 VisitOMPClauseList(C);
Alexey Bataev4a5bb772014-10-08 14:01:46 +0000346 for (auto *E : C->private_copies()) {
347 Profiler->VisitStmt(E);
348 }
349 for (auto *E : C->inits()) {
350 Profiler->VisitStmt(E);
351 }
Alexey Bataevd5af8e42013-10-01 05:32:34 +0000352}
Alexander Musman1bb328c2014-06-04 13:06:39 +0000353void
354OMPClauseProfiler::VisitOMPLastprivateClause(const OMPLastprivateClause *C) {
355 VisitOMPClauseList(C);
Alexey Bataev38e89532015-04-16 04:54:05 +0000356 for (auto *E : C->source_exprs()) {
357 Profiler->VisitStmt(E);
358 }
359 for (auto *E : C->destination_exprs()) {
360 Profiler->VisitStmt(E);
361 }
362 for (auto *E : C->assignment_ops()) {
363 Profiler->VisitStmt(E);
364 }
Alexander Musman1bb328c2014-06-04 13:06:39 +0000365}
Alexey Bataev758e55e2013-09-06 18:03:48 +0000366void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) {
Alexey Bataev756c1962013-09-24 03:17:45 +0000367 VisitOMPClauseList(C);
Alexey Bataev758e55e2013-09-06 18:03:48 +0000368}
Alexey Bataevc5e02582014-06-16 07:08:35 +0000369void OMPClauseProfiler::VisitOMPReductionClause(
370 const OMPReductionClause *C) {
371 Profiler->VisitNestedNameSpecifier(
372 C->getQualifierLoc().getNestedNameSpecifier());
373 Profiler->VisitName(C->getNameInfo().getName());
374 VisitOMPClauseList(C);
Alexey Bataev794ba0d2015-04-10 10:43:45 +0000375 for (auto *E : C->lhs_exprs()) {
376 Profiler->VisitStmt(E);
377 }
378 for (auto *E : C->rhs_exprs()) {
379 Profiler->VisitStmt(E);
380 }
381 for (auto *E : C->reduction_ops()) {
382 Profiler->VisitStmt(E);
383 }
Alexey Bataevc5e02582014-06-16 07:08:35 +0000384}
Alexander Musman8dba6642014-04-22 13:09:42 +0000385void OMPClauseProfiler::VisitOMPLinearClause(const OMPLinearClause *C) {
386 VisitOMPClauseList(C);
Alexey Bataevbd9fec12015-08-18 06:47:21 +0000387 for (auto *E : C->privates()) {
388 Profiler->VisitStmt(E);
389 }
Alexander Musman3276a272015-03-21 10:12:56 +0000390 for (auto *E : C->inits()) {
391 Profiler->VisitStmt(E);
392 }
393 for (auto *E : C->updates()) {
394 Profiler->VisitStmt(E);
395 }
396 for (auto *E : C->finals()) {
397 Profiler->VisitStmt(E);
398 }
Alexander Musman8dba6642014-04-22 13:09:42 +0000399 Profiler->VisitStmt(C->getStep());
Alexander Musman3276a272015-03-21 10:12:56 +0000400 Profiler->VisitStmt(C->getCalcStep());
Alexander Musman8dba6642014-04-22 13:09:42 +0000401}
Alexander Musmanf0d76e72014-05-29 14:36:25 +0000402void OMPClauseProfiler::VisitOMPAlignedClause(const OMPAlignedClause *C) {
403 VisitOMPClauseList(C);
404 Profiler->VisitStmt(C->getAlignment());
405}
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000406void OMPClauseProfiler::VisitOMPCopyinClause(const OMPCopyinClause *C) {
407 VisitOMPClauseList(C);
Alexey Bataevf56f98c2015-04-16 05:39:01 +0000408 for (auto *E : C->source_exprs()) {
409 Profiler->VisitStmt(E);
410 }
411 for (auto *E : C->destination_exprs()) {
412 Profiler->VisitStmt(E);
413 }
414 for (auto *E : C->assignment_ops()) {
415 Profiler->VisitStmt(E);
416 }
Alexey Bataevd48bcd82014-03-31 03:36:38 +0000417}
Alexey Bataevbae9a792014-06-27 10:37:06 +0000418void
419OMPClauseProfiler::VisitOMPCopyprivateClause(const OMPCopyprivateClause *C) {
420 VisitOMPClauseList(C);
Alexey Bataeva63048e2015-03-23 06:18:07 +0000421 for (auto *E : C->source_exprs()) {
422 Profiler->VisitStmt(E);
423 }
424 for (auto *E : C->destination_exprs()) {
425 Profiler->VisitStmt(E);
426 }
427 for (auto *E : C->assignment_ops()) {
428 Profiler->VisitStmt(E);
429 }
Alexey Bataevbae9a792014-06-27 10:37:06 +0000430}
Alexey Bataev6125da92014-07-21 11:26:11 +0000431void OMPClauseProfiler::VisitOMPFlushClause(const OMPFlushClause *C) {
432 VisitOMPClauseList(C);
433}
Alexey Bataev1c2cfbc2015-06-23 14:25:19 +0000434void OMPClauseProfiler::VisitOMPDependClause(const OMPDependClause *C) {
435 VisitOMPClauseList(C);
436}
Michael Wonge710d542015-08-07 16:16:36 +0000437void OMPClauseProfiler::VisitOMPDeviceClause(const OMPDeviceClause *C) {
438 Profiler->VisitStmt(C->getDevice());
439}
Alexander Kornienkoab9db512015-06-22 23:07:51 +0000440}
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000441
442void
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000443StmtProfiler::VisitOMPExecutableDirective(const OMPExecutableDirective *S) {
Alexey Bataev5ec3eb12013-07-19 03:13:43 +0000444 VisitStmt(S);
445 OMPClauseProfiler P(this);
446 ArrayRef<OMPClause *> Clauses = S->clauses();
447 for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
448 I != E; ++I)
449 if (*I)
450 P.Visit(*I);
451}
452
Alexander Musman3aaab662014-08-19 11:27:13 +0000453void StmtProfiler::VisitOMPLoopDirective(const OMPLoopDirective *S) {
454 VisitOMPExecutableDirective(S);
455}
456
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000457void StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) {
458 VisitOMPExecutableDirective(S);
459}
460
461void StmtProfiler::VisitOMPSimdDirective(const OMPSimdDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000462 VisitOMPLoopDirective(S);
Alexey Bataev1b59ab52014-02-27 08:29:12 +0000463}
464
Alexey Bataevf29276e2014-06-18 04:14:57 +0000465void StmtProfiler::VisitOMPForDirective(const OMPForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000466 VisitOMPLoopDirective(S);
Alexey Bataevf29276e2014-06-18 04:14:57 +0000467}
468
Alexander Musmanf82886e2014-09-18 05:12:34 +0000469void StmtProfiler::VisitOMPForSimdDirective(const OMPForSimdDirective *S) {
470 VisitOMPLoopDirective(S);
471}
472
Alexey Bataevd3f8dd22014-06-25 11:44:49 +0000473void StmtProfiler::VisitOMPSectionsDirective(const OMPSectionsDirective *S) {
474 VisitOMPExecutableDirective(S);
475}
476
Alexey Bataev1e0498a2014-06-26 08:21:58 +0000477void StmtProfiler::VisitOMPSectionDirective(const OMPSectionDirective *S) {
478 VisitOMPExecutableDirective(S);
479}
480
Alexey Bataevd1e40fb2014-06-26 12:05:45 +0000481void StmtProfiler::VisitOMPSingleDirective(const OMPSingleDirective *S) {
482 VisitOMPExecutableDirective(S);
483}
484
Alexander Musman80c22892014-07-17 08:54:58 +0000485void StmtProfiler::VisitOMPMasterDirective(const OMPMasterDirective *S) {
486 VisitOMPExecutableDirective(S);
487}
488
Alexander Musmand9ed09f2014-07-21 09:42:05 +0000489void StmtProfiler::VisitOMPCriticalDirective(const OMPCriticalDirective *S) {
490 VisitOMPExecutableDirective(S);
491 VisitName(S->getDirectiveName().getName());
492}
493
Alexey Bataev4acb8592014-07-07 13:01:15 +0000494void
495StmtProfiler::VisitOMPParallelForDirective(const OMPParallelForDirective *S) {
Alexander Musman3aaab662014-08-19 11:27:13 +0000496 VisitOMPLoopDirective(S);
Alexey Bataev4acb8592014-07-07 13:01:15 +0000497}
498
Alexander Musmane4e893b2014-09-23 09:33:00 +0000499void StmtProfiler::VisitOMPParallelForSimdDirective(
500 const OMPParallelForSimdDirective *S) {
501 VisitOMPLoopDirective(S);
502}
503
Alexey Bataev84d0b3e2014-07-08 08:12:03 +0000504void StmtProfiler::VisitOMPParallelSectionsDirective(
505 const OMPParallelSectionsDirective *S) {
506 VisitOMPExecutableDirective(S);
507}
508
Alexey Bataev9c2e8ee2014-07-11 11:25:16 +0000509void StmtProfiler::VisitOMPTaskDirective(const OMPTaskDirective *S) {
510 VisitOMPExecutableDirective(S);
511}
512
Alexey Bataev68446b72014-07-18 07:47:19 +0000513void StmtProfiler::VisitOMPTaskyieldDirective(const OMPTaskyieldDirective *S) {
514 VisitOMPExecutableDirective(S);
515}
516
Alexey Bataev4d1dfea2014-07-18 09:11:51 +0000517void StmtProfiler::VisitOMPBarrierDirective(const OMPBarrierDirective *S) {
518 VisitOMPExecutableDirective(S);
519}
520
Alexey Bataev2df347a2014-07-18 10:17:07 +0000521void StmtProfiler::VisitOMPTaskwaitDirective(const OMPTaskwaitDirective *S) {
522 VisitOMPExecutableDirective(S);
523}
524
Alexey Bataevc30dd2d2015-06-18 12:14:09 +0000525void StmtProfiler::VisitOMPTaskgroupDirective(const OMPTaskgroupDirective *S) {
526 VisitOMPExecutableDirective(S);
527}
528
Alexey Bataev6125da92014-07-21 11:26:11 +0000529void StmtProfiler::VisitOMPFlushDirective(const OMPFlushDirective *S) {
530 VisitOMPExecutableDirective(S);
531}
532
Alexey Bataev9fb6e642014-07-22 06:45:04 +0000533void StmtProfiler::VisitOMPOrderedDirective(const OMPOrderedDirective *S) {
534 VisitOMPExecutableDirective(S);
535}
536
Alexey Bataev0162e452014-07-22 10:10:35 +0000537void StmtProfiler::VisitOMPAtomicDirective(const OMPAtomicDirective *S) {
538 VisitOMPExecutableDirective(S);
539}
540
Alexey Bataev0bd520b2014-09-19 08:19:49 +0000541void StmtProfiler::VisitOMPTargetDirective(const OMPTargetDirective *S) {
542 VisitOMPExecutableDirective(S);
543}
544
Michael Wong65f367f2015-07-21 13:44:28 +0000545void StmtProfiler::VisitOMPTargetDataDirective(const OMPTargetDataDirective *S) {
546 VisitOMPExecutableDirective(S);
547}
548
Alexey Bataev13314bf2014-10-09 04:18:56 +0000549void StmtProfiler::VisitOMPTeamsDirective(const OMPTeamsDirective *S) {
550 VisitOMPExecutableDirective(S);
551}
552
Alexey Bataev6d4ed052015-07-01 06:57:41 +0000553void StmtProfiler::VisitOMPCancellationPointDirective(
554 const OMPCancellationPointDirective *S) {
555 VisitOMPExecutableDirective(S);
556}
557
Alexey Bataev80909872015-07-02 11:25:17 +0000558void StmtProfiler::VisitOMPCancelDirective(const OMPCancelDirective *S) {
559 VisitOMPExecutableDirective(S);
560}
561
Chandler Carruth631abd92011-06-16 06:47:06 +0000562void StmtProfiler::VisitExpr(const Expr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000563 VisitStmt(S);
564}
565
Chandler Carruth631abd92011-06-16 06:47:06 +0000566void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000567 VisitExpr(S);
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000568 if (!Canonical)
569 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000570 VisitDecl(S->getDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000571 if (!Canonical)
572 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000573}
574
Chandler Carruth631abd92011-06-16 06:47:06 +0000575void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000576 VisitExpr(S);
577 ID.AddInteger(S->getIdentType());
578}
579
Chandler Carruth631abd92011-06-16 06:47:06 +0000580void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000581 VisitExpr(S);
582 S->getValue().Profile(ID);
Richard Smithe9f130c2014-11-20 03:37:32 +0000583 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000584}
585
Chandler Carruth631abd92011-06-16 06:47:06 +0000586void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000587 VisitExpr(S);
Douglas Gregorfb65e592011-07-27 05:40:30 +0000588 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000589 ID.AddInteger(S->getValue());
590}
591
Chandler Carruth631abd92011-06-16 06:47:06 +0000592void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000593 VisitExpr(S);
594 S->getValue().Profile(ID);
595 ID.AddBoolean(S->isExact());
Richard Smithe9f130c2014-11-20 03:37:32 +0000596 ID.AddInteger(S->getType()->castAs<BuiltinType>()->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000597}
598
Chandler Carruth631abd92011-06-16 06:47:06 +0000599void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000600 VisitExpr(S);
601}
602
Chandler Carruth631abd92011-06-16 06:47:06 +0000603void StmtProfiler::VisitStringLiteral(const StringLiteral *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000604 VisitExpr(S);
Douglas Gregor9d0eb8f2011-11-02 17:26:05 +0000605 ID.AddString(S->getBytes());
Douglas Gregorfb65e592011-07-27 05:40:30 +0000606 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000607}
608
Chandler Carruth631abd92011-06-16 06:47:06 +0000609void StmtProfiler::VisitParenExpr(const ParenExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000610 VisitExpr(S);
611}
612
Chandler Carruth631abd92011-06-16 06:47:06 +0000613void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) {
Nate Begeman5ec4b312009-08-10 23:49:36 +0000614 VisitExpr(S);
615}
616
Chandler Carruth631abd92011-06-16 06:47:06 +0000617void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000618 VisitExpr(S);
619 ID.AddInteger(S->getOpcode());
620}
621
Chandler Carruth631abd92011-06-16 06:47:06 +0000622void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) {
Douglas Gregor882211c2010-04-28 22:16:22 +0000623 VisitType(S->getTypeSourceInfo()->getType());
624 unsigned n = S->getNumComponents();
625 for (unsigned i = 0; i < n; ++i) {
626 const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i);
627 ID.AddInteger(ON.getKind());
628 switch (ON.getKind()) {
629 case OffsetOfExpr::OffsetOfNode::Array:
630 // Expressions handled below.
631 break;
632
633 case OffsetOfExpr::OffsetOfNode::Field:
634 VisitDecl(ON.getField());
635 break;
636
637 case OffsetOfExpr::OffsetOfNode::Identifier:
638 ID.AddPointer(ON.getFieldName());
639 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +0000640
Douglas Gregord1702062010-04-29 00:18:15 +0000641 case OffsetOfExpr::OffsetOfNode::Base:
642 // These nodes are implicit, and therefore don't need profiling.
643 break;
Douglas Gregor882211c2010-04-28 22:16:22 +0000644 }
645 }
Alexis Hunta8136cc2010-05-05 15:23:54 +0000646
Douglas Gregor882211c2010-04-28 22:16:22 +0000647 VisitExpr(S);
648}
649
Chandler Carruth631abd92011-06-16 06:47:06 +0000650void
651StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000652 VisitExpr(S);
Peter Collingbournee190dee2011-03-11 19:24:49 +0000653 ID.AddInteger(S->getKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000654 if (S->isArgumentType())
655 VisitType(S->getArgumentType());
656}
657
Chandler Carruth631abd92011-06-16 06:47:06 +0000658void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000659 VisitExpr(S);
660}
661
Chandler Carruth631abd92011-06-16 06:47:06 +0000662void StmtProfiler::VisitCallExpr(const CallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000663 VisitExpr(S);
664}
665
Chandler Carruth631abd92011-06-16 06:47:06 +0000666void StmtProfiler::VisitMemberExpr(const MemberExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000667 VisitExpr(S);
668 VisitDecl(S->getMemberDecl());
Douglas Gregorf5b160f2010-07-13 08:37:11 +0000669 if (!Canonical)
670 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000671 ID.AddBoolean(S->isArrow());
672}
673
Chandler Carruth631abd92011-06-16 06:47:06 +0000674void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000675 VisitExpr(S);
676 ID.AddBoolean(S->isFileScope());
677}
678
Chandler Carruth631abd92011-06-16 06:47:06 +0000679void StmtProfiler::VisitCastExpr(const CastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000680 VisitExpr(S);
681}
682
Chandler Carruth631abd92011-06-16 06:47:06 +0000683void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000684 VisitCastExpr(S);
John McCall2536c6d2010-08-25 10:28:54 +0000685 ID.AddInteger(S->getValueKind());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000686}
687
Chandler Carruth631abd92011-06-16 06:47:06 +0000688void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000689 VisitCastExpr(S);
690 VisitType(S->getTypeAsWritten());
691}
692
Chandler Carruth631abd92011-06-16 06:47:06 +0000693void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000694 VisitExplicitCastExpr(S);
695}
696
Chandler Carruth631abd92011-06-16 06:47:06 +0000697void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000698 VisitExpr(S);
699 ID.AddInteger(S->getOpcode());
700}
701
Chandler Carruth631abd92011-06-16 06:47:06 +0000702void
703StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000704 VisitBinaryOperator(S);
705}
706
Chandler Carruth631abd92011-06-16 06:47:06 +0000707void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000708 VisitExpr(S);
709}
710
Chandler Carruth631abd92011-06-16 06:47:06 +0000711void StmtProfiler::VisitBinaryConditionalOperator(
Chandler Carruthcf5f43c2011-06-21 23:26:32 +0000712 const BinaryConditionalOperator *S) {
John McCallc07a0c72011-02-17 10:25:35 +0000713 VisitExpr(S);
714}
715
Chandler Carruth631abd92011-06-16 06:47:06 +0000716void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000717 VisitExpr(S);
Chris Lattnerc8e630e2011-02-17 07:39:24 +0000718 VisitDecl(S->getLabel());
Douglas Gregor5c193b92009-07-28 00:33:38 +0000719}
720
Chandler Carruth631abd92011-06-16 06:47:06 +0000721void StmtProfiler::VisitStmtExpr(const StmtExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000722 VisitExpr(S);
723}
724
Chandler Carruth631abd92011-06-16 06:47:06 +0000725void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000726 VisitExpr(S);
727}
728
Hal Finkelc4d7c822013-09-18 03:29:45 +0000729void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) {
730 VisitExpr(S);
731}
732
Chandler Carruth631abd92011-06-16 06:47:06 +0000733void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000734 VisitExpr(S);
735}
736
Chandler Carruth631abd92011-06-16 06:47:06 +0000737void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000738 VisitExpr(S);
739}
740
Chandler Carruth631abd92011-06-16 06:47:06 +0000741void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +0000742 VisitExpr(S);
743}
744
Chandler Carruth631abd92011-06-16 06:47:06 +0000745void StmtProfiler::VisitInitListExpr(const InitListExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000746 if (S->getSyntacticForm()) {
747 VisitInitListExpr(S->getSyntacticForm());
748 return;
749 }
Mike Stump11289f42009-09-09 15:08:12 +0000750
Douglas Gregor5c193b92009-07-28 00:33:38 +0000751 VisitExpr(S);
752}
753
Chandler Carruth631abd92011-06-16 06:47:06 +0000754void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000755 VisitExpr(S);
756 ID.AddBoolean(S->usesGNUSyntax());
Chandler Carruth631abd92011-06-16 06:47:06 +0000757 for (DesignatedInitExpr::const_designators_iterator D =
758 S->designators_begin(), DEnd = S->designators_end();
Douglas Gregor5c193b92009-07-28 00:33:38 +0000759 D != DEnd; ++D) {
760 if (D->isFieldDesignator()) {
761 ID.AddInteger(0);
762 VisitName(D->getFieldName());
763 continue;
764 }
Mike Stump11289f42009-09-09 15:08:12 +0000765
Douglas Gregor5c193b92009-07-28 00:33:38 +0000766 if (D->isArrayDesignator()) {
767 ID.AddInteger(1);
768 } else {
769 assert(D->isArrayRangeDesignator());
770 ID.AddInteger(2);
771 }
772 ID.AddInteger(D->getFirstExprIndex());
773 }
774}
775
Yunzhong Gaocb779302015-06-10 00:27:52 +0000776// Seems that if VisitInitListExpr() only works on the syntactic form of an
777// InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
778void StmtProfiler::VisitDesignatedInitUpdateExpr(
779 const DesignatedInitUpdateExpr *S) {
780 llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
781 "initializer");
782}
783
784void StmtProfiler::VisitNoInitExpr(const NoInitExpr *S) {
785 llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
786}
787
Chandler Carruth631abd92011-06-16 06:47:06 +0000788void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000789 VisitExpr(S);
790}
791
Chandler Carruth631abd92011-06-16 06:47:06 +0000792void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000793 VisitExpr(S);
794 VisitName(&S->getAccessor());
795}
796
Chandler Carruth631abd92011-06-16 06:47:06 +0000797void StmtProfiler::VisitBlockExpr(const BlockExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +0000798 VisitExpr(S);
799 VisitDecl(S->getBlockDecl());
800}
801
Chandler Carruth631abd92011-06-16 06:47:06 +0000802void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) {
Peter Collingbourne91147592011-04-15 00:35:48 +0000803 VisitExpr(S);
804 for (unsigned i = 0; i != S->getNumAssocs(); ++i) {
805 QualType T = S->getAssocType(i);
806 if (T.isNull())
Craig Topper36250ad2014-05-12 05:36:57 +0000807 ID.AddPointer(nullptr);
Peter Collingbourne91147592011-04-15 00:35:48 +0000808 else
809 VisitType(T);
810 VisitExpr(S->getAssocExpr(i));
811 }
812}
813
John McCallfe96e0b2011-11-06 09:01:30 +0000814void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) {
815 VisitExpr(S);
816 for (PseudoObjectExpr::const_semantics_iterator
817 i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i)
818 // Normally, we would not profile the source expressions of OVEs.
819 if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i))
820 Visit(OVE->getSourceExpr());
821}
822
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000823void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) {
824 VisitExpr(S);
Eli Friedman4b72fdd2011-10-14 20:59:01 +0000825 ID.AddInteger(S->getOp());
Eli Friedmandf14b3a2011-10-11 02:20:01 +0000826}
827
Chandler Carruth631abd92011-06-16 06:47:06 +0000828static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S,
John McCalle3027922010-08-25 11:45:40 +0000829 UnaryOperatorKind &UnaryOp,
830 BinaryOperatorKind &BinaryOp) {
Douglas Gregore9ceb312010-05-19 04:13:23 +0000831 switch (S->getOperator()) {
832 case OO_None:
833 case OO_New:
834 case OO_Delete:
835 case OO_Array_New:
836 case OO_Array_Delete:
837 case OO_Arrow:
838 case OO_Call:
839 case OO_Conditional:
840 case NUM_OVERLOADED_OPERATORS:
841 llvm_unreachable("Invalid operator call kind");
Douglas Gregore9ceb312010-05-19 04:13:23 +0000842
843 case OO_Plus:
844 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000845 UnaryOp = UO_Plus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000846 return Stmt::UnaryOperatorClass;
847 }
848
John McCalle3027922010-08-25 11:45:40 +0000849 BinaryOp = BO_Add;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000850 return Stmt::BinaryOperatorClass;
851
852 case OO_Minus:
853 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000854 UnaryOp = UO_Minus;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000855 return Stmt::UnaryOperatorClass;
856 }
857
John McCalle3027922010-08-25 11:45:40 +0000858 BinaryOp = BO_Sub;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000859 return Stmt::BinaryOperatorClass;
860
861 case OO_Star:
862 if (S->getNumArgs() == 1) {
Richard Smithf15acc52014-06-05 22:43:40 +0000863 UnaryOp = UO_Deref;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000864 return Stmt::UnaryOperatorClass;
865 }
866
Richard Smithf15acc52014-06-05 22:43:40 +0000867 BinaryOp = BO_Mul;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000868 return Stmt::BinaryOperatorClass;
869
870 case OO_Slash:
John McCalle3027922010-08-25 11:45:40 +0000871 BinaryOp = BO_Div;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000872 return Stmt::BinaryOperatorClass;
873
874 case OO_Percent:
John McCalle3027922010-08-25 11:45:40 +0000875 BinaryOp = BO_Rem;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000876 return Stmt::BinaryOperatorClass;
877
878 case OO_Caret:
John McCalle3027922010-08-25 11:45:40 +0000879 BinaryOp = BO_Xor;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000880 return Stmt::BinaryOperatorClass;
881
882 case OO_Amp:
883 if (S->getNumArgs() == 1) {
John McCalle3027922010-08-25 11:45:40 +0000884 UnaryOp = UO_AddrOf;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000885 return Stmt::UnaryOperatorClass;
886 }
887
John McCalle3027922010-08-25 11:45:40 +0000888 BinaryOp = BO_And;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000889 return Stmt::BinaryOperatorClass;
890
891 case OO_Pipe:
John McCalle3027922010-08-25 11:45:40 +0000892 BinaryOp = BO_Or;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000893 return Stmt::BinaryOperatorClass;
894
895 case OO_Tilde:
John McCalle3027922010-08-25 11:45:40 +0000896 UnaryOp = UO_Not;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000897 return Stmt::UnaryOperatorClass;
898
899 case OO_Exclaim:
John McCalle3027922010-08-25 11:45:40 +0000900 UnaryOp = UO_LNot;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000901 return Stmt::UnaryOperatorClass;
902
903 case OO_Equal:
John McCalle3027922010-08-25 11:45:40 +0000904 BinaryOp = BO_Assign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000905 return Stmt::BinaryOperatorClass;
906
907 case OO_Less:
John McCalle3027922010-08-25 11:45:40 +0000908 BinaryOp = BO_LT;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000909 return Stmt::BinaryOperatorClass;
910
911 case OO_Greater:
John McCalle3027922010-08-25 11:45:40 +0000912 BinaryOp = BO_GT;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000913 return Stmt::BinaryOperatorClass;
914
915 case OO_PlusEqual:
John McCalle3027922010-08-25 11:45:40 +0000916 BinaryOp = BO_AddAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000917 return Stmt::CompoundAssignOperatorClass;
918
919 case OO_MinusEqual:
John McCalle3027922010-08-25 11:45:40 +0000920 BinaryOp = BO_SubAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000921 return Stmt::CompoundAssignOperatorClass;
922
923 case OO_StarEqual:
John McCalle3027922010-08-25 11:45:40 +0000924 BinaryOp = BO_MulAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000925 return Stmt::CompoundAssignOperatorClass;
926
927 case OO_SlashEqual:
John McCalle3027922010-08-25 11:45:40 +0000928 BinaryOp = BO_DivAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000929 return Stmt::CompoundAssignOperatorClass;
930
931 case OO_PercentEqual:
John McCalle3027922010-08-25 11:45:40 +0000932 BinaryOp = BO_RemAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000933 return Stmt::CompoundAssignOperatorClass;
934
935 case OO_CaretEqual:
John McCalle3027922010-08-25 11:45:40 +0000936 BinaryOp = BO_XorAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000937 return Stmt::CompoundAssignOperatorClass;
938
939 case OO_AmpEqual:
John McCalle3027922010-08-25 11:45:40 +0000940 BinaryOp = BO_AndAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000941 return Stmt::CompoundAssignOperatorClass;
942
943 case OO_PipeEqual:
John McCalle3027922010-08-25 11:45:40 +0000944 BinaryOp = BO_OrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000945 return Stmt::CompoundAssignOperatorClass;
946
947 case OO_LessLess:
John McCalle3027922010-08-25 11:45:40 +0000948 BinaryOp = BO_Shl;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000949 return Stmt::BinaryOperatorClass;
950
951 case OO_GreaterGreater:
John McCalle3027922010-08-25 11:45:40 +0000952 BinaryOp = BO_Shr;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000953 return Stmt::BinaryOperatorClass;
954
955 case OO_LessLessEqual:
John McCalle3027922010-08-25 11:45:40 +0000956 BinaryOp = BO_ShlAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000957 return Stmt::CompoundAssignOperatorClass;
958
959 case OO_GreaterGreaterEqual:
John McCalle3027922010-08-25 11:45:40 +0000960 BinaryOp = BO_ShrAssign;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000961 return Stmt::CompoundAssignOperatorClass;
962
963 case OO_EqualEqual:
John McCalle3027922010-08-25 11:45:40 +0000964 BinaryOp = BO_EQ;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000965 return Stmt::BinaryOperatorClass;
966
967 case OO_ExclaimEqual:
John McCalle3027922010-08-25 11:45:40 +0000968 BinaryOp = BO_NE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000969 return Stmt::BinaryOperatorClass;
970
971 case OO_LessEqual:
John McCalle3027922010-08-25 11:45:40 +0000972 BinaryOp = BO_LE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000973 return Stmt::BinaryOperatorClass;
974
975 case OO_GreaterEqual:
John McCalle3027922010-08-25 11:45:40 +0000976 BinaryOp = BO_GE;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000977 return Stmt::BinaryOperatorClass;
978
979 case OO_AmpAmp:
John McCalle3027922010-08-25 11:45:40 +0000980 BinaryOp = BO_LAnd;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000981 return Stmt::BinaryOperatorClass;
982
983 case OO_PipePipe:
John McCalle3027922010-08-25 11:45:40 +0000984 BinaryOp = BO_LOr;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000985 return Stmt::BinaryOperatorClass;
986
987 case OO_PlusPlus:
John McCalle3027922010-08-25 11:45:40 +0000988 UnaryOp = S->getNumArgs() == 1? UO_PreInc
989 : UO_PostInc;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000990 return Stmt::UnaryOperatorClass;
991
992 case OO_MinusMinus:
John McCalle3027922010-08-25 11:45:40 +0000993 UnaryOp = S->getNumArgs() == 1? UO_PreDec
994 : UO_PostDec;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000995 return Stmt::UnaryOperatorClass;
996
997 case OO_Comma:
John McCalle3027922010-08-25 11:45:40 +0000998 BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +0000999 return Stmt::BinaryOperatorClass;
1000
1001
1002 case OO_ArrowStar:
John McCalle3027922010-08-25 11:45:40 +00001003 BinaryOp = BO_PtrMemI;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001004 return Stmt::BinaryOperatorClass;
1005
1006 case OO_Subscript:
1007 return Stmt::ArraySubscriptExprClass;
1008 }
1009
1010 llvm_unreachable("Invalid overloaded operator expression");
1011}
Richard Smithf15acc52014-06-05 22:43:40 +00001012
Douglas Gregore9ceb312010-05-19 04:13:23 +00001013
Chandler Carruth631abd92011-06-16 06:47:06 +00001014void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) {
Douglas Gregore9ceb312010-05-19 04:13:23 +00001015 if (S->isTypeDependent()) {
1016 // Type-dependent operator calls are profiled like their underlying
1017 // syntactic operator.
John McCalle3027922010-08-25 11:45:40 +00001018 UnaryOperatorKind UnaryOp = UO_Extension;
1019 BinaryOperatorKind BinaryOp = BO_Comma;
Douglas Gregore9ceb312010-05-19 04:13:23 +00001020 Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp);
Richard Smithf15acc52014-06-05 22:43:40 +00001021
Douglas Gregore9ceb312010-05-19 04:13:23 +00001022 ID.AddInteger(SC);
1023 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1024 Visit(S->getArg(I));
1025 if (SC == Stmt::UnaryOperatorClass)
1026 ID.AddInteger(UnaryOp);
1027 else if (SC == Stmt::BinaryOperatorClass ||
1028 SC == Stmt::CompoundAssignOperatorClass)
1029 ID.AddInteger(BinaryOp);
1030 else
1031 assert(SC == Stmt::ArraySubscriptExprClass);
Richard Smithf15acc52014-06-05 22:43:40 +00001032
Douglas Gregore9ceb312010-05-19 04:13:23 +00001033 return;
1034 }
Richard Smithf15acc52014-06-05 22:43:40 +00001035
Douglas Gregor5c193b92009-07-28 00:33:38 +00001036 VisitCallExpr(S);
1037 ID.AddInteger(S->getOperator());
1038}
1039
Chandler Carruth631abd92011-06-16 06:47:06 +00001040void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001041 VisitCallExpr(S);
1042}
1043
Chandler Carruth631abd92011-06-16 06:47:06 +00001044void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) {
Peter Collingbourne41f85462011-02-09 21:07:24 +00001045 VisitCallExpr(S);
1046}
1047
Chandler Carruth631abd92011-06-16 06:47:06 +00001048void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) {
Tanya Lattner55808c12011-06-04 00:47:47 +00001049 VisitExpr(S);
1050}
1051
Chandler Carruth631abd92011-06-16 06:47:06 +00001052void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001053 VisitExplicitCastExpr(S);
1054}
1055
Chandler Carruth631abd92011-06-16 06:47:06 +00001056void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001057 VisitCXXNamedCastExpr(S);
1058}
1059
Chandler Carruth631abd92011-06-16 06:47:06 +00001060void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001061 VisitCXXNamedCastExpr(S);
1062}
1063
Chandler Carruth631abd92011-06-16 06:47:06 +00001064void
1065StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001066 VisitCXXNamedCastExpr(S);
1067}
1068
Chandler Carruth631abd92011-06-16 06:47:06 +00001069void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001070 VisitCXXNamedCastExpr(S);
1071}
1072
Richard Smithc67fdd42012-03-07 08:35:16 +00001073void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) {
1074 VisitCallExpr(S);
1075}
1076
Chandler Carruth631abd92011-06-16 06:47:06 +00001077void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001078 VisitExpr(S);
1079 ID.AddBoolean(S->getValue());
1080}
1081
Chandler Carruth631abd92011-06-16 06:47:06 +00001082void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) {
Douglas Gregor00044172009-07-29 16:09:57 +00001083 VisitExpr(S);
1084}
1085
Richard Smithcc1b96d2013-06-12 22:31:48 +00001086void StmtProfiler::VisitCXXStdInitializerListExpr(
1087 const CXXStdInitializerListExpr *S) {
1088 VisitExpr(S);
1089}
1090
Chandler Carruth631abd92011-06-16 06:47:06 +00001091void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001092 VisitExpr(S);
1093 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001094 VisitType(S->getTypeOperandSourceInfo()->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001095}
1096
Chandler Carruth631abd92011-06-16 06:47:06 +00001097void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) {
Francois Pichet9f4f2072010-09-08 12:20:18 +00001098 VisitExpr(S);
1099 if (S->isTypeOperand())
David Majnemer143c55e2013-09-27 07:04:31 +00001100 VisitType(S->getTypeOperandSourceInfo()->getType());
Francois Pichet9f4f2072010-09-08 12:20:18 +00001101}
1102
John McCall5e77d762013-04-16 07:28:30 +00001103void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) {
1104 VisitExpr(S);
1105 VisitDecl(S->getPropertyDecl());
1106}
1107
Chandler Carruth631abd92011-06-16 06:47:06 +00001108void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001109 VisitExpr(S);
Douglas Gregor3024f072012-04-16 07:05:22 +00001110 ID.AddBoolean(S->isImplicit());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001111}
1112
Chandler Carruth631abd92011-06-16 06:47:06 +00001113void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001114 VisitExpr(S);
1115}
1116
Chandler Carruth631abd92011-06-16 06:47:06 +00001117void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001118 VisitExpr(S);
1119 VisitDecl(S->getParam());
1120}
1121
Richard Smith852c9db2013-04-20 22:23:05 +00001122void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) {
1123 VisitExpr(S);
1124 VisitDecl(S->getField());
1125}
1126
Chandler Carruth631abd92011-06-16 06:47:06 +00001127void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001128 VisitExpr(S);
1129 VisitDecl(
1130 const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
1131}
1132
Chandler Carruth631abd92011-06-16 06:47:06 +00001133void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001134 VisitExpr(S);
1135 VisitDecl(S->getConstructor());
1136 ID.AddBoolean(S->isElidable());
1137}
1138
Chandler Carruth631abd92011-06-16 06:47:06 +00001139void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001140 VisitExplicitCastExpr(S);
1141}
1142
Chandler Carruth631abd92011-06-16 06:47:06 +00001143void
1144StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001145 VisitCXXConstructExpr(S);
1146}
1147
Chandler Carruth631abd92011-06-16 06:47:06 +00001148void
Douglas Gregore31e6062012-02-07 10:09:13 +00001149StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) {
1150 VisitExpr(S);
1151 for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(),
1152 CEnd = S->explicit_capture_end();
1153 C != CEnd; ++C) {
1154 ID.AddInteger(C->getCaptureKind());
Richard Smithba71c082013-05-16 06:20:58 +00001155 switch (C->getCaptureKind()) {
1156 case LCK_This:
1157 break;
1158 case LCK_ByRef:
1159 case LCK_ByCopy:
Douglas Gregore31e6062012-02-07 10:09:13 +00001160 VisitDecl(C->getCapturedVar());
1161 ID.AddBoolean(C->isPackExpansion());
Richard Smithba71c082013-05-16 06:20:58 +00001162 break;
Alexey Bataev39c81e22014-08-28 04:28:19 +00001163 case LCK_VLAType:
1164 llvm_unreachable("VLA type in explicit captures.");
Douglas Gregore31e6062012-02-07 10:09:13 +00001165 }
1166 }
1167 // Note: If we actually needed to be able to match lambda
1168 // expressions, we would have to consider parameters and return type
1169 // here, among other things.
1170 VisitStmt(S->getBody());
1171}
1172
1173void
Chandler Carruth631abd92011-06-16 06:47:06 +00001174StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001175 VisitExpr(S);
1176}
1177
Chandler Carruth631abd92011-06-16 06:47:06 +00001178void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001179 VisitExpr(S);
1180 ID.AddBoolean(S->isGlobalDelete());
1181 ID.AddBoolean(S->isArrayForm());
1182 VisitDecl(S->getOperatorDelete());
1183}
1184
1185
Chandler Carruth631abd92011-06-16 06:47:06 +00001186void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001187 VisitExpr(S);
1188 VisitType(S->getAllocatedType());
1189 VisitDecl(S->getOperatorNew());
1190 VisitDecl(S->getOperatorDelete());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001191 ID.AddBoolean(S->isArray());
1192 ID.AddInteger(S->getNumPlacementArgs());
1193 ID.AddBoolean(S->isGlobalNew());
1194 ID.AddBoolean(S->isParenTypeId());
Sebastian Redl6047f072012-02-16 12:22:20 +00001195 ID.AddInteger(S->getInitializationStyle());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001196}
1197
Chandler Carruth631abd92011-06-16 06:47:06 +00001198void
1199StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) {
Douglas Gregorad8a3362009-09-04 17:36:40 +00001200 VisitExpr(S);
1201 ID.AddBoolean(S->isArrow());
1202 VisitNestedNameSpecifier(S->getQualifier());
Craig Topper36250ad2014-05-12 05:36:57 +00001203 ID.AddBoolean(S->getScopeTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001204 if (S->getScopeTypeInfo())
1205 VisitType(S->getScopeTypeInfo()->getType());
Craig Topper36250ad2014-05-12 05:36:57 +00001206 ID.AddBoolean(S->getDestroyedTypeInfo() != nullptr);
Eli Friedman85641392013-08-09 23:37:05 +00001207 if (S->getDestroyedTypeInfo())
1208 VisitType(S->getDestroyedType());
1209 else
1210 ID.AddPointer(S->getDestroyedTypeIdentifier());
Douglas Gregorad8a3362009-09-04 17:36:40 +00001211}
1212
Chandler Carruth631abd92011-06-16 06:47:06 +00001213void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) {
Argyrios Kyrtzidisb482eb82010-08-15 20:53:20 +00001214 VisitExpr(S);
John McCalle66edc12009-11-24 19:00:30 +00001215 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001216 VisitName(S->getName());
John McCalle66edc12009-11-24 19:00:30 +00001217 ID.AddBoolean(S->hasExplicitTemplateArgs());
1218 if (S->hasExplicitTemplateArgs())
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001219 VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(),
1220 S->getExplicitTemplateArgs().NumTemplateArgs);
1221}
1222
1223void
Chandler Carruth631abd92011-06-16 06:47:06 +00001224StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) {
Argyrios Kyrtzidisf4505452010-08-15 01:15:38 +00001225 VisitOverloadExpr(S);
Douglas Gregor5c193b92009-07-28 00:33:38 +00001226}
1227
Douglas Gregor29c42f22012-02-24 07:38:34 +00001228void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) {
1229 VisitExpr(S);
1230 ID.AddInteger(S->getTrait());
1231 ID.AddInteger(S->getNumArgs());
1232 for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I)
1233 VisitType(S->getArg(I)->getType());
1234}
1235
Chandler Carruth631abd92011-06-16 06:47:06 +00001236void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) {
John Wiegley6242b6a2011-04-28 00:16:57 +00001237 VisitExpr(S);
1238 ID.AddInteger(S->getTrait());
1239 VisitType(S->getQueriedType());
1240}
1241
Chandler Carruth631abd92011-06-16 06:47:06 +00001242void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) {
John Wiegleyf9f65842011-04-25 06:54:41 +00001243 VisitExpr(S);
1244 ID.AddInteger(S->getTrait());
1245 VisitExpr(S->getQueriedExpression());
1246}
1247
Chandler Carruth631abd92011-06-16 06:47:06 +00001248void StmtProfiler::VisitDependentScopeDeclRefExpr(
1249 const DependentScopeDeclRefExpr *S) {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001250 VisitExpr(S);
1251 VisitName(S->getDeclName());
1252 VisitNestedNameSpecifier(S->getQualifier());
John McCalle66edc12009-11-24 19:00:30 +00001253 ID.AddBoolean(S->hasExplicitTemplateArgs());
1254 if (S->hasExplicitTemplateArgs())
1255 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001256}
1257
Chandler Carruth631abd92011-06-16 06:47:06 +00001258void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001259 VisitExpr(S);
Douglas Gregora7095092009-07-28 14:44:31 +00001260}
1261
Chandler Carruth631abd92011-06-16 06:47:06 +00001262void StmtProfiler::VisitCXXUnresolvedConstructExpr(
1263 const CXXUnresolvedConstructExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001264 VisitExpr(S);
1265 VisitType(S->getTypeAsWritten());
1266}
1267
Chandler Carruth631abd92011-06-16 06:47:06 +00001268void StmtProfiler::VisitCXXDependentScopeMemberExpr(
1269 const CXXDependentScopeMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001270 ID.AddBoolean(S->isImplicitAccess());
1271 if (!S->isImplicitAccess()) {
1272 VisitExpr(S);
1273 ID.AddBoolean(S->isArrow());
1274 }
Douglas Gregorc26e0f62009-09-03 16:14:30 +00001275 VisitNestedNameSpecifier(S->getQualifier());
Douglas Gregora7095092009-07-28 14:44:31 +00001276 VisitName(S->getMember());
John McCall2d74de92009-12-01 22:10:20 +00001277 ID.AddBoolean(S->hasExplicitTemplateArgs());
1278 if (S->hasExplicitTemplateArgs())
John McCall10eae182009-11-30 22:42:35 +00001279 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
1280}
1281
Chandler Carruth631abd92011-06-16 06:47:06 +00001282void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) {
John McCall2d74de92009-12-01 22:10:20 +00001283 ID.AddBoolean(S->isImplicitAccess());
1284 if (!S->isImplicitAccess()) {
1285 VisitExpr(S);
1286 ID.AddBoolean(S->isArrow());
1287 }
John McCall10eae182009-11-30 22:42:35 +00001288 VisitNestedNameSpecifier(S->getQualifier());
1289 VisitName(S->getMemberName());
1290 ID.AddBoolean(S->hasExplicitTemplateArgs());
1291 if (S->hasExplicitTemplateArgs())
1292 VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
Douglas Gregora7095092009-07-28 14:44:31 +00001293}
1294
Chandler Carruth631abd92011-06-16 06:47:06 +00001295void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) {
Sebastian Redl4202c0f2010-09-10 20:55:43 +00001296 VisitExpr(S);
1297}
1298
Chandler Carruth631abd92011-06-16 06:47:06 +00001299void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) {
Douglas Gregore8e9dd62011-01-03 17:17:50 +00001300 VisitExpr(S);
1301}
1302
Chandler Carruth631abd92011-06-16 06:47:06 +00001303void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) {
Douglas Gregor820ba7b2011-01-04 17:33:58 +00001304 VisitExpr(S);
1305 VisitDecl(S->getPack());
1306}
1307
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001308void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr(
Chandler Carruth631abd92011-06-16 06:47:06 +00001309 const SubstNonTypeTemplateParmPackExpr *S) {
Douglas Gregorcdbc5392011-01-15 01:15:58 +00001310 VisitExpr(S);
1311 VisitDecl(S->getParameterPack());
1312 VisitTemplateArgument(S->getArgumentPack());
1313}
1314
John McCall7c454bb2011-07-15 05:09:51 +00001315void StmtProfiler::VisitSubstNonTypeTemplateParmExpr(
1316 const SubstNonTypeTemplateParmExpr *E) {
1317 // Profile exactly as the replacement expression.
1318 Visit(E->getReplacement());
1319}
1320
Richard Smithb15fe3a2012-09-12 00:56:43 +00001321void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) {
1322 VisitExpr(S);
1323 VisitDecl(S->getParameterPack());
1324 ID.AddInteger(S->getNumExpansions());
1325 for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I)
1326 VisitDecl(*I);
1327}
1328
Douglas Gregorfe314812011-06-21 17:03:29 +00001329void StmtProfiler::VisitMaterializeTemporaryExpr(
1330 const MaterializeTemporaryExpr *S) {
1331 VisitExpr(S);
1332}
1333
Richard Smith0f0af192014-11-08 05:07:16 +00001334void StmtProfiler::VisitCXXFoldExpr(const CXXFoldExpr *S) {
1335 VisitExpr(S);
1336 ID.AddInteger(S->getOperator());
1337}
1338
Chandler Carruth631abd92011-06-16 06:47:06 +00001339void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) {
John McCall8d69a212010-11-15 23:31:06 +00001340 VisitExpr(E);
1341}
1342
Kaelyn Takatae1f49d52014-10-27 18:07:20 +00001343void StmtProfiler::VisitTypoExpr(const TypoExpr *E) {
1344 VisitExpr(E);
1345}
1346
Chandler Carruth631abd92011-06-16 06:47:06 +00001347void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001348 VisitExpr(S);
1349}
1350
Patrick Beard0caa3942012-04-19 00:25:12 +00001351void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) {
Ted Kremeneke65b0862012-03-06 20:05:56 +00001352 VisitExpr(E);
1353}
1354
1355void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) {
1356 VisitExpr(E);
1357}
1358
1359void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) {
1360 VisitExpr(E);
1361}
1362
Chandler Carruth631abd92011-06-16 06:47:06 +00001363void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001364 VisitExpr(S);
1365 VisitType(S->getEncodedType());
1366}
1367
Chandler Carruth631abd92011-06-16 06:47:06 +00001368void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001369 VisitExpr(S);
1370 VisitName(S->getSelector());
1371}
1372
Chandler Carruth631abd92011-06-16 06:47:06 +00001373void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001374 VisitExpr(S);
1375 VisitDecl(S->getProtocol());
1376}
1377
Chandler Carruth631abd92011-06-16 06:47:06 +00001378void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001379 VisitExpr(S);
1380 VisitDecl(S->getDecl());
1381 ID.AddBoolean(S->isArrow());
1382 ID.AddBoolean(S->isFreeIvar());
1383}
1384
Chandler Carruth631abd92011-06-16 06:47:06 +00001385void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001386 VisitExpr(S);
John McCallb7bd14f2010-12-02 01:19:52 +00001387 if (S->isImplicitProperty()) {
1388 VisitDecl(S->getImplicitPropertyGetter());
1389 VisitDecl(S->getImplicitPropertySetter());
1390 } else {
1391 VisitDecl(S->getExplicitProperty());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001392 }
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001393 if (S->isSuperReceiver()) {
1394 ID.AddBoolean(S->isSuperReceiver());
John McCallb7bd14f2010-12-02 01:19:52 +00001395 VisitType(S->getSuperReceiverType());
Fariborz Jahanian681c0752010-10-14 16:04:05 +00001396 }
Douglas Gregora7095092009-07-28 14:44:31 +00001397}
1398
Ted Kremeneke65b0862012-03-06 20:05:56 +00001399void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) {
1400 VisitExpr(S);
1401 VisitDecl(S->getAtIndexMethodDecl());
1402 VisitDecl(S->setAtIndexMethodDecl());
1403}
1404
Chandler Carruth631abd92011-06-16 06:47:06 +00001405void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001406 VisitExpr(S);
1407 VisitName(S->getSelector());
1408 VisitDecl(S->getMethodDecl());
1409}
1410
Chandler Carruth631abd92011-06-16 06:47:06 +00001411void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) {
Douglas Gregora7095092009-07-28 14:44:31 +00001412 VisitExpr(S);
1413 ID.AddBoolean(S->isArrow());
1414}
1415
Ted Kremeneke65b0862012-03-06 20:05:56 +00001416void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) {
1417 VisitExpr(S);
1418 ID.AddBoolean(S->getValue());
1419}
1420
Chandler Carruth631abd92011-06-16 06:47:06 +00001421void StmtProfiler::VisitObjCIndirectCopyRestoreExpr(
1422 const ObjCIndirectCopyRestoreExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001423 VisitExpr(S);
1424 ID.AddBoolean(S->shouldCopy());
1425}
1426
Chandler Carruth631abd92011-06-16 06:47:06 +00001427void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) {
John McCall31168b02011-06-15 23:02:42 +00001428 VisitExplicitCastExpr(S);
1429 ID.AddBoolean(S->getBridgeKind());
1430}
1431
Chandler Carruth631abd92011-06-16 06:47:06 +00001432void StmtProfiler::VisitDecl(const Decl *D) {
Douglas Gregor70317122009-07-31 15:45:02 +00001433 ID.AddInteger(D? D->getKind() : 0);
Mike Stump11289f42009-09-09 15:08:12 +00001434
Douglas Gregora5dd9f82009-07-30 23:18:24 +00001435 if (Canonical && D) {
Chandler Carruth631abd92011-06-16 06:47:06 +00001436 if (const NonTypeTemplateParmDecl *NTTP =
1437 dyn_cast<NonTypeTemplateParmDecl>(D)) {
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001438 ID.AddInteger(NTTP->getDepth());
1439 ID.AddInteger(NTTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001440 ID.AddBoolean(NTTP->isParameterPack());
Douglas Gregor00044172009-07-29 16:09:57 +00001441 VisitType(NTTP->getType());
Douglas Gregor5c193b92009-07-28 00:33:38 +00001442 return;
1443 }
Mike Stump11289f42009-09-09 15:08:12 +00001444
Chandler Carruth631abd92011-06-16 06:47:06 +00001445 if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
John McCall8fb0d9d2011-05-01 22:35:37 +00001446 // The Itanium C++ ABI uses the type, scope depth, and scope
1447 // index of a parameter when mangling expressions that involve
1448 // function parameters, so we will use the parameter's type for
1449 // establishing function parameter identity. That way, our
1450 // definition of "equivalent" (per C++ [temp.over.link]) is at
1451 // least as strong as the definition of "equivalent" used for
1452 // name mangling.
Douglas Gregor70317122009-07-31 15:45:02 +00001453 VisitType(Parm->getType());
John McCall8fb0d9d2011-05-01 22:35:37 +00001454 ID.AddInteger(Parm->getFunctionScopeDepth());
1455 ID.AddInteger(Parm->getFunctionScopeIndex());
Douglas Gregor70317122009-07-31 15:45:02 +00001456 return;
1457 }
Mike Stump11289f42009-09-09 15:08:12 +00001458
Richard Smithd9a1cd82012-04-02 18:53:24 +00001459 if (const TemplateTypeParmDecl *TTP =
1460 dyn_cast<TemplateTypeParmDecl>(D)) {
1461 ID.AddInteger(TTP->getDepth());
1462 ID.AddInteger(TTP->getIndex());
1463 ID.AddBoolean(TTP->isParameterPack());
1464 return;
1465 }
1466
Chandler Carruth631abd92011-06-16 06:47:06 +00001467 if (const TemplateTemplateParmDecl *TTP =
1468 dyn_cast<TemplateTemplateParmDecl>(D)) {
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001469 ID.AddInteger(TTP->getDepth());
1470 ID.AddInteger(TTP->getIndex());
Douglas Gregorf5500772011-01-05 15:48:55 +00001471 ID.AddBoolean(TTP->isParameterPack());
Douglas Gregorc97f09f2009-07-31 15:46:56 +00001472 return;
1473 }
Douglas Gregor5c193b92009-07-28 00:33:38 +00001474 }
Mike Stump11289f42009-09-09 15:08:12 +00001475
Craig Topper36250ad2014-05-12 05:36:57 +00001476 ID.AddPointer(D? D->getCanonicalDecl() : nullptr);
Douglas Gregord9aedfa2009-07-28 15:32:17 +00001477}
1478
1479void StmtProfiler::VisitType(QualType T) {
1480 if (Canonical)
1481 T = Context.getCanonicalType(T);
Mike Stump11289f42009-09-09 15:08:12 +00001482
Douglas Gregor5c193b92009-07-28 00:33:38 +00001483 ID.AddPointer(T.getAsOpaquePtr());
1484}
1485
1486void StmtProfiler::VisitName(DeclarationName Name) {
1487 ID.AddPointer(Name.getAsOpaquePtr());
1488}
1489
1490void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
1491 if (Canonical)
1492 NNS = Context.getCanonicalNestedNameSpecifier(NNS);
1493 ID.AddPointer(NNS);
1494}
1495
1496void StmtProfiler::VisitTemplateName(TemplateName Name) {
1497 if (Canonical)
1498 Name = Context.getCanonicalTemplateName(Name);
Mike Stump11289f42009-09-09 15:08:12 +00001499
Douglas Gregor5c193b92009-07-28 00:33:38 +00001500 Name.Profile(ID);
1501}
1502
John McCall0ad16662009-10-29 08:12:44 +00001503void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
Douglas Gregor5c193b92009-07-28 00:33:38 +00001504 unsigned NumArgs) {
1505 ID.AddInteger(NumArgs);
John McCall0ad16662009-10-29 08:12:44 +00001506 for (unsigned I = 0; I != NumArgs; ++I)
1507 VisitTemplateArgument(Args[I].getArgument());
1508}
Mike Stump11289f42009-09-09 15:08:12 +00001509
John McCall0ad16662009-10-29 08:12:44 +00001510void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
1511 // Mostly repetitive with TemplateArgument::Profile!
1512 ID.AddInteger(Arg.getKind());
1513 switch (Arg.getKind()) {
1514 case TemplateArgument::Null:
1515 break;
Mike Stump11289f42009-09-09 15:08:12 +00001516
John McCall0ad16662009-10-29 08:12:44 +00001517 case TemplateArgument::Type:
1518 VisitType(Arg.getAsType());
1519 break;
Mike Stump11289f42009-09-09 15:08:12 +00001520
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001521 case TemplateArgument::Template:
Douglas Gregore4ff4b52011-01-05 18:58:31 +00001522 case TemplateArgument::TemplateExpansion:
1523 VisitTemplateName(Arg.getAsTemplateOrTemplatePattern());
Douglas Gregor9167f8b2009-11-11 01:00:40 +00001524 break;
Alexis Hunta8136cc2010-05-05 15:23:54 +00001525
John McCall0ad16662009-10-29 08:12:44 +00001526 case TemplateArgument::Declaration:
1527 VisitDecl(Arg.getAsDecl());
1528 break;
Mike Stump11289f42009-09-09 15:08:12 +00001529
Eli Friedmanb826a002012-09-26 02:36:12 +00001530 case TemplateArgument::NullPtr:
1531 VisitType(Arg.getNullPtrType());
1532 break;
1533
John McCall0ad16662009-10-29 08:12:44 +00001534 case TemplateArgument::Integral:
Benjamin Kramer6003ad52012-06-07 15:09:51 +00001535 Arg.getAsIntegral().Profile(ID);
John McCall0ad16662009-10-29 08:12:44 +00001536 VisitType(Arg.getIntegralType());
1537 break;
Mike Stump11289f42009-09-09 15:08:12 +00001538
John McCall0ad16662009-10-29 08:12:44 +00001539 case TemplateArgument::Expression:
1540 Visit(Arg.getAsExpr());
1541 break;
Mike Stump11289f42009-09-09 15:08:12 +00001542
John McCall0ad16662009-10-29 08:12:44 +00001543 case TemplateArgument::Pack:
Aaron Ballman2a89e852014-07-15 21:32:31 +00001544 for (const auto &P : Arg.pack_elements())
1545 VisitTemplateArgument(P);
John McCall0ad16662009-10-29 08:12:44 +00001546 break;
Douglas Gregor5c193b92009-07-28 00:33:38 +00001547 }
1548}
1549
Jay Foad39c79802011-01-12 09:06:06 +00001550void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
Chandler Carruth631abd92011-06-16 06:47:06 +00001551 bool Canonical) const {
Douglas Gregor5c193b92009-07-28 00:33:38 +00001552 StmtProfiler Profiler(ID, Context, Canonical);
1553 Profiler.Visit(this);
1554}