1*f4a2713aSLionel Sambuc //===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===// 2*f4a2713aSLionel Sambuc // 3*f4a2713aSLionel Sambuc // The LLVM Compiler Infrastructure 4*f4a2713aSLionel Sambuc // 5*f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source 6*f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details. 7*f4a2713aSLionel Sambuc // 8*f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===// 9*f4a2713aSLionel Sambuc // 10*f4a2713aSLionel Sambuc // This file implements the Stmt::Profile method, which builds a unique bit 11*f4a2713aSLionel Sambuc // representation that identifies a statement/expression. 12*f4a2713aSLionel Sambuc // 13*f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===// 14*f4a2713aSLionel Sambuc #include "clang/AST/ASTContext.h" 15*f4a2713aSLionel Sambuc #include "clang/AST/DeclCXX.h" 16*f4a2713aSLionel Sambuc #include "clang/AST/DeclObjC.h" 17*f4a2713aSLionel Sambuc #include "clang/AST/DeclTemplate.h" 18*f4a2713aSLionel Sambuc #include "clang/AST/Expr.h" 19*f4a2713aSLionel Sambuc #include "clang/AST/ExprCXX.h" 20*f4a2713aSLionel Sambuc #include "clang/AST/ExprObjC.h" 21*f4a2713aSLionel Sambuc #include "clang/AST/StmtVisitor.h" 22*f4a2713aSLionel Sambuc #include "llvm/ADT/FoldingSet.h" 23*f4a2713aSLionel Sambuc using namespace clang; 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc namespace { 26*f4a2713aSLionel Sambuc class StmtProfiler : public ConstStmtVisitor<StmtProfiler> { 27*f4a2713aSLionel Sambuc llvm::FoldingSetNodeID &ID; 28*f4a2713aSLionel Sambuc const ASTContext &Context; 29*f4a2713aSLionel Sambuc bool Canonical; 30*f4a2713aSLionel Sambuc 31*f4a2713aSLionel Sambuc public: 32*f4a2713aSLionel Sambuc StmtProfiler(llvm::FoldingSetNodeID &ID, const ASTContext &Context, 33*f4a2713aSLionel Sambuc bool Canonical) 34*f4a2713aSLionel Sambuc : ID(ID), Context(Context), Canonical(Canonical) { } 35*f4a2713aSLionel Sambuc 36*f4a2713aSLionel Sambuc void VisitStmt(const Stmt *S); 37*f4a2713aSLionel Sambuc 38*f4a2713aSLionel Sambuc #define STMT(Node, Base) void Visit##Node(const Node *S); 39*f4a2713aSLionel Sambuc #include "clang/AST/StmtNodes.inc" 40*f4a2713aSLionel Sambuc 41*f4a2713aSLionel Sambuc /// \brief Visit a declaration that is referenced within an expression 42*f4a2713aSLionel Sambuc /// or statement. 43*f4a2713aSLionel Sambuc void VisitDecl(const Decl *D); 44*f4a2713aSLionel Sambuc 45*f4a2713aSLionel Sambuc /// \brief Visit a type that is referenced within an expression or 46*f4a2713aSLionel Sambuc /// statement. 47*f4a2713aSLionel Sambuc void VisitType(QualType T); 48*f4a2713aSLionel Sambuc 49*f4a2713aSLionel Sambuc /// \brief Visit a name that occurs within an expression or statement. 50*f4a2713aSLionel Sambuc void VisitName(DeclarationName Name); 51*f4a2713aSLionel Sambuc 52*f4a2713aSLionel Sambuc /// \brief Visit a nested-name-specifier that occurs within an expression 53*f4a2713aSLionel Sambuc /// or statement. 54*f4a2713aSLionel Sambuc void VisitNestedNameSpecifier(NestedNameSpecifier *NNS); 55*f4a2713aSLionel Sambuc 56*f4a2713aSLionel Sambuc /// \brief Visit a template name that occurs within an expression or 57*f4a2713aSLionel Sambuc /// statement. 58*f4a2713aSLionel Sambuc void VisitTemplateName(TemplateName Name); 59*f4a2713aSLionel Sambuc 60*f4a2713aSLionel Sambuc /// \brief Visit template arguments that occur within an expression or 61*f4a2713aSLionel Sambuc /// statement. 62*f4a2713aSLionel Sambuc void VisitTemplateArguments(const TemplateArgumentLoc *Args, 63*f4a2713aSLionel Sambuc unsigned NumArgs); 64*f4a2713aSLionel Sambuc 65*f4a2713aSLionel Sambuc /// \brief Visit a single template argument. 66*f4a2713aSLionel Sambuc void VisitTemplateArgument(const TemplateArgument &Arg); 67*f4a2713aSLionel Sambuc }; 68*f4a2713aSLionel Sambuc } 69*f4a2713aSLionel Sambuc 70*f4a2713aSLionel Sambuc void StmtProfiler::VisitStmt(const Stmt *S) { 71*f4a2713aSLionel Sambuc ID.AddInteger(S->getStmtClass()); 72*f4a2713aSLionel Sambuc for (Stmt::const_child_range C = S->children(); C; ++C) { 73*f4a2713aSLionel Sambuc if (*C) 74*f4a2713aSLionel Sambuc Visit(*C); 75*f4a2713aSLionel Sambuc else 76*f4a2713aSLionel Sambuc ID.AddInteger(0); 77*f4a2713aSLionel Sambuc } 78*f4a2713aSLionel Sambuc } 79*f4a2713aSLionel Sambuc 80*f4a2713aSLionel Sambuc void StmtProfiler::VisitDeclStmt(const DeclStmt *S) { 81*f4a2713aSLionel Sambuc VisitStmt(S); 82*f4a2713aSLionel Sambuc for (DeclStmt::const_decl_iterator D = S->decl_begin(), DEnd = S->decl_end(); 83*f4a2713aSLionel Sambuc D != DEnd; ++D) 84*f4a2713aSLionel Sambuc VisitDecl(*D); 85*f4a2713aSLionel Sambuc } 86*f4a2713aSLionel Sambuc 87*f4a2713aSLionel Sambuc void StmtProfiler::VisitNullStmt(const NullStmt *S) { 88*f4a2713aSLionel Sambuc VisitStmt(S); 89*f4a2713aSLionel Sambuc } 90*f4a2713aSLionel Sambuc 91*f4a2713aSLionel Sambuc void StmtProfiler::VisitCompoundStmt(const CompoundStmt *S) { 92*f4a2713aSLionel Sambuc VisitStmt(S); 93*f4a2713aSLionel Sambuc } 94*f4a2713aSLionel Sambuc 95*f4a2713aSLionel Sambuc void StmtProfiler::VisitSwitchCase(const SwitchCase *S) { 96*f4a2713aSLionel Sambuc VisitStmt(S); 97*f4a2713aSLionel Sambuc } 98*f4a2713aSLionel Sambuc 99*f4a2713aSLionel Sambuc void StmtProfiler::VisitCaseStmt(const CaseStmt *S) { 100*f4a2713aSLionel Sambuc VisitStmt(S); 101*f4a2713aSLionel Sambuc } 102*f4a2713aSLionel Sambuc 103*f4a2713aSLionel Sambuc void StmtProfiler::VisitDefaultStmt(const DefaultStmt *S) { 104*f4a2713aSLionel Sambuc VisitStmt(S); 105*f4a2713aSLionel Sambuc } 106*f4a2713aSLionel Sambuc 107*f4a2713aSLionel Sambuc void StmtProfiler::VisitLabelStmt(const LabelStmt *S) { 108*f4a2713aSLionel Sambuc VisitStmt(S); 109*f4a2713aSLionel Sambuc VisitDecl(S->getDecl()); 110*f4a2713aSLionel Sambuc } 111*f4a2713aSLionel Sambuc 112*f4a2713aSLionel Sambuc void StmtProfiler::VisitAttributedStmt(const AttributedStmt *S) { 113*f4a2713aSLionel Sambuc VisitStmt(S); 114*f4a2713aSLionel Sambuc // TODO: maybe visit attributes? 115*f4a2713aSLionel Sambuc } 116*f4a2713aSLionel Sambuc 117*f4a2713aSLionel Sambuc void StmtProfiler::VisitIfStmt(const IfStmt *S) { 118*f4a2713aSLionel Sambuc VisitStmt(S); 119*f4a2713aSLionel Sambuc VisitDecl(S->getConditionVariable()); 120*f4a2713aSLionel Sambuc } 121*f4a2713aSLionel Sambuc 122*f4a2713aSLionel Sambuc void StmtProfiler::VisitSwitchStmt(const SwitchStmt *S) { 123*f4a2713aSLionel Sambuc VisitStmt(S); 124*f4a2713aSLionel Sambuc VisitDecl(S->getConditionVariable()); 125*f4a2713aSLionel Sambuc } 126*f4a2713aSLionel Sambuc 127*f4a2713aSLionel Sambuc void StmtProfiler::VisitWhileStmt(const WhileStmt *S) { 128*f4a2713aSLionel Sambuc VisitStmt(S); 129*f4a2713aSLionel Sambuc VisitDecl(S->getConditionVariable()); 130*f4a2713aSLionel Sambuc } 131*f4a2713aSLionel Sambuc 132*f4a2713aSLionel Sambuc void StmtProfiler::VisitDoStmt(const DoStmt *S) { 133*f4a2713aSLionel Sambuc VisitStmt(S); 134*f4a2713aSLionel Sambuc } 135*f4a2713aSLionel Sambuc 136*f4a2713aSLionel Sambuc void StmtProfiler::VisitForStmt(const ForStmt *S) { 137*f4a2713aSLionel Sambuc VisitStmt(S); 138*f4a2713aSLionel Sambuc } 139*f4a2713aSLionel Sambuc 140*f4a2713aSLionel Sambuc void StmtProfiler::VisitGotoStmt(const GotoStmt *S) { 141*f4a2713aSLionel Sambuc VisitStmt(S); 142*f4a2713aSLionel Sambuc VisitDecl(S->getLabel()); 143*f4a2713aSLionel Sambuc } 144*f4a2713aSLionel Sambuc 145*f4a2713aSLionel Sambuc void StmtProfiler::VisitIndirectGotoStmt(const IndirectGotoStmt *S) { 146*f4a2713aSLionel Sambuc VisitStmt(S); 147*f4a2713aSLionel Sambuc } 148*f4a2713aSLionel Sambuc 149*f4a2713aSLionel Sambuc void StmtProfiler::VisitContinueStmt(const ContinueStmt *S) { 150*f4a2713aSLionel Sambuc VisitStmt(S); 151*f4a2713aSLionel Sambuc } 152*f4a2713aSLionel Sambuc 153*f4a2713aSLionel Sambuc void StmtProfiler::VisitBreakStmt(const BreakStmt *S) { 154*f4a2713aSLionel Sambuc VisitStmt(S); 155*f4a2713aSLionel Sambuc } 156*f4a2713aSLionel Sambuc 157*f4a2713aSLionel Sambuc void StmtProfiler::VisitReturnStmt(const ReturnStmt *S) { 158*f4a2713aSLionel Sambuc VisitStmt(S); 159*f4a2713aSLionel Sambuc } 160*f4a2713aSLionel Sambuc 161*f4a2713aSLionel Sambuc void StmtProfiler::VisitGCCAsmStmt(const GCCAsmStmt *S) { 162*f4a2713aSLionel Sambuc VisitStmt(S); 163*f4a2713aSLionel Sambuc ID.AddBoolean(S->isVolatile()); 164*f4a2713aSLionel Sambuc ID.AddBoolean(S->isSimple()); 165*f4a2713aSLionel Sambuc VisitStringLiteral(S->getAsmString()); 166*f4a2713aSLionel Sambuc ID.AddInteger(S->getNumOutputs()); 167*f4a2713aSLionel Sambuc for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) { 168*f4a2713aSLionel Sambuc ID.AddString(S->getOutputName(I)); 169*f4a2713aSLionel Sambuc VisitStringLiteral(S->getOutputConstraintLiteral(I)); 170*f4a2713aSLionel Sambuc } 171*f4a2713aSLionel Sambuc ID.AddInteger(S->getNumInputs()); 172*f4a2713aSLionel Sambuc for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) { 173*f4a2713aSLionel Sambuc ID.AddString(S->getInputName(I)); 174*f4a2713aSLionel Sambuc VisitStringLiteral(S->getInputConstraintLiteral(I)); 175*f4a2713aSLionel Sambuc } 176*f4a2713aSLionel Sambuc ID.AddInteger(S->getNumClobbers()); 177*f4a2713aSLionel Sambuc for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) 178*f4a2713aSLionel Sambuc VisitStringLiteral(S->getClobberStringLiteral(I)); 179*f4a2713aSLionel Sambuc } 180*f4a2713aSLionel Sambuc 181*f4a2713aSLionel Sambuc void StmtProfiler::VisitMSAsmStmt(const MSAsmStmt *S) { 182*f4a2713aSLionel Sambuc // FIXME: Implement MS style inline asm statement profiler. 183*f4a2713aSLionel Sambuc VisitStmt(S); 184*f4a2713aSLionel Sambuc } 185*f4a2713aSLionel Sambuc 186*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXCatchStmt(const CXXCatchStmt *S) { 187*f4a2713aSLionel Sambuc VisitStmt(S); 188*f4a2713aSLionel Sambuc VisitType(S->getCaughtType()); 189*f4a2713aSLionel Sambuc } 190*f4a2713aSLionel Sambuc 191*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXTryStmt(const CXXTryStmt *S) { 192*f4a2713aSLionel Sambuc VisitStmt(S); 193*f4a2713aSLionel Sambuc } 194*f4a2713aSLionel Sambuc 195*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXForRangeStmt(const CXXForRangeStmt *S) { 196*f4a2713aSLionel Sambuc VisitStmt(S); 197*f4a2713aSLionel Sambuc } 198*f4a2713aSLionel Sambuc 199*f4a2713aSLionel Sambuc void StmtProfiler::VisitMSDependentExistsStmt(const MSDependentExistsStmt *S) { 200*f4a2713aSLionel Sambuc VisitStmt(S); 201*f4a2713aSLionel Sambuc ID.AddBoolean(S->isIfExists()); 202*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifierLoc().getNestedNameSpecifier()); 203*f4a2713aSLionel Sambuc VisitName(S->getNameInfo().getName()); 204*f4a2713aSLionel Sambuc } 205*f4a2713aSLionel Sambuc 206*f4a2713aSLionel Sambuc void StmtProfiler::VisitSEHTryStmt(const SEHTryStmt *S) { 207*f4a2713aSLionel Sambuc VisitStmt(S); 208*f4a2713aSLionel Sambuc } 209*f4a2713aSLionel Sambuc 210*f4a2713aSLionel Sambuc void StmtProfiler::VisitSEHFinallyStmt(const SEHFinallyStmt *S) { 211*f4a2713aSLionel Sambuc VisitStmt(S); 212*f4a2713aSLionel Sambuc } 213*f4a2713aSLionel Sambuc 214*f4a2713aSLionel Sambuc void StmtProfiler::VisitSEHExceptStmt(const SEHExceptStmt *S) { 215*f4a2713aSLionel Sambuc VisitStmt(S); 216*f4a2713aSLionel Sambuc } 217*f4a2713aSLionel Sambuc 218*f4a2713aSLionel Sambuc void StmtProfiler::VisitCapturedStmt(const CapturedStmt *S) { 219*f4a2713aSLionel Sambuc VisitStmt(S); 220*f4a2713aSLionel Sambuc } 221*f4a2713aSLionel Sambuc 222*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCForCollectionStmt(const ObjCForCollectionStmt *S) { 223*f4a2713aSLionel Sambuc VisitStmt(S); 224*f4a2713aSLionel Sambuc } 225*f4a2713aSLionel Sambuc 226*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCAtCatchStmt(const ObjCAtCatchStmt *S) { 227*f4a2713aSLionel Sambuc VisitStmt(S); 228*f4a2713aSLionel Sambuc ID.AddBoolean(S->hasEllipsis()); 229*f4a2713aSLionel Sambuc if (S->getCatchParamDecl()) 230*f4a2713aSLionel Sambuc VisitType(S->getCatchParamDecl()->getType()); 231*f4a2713aSLionel Sambuc } 232*f4a2713aSLionel Sambuc 233*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCAtFinallyStmt(const ObjCAtFinallyStmt *S) { 234*f4a2713aSLionel Sambuc VisitStmt(S); 235*f4a2713aSLionel Sambuc } 236*f4a2713aSLionel Sambuc 237*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCAtTryStmt(const ObjCAtTryStmt *S) { 238*f4a2713aSLionel Sambuc VisitStmt(S); 239*f4a2713aSLionel Sambuc } 240*f4a2713aSLionel Sambuc 241*f4a2713aSLionel Sambuc void 242*f4a2713aSLionel Sambuc StmtProfiler::VisitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt *S) { 243*f4a2713aSLionel Sambuc VisitStmt(S); 244*f4a2713aSLionel Sambuc } 245*f4a2713aSLionel Sambuc 246*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCAtThrowStmt(const ObjCAtThrowStmt *S) { 247*f4a2713aSLionel Sambuc VisitStmt(S); 248*f4a2713aSLionel Sambuc } 249*f4a2713aSLionel Sambuc 250*f4a2713aSLionel Sambuc void 251*f4a2713aSLionel Sambuc StmtProfiler::VisitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt *S) { 252*f4a2713aSLionel Sambuc VisitStmt(S); 253*f4a2713aSLionel Sambuc } 254*f4a2713aSLionel Sambuc 255*f4a2713aSLionel Sambuc namespace { 256*f4a2713aSLionel Sambuc class OMPClauseProfiler : public ConstOMPClauseVisitor<OMPClauseProfiler> { 257*f4a2713aSLionel Sambuc StmtProfiler *Profiler; 258*f4a2713aSLionel Sambuc /// \brief Process clauses with list of variables. 259*f4a2713aSLionel Sambuc template <typename T> 260*f4a2713aSLionel Sambuc void VisitOMPClauseList(T *Node); 261*f4a2713aSLionel Sambuc public: 262*f4a2713aSLionel Sambuc OMPClauseProfiler(StmtProfiler *P) : Profiler(P) { } 263*f4a2713aSLionel Sambuc #define OPENMP_CLAUSE(Name, Class) \ 264*f4a2713aSLionel Sambuc void Visit##Class(const Class *C); 265*f4a2713aSLionel Sambuc #include "clang/Basic/OpenMPKinds.def" 266*f4a2713aSLionel Sambuc }; 267*f4a2713aSLionel Sambuc 268*f4a2713aSLionel Sambuc void OMPClauseProfiler::VisitOMPDefaultClause(const OMPDefaultClause *C) { } 269*f4a2713aSLionel Sambuc 270*f4a2713aSLionel Sambuc template<typename T> 271*f4a2713aSLionel Sambuc void OMPClauseProfiler::VisitOMPClauseList(T *Node) { 272*f4a2713aSLionel Sambuc for (typename T::varlist_const_iterator I = Node->varlist_begin(), 273*f4a2713aSLionel Sambuc E = Node->varlist_end(); 274*f4a2713aSLionel Sambuc I != E; ++I) 275*f4a2713aSLionel Sambuc Profiler->VisitStmt(*I); 276*f4a2713aSLionel Sambuc } 277*f4a2713aSLionel Sambuc 278*f4a2713aSLionel Sambuc void OMPClauseProfiler::VisitOMPPrivateClause(const OMPPrivateClause *C) { 279*f4a2713aSLionel Sambuc VisitOMPClauseList(C); 280*f4a2713aSLionel Sambuc } 281*f4a2713aSLionel Sambuc void OMPClauseProfiler::VisitOMPFirstprivateClause( 282*f4a2713aSLionel Sambuc const OMPFirstprivateClause *C) { 283*f4a2713aSLionel Sambuc VisitOMPClauseList(C); 284*f4a2713aSLionel Sambuc } 285*f4a2713aSLionel Sambuc void OMPClauseProfiler::VisitOMPSharedClause(const OMPSharedClause *C) { 286*f4a2713aSLionel Sambuc VisitOMPClauseList(C); 287*f4a2713aSLionel Sambuc } 288*f4a2713aSLionel Sambuc } 289*f4a2713aSLionel Sambuc 290*f4a2713aSLionel Sambuc void 291*f4a2713aSLionel Sambuc StmtProfiler::VisitOMPParallelDirective(const OMPParallelDirective *S) { 292*f4a2713aSLionel Sambuc VisitStmt(S); 293*f4a2713aSLionel Sambuc OMPClauseProfiler P(this); 294*f4a2713aSLionel Sambuc ArrayRef<OMPClause *> Clauses = S->clauses(); 295*f4a2713aSLionel Sambuc for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end(); 296*f4a2713aSLionel Sambuc I != E; ++I) 297*f4a2713aSLionel Sambuc if (*I) 298*f4a2713aSLionel Sambuc P.Visit(*I); 299*f4a2713aSLionel Sambuc } 300*f4a2713aSLionel Sambuc 301*f4a2713aSLionel Sambuc void StmtProfiler::VisitExpr(const Expr *S) { 302*f4a2713aSLionel Sambuc VisitStmt(S); 303*f4a2713aSLionel Sambuc } 304*f4a2713aSLionel Sambuc 305*f4a2713aSLionel Sambuc void StmtProfiler::VisitDeclRefExpr(const DeclRefExpr *S) { 306*f4a2713aSLionel Sambuc VisitExpr(S); 307*f4a2713aSLionel Sambuc if (!Canonical) 308*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 309*f4a2713aSLionel Sambuc VisitDecl(S->getDecl()); 310*f4a2713aSLionel Sambuc if (!Canonical) 311*f4a2713aSLionel Sambuc VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 312*f4a2713aSLionel Sambuc } 313*f4a2713aSLionel Sambuc 314*f4a2713aSLionel Sambuc void StmtProfiler::VisitPredefinedExpr(const PredefinedExpr *S) { 315*f4a2713aSLionel Sambuc VisitExpr(S); 316*f4a2713aSLionel Sambuc ID.AddInteger(S->getIdentType()); 317*f4a2713aSLionel Sambuc } 318*f4a2713aSLionel Sambuc 319*f4a2713aSLionel Sambuc void StmtProfiler::VisitIntegerLiteral(const IntegerLiteral *S) { 320*f4a2713aSLionel Sambuc VisitExpr(S); 321*f4a2713aSLionel Sambuc S->getValue().Profile(ID); 322*f4a2713aSLionel Sambuc } 323*f4a2713aSLionel Sambuc 324*f4a2713aSLionel Sambuc void StmtProfiler::VisitCharacterLiteral(const CharacterLiteral *S) { 325*f4a2713aSLionel Sambuc VisitExpr(S); 326*f4a2713aSLionel Sambuc ID.AddInteger(S->getKind()); 327*f4a2713aSLionel Sambuc ID.AddInteger(S->getValue()); 328*f4a2713aSLionel Sambuc } 329*f4a2713aSLionel Sambuc 330*f4a2713aSLionel Sambuc void StmtProfiler::VisitFloatingLiteral(const FloatingLiteral *S) { 331*f4a2713aSLionel Sambuc VisitExpr(S); 332*f4a2713aSLionel Sambuc S->getValue().Profile(ID); 333*f4a2713aSLionel Sambuc ID.AddBoolean(S->isExact()); 334*f4a2713aSLionel Sambuc } 335*f4a2713aSLionel Sambuc 336*f4a2713aSLionel Sambuc void StmtProfiler::VisitImaginaryLiteral(const ImaginaryLiteral *S) { 337*f4a2713aSLionel Sambuc VisitExpr(S); 338*f4a2713aSLionel Sambuc } 339*f4a2713aSLionel Sambuc 340*f4a2713aSLionel Sambuc void StmtProfiler::VisitStringLiteral(const StringLiteral *S) { 341*f4a2713aSLionel Sambuc VisitExpr(S); 342*f4a2713aSLionel Sambuc ID.AddString(S->getBytes()); 343*f4a2713aSLionel Sambuc ID.AddInteger(S->getKind()); 344*f4a2713aSLionel Sambuc } 345*f4a2713aSLionel Sambuc 346*f4a2713aSLionel Sambuc void StmtProfiler::VisitParenExpr(const ParenExpr *S) { 347*f4a2713aSLionel Sambuc VisitExpr(S); 348*f4a2713aSLionel Sambuc } 349*f4a2713aSLionel Sambuc 350*f4a2713aSLionel Sambuc void StmtProfiler::VisitParenListExpr(const ParenListExpr *S) { 351*f4a2713aSLionel Sambuc VisitExpr(S); 352*f4a2713aSLionel Sambuc } 353*f4a2713aSLionel Sambuc 354*f4a2713aSLionel Sambuc void StmtProfiler::VisitUnaryOperator(const UnaryOperator *S) { 355*f4a2713aSLionel Sambuc VisitExpr(S); 356*f4a2713aSLionel Sambuc ID.AddInteger(S->getOpcode()); 357*f4a2713aSLionel Sambuc } 358*f4a2713aSLionel Sambuc 359*f4a2713aSLionel Sambuc void StmtProfiler::VisitOffsetOfExpr(const OffsetOfExpr *S) { 360*f4a2713aSLionel Sambuc VisitType(S->getTypeSourceInfo()->getType()); 361*f4a2713aSLionel Sambuc unsigned n = S->getNumComponents(); 362*f4a2713aSLionel Sambuc for (unsigned i = 0; i < n; ++i) { 363*f4a2713aSLionel Sambuc const OffsetOfExpr::OffsetOfNode& ON = S->getComponent(i); 364*f4a2713aSLionel Sambuc ID.AddInteger(ON.getKind()); 365*f4a2713aSLionel Sambuc switch (ON.getKind()) { 366*f4a2713aSLionel Sambuc case OffsetOfExpr::OffsetOfNode::Array: 367*f4a2713aSLionel Sambuc // Expressions handled below. 368*f4a2713aSLionel Sambuc break; 369*f4a2713aSLionel Sambuc 370*f4a2713aSLionel Sambuc case OffsetOfExpr::OffsetOfNode::Field: 371*f4a2713aSLionel Sambuc VisitDecl(ON.getField()); 372*f4a2713aSLionel Sambuc break; 373*f4a2713aSLionel Sambuc 374*f4a2713aSLionel Sambuc case OffsetOfExpr::OffsetOfNode::Identifier: 375*f4a2713aSLionel Sambuc ID.AddPointer(ON.getFieldName()); 376*f4a2713aSLionel Sambuc break; 377*f4a2713aSLionel Sambuc 378*f4a2713aSLionel Sambuc case OffsetOfExpr::OffsetOfNode::Base: 379*f4a2713aSLionel Sambuc // These nodes are implicit, and therefore don't need profiling. 380*f4a2713aSLionel Sambuc break; 381*f4a2713aSLionel Sambuc } 382*f4a2713aSLionel Sambuc } 383*f4a2713aSLionel Sambuc 384*f4a2713aSLionel Sambuc VisitExpr(S); 385*f4a2713aSLionel Sambuc } 386*f4a2713aSLionel Sambuc 387*f4a2713aSLionel Sambuc void 388*f4a2713aSLionel Sambuc StmtProfiler::VisitUnaryExprOrTypeTraitExpr(const UnaryExprOrTypeTraitExpr *S) { 389*f4a2713aSLionel Sambuc VisitExpr(S); 390*f4a2713aSLionel Sambuc ID.AddInteger(S->getKind()); 391*f4a2713aSLionel Sambuc if (S->isArgumentType()) 392*f4a2713aSLionel Sambuc VisitType(S->getArgumentType()); 393*f4a2713aSLionel Sambuc } 394*f4a2713aSLionel Sambuc 395*f4a2713aSLionel Sambuc void StmtProfiler::VisitArraySubscriptExpr(const ArraySubscriptExpr *S) { 396*f4a2713aSLionel Sambuc VisitExpr(S); 397*f4a2713aSLionel Sambuc } 398*f4a2713aSLionel Sambuc 399*f4a2713aSLionel Sambuc void StmtProfiler::VisitCallExpr(const CallExpr *S) { 400*f4a2713aSLionel Sambuc VisitExpr(S); 401*f4a2713aSLionel Sambuc } 402*f4a2713aSLionel Sambuc 403*f4a2713aSLionel Sambuc void StmtProfiler::VisitMemberExpr(const MemberExpr *S) { 404*f4a2713aSLionel Sambuc VisitExpr(S); 405*f4a2713aSLionel Sambuc VisitDecl(S->getMemberDecl()); 406*f4a2713aSLionel Sambuc if (!Canonical) 407*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 408*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrow()); 409*f4a2713aSLionel Sambuc } 410*f4a2713aSLionel Sambuc 411*f4a2713aSLionel Sambuc void StmtProfiler::VisitCompoundLiteralExpr(const CompoundLiteralExpr *S) { 412*f4a2713aSLionel Sambuc VisitExpr(S); 413*f4a2713aSLionel Sambuc ID.AddBoolean(S->isFileScope()); 414*f4a2713aSLionel Sambuc } 415*f4a2713aSLionel Sambuc 416*f4a2713aSLionel Sambuc void StmtProfiler::VisitCastExpr(const CastExpr *S) { 417*f4a2713aSLionel Sambuc VisitExpr(S); 418*f4a2713aSLionel Sambuc } 419*f4a2713aSLionel Sambuc 420*f4a2713aSLionel Sambuc void StmtProfiler::VisitImplicitCastExpr(const ImplicitCastExpr *S) { 421*f4a2713aSLionel Sambuc VisitCastExpr(S); 422*f4a2713aSLionel Sambuc ID.AddInteger(S->getValueKind()); 423*f4a2713aSLionel Sambuc } 424*f4a2713aSLionel Sambuc 425*f4a2713aSLionel Sambuc void StmtProfiler::VisitExplicitCastExpr(const ExplicitCastExpr *S) { 426*f4a2713aSLionel Sambuc VisitCastExpr(S); 427*f4a2713aSLionel Sambuc VisitType(S->getTypeAsWritten()); 428*f4a2713aSLionel Sambuc } 429*f4a2713aSLionel Sambuc 430*f4a2713aSLionel Sambuc void StmtProfiler::VisitCStyleCastExpr(const CStyleCastExpr *S) { 431*f4a2713aSLionel Sambuc VisitExplicitCastExpr(S); 432*f4a2713aSLionel Sambuc } 433*f4a2713aSLionel Sambuc 434*f4a2713aSLionel Sambuc void StmtProfiler::VisitBinaryOperator(const BinaryOperator *S) { 435*f4a2713aSLionel Sambuc VisitExpr(S); 436*f4a2713aSLionel Sambuc ID.AddInteger(S->getOpcode()); 437*f4a2713aSLionel Sambuc } 438*f4a2713aSLionel Sambuc 439*f4a2713aSLionel Sambuc void 440*f4a2713aSLionel Sambuc StmtProfiler::VisitCompoundAssignOperator(const CompoundAssignOperator *S) { 441*f4a2713aSLionel Sambuc VisitBinaryOperator(S); 442*f4a2713aSLionel Sambuc } 443*f4a2713aSLionel Sambuc 444*f4a2713aSLionel Sambuc void StmtProfiler::VisitConditionalOperator(const ConditionalOperator *S) { 445*f4a2713aSLionel Sambuc VisitExpr(S); 446*f4a2713aSLionel Sambuc } 447*f4a2713aSLionel Sambuc 448*f4a2713aSLionel Sambuc void StmtProfiler::VisitBinaryConditionalOperator( 449*f4a2713aSLionel Sambuc const BinaryConditionalOperator *S) { 450*f4a2713aSLionel Sambuc VisitExpr(S); 451*f4a2713aSLionel Sambuc } 452*f4a2713aSLionel Sambuc 453*f4a2713aSLionel Sambuc void StmtProfiler::VisitAddrLabelExpr(const AddrLabelExpr *S) { 454*f4a2713aSLionel Sambuc VisitExpr(S); 455*f4a2713aSLionel Sambuc VisitDecl(S->getLabel()); 456*f4a2713aSLionel Sambuc } 457*f4a2713aSLionel Sambuc 458*f4a2713aSLionel Sambuc void StmtProfiler::VisitStmtExpr(const StmtExpr *S) { 459*f4a2713aSLionel Sambuc VisitExpr(S); 460*f4a2713aSLionel Sambuc } 461*f4a2713aSLionel Sambuc 462*f4a2713aSLionel Sambuc void StmtProfiler::VisitShuffleVectorExpr(const ShuffleVectorExpr *S) { 463*f4a2713aSLionel Sambuc VisitExpr(S); 464*f4a2713aSLionel Sambuc } 465*f4a2713aSLionel Sambuc 466*f4a2713aSLionel Sambuc void StmtProfiler::VisitConvertVectorExpr(const ConvertVectorExpr *S) { 467*f4a2713aSLionel Sambuc VisitExpr(S); 468*f4a2713aSLionel Sambuc } 469*f4a2713aSLionel Sambuc 470*f4a2713aSLionel Sambuc void StmtProfiler::VisitChooseExpr(const ChooseExpr *S) { 471*f4a2713aSLionel Sambuc VisitExpr(S); 472*f4a2713aSLionel Sambuc } 473*f4a2713aSLionel Sambuc 474*f4a2713aSLionel Sambuc void StmtProfiler::VisitGNUNullExpr(const GNUNullExpr *S) { 475*f4a2713aSLionel Sambuc VisitExpr(S); 476*f4a2713aSLionel Sambuc } 477*f4a2713aSLionel Sambuc 478*f4a2713aSLionel Sambuc void StmtProfiler::VisitVAArgExpr(const VAArgExpr *S) { 479*f4a2713aSLionel Sambuc VisitExpr(S); 480*f4a2713aSLionel Sambuc } 481*f4a2713aSLionel Sambuc 482*f4a2713aSLionel Sambuc void StmtProfiler::VisitInitListExpr(const InitListExpr *S) { 483*f4a2713aSLionel Sambuc if (S->getSyntacticForm()) { 484*f4a2713aSLionel Sambuc VisitInitListExpr(S->getSyntacticForm()); 485*f4a2713aSLionel Sambuc return; 486*f4a2713aSLionel Sambuc } 487*f4a2713aSLionel Sambuc 488*f4a2713aSLionel Sambuc VisitExpr(S); 489*f4a2713aSLionel Sambuc } 490*f4a2713aSLionel Sambuc 491*f4a2713aSLionel Sambuc void StmtProfiler::VisitDesignatedInitExpr(const DesignatedInitExpr *S) { 492*f4a2713aSLionel Sambuc VisitExpr(S); 493*f4a2713aSLionel Sambuc ID.AddBoolean(S->usesGNUSyntax()); 494*f4a2713aSLionel Sambuc for (DesignatedInitExpr::const_designators_iterator D = 495*f4a2713aSLionel Sambuc S->designators_begin(), DEnd = S->designators_end(); 496*f4a2713aSLionel Sambuc D != DEnd; ++D) { 497*f4a2713aSLionel Sambuc if (D->isFieldDesignator()) { 498*f4a2713aSLionel Sambuc ID.AddInteger(0); 499*f4a2713aSLionel Sambuc VisitName(D->getFieldName()); 500*f4a2713aSLionel Sambuc continue; 501*f4a2713aSLionel Sambuc } 502*f4a2713aSLionel Sambuc 503*f4a2713aSLionel Sambuc if (D->isArrayDesignator()) { 504*f4a2713aSLionel Sambuc ID.AddInteger(1); 505*f4a2713aSLionel Sambuc } else { 506*f4a2713aSLionel Sambuc assert(D->isArrayRangeDesignator()); 507*f4a2713aSLionel Sambuc ID.AddInteger(2); 508*f4a2713aSLionel Sambuc } 509*f4a2713aSLionel Sambuc ID.AddInteger(D->getFirstExprIndex()); 510*f4a2713aSLionel Sambuc } 511*f4a2713aSLionel Sambuc } 512*f4a2713aSLionel Sambuc 513*f4a2713aSLionel Sambuc void StmtProfiler::VisitImplicitValueInitExpr(const ImplicitValueInitExpr *S) { 514*f4a2713aSLionel Sambuc VisitExpr(S); 515*f4a2713aSLionel Sambuc } 516*f4a2713aSLionel Sambuc 517*f4a2713aSLionel Sambuc void StmtProfiler::VisitExtVectorElementExpr(const ExtVectorElementExpr *S) { 518*f4a2713aSLionel Sambuc VisitExpr(S); 519*f4a2713aSLionel Sambuc VisitName(&S->getAccessor()); 520*f4a2713aSLionel Sambuc } 521*f4a2713aSLionel Sambuc 522*f4a2713aSLionel Sambuc void StmtProfiler::VisitBlockExpr(const BlockExpr *S) { 523*f4a2713aSLionel Sambuc VisitExpr(S); 524*f4a2713aSLionel Sambuc VisitDecl(S->getBlockDecl()); 525*f4a2713aSLionel Sambuc } 526*f4a2713aSLionel Sambuc 527*f4a2713aSLionel Sambuc void StmtProfiler::VisitGenericSelectionExpr(const GenericSelectionExpr *S) { 528*f4a2713aSLionel Sambuc VisitExpr(S); 529*f4a2713aSLionel Sambuc for (unsigned i = 0; i != S->getNumAssocs(); ++i) { 530*f4a2713aSLionel Sambuc QualType T = S->getAssocType(i); 531*f4a2713aSLionel Sambuc if (T.isNull()) 532*f4a2713aSLionel Sambuc ID.AddPointer(0); 533*f4a2713aSLionel Sambuc else 534*f4a2713aSLionel Sambuc VisitType(T); 535*f4a2713aSLionel Sambuc VisitExpr(S->getAssocExpr(i)); 536*f4a2713aSLionel Sambuc } 537*f4a2713aSLionel Sambuc } 538*f4a2713aSLionel Sambuc 539*f4a2713aSLionel Sambuc void StmtProfiler::VisitPseudoObjectExpr(const PseudoObjectExpr *S) { 540*f4a2713aSLionel Sambuc VisitExpr(S); 541*f4a2713aSLionel Sambuc for (PseudoObjectExpr::const_semantics_iterator 542*f4a2713aSLionel Sambuc i = S->semantics_begin(), e = S->semantics_end(); i != e; ++i) 543*f4a2713aSLionel Sambuc // Normally, we would not profile the source expressions of OVEs. 544*f4a2713aSLionel Sambuc if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(*i)) 545*f4a2713aSLionel Sambuc Visit(OVE->getSourceExpr()); 546*f4a2713aSLionel Sambuc } 547*f4a2713aSLionel Sambuc 548*f4a2713aSLionel Sambuc void StmtProfiler::VisitAtomicExpr(const AtomicExpr *S) { 549*f4a2713aSLionel Sambuc VisitExpr(S); 550*f4a2713aSLionel Sambuc ID.AddInteger(S->getOp()); 551*f4a2713aSLionel Sambuc } 552*f4a2713aSLionel Sambuc 553*f4a2713aSLionel Sambuc static Stmt::StmtClass DecodeOperatorCall(const CXXOperatorCallExpr *S, 554*f4a2713aSLionel Sambuc UnaryOperatorKind &UnaryOp, 555*f4a2713aSLionel Sambuc BinaryOperatorKind &BinaryOp) { 556*f4a2713aSLionel Sambuc switch (S->getOperator()) { 557*f4a2713aSLionel Sambuc case OO_None: 558*f4a2713aSLionel Sambuc case OO_New: 559*f4a2713aSLionel Sambuc case OO_Delete: 560*f4a2713aSLionel Sambuc case OO_Array_New: 561*f4a2713aSLionel Sambuc case OO_Array_Delete: 562*f4a2713aSLionel Sambuc case OO_Arrow: 563*f4a2713aSLionel Sambuc case OO_Call: 564*f4a2713aSLionel Sambuc case OO_Conditional: 565*f4a2713aSLionel Sambuc case NUM_OVERLOADED_OPERATORS: 566*f4a2713aSLionel Sambuc llvm_unreachable("Invalid operator call kind"); 567*f4a2713aSLionel Sambuc 568*f4a2713aSLionel Sambuc case OO_Plus: 569*f4a2713aSLionel Sambuc if (S->getNumArgs() == 1) { 570*f4a2713aSLionel Sambuc UnaryOp = UO_Plus; 571*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 572*f4a2713aSLionel Sambuc } 573*f4a2713aSLionel Sambuc 574*f4a2713aSLionel Sambuc BinaryOp = BO_Add; 575*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 576*f4a2713aSLionel Sambuc 577*f4a2713aSLionel Sambuc case OO_Minus: 578*f4a2713aSLionel Sambuc if (S->getNumArgs() == 1) { 579*f4a2713aSLionel Sambuc UnaryOp = UO_Minus; 580*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 581*f4a2713aSLionel Sambuc } 582*f4a2713aSLionel Sambuc 583*f4a2713aSLionel Sambuc BinaryOp = BO_Sub; 584*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 585*f4a2713aSLionel Sambuc 586*f4a2713aSLionel Sambuc case OO_Star: 587*f4a2713aSLionel Sambuc if (S->getNumArgs() == 1) { 588*f4a2713aSLionel Sambuc UnaryOp = UO_Minus; 589*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 590*f4a2713aSLionel Sambuc } 591*f4a2713aSLionel Sambuc 592*f4a2713aSLionel Sambuc BinaryOp = BO_Sub; 593*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 594*f4a2713aSLionel Sambuc 595*f4a2713aSLionel Sambuc case OO_Slash: 596*f4a2713aSLionel Sambuc BinaryOp = BO_Div; 597*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 598*f4a2713aSLionel Sambuc 599*f4a2713aSLionel Sambuc case OO_Percent: 600*f4a2713aSLionel Sambuc BinaryOp = BO_Rem; 601*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 602*f4a2713aSLionel Sambuc 603*f4a2713aSLionel Sambuc case OO_Caret: 604*f4a2713aSLionel Sambuc BinaryOp = BO_Xor; 605*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 606*f4a2713aSLionel Sambuc 607*f4a2713aSLionel Sambuc case OO_Amp: 608*f4a2713aSLionel Sambuc if (S->getNumArgs() == 1) { 609*f4a2713aSLionel Sambuc UnaryOp = UO_AddrOf; 610*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 611*f4a2713aSLionel Sambuc } 612*f4a2713aSLionel Sambuc 613*f4a2713aSLionel Sambuc BinaryOp = BO_And; 614*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 615*f4a2713aSLionel Sambuc 616*f4a2713aSLionel Sambuc case OO_Pipe: 617*f4a2713aSLionel Sambuc BinaryOp = BO_Or; 618*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 619*f4a2713aSLionel Sambuc 620*f4a2713aSLionel Sambuc case OO_Tilde: 621*f4a2713aSLionel Sambuc UnaryOp = UO_Not; 622*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 623*f4a2713aSLionel Sambuc 624*f4a2713aSLionel Sambuc case OO_Exclaim: 625*f4a2713aSLionel Sambuc UnaryOp = UO_LNot; 626*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 627*f4a2713aSLionel Sambuc 628*f4a2713aSLionel Sambuc case OO_Equal: 629*f4a2713aSLionel Sambuc BinaryOp = BO_Assign; 630*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 631*f4a2713aSLionel Sambuc 632*f4a2713aSLionel Sambuc case OO_Less: 633*f4a2713aSLionel Sambuc BinaryOp = BO_LT; 634*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 635*f4a2713aSLionel Sambuc 636*f4a2713aSLionel Sambuc case OO_Greater: 637*f4a2713aSLionel Sambuc BinaryOp = BO_GT; 638*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 639*f4a2713aSLionel Sambuc 640*f4a2713aSLionel Sambuc case OO_PlusEqual: 641*f4a2713aSLionel Sambuc BinaryOp = BO_AddAssign; 642*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 643*f4a2713aSLionel Sambuc 644*f4a2713aSLionel Sambuc case OO_MinusEqual: 645*f4a2713aSLionel Sambuc BinaryOp = BO_SubAssign; 646*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 647*f4a2713aSLionel Sambuc 648*f4a2713aSLionel Sambuc case OO_StarEqual: 649*f4a2713aSLionel Sambuc BinaryOp = BO_MulAssign; 650*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 651*f4a2713aSLionel Sambuc 652*f4a2713aSLionel Sambuc case OO_SlashEqual: 653*f4a2713aSLionel Sambuc BinaryOp = BO_DivAssign; 654*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 655*f4a2713aSLionel Sambuc 656*f4a2713aSLionel Sambuc case OO_PercentEqual: 657*f4a2713aSLionel Sambuc BinaryOp = BO_RemAssign; 658*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 659*f4a2713aSLionel Sambuc 660*f4a2713aSLionel Sambuc case OO_CaretEqual: 661*f4a2713aSLionel Sambuc BinaryOp = BO_XorAssign; 662*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 663*f4a2713aSLionel Sambuc 664*f4a2713aSLionel Sambuc case OO_AmpEqual: 665*f4a2713aSLionel Sambuc BinaryOp = BO_AndAssign; 666*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 667*f4a2713aSLionel Sambuc 668*f4a2713aSLionel Sambuc case OO_PipeEqual: 669*f4a2713aSLionel Sambuc BinaryOp = BO_OrAssign; 670*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 671*f4a2713aSLionel Sambuc 672*f4a2713aSLionel Sambuc case OO_LessLess: 673*f4a2713aSLionel Sambuc BinaryOp = BO_Shl; 674*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 675*f4a2713aSLionel Sambuc 676*f4a2713aSLionel Sambuc case OO_GreaterGreater: 677*f4a2713aSLionel Sambuc BinaryOp = BO_Shr; 678*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 679*f4a2713aSLionel Sambuc 680*f4a2713aSLionel Sambuc case OO_LessLessEqual: 681*f4a2713aSLionel Sambuc BinaryOp = BO_ShlAssign; 682*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 683*f4a2713aSLionel Sambuc 684*f4a2713aSLionel Sambuc case OO_GreaterGreaterEqual: 685*f4a2713aSLionel Sambuc BinaryOp = BO_ShrAssign; 686*f4a2713aSLionel Sambuc return Stmt::CompoundAssignOperatorClass; 687*f4a2713aSLionel Sambuc 688*f4a2713aSLionel Sambuc case OO_EqualEqual: 689*f4a2713aSLionel Sambuc BinaryOp = BO_EQ; 690*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 691*f4a2713aSLionel Sambuc 692*f4a2713aSLionel Sambuc case OO_ExclaimEqual: 693*f4a2713aSLionel Sambuc BinaryOp = BO_NE; 694*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 695*f4a2713aSLionel Sambuc 696*f4a2713aSLionel Sambuc case OO_LessEqual: 697*f4a2713aSLionel Sambuc BinaryOp = BO_LE; 698*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 699*f4a2713aSLionel Sambuc 700*f4a2713aSLionel Sambuc case OO_GreaterEqual: 701*f4a2713aSLionel Sambuc BinaryOp = BO_GE; 702*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 703*f4a2713aSLionel Sambuc 704*f4a2713aSLionel Sambuc case OO_AmpAmp: 705*f4a2713aSLionel Sambuc BinaryOp = BO_LAnd; 706*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 707*f4a2713aSLionel Sambuc 708*f4a2713aSLionel Sambuc case OO_PipePipe: 709*f4a2713aSLionel Sambuc BinaryOp = BO_LOr; 710*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 711*f4a2713aSLionel Sambuc 712*f4a2713aSLionel Sambuc case OO_PlusPlus: 713*f4a2713aSLionel Sambuc UnaryOp = S->getNumArgs() == 1? UO_PreInc 714*f4a2713aSLionel Sambuc : UO_PostInc; 715*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 716*f4a2713aSLionel Sambuc 717*f4a2713aSLionel Sambuc case OO_MinusMinus: 718*f4a2713aSLionel Sambuc UnaryOp = S->getNumArgs() == 1? UO_PreDec 719*f4a2713aSLionel Sambuc : UO_PostDec; 720*f4a2713aSLionel Sambuc return Stmt::UnaryOperatorClass; 721*f4a2713aSLionel Sambuc 722*f4a2713aSLionel Sambuc case OO_Comma: 723*f4a2713aSLionel Sambuc BinaryOp = BO_Comma; 724*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 725*f4a2713aSLionel Sambuc 726*f4a2713aSLionel Sambuc 727*f4a2713aSLionel Sambuc case OO_ArrowStar: 728*f4a2713aSLionel Sambuc BinaryOp = BO_PtrMemI; 729*f4a2713aSLionel Sambuc return Stmt::BinaryOperatorClass; 730*f4a2713aSLionel Sambuc 731*f4a2713aSLionel Sambuc case OO_Subscript: 732*f4a2713aSLionel Sambuc return Stmt::ArraySubscriptExprClass; 733*f4a2713aSLionel Sambuc } 734*f4a2713aSLionel Sambuc 735*f4a2713aSLionel Sambuc llvm_unreachable("Invalid overloaded operator expression"); 736*f4a2713aSLionel Sambuc } 737*f4a2713aSLionel Sambuc 738*f4a2713aSLionel Sambuc 739*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXOperatorCallExpr(const CXXOperatorCallExpr *S) { 740*f4a2713aSLionel Sambuc if (S->isTypeDependent()) { 741*f4a2713aSLionel Sambuc // Type-dependent operator calls are profiled like their underlying 742*f4a2713aSLionel Sambuc // syntactic operator. 743*f4a2713aSLionel Sambuc UnaryOperatorKind UnaryOp = UO_Extension; 744*f4a2713aSLionel Sambuc BinaryOperatorKind BinaryOp = BO_Comma; 745*f4a2713aSLionel Sambuc Stmt::StmtClass SC = DecodeOperatorCall(S, UnaryOp, BinaryOp); 746*f4a2713aSLionel Sambuc 747*f4a2713aSLionel Sambuc ID.AddInteger(SC); 748*f4a2713aSLionel Sambuc for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) 749*f4a2713aSLionel Sambuc Visit(S->getArg(I)); 750*f4a2713aSLionel Sambuc if (SC == Stmt::UnaryOperatorClass) 751*f4a2713aSLionel Sambuc ID.AddInteger(UnaryOp); 752*f4a2713aSLionel Sambuc else if (SC == Stmt::BinaryOperatorClass || 753*f4a2713aSLionel Sambuc SC == Stmt::CompoundAssignOperatorClass) 754*f4a2713aSLionel Sambuc ID.AddInteger(BinaryOp); 755*f4a2713aSLionel Sambuc else 756*f4a2713aSLionel Sambuc assert(SC == Stmt::ArraySubscriptExprClass); 757*f4a2713aSLionel Sambuc 758*f4a2713aSLionel Sambuc return; 759*f4a2713aSLionel Sambuc } 760*f4a2713aSLionel Sambuc 761*f4a2713aSLionel Sambuc VisitCallExpr(S); 762*f4a2713aSLionel Sambuc ID.AddInteger(S->getOperator()); 763*f4a2713aSLionel Sambuc } 764*f4a2713aSLionel Sambuc 765*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXMemberCallExpr(const CXXMemberCallExpr *S) { 766*f4a2713aSLionel Sambuc VisitCallExpr(S); 767*f4a2713aSLionel Sambuc } 768*f4a2713aSLionel Sambuc 769*f4a2713aSLionel Sambuc void StmtProfiler::VisitCUDAKernelCallExpr(const CUDAKernelCallExpr *S) { 770*f4a2713aSLionel Sambuc VisitCallExpr(S); 771*f4a2713aSLionel Sambuc } 772*f4a2713aSLionel Sambuc 773*f4a2713aSLionel Sambuc void StmtProfiler::VisitAsTypeExpr(const AsTypeExpr *S) { 774*f4a2713aSLionel Sambuc VisitExpr(S); 775*f4a2713aSLionel Sambuc } 776*f4a2713aSLionel Sambuc 777*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXNamedCastExpr(const CXXNamedCastExpr *S) { 778*f4a2713aSLionel Sambuc VisitExplicitCastExpr(S); 779*f4a2713aSLionel Sambuc } 780*f4a2713aSLionel Sambuc 781*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXStaticCastExpr(const CXXStaticCastExpr *S) { 782*f4a2713aSLionel Sambuc VisitCXXNamedCastExpr(S); 783*f4a2713aSLionel Sambuc } 784*f4a2713aSLionel Sambuc 785*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXDynamicCastExpr(const CXXDynamicCastExpr *S) { 786*f4a2713aSLionel Sambuc VisitCXXNamedCastExpr(S); 787*f4a2713aSLionel Sambuc } 788*f4a2713aSLionel Sambuc 789*f4a2713aSLionel Sambuc void 790*f4a2713aSLionel Sambuc StmtProfiler::VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *S) { 791*f4a2713aSLionel Sambuc VisitCXXNamedCastExpr(S); 792*f4a2713aSLionel Sambuc } 793*f4a2713aSLionel Sambuc 794*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXConstCastExpr(const CXXConstCastExpr *S) { 795*f4a2713aSLionel Sambuc VisitCXXNamedCastExpr(S); 796*f4a2713aSLionel Sambuc } 797*f4a2713aSLionel Sambuc 798*f4a2713aSLionel Sambuc void StmtProfiler::VisitUserDefinedLiteral(const UserDefinedLiteral *S) { 799*f4a2713aSLionel Sambuc VisitCallExpr(S); 800*f4a2713aSLionel Sambuc } 801*f4a2713aSLionel Sambuc 802*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *S) { 803*f4a2713aSLionel Sambuc VisitExpr(S); 804*f4a2713aSLionel Sambuc ID.AddBoolean(S->getValue()); 805*f4a2713aSLionel Sambuc } 806*f4a2713aSLionel Sambuc 807*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *S) { 808*f4a2713aSLionel Sambuc VisitExpr(S); 809*f4a2713aSLionel Sambuc } 810*f4a2713aSLionel Sambuc 811*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXStdInitializerListExpr( 812*f4a2713aSLionel Sambuc const CXXStdInitializerListExpr *S) { 813*f4a2713aSLionel Sambuc VisitExpr(S); 814*f4a2713aSLionel Sambuc } 815*f4a2713aSLionel Sambuc 816*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXTypeidExpr(const CXXTypeidExpr *S) { 817*f4a2713aSLionel Sambuc VisitExpr(S); 818*f4a2713aSLionel Sambuc if (S->isTypeOperand()) 819*f4a2713aSLionel Sambuc VisitType(S->getTypeOperandSourceInfo()->getType()); 820*f4a2713aSLionel Sambuc } 821*f4a2713aSLionel Sambuc 822*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXUuidofExpr(const CXXUuidofExpr *S) { 823*f4a2713aSLionel Sambuc VisitExpr(S); 824*f4a2713aSLionel Sambuc if (S->isTypeOperand()) 825*f4a2713aSLionel Sambuc VisitType(S->getTypeOperandSourceInfo()->getType()); 826*f4a2713aSLionel Sambuc } 827*f4a2713aSLionel Sambuc 828*f4a2713aSLionel Sambuc void StmtProfiler::VisitMSPropertyRefExpr(const MSPropertyRefExpr *S) { 829*f4a2713aSLionel Sambuc VisitExpr(S); 830*f4a2713aSLionel Sambuc VisitDecl(S->getPropertyDecl()); 831*f4a2713aSLionel Sambuc } 832*f4a2713aSLionel Sambuc 833*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXThisExpr(const CXXThisExpr *S) { 834*f4a2713aSLionel Sambuc VisitExpr(S); 835*f4a2713aSLionel Sambuc ID.AddBoolean(S->isImplicit()); 836*f4a2713aSLionel Sambuc } 837*f4a2713aSLionel Sambuc 838*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXThrowExpr(const CXXThrowExpr *S) { 839*f4a2713aSLionel Sambuc VisitExpr(S); 840*f4a2713aSLionel Sambuc } 841*f4a2713aSLionel Sambuc 842*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXDefaultArgExpr(const CXXDefaultArgExpr *S) { 843*f4a2713aSLionel Sambuc VisitExpr(S); 844*f4a2713aSLionel Sambuc VisitDecl(S->getParam()); 845*f4a2713aSLionel Sambuc } 846*f4a2713aSLionel Sambuc 847*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXDefaultInitExpr(const CXXDefaultInitExpr *S) { 848*f4a2713aSLionel Sambuc VisitExpr(S); 849*f4a2713aSLionel Sambuc VisitDecl(S->getField()); 850*f4a2713aSLionel Sambuc } 851*f4a2713aSLionel Sambuc 852*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *S) { 853*f4a2713aSLionel Sambuc VisitExpr(S); 854*f4a2713aSLionel Sambuc VisitDecl( 855*f4a2713aSLionel Sambuc const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor())); 856*f4a2713aSLionel Sambuc } 857*f4a2713aSLionel Sambuc 858*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXConstructExpr(const CXXConstructExpr *S) { 859*f4a2713aSLionel Sambuc VisitExpr(S); 860*f4a2713aSLionel Sambuc VisitDecl(S->getConstructor()); 861*f4a2713aSLionel Sambuc ID.AddBoolean(S->isElidable()); 862*f4a2713aSLionel Sambuc } 863*f4a2713aSLionel Sambuc 864*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXFunctionalCastExpr(const CXXFunctionalCastExpr *S) { 865*f4a2713aSLionel Sambuc VisitExplicitCastExpr(S); 866*f4a2713aSLionel Sambuc } 867*f4a2713aSLionel Sambuc 868*f4a2713aSLionel Sambuc void 869*f4a2713aSLionel Sambuc StmtProfiler::VisitCXXTemporaryObjectExpr(const CXXTemporaryObjectExpr *S) { 870*f4a2713aSLionel Sambuc VisitCXXConstructExpr(S); 871*f4a2713aSLionel Sambuc } 872*f4a2713aSLionel Sambuc 873*f4a2713aSLionel Sambuc void 874*f4a2713aSLionel Sambuc StmtProfiler::VisitLambdaExpr(const LambdaExpr *S) { 875*f4a2713aSLionel Sambuc VisitExpr(S); 876*f4a2713aSLionel Sambuc for (LambdaExpr::capture_iterator C = S->explicit_capture_begin(), 877*f4a2713aSLionel Sambuc CEnd = S->explicit_capture_end(); 878*f4a2713aSLionel Sambuc C != CEnd; ++C) { 879*f4a2713aSLionel Sambuc ID.AddInteger(C->getCaptureKind()); 880*f4a2713aSLionel Sambuc switch (C->getCaptureKind()) { 881*f4a2713aSLionel Sambuc case LCK_This: 882*f4a2713aSLionel Sambuc break; 883*f4a2713aSLionel Sambuc case LCK_ByRef: 884*f4a2713aSLionel Sambuc case LCK_ByCopy: 885*f4a2713aSLionel Sambuc VisitDecl(C->getCapturedVar()); 886*f4a2713aSLionel Sambuc ID.AddBoolean(C->isPackExpansion()); 887*f4a2713aSLionel Sambuc break; 888*f4a2713aSLionel Sambuc } 889*f4a2713aSLionel Sambuc } 890*f4a2713aSLionel Sambuc // Note: If we actually needed to be able to match lambda 891*f4a2713aSLionel Sambuc // expressions, we would have to consider parameters and return type 892*f4a2713aSLionel Sambuc // here, among other things. 893*f4a2713aSLionel Sambuc VisitStmt(S->getBody()); 894*f4a2713aSLionel Sambuc } 895*f4a2713aSLionel Sambuc 896*f4a2713aSLionel Sambuc void 897*f4a2713aSLionel Sambuc StmtProfiler::VisitCXXScalarValueInitExpr(const CXXScalarValueInitExpr *S) { 898*f4a2713aSLionel Sambuc VisitExpr(S); 899*f4a2713aSLionel Sambuc } 900*f4a2713aSLionel Sambuc 901*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXDeleteExpr(const CXXDeleteExpr *S) { 902*f4a2713aSLionel Sambuc VisitExpr(S); 903*f4a2713aSLionel Sambuc ID.AddBoolean(S->isGlobalDelete()); 904*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrayForm()); 905*f4a2713aSLionel Sambuc VisitDecl(S->getOperatorDelete()); 906*f4a2713aSLionel Sambuc } 907*f4a2713aSLionel Sambuc 908*f4a2713aSLionel Sambuc 909*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXNewExpr(const CXXNewExpr *S) { 910*f4a2713aSLionel Sambuc VisitExpr(S); 911*f4a2713aSLionel Sambuc VisitType(S->getAllocatedType()); 912*f4a2713aSLionel Sambuc VisitDecl(S->getOperatorNew()); 913*f4a2713aSLionel Sambuc VisitDecl(S->getOperatorDelete()); 914*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArray()); 915*f4a2713aSLionel Sambuc ID.AddInteger(S->getNumPlacementArgs()); 916*f4a2713aSLionel Sambuc ID.AddBoolean(S->isGlobalNew()); 917*f4a2713aSLionel Sambuc ID.AddBoolean(S->isParenTypeId()); 918*f4a2713aSLionel Sambuc ID.AddInteger(S->getInitializationStyle()); 919*f4a2713aSLionel Sambuc } 920*f4a2713aSLionel Sambuc 921*f4a2713aSLionel Sambuc void 922*f4a2713aSLionel Sambuc StmtProfiler::VisitCXXPseudoDestructorExpr(const CXXPseudoDestructorExpr *S) { 923*f4a2713aSLionel Sambuc VisitExpr(S); 924*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrow()); 925*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 926*f4a2713aSLionel Sambuc ID.AddBoolean(S->getScopeTypeInfo() != 0); 927*f4a2713aSLionel Sambuc if (S->getScopeTypeInfo()) 928*f4a2713aSLionel Sambuc VisitType(S->getScopeTypeInfo()->getType()); 929*f4a2713aSLionel Sambuc ID.AddBoolean(S->getDestroyedTypeInfo() != 0); 930*f4a2713aSLionel Sambuc if (S->getDestroyedTypeInfo()) 931*f4a2713aSLionel Sambuc VisitType(S->getDestroyedType()); 932*f4a2713aSLionel Sambuc else 933*f4a2713aSLionel Sambuc ID.AddPointer(S->getDestroyedTypeIdentifier()); 934*f4a2713aSLionel Sambuc } 935*f4a2713aSLionel Sambuc 936*f4a2713aSLionel Sambuc void StmtProfiler::VisitOverloadExpr(const OverloadExpr *S) { 937*f4a2713aSLionel Sambuc VisitExpr(S); 938*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 939*f4a2713aSLionel Sambuc VisitName(S->getName()); 940*f4a2713aSLionel Sambuc ID.AddBoolean(S->hasExplicitTemplateArgs()); 941*f4a2713aSLionel Sambuc if (S->hasExplicitTemplateArgs()) 942*f4a2713aSLionel Sambuc VisitTemplateArguments(S->getExplicitTemplateArgs().getTemplateArgs(), 943*f4a2713aSLionel Sambuc S->getExplicitTemplateArgs().NumTemplateArgs); 944*f4a2713aSLionel Sambuc } 945*f4a2713aSLionel Sambuc 946*f4a2713aSLionel Sambuc void 947*f4a2713aSLionel Sambuc StmtProfiler::VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *S) { 948*f4a2713aSLionel Sambuc VisitOverloadExpr(S); 949*f4a2713aSLionel Sambuc } 950*f4a2713aSLionel Sambuc 951*f4a2713aSLionel Sambuc void StmtProfiler::VisitUnaryTypeTraitExpr(const UnaryTypeTraitExpr *S) { 952*f4a2713aSLionel Sambuc VisitExpr(S); 953*f4a2713aSLionel Sambuc ID.AddInteger(S->getTrait()); 954*f4a2713aSLionel Sambuc VisitType(S->getQueriedType()); 955*f4a2713aSLionel Sambuc } 956*f4a2713aSLionel Sambuc 957*f4a2713aSLionel Sambuc void StmtProfiler::VisitBinaryTypeTraitExpr(const BinaryTypeTraitExpr *S) { 958*f4a2713aSLionel Sambuc VisitExpr(S); 959*f4a2713aSLionel Sambuc ID.AddInteger(S->getTrait()); 960*f4a2713aSLionel Sambuc VisitType(S->getLhsType()); 961*f4a2713aSLionel Sambuc VisitType(S->getRhsType()); 962*f4a2713aSLionel Sambuc } 963*f4a2713aSLionel Sambuc 964*f4a2713aSLionel Sambuc void StmtProfiler::VisitTypeTraitExpr(const TypeTraitExpr *S) { 965*f4a2713aSLionel Sambuc VisitExpr(S); 966*f4a2713aSLionel Sambuc ID.AddInteger(S->getTrait()); 967*f4a2713aSLionel Sambuc ID.AddInteger(S->getNumArgs()); 968*f4a2713aSLionel Sambuc for (unsigned I = 0, N = S->getNumArgs(); I != N; ++I) 969*f4a2713aSLionel Sambuc VisitType(S->getArg(I)->getType()); 970*f4a2713aSLionel Sambuc } 971*f4a2713aSLionel Sambuc 972*f4a2713aSLionel Sambuc void StmtProfiler::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *S) { 973*f4a2713aSLionel Sambuc VisitExpr(S); 974*f4a2713aSLionel Sambuc ID.AddInteger(S->getTrait()); 975*f4a2713aSLionel Sambuc VisitType(S->getQueriedType()); 976*f4a2713aSLionel Sambuc } 977*f4a2713aSLionel Sambuc 978*f4a2713aSLionel Sambuc void StmtProfiler::VisitExpressionTraitExpr(const ExpressionTraitExpr *S) { 979*f4a2713aSLionel Sambuc VisitExpr(S); 980*f4a2713aSLionel Sambuc ID.AddInteger(S->getTrait()); 981*f4a2713aSLionel Sambuc VisitExpr(S->getQueriedExpression()); 982*f4a2713aSLionel Sambuc } 983*f4a2713aSLionel Sambuc 984*f4a2713aSLionel Sambuc void StmtProfiler::VisitDependentScopeDeclRefExpr( 985*f4a2713aSLionel Sambuc const DependentScopeDeclRefExpr *S) { 986*f4a2713aSLionel Sambuc VisitExpr(S); 987*f4a2713aSLionel Sambuc VisitName(S->getDeclName()); 988*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 989*f4a2713aSLionel Sambuc ID.AddBoolean(S->hasExplicitTemplateArgs()); 990*f4a2713aSLionel Sambuc if (S->hasExplicitTemplateArgs()) 991*f4a2713aSLionel Sambuc VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 992*f4a2713aSLionel Sambuc } 993*f4a2713aSLionel Sambuc 994*f4a2713aSLionel Sambuc void StmtProfiler::VisitExprWithCleanups(const ExprWithCleanups *S) { 995*f4a2713aSLionel Sambuc VisitExpr(S); 996*f4a2713aSLionel Sambuc } 997*f4a2713aSLionel Sambuc 998*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXUnresolvedConstructExpr( 999*f4a2713aSLionel Sambuc const CXXUnresolvedConstructExpr *S) { 1000*f4a2713aSLionel Sambuc VisitExpr(S); 1001*f4a2713aSLionel Sambuc VisitType(S->getTypeAsWritten()); 1002*f4a2713aSLionel Sambuc } 1003*f4a2713aSLionel Sambuc 1004*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXDependentScopeMemberExpr( 1005*f4a2713aSLionel Sambuc const CXXDependentScopeMemberExpr *S) { 1006*f4a2713aSLionel Sambuc ID.AddBoolean(S->isImplicitAccess()); 1007*f4a2713aSLionel Sambuc if (!S->isImplicitAccess()) { 1008*f4a2713aSLionel Sambuc VisitExpr(S); 1009*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrow()); 1010*f4a2713aSLionel Sambuc } 1011*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 1012*f4a2713aSLionel Sambuc VisitName(S->getMember()); 1013*f4a2713aSLionel Sambuc ID.AddBoolean(S->hasExplicitTemplateArgs()); 1014*f4a2713aSLionel Sambuc if (S->hasExplicitTemplateArgs()) 1015*f4a2713aSLionel Sambuc VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 1016*f4a2713aSLionel Sambuc } 1017*f4a2713aSLionel Sambuc 1018*f4a2713aSLionel Sambuc void StmtProfiler::VisitUnresolvedMemberExpr(const UnresolvedMemberExpr *S) { 1019*f4a2713aSLionel Sambuc ID.AddBoolean(S->isImplicitAccess()); 1020*f4a2713aSLionel Sambuc if (!S->isImplicitAccess()) { 1021*f4a2713aSLionel Sambuc VisitExpr(S); 1022*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrow()); 1023*f4a2713aSLionel Sambuc } 1024*f4a2713aSLionel Sambuc VisitNestedNameSpecifier(S->getQualifier()); 1025*f4a2713aSLionel Sambuc VisitName(S->getMemberName()); 1026*f4a2713aSLionel Sambuc ID.AddBoolean(S->hasExplicitTemplateArgs()); 1027*f4a2713aSLionel Sambuc if (S->hasExplicitTemplateArgs()) 1028*f4a2713aSLionel Sambuc VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs()); 1029*f4a2713aSLionel Sambuc } 1030*f4a2713aSLionel Sambuc 1031*f4a2713aSLionel Sambuc void StmtProfiler::VisitCXXNoexceptExpr(const CXXNoexceptExpr *S) { 1032*f4a2713aSLionel Sambuc VisitExpr(S); 1033*f4a2713aSLionel Sambuc } 1034*f4a2713aSLionel Sambuc 1035*f4a2713aSLionel Sambuc void StmtProfiler::VisitPackExpansionExpr(const PackExpansionExpr *S) { 1036*f4a2713aSLionel Sambuc VisitExpr(S); 1037*f4a2713aSLionel Sambuc } 1038*f4a2713aSLionel Sambuc 1039*f4a2713aSLionel Sambuc void StmtProfiler::VisitSizeOfPackExpr(const SizeOfPackExpr *S) { 1040*f4a2713aSLionel Sambuc VisitExpr(S); 1041*f4a2713aSLionel Sambuc VisitDecl(S->getPack()); 1042*f4a2713aSLionel Sambuc } 1043*f4a2713aSLionel Sambuc 1044*f4a2713aSLionel Sambuc void StmtProfiler::VisitSubstNonTypeTemplateParmPackExpr( 1045*f4a2713aSLionel Sambuc const SubstNonTypeTemplateParmPackExpr *S) { 1046*f4a2713aSLionel Sambuc VisitExpr(S); 1047*f4a2713aSLionel Sambuc VisitDecl(S->getParameterPack()); 1048*f4a2713aSLionel Sambuc VisitTemplateArgument(S->getArgumentPack()); 1049*f4a2713aSLionel Sambuc } 1050*f4a2713aSLionel Sambuc 1051*f4a2713aSLionel Sambuc void StmtProfiler::VisitSubstNonTypeTemplateParmExpr( 1052*f4a2713aSLionel Sambuc const SubstNonTypeTemplateParmExpr *E) { 1053*f4a2713aSLionel Sambuc // Profile exactly as the replacement expression. 1054*f4a2713aSLionel Sambuc Visit(E->getReplacement()); 1055*f4a2713aSLionel Sambuc } 1056*f4a2713aSLionel Sambuc 1057*f4a2713aSLionel Sambuc void StmtProfiler::VisitFunctionParmPackExpr(const FunctionParmPackExpr *S) { 1058*f4a2713aSLionel Sambuc VisitExpr(S); 1059*f4a2713aSLionel Sambuc VisitDecl(S->getParameterPack()); 1060*f4a2713aSLionel Sambuc ID.AddInteger(S->getNumExpansions()); 1061*f4a2713aSLionel Sambuc for (FunctionParmPackExpr::iterator I = S->begin(), E = S->end(); I != E; ++I) 1062*f4a2713aSLionel Sambuc VisitDecl(*I); 1063*f4a2713aSLionel Sambuc } 1064*f4a2713aSLionel Sambuc 1065*f4a2713aSLionel Sambuc void StmtProfiler::VisitMaterializeTemporaryExpr( 1066*f4a2713aSLionel Sambuc const MaterializeTemporaryExpr *S) { 1067*f4a2713aSLionel Sambuc VisitExpr(S); 1068*f4a2713aSLionel Sambuc } 1069*f4a2713aSLionel Sambuc 1070*f4a2713aSLionel Sambuc void StmtProfiler::VisitOpaqueValueExpr(const OpaqueValueExpr *E) { 1071*f4a2713aSLionel Sambuc VisitExpr(E); 1072*f4a2713aSLionel Sambuc } 1073*f4a2713aSLionel Sambuc 1074*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCStringLiteral(const ObjCStringLiteral *S) { 1075*f4a2713aSLionel Sambuc VisitExpr(S); 1076*f4a2713aSLionel Sambuc } 1077*f4a2713aSLionel Sambuc 1078*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCBoxedExpr(const ObjCBoxedExpr *E) { 1079*f4a2713aSLionel Sambuc VisitExpr(E); 1080*f4a2713aSLionel Sambuc } 1081*f4a2713aSLionel Sambuc 1082*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCArrayLiteral(const ObjCArrayLiteral *E) { 1083*f4a2713aSLionel Sambuc VisitExpr(E); 1084*f4a2713aSLionel Sambuc } 1085*f4a2713aSLionel Sambuc 1086*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E) { 1087*f4a2713aSLionel Sambuc VisitExpr(E); 1088*f4a2713aSLionel Sambuc } 1089*f4a2713aSLionel Sambuc 1090*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCEncodeExpr(const ObjCEncodeExpr *S) { 1091*f4a2713aSLionel Sambuc VisitExpr(S); 1092*f4a2713aSLionel Sambuc VisitType(S->getEncodedType()); 1093*f4a2713aSLionel Sambuc } 1094*f4a2713aSLionel Sambuc 1095*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCSelectorExpr(const ObjCSelectorExpr *S) { 1096*f4a2713aSLionel Sambuc VisitExpr(S); 1097*f4a2713aSLionel Sambuc VisitName(S->getSelector()); 1098*f4a2713aSLionel Sambuc } 1099*f4a2713aSLionel Sambuc 1100*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCProtocolExpr(const ObjCProtocolExpr *S) { 1101*f4a2713aSLionel Sambuc VisitExpr(S); 1102*f4a2713aSLionel Sambuc VisitDecl(S->getProtocol()); 1103*f4a2713aSLionel Sambuc } 1104*f4a2713aSLionel Sambuc 1105*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCIvarRefExpr(const ObjCIvarRefExpr *S) { 1106*f4a2713aSLionel Sambuc VisitExpr(S); 1107*f4a2713aSLionel Sambuc VisitDecl(S->getDecl()); 1108*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrow()); 1109*f4a2713aSLionel Sambuc ID.AddBoolean(S->isFreeIvar()); 1110*f4a2713aSLionel Sambuc } 1111*f4a2713aSLionel Sambuc 1112*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCPropertyRefExpr(const ObjCPropertyRefExpr *S) { 1113*f4a2713aSLionel Sambuc VisitExpr(S); 1114*f4a2713aSLionel Sambuc if (S->isImplicitProperty()) { 1115*f4a2713aSLionel Sambuc VisitDecl(S->getImplicitPropertyGetter()); 1116*f4a2713aSLionel Sambuc VisitDecl(S->getImplicitPropertySetter()); 1117*f4a2713aSLionel Sambuc } else { 1118*f4a2713aSLionel Sambuc VisitDecl(S->getExplicitProperty()); 1119*f4a2713aSLionel Sambuc } 1120*f4a2713aSLionel Sambuc if (S->isSuperReceiver()) { 1121*f4a2713aSLionel Sambuc ID.AddBoolean(S->isSuperReceiver()); 1122*f4a2713aSLionel Sambuc VisitType(S->getSuperReceiverType()); 1123*f4a2713aSLionel Sambuc } 1124*f4a2713aSLionel Sambuc } 1125*f4a2713aSLionel Sambuc 1126*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCSubscriptRefExpr(const ObjCSubscriptRefExpr *S) { 1127*f4a2713aSLionel Sambuc VisitExpr(S); 1128*f4a2713aSLionel Sambuc VisitDecl(S->getAtIndexMethodDecl()); 1129*f4a2713aSLionel Sambuc VisitDecl(S->setAtIndexMethodDecl()); 1130*f4a2713aSLionel Sambuc } 1131*f4a2713aSLionel Sambuc 1132*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCMessageExpr(const ObjCMessageExpr *S) { 1133*f4a2713aSLionel Sambuc VisitExpr(S); 1134*f4a2713aSLionel Sambuc VisitName(S->getSelector()); 1135*f4a2713aSLionel Sambuc VisitDecl(S->getMethodDecl()); 1136*f4a2713aSLionel Sambuc } 1137*f4a2713aSLionel Sambuc 1138*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCIsaExpr(const ObjCIsaExpr *S) { 1139*f4a2713aSLionel Sambuc VisitExpr(S); 1140*f4a2713aSLionel Sambuc ID.AddBoolean(S->isArrow()); 1141*f4a2713aSLionel Sambuc } 1142*f4a2713aSLionel Sambuc 1143*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCBoolLiteralExpr(const ObjCBoolLiteralExpr *S) { 1144*f4a2713aSLionel Sambuc VisitExpr(S); 1145*f4a2713aSLionel Sambuc ID.AddBoolean(S->getValue()); 1146*f4a2713aSLionel Sambuc } 1147*f4a2713aSLionel Sambuc 1148*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCIndirectCopyRestoreExpr( 1149*f4a2713aSLionel Sambuc const ObjCIndirectCopyRestoreExpr *S) { 1150*f4a2713aSLionel Sambuc VisitExpr(S); 1151*f4a2713aSLionel Sambuc ID.AddBoolean(S->shouldCopy()); 1152*f4a2713aSLionel Sambuc } 1153*f4a2713aSLionel Sambuc 1154*f4a2713aSLionel Sambuc void StmtProfiler::VisitObjCBridgedCastExpr(const ObjCBridgedCastExpr *S) { 1155*f4a2713aSLionel Sambuc VisitExplicitCastExpr(S); 1156*f4a2713aSLionel Sambuc ID.AddBoolean(S->getBridgeKind()); 1157*f4a2713aSLionel Sambuc } 1158*f4a2713aSLionel Sambuc 1159*f4a2713aSLionel Sambuc void StmtProfiler::VisitDecl(const Decl *D) { 1160*f4a2713aSLionel Sambuc ID.AddInteger(D? D->getKind() : 0); 1161*f4a2713aSLionel Sambuc 1162*f4a2713aSLionel Sambuc if (Canonical && D) { 1163*f4a2713aSLionel Sambuc if (const NonTypeTemplateParmDecl *NTTP = 1164*f4a2713aSLionel Sambuc dyn_cast<NonTypeTemplateParmDecl>(D)) { 1165*f4a2713aSLionel Sambuc ID.AddInteger(NTTP->getDepth()); 1166*f4a2713aSLionel Sambuc ID.AddInteger(NTTP->getIndex()); 1167*f4a2713aSLionel Sambuc ID.AddBoolean(NTTP->isParameterPack()); 1168*f4a2713aSLionel Sambuc VisitType(NTTP->getType()); 1169*f4a2713aSLionel Sambuc return; 1170*f4a2713aSLionel Sambuc } 1171*f4a2713aSLionel Sambuc 1172*f4a2713aSLionel Sambuc if (const ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) { 1173*f4a2713aSLionel Sambuc // The Itanium C++ ABI uses the type, scope depth, and scope 1174*f4a2713aSLionel Sambuc // index of a parameter when mangling expressions that involve 1175*f4a2713aSLionel Sambuc // function parameters, so we will use the parameter's type for 1176*f4a2713aSLionel Sambuc // establishing function parameter identity. That way, our 1177*f4a2713aSLionel Sambuc // definition of "equivalent" (per C++ [temp.over.link]) is at 1178*f4a2713aSLionel Sambuc // least as strong as the definition of "equivalent" used for 1179*f4a2713aSLionel Sambuc // name mangling. 1180*f4a2713aSLionel Sambuc VisitType(Parm->getType()); 1181*f4a2713aSLionel Sambuc ID.AddInteger(Parm->getFunctionScopeDepth()); 1182*f4a2713aSLionel Sambuc ID.AddInteger(Parm->getFunctionScopeIndex()); 1183*f4a2713aSLionel Sambuc return; 1184*f4a2713aSLionel Sambuc } 1185*f4a2713aSLionel Sambuc 1186*f4a2713aSLionel Sambuc if (const TemplateTypeParmDecl *TTP = 1187*f4a2713aSLionel Sambuc dyn_cast<TemplateTypeParmDecl>(D)) { 1188*f4a2713aSLionel Sambuc ID.AddInteger(TTP->getDepth()); 1189*f4a2713aSLionel Sambuc ID.AddInteger(TTP->getIndex()); 1190*f4a2713aSLionel Sambuc ID.AddBoolean(TTP->isParameterPack()); 1191*f4a2713aSLionel Sambuc return; 1192*f4a2713aSLionel Sambuc } 1193*f4a2713aSLionel Sambuc 1194*f4a2713aSLionel Sambuc if (const TemplateTemplateParmDecl *TTP = 1195*f4a2713aSLionel Sambuc dyn_cast<TemplateTemplateParmDecl>(D)) { 1196*f4a2713aSLionel Sambuc ID.AddInteger(TTP->getDepth()); 1197*f4a2713aSLionel Sambuc ID.AddInteger(TTP->getIndex()); 1198*f4a2713aSLionel Sambuc ID.AddBoolean(TTP->isParameterPack()); 1199*f4a2713aSLionel Sambuc return; 1200*f4a2713aSLionel Sambuc } 1201*f4a2713aSLionel Sambuc } 1202*f4a2713aSLionel Sambuc 1203*f4a2713aSLionel Sambuc ID.AddPointer(D? D->getCanonicalDecl() : 0); 1204*f4a2713aSLionel Sambuc } 1205*f4a2713aSLionel Sambuc 1206*f4a2713aSLionel Sambuc void StmtProfiler::VisitType(QualType T) { 1207*f4a2713aSLionel Sambuc if (Canonical) 1208*f4a2713aSLionel Sambuc T = Context.getCanonicalType(T); 1209*f4a2713aSLionel Sambuc 1210*f4a2713aSLionel Sambuc ID.AddPointer(T.getAsOpaquePtr()); 1211*f4a2713aSLionel Sambuc } 1212*f4a2713aSLionel Sambuc 1213*f4a2713aSLionel Sambuc void StmtProfiler::VisitName(DeclarationName Name) { 1214*f4a2713aSLionel Sambuc ID.AddPointer(Name.getAsOpaquePtr()); 1215*f4a2713aSLionel Sambuc } 1216*f4a2713aSLionel Sambuc 1217*f4a2713aSLionel Sambuc void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) { 1218*f4a2713aSLionel Sambuc if (Canonical) 1219*f4a2713aSLionel Sambuc NNS = Context.getCanonicalNestedNameSpecifier(NNS); 1220*f4a2713aSLionel Sambuc ID.AddPointer(NNS); 1221*f4a2713aSLionel Sambuc } 1222*f4a2713aSLionel Sambuc 1223*f4a2713aSLionel Sambuc void StmtProfiler::VisitTemplateName(TemplateName Name) { 1224*f4a2713aSLionel Sambuc if (Canonical) 1225*f4a2713aSLionel Sambuc Name = Context.getCanonicalTemplateName(Name); 1226*f4a2713aSLionel Sambuc 1227*f4a2713aSLionel Sambuc Name.Profile(ID); 1228*f4a2713aSLionel Sambuc } 1229*f4a2713aSLionel Sambuc 1230*f4a2713aSLionel Sambuc void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args, 1231*f4a2713aSLionel Sambuc unsigned NumArgs) { 1232*f4a2713aSLionel Sambuc ID.AddInteger(NumArgs); 1233*f4a2713aSLionel Sambuc for (unsigned I = 0; I != NumArgs; ++I) 1234*f4a2713aSLionel Sambuc VisitTemplateArgument(Args[I].getArgument()); 1235*f4a2713aSLionel Sambuc } 1236*f4a2713aSLionel Sambuc 1237*f4a2713aSLionel Sambuc void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) { 1238*f4a2713aSLionel Sambuc // Mostly repetitive with TemplateArgument::Profile! 1239*f4a2713aSLionel Sambuc ID.AddInteger(Arg.getKind()); 1240*f4a2713aSLionel Sambuc switch (Arg.getKind()) { 1241*f4a2713aSLionel Sambuc case TemplateArgument::Null: 1242*f4a2713aSLionel Sambuc break; 1243*f4a2713aSLionel Sambuc 1244*f4a2713aSLionel Sambuc case TemplateArgument::Type: 1245*f4a2713aSLionel Sambuc VisitType(Arg.getAsType()); 1246*f4a2713aSLionel Sambuc break; 1247*f4a2713aSLionel Sambuc 1248*f4a2713aSLionel Sambuc case TemplateArgument::Template: 1249*f4a2713aSLionel Sambuc case TemplateArgument::TemplateExpansion: 1250*f4a2713aSLionel Sambuc VisitTemplateName(Arg.getAsTemplateOrTemplatePattern()); 1251*f4a2713aSLionel Sambuc break; 1252*f4a2713aSLionel Sambuc 1253*f4a2713aSLionel Sambuc case TemplateArgument::Declaration: 1254*f4a2713aSLionel Sambuc VisitDecl(Arg.getAsDecl()); 1255*f4a2713aSLionel Sambuc break; 1256*f4a2713aSLionel Sambuc 1257*f4a2713aSLionel Sambuc case TemplateArgument::NullPtr: 1258*f4a2713aSLionel Sambuc VisitType(Arg.getNullPtrType()); 1259*f4a2713aSLionel Sambuc break; 1260*f4a2713aSLionel Sambuc 1261*f4a2713aSLionel Sambuc case TemplateArgument::Integral: 1262*f4a2713aSLionel Sambuc Arg.getAsIntegral().Profile(ID); 1263*f4a2713aSLionel Sambuc VisitType(Arg.getIntegralType()); 1264*f4a2713aSLionel Sambuc break; 1265*f4a2713aSLionel Sambuc 1266*f4a2713aSLionel Sambuc case TemplateArgument::Expression: 1267*f4a2713aSLionel Sambuc Visit(Arg.getAsExpr()); 1268*f4a2713aSLionel Sambuc break; 1269*f4a2713aSLionel Sambuc 1270*f4a2713aSLionel Sambuc case TemplateArgument::Pack: 1271*f4a2713aSLionel Sambuc const TemplateArgument *Pack = Arg.pack_begin(); 1272*f4a2713aSLionel Sambuc for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i) 1273*f4a2713aSLionel Sambuc VisitTemplateArgument(Pack[i]); 1274*f4a2713aSLionel Sambuc break; 1275*f4a2713aSLionel Sambuc } 1276*f4a2713aSLionel Sambuc } 1277*f4a2713aSLionel Sambuc 1278*f4a2713aSLionel Sambuc void Stmt::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, 1279*f4a2713aSLionel Sambuc bool Canonical) const { 1280*f4a2713aSLionel Sambuc StmtProfiler Profiler(ID, Context, Canonical); 1281*f4a2713aSLionel Sambuc Profiler.Visit(this); 1282*f4a2713aSLionel Sambuc } 1283