zcov: / lib/AST/StmtProfile.cpp


Files: 1 Branches Taken: 30.6% 22 / 72
Generated: 2010-02-10 01:31 Branches Executed: 50.0% 36 / 72
Line Coverage: 30.3% 154 / 509


Programs: 2 Runs 3018


       1                 : //===---- StmtProfile.cpp - Profile implementation for Stmt ASTs ----------===//
       2                 : //
       3                 : //                     The LLVM Compiler Infrastructure
       4                 : //
       5                 : // This file is distributed under the University of Illinois Open Source
       6                 : // License. See LICENSE.TXT for details.
       7                 : //
       8                 : //===----------------------------------------------------------------------===//
       9                 : //
      10                 : // This file implements the Stmt::Profile method, which builds a unique bit
      11                 : // representation that identifies a statement/expression.
      12                 : //
      13                 : //===----------------------------------------------------------------------===//
      14                 : #include "clang/AST/ASTContext.h"
      15                 : #include "clang/AST/DeclCXX.h"
      16                 : #include "clang/AST/DeclObjC.h"
      17                 : #include "clang/AST/DeclTemplate.h"
      18                 : #include "clang/AST/Expr.h"
      19                 : #include "clang/AST/ExprCXX.h"
      20                 : #include "clang/AST/ExprObjC.h"
      21                 : #include "clang/AST/StmtVisitor.h"
      22                 : #include "llvm/ADT/FoldingSet.h"
      23                 : using namespace clang;
      24                 : 
      25                 : namespace {
      26                 :   class StmtProfiler : public StmtVisitor<StmtProfiler> {
      27                 :     llvm::FoldingSetNodeID &ID;
      28                 :     ASTContext &Context;
      29                 :     bool Canonical;
      30                 : 
      31                 :   public:
      32                 :     StmtProfiler(llvm::FoldingSetNodeID &ID, ASTContext &Context,
      33              290:                  bool Canonical)
      34              290:       : ID(ID), Context(Context), Canonical(Canonical) { }
      35                 : 
      36                 :     void VisitStmt(Stmt *S);
      37                 : 
      38                 : #define STMT(Node, Base) void Visit##Node(Node *S);
      39                 : #include "clang/AST/StmtNodes.def"
      40                 : 
      41                 :     /// \brief Visit a declaration that is referenced within an expression
      42                 :     /// or statement.
      43                 :     void VisitDecl(Decl *D);
      44                 : 
      45                 :     /// \brief Visit a type that is referenced within an expression or
      46                 :     /// statement.
      47                 :     void VisitType(QualType T);
      48                 : 
      49                 :     /// \brief Visit a name that occurs within an expression or statement.
      50                 :     void VisitName(DeclarationName Name);
      51                 : 
      52                 :     /// \brief Visit a nested-name-specifier that occurs within an expression
      53                 :     /// or statement.
      54                 :     void VisitNestedNameSpecifier(NestedNameSpecifier *NNS);
      55                 : 
      56                 :     /// \brief Visit a template name that occurs within an expression or
      57                 :     /// statement.
      58                 :     void VisitTemplateName(TemplateName Name);
      59                 : 
      60                 :     /// \brief Visit template arguments that occur within an expression or
      61                 :     /// statement.
      62                 :     void VisitTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs);
      63                 : 
      64                 :     /// \brief Visit a single template argument.
      65                 :     void VisitTemplateArgument(const TemplateArgument &Arg);
      66                 :   };
      67                 : }
      68                 : 
      69              535: void StmtProfiler::VisitStmt(Stmt *S) {
      70              535:   ID.AddInteger(S->getStmtClass());
                      246: branch 4 taken
                      535: branch 5 taken
      71              781:   for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
      72                 :        C != CEnd; ++C)
      73              246:     Visit(*C);
      74              535: }
      75                 : 
      76                0: void StmtProfiler::VisitDeclStmt(DeclStmt *S) {
      77                0:   VisitStmt(S);
                        0: branch 2 not taken
                        0: branch 3 not taken
      78                0:   for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
      79                 :        D != DEnd; ++D)
      80                0:     VisitDecl(*D);
      81                0: }
      82                 : 
      83                0: void StmtProfiler::VisitNullStmt(NullStmt *S) {
      84                0:   VisitStmt(S);
      85                0: }
      86                 : 
      87                0: void StmtProfiler::VisitCompoundStmt(CompoundStmt *S) {
      88                0:   VisitStmt(S);
      89                0: }
      90                 : 
      91                0: void StmtProfiler::VisitSwitchCase(SwitchCase *S) {
      92                0:   VisitStmt(S);
      93                0: }
      94                 : 
      95                0: void StmtProfiler::VisitCaseStmt(CaseStmt *S) {
      96                0:   VisitStmt(S);
      97                0: }
      98                 : 
      99                0: void StmtProfiler::VisitDefaultStmt(DefaultStmt *S) {
     100                0:   VisitStmt(S);
     101                0: }
     102                 : 
     103                0: void StmtProfiler::VisitLabelStmt(LabelStmt *S) {
     104                0:   VisitStmt(S);
     105                0:   VisitName(S->getID());
     106                0: }
     107                 : 
     108                0: void StmtProfiler::VisitIfStmt(IfStmt *S) {
     109                0:   VisitStmt(S);
     110                0:   VisitDecl(S->getConditionVariable());
     111                0: }
     112                 : 
     113                0: void StmtProfiler::VisitSwitchStmt(SwitchStmt *S) {
     114                0:   VisitStmt(S);
     115                0:   VisitDecl(S->getConditionVariable());
     116                0: }
     117                 : 
     118                0: void StmtProfiler::VisitWhileStmt(WhileStmt *S) {
     119                0:   VisitStmt(S);
     120                0:   VisitDecl(S->getConditionVariable());
     121                0: }
     122                 : 
     123                0: void StmtProfiler::VisitDoStmt(DoStmt *S) {
     124                0:   VisitStmt(S);
     125                0: }
     126                 : 
     127                0: void StmtProfiler::VisitForStmt(ForStmt *S) {
     128                0:   VisitStmt(S);
     129                0: }
     130                 : 
     131                0: void StmtProfiler::VisitGotoStmt(GotoStmt *S) {
     132                0:   VisitStmt(S);
     133                0:   VisitName(S->getLabel()->getID());
     134                0: }
     135                 : 
     136                0: void StmtProfiler::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
     137                0:   VisitStmt(S);
     138                0: }
     139                 : 
     140                0: void StmtProfiler::VisitContinueStmt(ContinueStmt *S) {
     141                0:   VisitStmt(S);
     142                0: }
     143                 : 
     144                0: void StmtProfiler::VisitBreakStmt(BreakStmt *S) {
     145                0:   VisitStmt(S);
     146                0: }
     147                 : 
     148                0: void StmtProfiler::VisitReturnStmt(ReturnStmt *S) {
     149                0:   VisitStmt(S);
     150                0: }
     151                 : 
     152                0: void StmtProfiler::VisitAsmStmt(AsmStmt *S) {
     153                0:   VisitStmt(S);
     154                0:   ID.AddBoolean(S->isVolatile());
     155                0:   ID.AddBoolean(S->isSimple());
     156                0:   VisitStringLiteral(S->getAsmString());
     157                0:   ID.AddInteger(S->getNumOutputs());
                        0: branch 1 not taken
                        0: branch 2 not taken
     158                0:   for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
     159                0:     ID.AddString(S->getOutputName(I));
     160                0:     VisitStringLiteral(S->getOutputConstraintLiteral(I));
     161                 :   }
     162                0:   ID.AddInteger(S->getNumInputs());
                        0: branch 1 not taken
                        0: branch 2 not taken
     163                0:   for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
     164                0:     ID.AddString(S->getInputName(I));
     165                0:     VisitStringLiteral(S->getInputConstraintLiteral(I));
     166                 :   }
     167                0:   ID.AddInteger(S->getNumClobbers());
                        0: branch 1 not taken
                        0: branch 2 not taken
     168                0:   for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
     169                0:     VisitStringLiteral(S->getClobber(I));
     170                0: }
     171                 : 
     172                0: void StmtProfiler::VisitCXXCatchStmt(CXXCatchStmt *S) {
     173                0:   VisitStmt(S);
     174                0:   VisitType(S->getCaughtType());
     175                0: }
     176                 : 
     177                0: void StmtProfiler::VisitCXXTryStmt(CXXTryStmt *S) {
     178                0:   VisitStmt(S);
     179                0: }
     180                 : 
     181                0: void StmtProfiler::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
     182                0:   VisitStmt(S);
     183                0: }
     184                 : 
     185                0: void StmtProfiler::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
     186                0:   VisitStmt(S);
     187                0:   ID.AddBoolean(S->hasEllipsis());
                        0: branch 1 not taken
                        0: branch 2 not taken
     188                0:   if (S->getCatchParamDecl())
     189                0:     VisitType(S->getCatchParamDecl()->getType());
     190                0: }
     191                 : 
     192                0: void StmtProfiler::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
     193                0:   VisitStmt(S);
     194                0: }
     195                 : 
     196                0: void StmtProfiler::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
     197                0:   VisitStmt(S);
     198                0: }
     199                 : 
     200                0: void StmtProfiler::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
     201                0:   VisitStmt(S);
     202                0: }
     203                 : 
     204                0: void StmtProfiler::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
     205                0:   VisitStmt(S);
     206                0: }
     207                 : 
     208              535: void StmtProfiler::VisitExpr(Expr *S) {
     209              535:   VisitStmt(S);
     210              535: }
     211                 : 
     212              278: void StmtProfiler::VisitDeclRefExpr(DeclRefExpr *S) {
     213              278:   VisitExpr(S);
     214              278:   VisitNestedNameSpecifier(S->getQualifier());
     215              278:   VisitDecl(S->getDecl());
     216              278:   VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
     217              278: }
     218                 : 
     219                0: void StmtProfiler::VisitPredefinedExpr(PredefinedExpr *S) {
     220                0:   VisitExpr(S);
     221                0:   ID.AddInteger(S->getIdentType());
     222                0: }
     223                 : 
     224               37: void StmtProfiler::VisitIntegerLiteral(IntegerLiteral *S) {
     225               37:   VisitExpr(S);
     226               37:   S->getValue().Profile(ID);
     227               37: }
     228                 : 
     229                0: void StmtProfiler::VisitCharacterLiteral(CharacterLiteral *S) {
     230                0:   VisitExpr(S);
     231                0:   ID.AddBoolean(S->isWide());
     232                0:   ID.AddInteger(S->getValue());
     233                0: }
     234                 : 
     235                2: void StmtProfiler::VisitFloatingLiteral(FloatingLiteral *S) {
     236                2:   VisitExpr(S);
     237                2:   S->getValue().Profile(ID);
     238                2:   ID.AddBoolean(S->isExact());
     239                2: }
     240                 : 
     241                0: void StmtProfiler::VisitImaginaryLiteral(ImaginaryLiteral *S) {
     242                0:   VisitExpr(S);
     243                0: }
     244                 : 
     245                0: void StmtProfiler::VisitStringLiteral(StringLiteral *S) {
     246                0:   VisitExpr(S);
     247                0:   ID.AddString(S->getString());
     248                0:   ID.AddBoolean(S->isWide());
     249                0: }
     250                 : 
     251               30: void StmtProfiler::VisitParenExpr(ParenExpr *S) {
     252               30:   VisitExpr(S);
     253               30: }
     254                 : 
     255                0: void StmtProfiler::VisitParenListExpr(ParenListExpr *S) {
     256                0:   VisitExpr(S);
     257                0: }
     258                 : 
     259               17: void StmtProfiler::VisitUnaryOperator(UnaryOperator *S) {
     260               17:   VisitExpr(S);
     261               17:   ID.AddInteger(S->getOpcode());
     262               17: }
     263                 : 
     264               24: void StmtProfiler::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr *S) {
     265               24:   VisitExpr(S);
     266               24:   ID.AddBoolean(S->isSizeOf());
                       12: branch 1 taken
                       12: branch 2 taken
     267               24:   if (S->isArgumentType())
     268               12:     VisitType(S->getArgumentType());
     269               24: }
     270                 : 
     271                0: void StmtProfiler::VisitArraySubscriptExpr(ArraySubscriptExpr *S) {
     272                0:   VisitExpr(S);
     273                0: }
     274                 : 
     275               22: void StmtProfiler::VisitCallExpr(CallExpr *S) {
     276               22:   VisitExpr(S);
     277               22: }
     278                 : 
     279                2: void StmtProfiler::VisitMemberExpr(MemberExpr *S) {
     280                2:   VisitExpr(S);
     281                2:   VisitDecl(S->getMemberDecl());
     282                2:   VisitNestedNameSpecifier(S->getQualifier());
     283                2:   ID.AddBoolean(S->isArrow());
     284                2: }
     285                 : 
     286                0: void StmtProfiler::VisitCompoundLiteralExpr(CompoundLiteralExpr *S) {
     287                0:   VisitExpr(S);
     288                0:   ID.AddBoolean(S->isFileScope());
     289                0: }
     290                 : 
     291               33: void StmtProfiler::VisitCastExpr(CastExpr *S) {
     292               33:   VisitExpr(S);
     293               33: }
     294                 : 
     295               30: void StmtProfiler::VisitImplicitCastExpr(ImplicitCastExpr *S) {
     296               30:   VisitCastExpr(S);
     297               30:   ID.AddBoolean(S->isLvalueCast());
     298               30: }
     299                 : 
     300                3: void StmtProfiler::VisitExplicitCastExpr(ExplicitCastExpr *S) {
     301                3:   VisitCastExpr(S);
     302                3:   VisitType(S->getTypeAsWritten());
     303                3: }
     304                 : 
     305                1: void StmtProfiler::VisitCStyleCastExpr(CStyleCastExpr *S) {
     306                1:   VisitExplicitCastExpr(S);
     307                1: }
     308                 : 
     309               33: void StmtProfiler::VisitBinaryOperator(BinaryOperator *S) {
     310               33:   VisitExpr(S);
     311               33:   ID.AddInteger(S->getOpcode());
     312               33: }
     313                 : 
     314                0: void StmtProfiler::VisitCompoundAssignOperator(CompoundAssignOperator *S) {
     315                0:   VisitBinaryOperator(S);
     316                0: }
     317                 : 
     318               12: void StmtProfiler::VisitConditionalOperator(ConditionalOperator *S) {
     319               12:   VisitExpr(S);
     320               12: }
     321                 : 
     322                0: void StmtProfiler::VisitAddrLabelExpr(AddrLabelExpr *S) {
     323                0:   VisitExpr(S);
     324                0:   VisitName(S->getLabel()->getID());
     325                0: }
     326                 : 
     327                0: void StmtProfiler::VisitStmtExpr(StmtExpr *S) {
     328                0:   VisitExpr(S);
     329                0: }
     330                 : 
     331                0: void StmtProfiler::VisitTypesCompatibleExpr(TypesCompatibleExpr *S) {
     332                0:   VisitExpr(S);
     333                0:   VisitType(S->getArgType1());
     334                0:   VisitType(S->getArgType2());
     335                0: }
     336                 : 
     337                0: void StmtProfiler::VisitShuffleVectorExpr(ShuffleVectorExpr *S) {
     338                0:   VisitExpr(S);
     339                0: }
     340                 : 
     341                0: void StmtProfiler::VisitChooseExpr(ChooseExpr *S) {
     342                0:   VisitExpr(S);
     343                0: }
     344                 : 
     345                0: void StmtProfiler::VisitGNUNullExpr(GNUNullExpr *S) {
     346                0:   VisitExpr(S);
     347                0: }
     348                 : 
     349                0: void StmtProfiler::VisitVAArgExpr(VAArgExpr *S) {
     350                0:   VisitExpr(S);
     351                0: }
     352                 : 
     353                0: void StmtProfiler::VisitInitListExpr(InitListExpr *S) {
                        0: branch 1 not taken
                        0: branch 2 not taken
     354                0:   if (S->getSyntacticForm()) {
     355                0:     VisitInitListExpr(S->getSyntacticForm());
     356                0:     return;
     357                 :   }
     358                 : 
     359                0:   VisitExpr(S);
     360                 : }
     361                 : 
     362                0: void StmtProfiler::VisitDesignatedInitExpr(DesignatedInitExpr *S) {
     363                0:   VisitExpr(S);
     364                0:   ID.AddBoolean(S->usesGNUSyntax());
                        0: branch 1 not taken
                        0: branch 2 not taken
     365                0:   for (DesignatedInitExpr::designators_iterator D = S->designators_begin(),
     366                0:                                              DEnd = S->designators_end();
     367                 :        D != DEnd; ++D) {
                        0: branch 1 not taken
                        0: branch 2 not taken
     368                0:     if (D->isFieldDesignator()) {
     369                0:       ID.AddInteger(0);
     370                0:       VisitName(D->getFieldName());
     371                0:       continue;
     372                 :     }
     373                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     374                0:     if (D->isArrayDesignator()) {
     375                0:       ID.AddInteger(1);
     376                 :     } else {
                        0: branch 1 not taken
                        0: branch 2 not taken
     377                0:       assert(D->isArrayRangeDesignator());
     378                0:       ID.AddInteger(2);
     379                 :     }
     380                0:     ID.AddInteger(D->getFirstExprIndex());
     381                 :   }
     382                0: }
     383                 : 
     384                0: void StmtProfiler::VisitImplicitValueInitExpr(ImplicitValueInitExpr *S) {
     385                0:   VisitExpr(S);
     386                0: }
     387                 : 
     388                0: void StmtProfiler::VisitExtVectorElementExpr(ExtVectorElementExpr *S) {
     389                0:   VisitExpr(S);
     390                0:   VisitName(&S->getAccessor());
     391                0: }
     392                 : 
     393                0: void StmtProfiler::VisitBlockExpr(BlockExpr *S) {
     394                0:   VisitExpr(S);
     395                0:   VisitDecl(S->getBlockDecl());
     396                0: }
     397                 : 
     398                0: void StmtProfiler::VisitBlockDeclRefExpr(BlockDeclRefExpr *S) {
     399                0:   VisitExpr(S);
     400                0:   VisitDecl(S->getDecl());
     401                0:   ID.AddBoolean(S->isByRef());
     402                0:   ID.AddBoolean(S->isConstQualAdded());
     403                0: }
     404                 : 
     405                7: void StmtProfiler::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
     406                7:   VisitCallExpr(S);
     407                7:   ID.AddInteger(S->getOperator());
     408                7: }
     409                 : 
     410                0: void StmtProfiler::VisitCXXMemberCallExpr(CXXMemberCallExpr *S) {
     411                0:   VisitCallExpr(S);
     412                0: }
     413                 : 
     414                1: void StmtProfiler::VisitCXXNamedCastExpr(CXXNamedCastExpr *S) {
     415                1:   VisitExplicitCastExpr(S);
     416                1: }
     417                 : 
     418                1: void StmtProfiler::VisitCXXStaticCastExpr(CXXStaticCastExpr *S) {
     419                1:   VisitCXXNamedCastExpr(S);
     420                1: }
     421                 : 
     422                0: void StmtProfiler::VisitCXXDynamicCastExpr(CXXDynamicCastExpr *S) {
     423                0:   VisitCXXNamedCastExpr(S);
     424                0: }
     425                 : 
     426                0: void StmtProfiler::VisitCXXReinterpretCastExpr(CXXReinterpretCastExpr *S) {
     427                0:   VisitCXXNamedCastExpr(S);
     428                0: }
     429                 : 
     430                0: void StmtProfiler::VisitCXXConstCastExpr(CXXConstCastExpr *S) {
     431                0:   VisitCXXNamedCastExpr(S);
     432                0: }
     433                 : 
     434                0: void StmtProfiler::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *S) {
     435                0:   VisitExpr(S);
     436                0:   ID.AddBoolean(S->getValue());
     437                0: }
     438                 : 
     439                0: void StmtProfiler::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *S) {
     440                0:   VisitExpr(S);
     441                0: }
     442                 : 
     443                0: void StmtProfiler::VisitCXXTypeidExpr(CXXTypeidExpr *S) {
     444                0:   VisitExpr(S);
                        0: branch 1 not taken
                        0: branch 2 not taken
     445                0:   if (S->isTypeOperand())
     446                0:     VisitType(S->getTypeOperand());
     447                0: }
     448                 : 
     449                1: void StmtProfiler::VisitCXXThisExpr(CXXThisExpr *S) {
     450                1:   VisitExpr(S);
     451                1: }
     452                 : 
     453                0: void StmtProfiler::VisitCXXThrowExpr(CXXThrowExpr *S) {
     454                0:   VisitExpr(S);
     455                0: }
     456                 : 
     457                0: void StmtProfiler::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *S) {
     458                0:   VisitExpr(S);
     459                0:   VisitDecl(S->getParam());
     460                0: }
     461                 : 
     462                0: void StmtProfiler::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *S) {
     463                0:   VisitExpr(S);
     464                 :   VisitDecl(
     465                0:          const_cast<CXXDestructorDecl *>(S->getTemporary()->getDestructor()));
     466                0: }
     467                 : 
     468                0: void StmtProfiler::VisitCXXBindReferenceExpr(CXXBindReferenceExpr *S) {
     469                0:   VisitExpr(S);
     470                0: }
     471                 : 
     472                0: void StmtProfiler::VisitCXXConstructExpr(CXXConstructExpr *S) {
     473                0:   VisitExpr(S);
     474                0:   VisitDecl(S->getConstructor());
     475                0:   ID.AddBoolean(S->isElidable());
     476                0: }
     477                 : 
     478                1: void StmtProfiler::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *S) {
     479                1:   VisitExplicitCastExpr(S);
     480                1: }
     481                 : 
     482                0: void StmtProfiler::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *S) {
     483                0:   VisitCXXConstructExpr(S);
     484                0: }
     485                 : 
     486                0: void StmtProfiler::VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *S) {
     487                0:   VisitExpr(S);
     488                0: }
     489                 : 
     490                0: void StmtProfiler::VisitCXXDeleteExpr(CXXDeleteExpr *S) {
     491                0:   VisitExpr(S);
     492                0:   ID.AddBoolean(S->isGlobalDelete());
     493                0:   ID.AddBoolean(S->isArrayForm());
     494                0:   VisitDecl(S->getOperatorDelete());
     495                0: }
     496                 : 
     497                 : 
     498                0: void StmtProfiler::VisitCXXNewExpr(CXXNewExpr *S) {
     499                0:   VisitExpr(S);
     500                0:   VisitType(S->getAllocatedType());
     501                0:   VisitDecl(S->getOperatorNew());
     502                0:   VisitDecl(S->getOperatorDelete());
     503                0:   VisitDecl(S->getConstructor());
     504                0:   ID.AddBoolean(S->isArray());
     505                0:   ID.AddInteger(S->getNumPlacementArgs());
     506                0:   ID.AddBoolean(S->isGlobalNew());
     507                0:   ID.AddBoolean(S->isParenTypeId());
     508                0:   ID.AddBoolean(S->hasInitializer());
     509                0:   ID.AddInteger(S->getNumConstructorArgs());
     510                0: }
     511                 : 
     512                0: void StmtProfiler::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *S) {
     513                0:   VisitExpr(S);
     514                0:   ID.AddBoolean(S->isArrow());
     515                0:   VisitNestedNameSpecifier(S->getQualifier());
     516                0:   VisitType(S->getDestroyedType());
     517                0: }
     518                 : 
     519                 : void
     520               20: StmtProfiler::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *S) {
     521               20:   VisitExpr(S);
     522               20:   VisitNestedNameSpecifier(S->getQualifier());
     523               20:   VisitName(S->getName());
     524               20:   ID.AddBoolean(S->hasExplicitTemplateArgs());
                        0: branch 1 not taken
                       20: branch 2 taken
     525               20:   if (S->hasExplicitTemplateArgs())
     526                0:     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
     527               20: }
     528                 : 
     529                0: void StmtProfiler::VisitUnaryTypeTraitExpr(UnaryTypeTraitExpr *S) {
     530                0:   VisitExpr(S);
     531                0:   ID.AddInteger(S->getTrait());
     532                0:   VisitType(S->getQueriedType());
     533                0: }
     534                 : 
     535                 : void
     536                9: StmtProfiler::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *S) {
     537                9:   VisitExpr(S);
     538                9:   VisitName(S->getDeclName());
     539                9:   VisitNestedNameSpecifier(S->getQualifier());
     540                9:   ID.AddBoolean(S->hasExplicitTemplateArgs());
                        0: branch 1 not taken
                        9: branch 2 taken
     541                9:   if (S->hasExplicitTemplateArgs())
     542                0:     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
     543                9: }
     544                 : 
     545                0: void StmtProfiler::VisitCXXExprWithTemporaries(CXXExprWithTemporaries *S) {
     546                0:   VisitExpr(S);
                        0: branch 1 not taken
                        0: branch 2 not taken
     547                0:   for (unsigned I = 0, N = S->getNumTemporaries(); I != N; ++I)
     548                 :     VisitDecl(
     549                0:       const_cast<CXXDestructorDecl *>(S->getTemporary(I)->getDestructor()));
     550                0: }
     551                 : 
     552                 : void
     553               12: StmtProfiler::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *S) {
     554               12:   VisitExpr(S);
     555               12:   VisitType(S->getTypeAsWritten());
     556               12: }
     557                 : 
     558                 : void
     559                3: StmtProfiler::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *S) {
     560                3:   ID.AddBoolean(S->isImplicitAccess());
                        3: branch 1 taken
                        0: branch 2 not taken
     561                3:   if (!S->isImplicitAccess()) {
     562                3:     VisitExpr(S);
     563                3:     ID.AddBoolean(S->isArrow());
     564                 :   }
     565                3:   VisitNestedNameSpecifier(S->getQualifier());
     566                3:   VisitName(S->getMember());
     567                3:   ID.AddBoolean(S->hasExplicitTemplateArgs());
                        0: branch 1 not taken
                        3: branch 2 taken
     568                3:   if (S->hasExplicitTemplateArgs())
     569                0:     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
     570                3: }
     571                 : 
     572                1: void StmtProfiler::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *S) {
     573                1:   ID.AddBoolean(S->isImplicitAccess());
                        0: branch 1 not taken
                        1: branch 2 taken
     574                1:   if (!S->isImplicitAccess()) {
     575                0:     VisitExpr(S);
     576                0:     ID.AddBoolean(S->isArrow());
     577                 :   }
     578                1:   VisitNestedNameSpecifier(S->getQualifier());
     579                1:   VisitName(S->getMemberName());
     580                1:   ID.AddBoolean(S->hasExplicitTemplateArgs());
                        0: branch 1 not taken
                        1: branch 2 taken
     581                1:   if (S->hasExplicitTemplateArgs())
     582                0:     VisitTemplateArguments(S->getTemplateArgs(), S->getNumTemplateArgs());
     583                1: }
     584                 : 
     585                0: void StmtProfiler::VisitObjCStringLiteral(ObjCStringLiteral *S) {
     586                0:   VisitExpr(S);
     587                0: }
     588                 : 
     589                0: void StmtProfiler::VisitObjCEncodeExpr(ObjCEncodeExpr *S) {
     590                0:   VisitExpr(S);
     591                0:   VisitType(S->getEncodedType());
     592                0: }
     593                 : 
     594                0: void StmtProfiler::VisitObjCSelectorExpr(ObjCSelectorExpr *S) {
     595                0:   VisitExpr(S);
     596                0:   VisitName(S->getSelector());
     597                0: }
     598                 : 
     599                0: void StmtProfiler::VisitObjCProtocolExpr(ObjCProtocolExpr *S) {
     600                0:   VisitExpr(S);
     601                0:   VisitDecl(S->getProtocol());
     602                0: }
     603                 : 
     604                0: void StmtProfiler::VisitObjCIvarRefExpr(ObjCIvarRefExpr *S) {
     605                0:   VisitExpr(S);
     606                0:   VisitDecl(S->getDecl());
     607                0:   ID.AddBoolean(S->isArrow());
     608                0:   ID.AddBoolean(S->isFreeIvar());
     609                0: }
     610                 : 
     611                0: void StmtProfiler::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *S) {
     612                0:   VisitExpr(S);
     613                0:   VisitDecl(S->getProperty());
     614                0: }
     615                 : 
     616                 : void StmtProfiler::VisitObjCImplicitSetterGetterRefExpr(
     617                0:                                   ObjCImplicitSetterGetterRefExpr *S) {
     618                0:   VisitExpr(S);
     619                0:   VisitDecl(S->getGetterMethod());
     620                0:   VisitDecl(S->getSetterMethod());
     621                0:   VisitDecl(S->getInterfaceDecl());
     622                0: }
     623                 : 
     624                0: void StmtProfiler::VisitObjCMessageExpr(ObjCMessageExpr *S) {
     625                0:   VisitExpr(S);
     626                0:   VisitName(S->getSelector());
     627                0:   VisitDecl(S->getMethodDecl());
     628                0: }
     629                 : 
     630                0: void StmtProfiler::VisitObjCSuperExpr(ObjCSuperExpr *S) {
     631                0:   VisitExpr(S);
     632                0: }
     633                 : 
     634                0: void StmtProfiler::VisitObjCIsaExpr(ObjCIsaExpr *S) {
     635                0:   VisitExpr(S);
     636                0:   ID.AddBoolean(S->isArrow());
     637                0: }
     638                 : 
     639              280: void StmtProfiler::VisitDecl(Decl *D) {
                      280: branch 0 taken
                        0: branch 1 not taken
     640              280:   ID.AddInteger(D? D->getKind() : 0);
     641                 : 
                      280: branch 0 taken
                        0: branch 1 not taken
                      280: branch 2 taken
                        0: branch 3 not taken
     642              280:   if (Canonical && D) {
                      270: branch 1 taken
                       10: branch 2 taken
     643              280:     if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(D)) {
     644              270:       ID.AddInteger(NTTP->getDepth());
     645              270:       ID.AddInteger(NTTP->getIndex());
     646              270:       VisitType(NTTP->getType());
     647              270:       return;
     648                 :     }
     649                 : 
                        5: branch 1 taken
                        5: branch 2 taken
     650               10:     if (ParmVarDecl *Parm = dyn_cast<ParmVarDecl>(D)) {
     651                 :       // The Itanium C++ ABI uses the type of a parameter when mangling
     652                 :       // expressions that involve function parameters, so we will use the
     653                 :       // parameter's type for establishing function parameter identity. That
     654                 :       // way, our definition of "equivalent" (per C++ [temp.over.link])
     655                 :       // matches the definition of "equivalent" used for name mangling.
     656                5:       VisitType(Parm->getType());
     657                5:       return;
     658                 :     }
     659                 : 
                        0: branch 1 not taken
                        5: branch 2 taken
     660                5:     if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(D)) {
     661                0:       ID.AddInteger(TTP->getDepth());
     662                0:       ID.AddInteger(TTP->getIndex());
     663                0:       return;
     664                 :     }
     665                 :   }
     666                 : 
                        5: branch 0 taken
                        0: branch 1 not taken
     667                5:   ID.AddPointer(D? D->getCanonicalDecl() : 0);
     668                 : }
     669                 : 
     670              302: void StmtProfiler::VisitType(QualType T) {
                      302: branch 0 taken
                        0: branch 1 not taken
     671              302:   if (Canonical)
     672              302:     T = Context.getCanonicalType(T);
     673                 : 
     674              302:   ID.AddPointer(T.getAsOpaquePtr());
     675              302: }
     676                 : 
     677               33: void StmtProfiler::VisitName(DeclarationName Name) {
     678               33:   ID.AddPointer(Name.getAsOpaquePtr());
     679               33: }
     680                 : 
     681              313: void StmtProfiler::VisitNestedNameSpecifier(NestedNameSpecifier *NNS) {
                      313: branch 0 taken
                        0: branch 1 not taken
     682              313:   if (Canonical)
     683              313:     NNS = Context.getCanonicalNestedNameSpecifier(NNS);
     684              313:   ID.AddPointer(NNS);
     685              313: }
     686                 : 
     687                0: void StmtProfiler::VisitTemplateName(TemplateName Name) {
                        0: branch 0 not taken
                        0: branch 1 not taken
     688                0:   if (Canonical)
     689                0:     Name = Context.getCanonicalTemplateName(Name);
     690                 : 
     691                0:   Name.Profile(ID);
     692                0: }
     693                 : 
     694                 : void StmtProfiler::VisitTemplateArguments(const TemplateArgumentLoc *Args,
     695              278:                                           unsigned NumArgs) {
     696              278:   ID.AddInteger(NumArgs);
                        0: branch 0 not taken
                      278: branch 1 taken
     697              278:   for (unsigned I = 0; I != NumArgs; ++I)
     698                0:     VisitTemplateArgument(Args[I].getArgument());
     699              278: }
     700                 : 
     701                0: void StmtProfiler::VisitTemplateArgument(const TemplateArgument &Arg) {
     702                 :   // Mostly repetitive with TemplateArgument::Profile!
     703                0:   ID.AddInteger(Arg.getKind());
                        0: branch 1 not taken
                        0: branch 2 not taken
                        0: branch 3 not taken
                        0: branch 4 not taken
                        0: branch 5 not taken
                        0: branch 6 not taken
                        0: branch 7 not taken
                        0: branch 8 not taken
     704                0:   switch (Arg.getKind()) {
     705                 :   case TemplateArgument::Null:
     706                0:     break;
     707                 : 
     708                 :   case TemplateArgument::Type:
     709                0:     VisitType(Arg.getAsType());
     710                0:     break;
     711                 : 
     712                 :   case TemplateArgument::Template:
     713                0:     VisitTemplateName(Arg.getAsTemplate());
     714                0:     break;
     715                 :       
     716                 :   case TemplateArgument::Declaration:
     717                0:     VisitDecl(Arg.getAsDecl());
     718                0:     break;
     719                 : 
     720                 :   case TemplateArgument::Integral:
     721                0:     Arg.getAsIntegral()->Profile(ID);
     722                0:     VisitType(Arg.getIntegralType());
     723                0:     break;
     724                 : 
     725                 :   case TemplateArgument::Expression:
     726                0:     Visit(Arg.getAsExpr());
     727                0:     break;
     728                 : 
     729                 :   case TemplateArgument::Pack:
     730                0:     const TemplateArgument *Pack = Arg.pack_begin();
                        0: branch 1 not taken
                        0: branch 2 not taken
     731                0:     for (unsigned i = 0, e = Arg.pack_size(); i != e; ++i)
     732                0:       VisitTemplateArgument(Pack[i]);
     733                 :     break;
     734                 :   }
     735                0: }
     736                 : 
     737                 : void Stmt::Profile(llvm::FoldingSetNodeID &ID, ASTContext &Context,
     738              290:                    bool Canonical) {
     739              290:   StmtProfiler Profiler(ID, Context, Canonical);
     740              290:   Profiler.Visit(this);
     741              290: }

Generated: 2010-02-10 01:31 by zcov