zcov: / lib/Frontend/PCHReaderDecl.cpp


Files: 1 Branches Taken: 34.5% 90 / 261
Generated: 2010-02-10 01:31 Branches Executed: 61.7% 161 / 261
Line Coverage: 75.2% 354 / 471


Programs: 2 Runs 3018


       1                 : //===--- PCHReaderDecl.cpp - Decl Deserialization ---------------*- C++ -*-===//
       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 PCHReader::ReadDeclRecord method, which is the
      11                 : // entrypoint for loading a decl.
      12                 : //
      13                 : //===----------------------------------------------------------------------===//
      14                 : 
      15                 : #include "clang/Frontend/PCHReader.h"
      16                 : #include "clang/AST/ASTConsumer.h"
      17                 : #include "clang/AST/ASTContext.h"
      18                 : #include "clang/AST/DeclVisitor.h"
      19                 : #include "clang/AST/DeclGroup.h"
      20                 : #include "clang/AST/Expr.h"
      21                 : using namespace clang;
      22                 : 
      23                 : 
      24                 : //===----------------------------------------------------------------------===//
      25                 : // Declaration deserialization
      26                 : //===----------------------------------------------------------------------===//
      27                 : 
      28                 : namespace {
      29                 :   class PCHDeclReader : public DeclVisitor<PCHDeclReader, void> {
      30                 :     PCHReader &Reader;
      31                 :     const PCHReader::RecordData &Record;
      32                 :     unsigned &Idx;
      33                 : 
      34                 :   public:
      35                 :     PCHDeclReader(PCHReader &Reader, const PCHReader::RecordData &Record,
      36              517:                   unsigned &Idx)
      37              517:       : Reader(Reader), Record(Record), Idx(Idx) { }
      38                 : 
      39                 :     void VisitDecl(Decl *D);
      40                 :     void VisitTranslationUnitDecl(TranslationUnitDecl *TU);
      41                 :     void VisitNamedDecl(NamedDecl *ND);
      42                 :     void VisitTypeDecl(TypeDecl *TD);
      43                 :     void VisitTypedefDecl(TypedefDecl *TD);
      44                 :     void VisitTagDecl(TagDecl *TD);
      45                 :     void VisitEnumDecl(EnumDecl *ED);
      46                 :     void VisitRecordDecl(RecordDecl *RD);
      47                 :     void VisitValueDecl(ValueDecl *VD);
      48                 :     void VisitEnumConstantDecl(EnumConstantDecl *ECD);
      49                 :     void VisitDeclaratorDecl(DeclaratorDecl *DD);
      50                 :     void VisitFunctionDecl(FunctionDecl *FD);
      51                 :     void VisitFieldDecl(FieldDecl *FD);
      52                 :     void VisitVarDecl(VarDecl *VD);
      53                 :     void VisitImplicitParamDecl(ImplicitParamDecl *PD);
      54                 :     void VisitParmVarDecl(ParmVarDecl *PD);
      55                 :     void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
      56                 :     void VisitBlockDecl(BlockDecl *BD);
      57                 :     std::pair<uint64_t, uint64_t> VisitDeclContext(DeclContext *DC);
      58                 :     void VisitObjCMethodDecl(ObjCMethodDecl *D);
      59                 :     void VisitObjCContainerDecl(ObjCContainerDecl *D);
      60                 :     void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D);
      61                 :     void VisitObjCIvarDecl(ObjCIvarDecl *D);
      62                 :     void VisitObjCProtocolDecl(ObjCProtocolDecl *D);
      63                 :     void VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D);
      64                 :     void VisitObjCClassDecl(ObjCClassDecl *D);
      65                 :     void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D);
      66                 :     void VisitObjCCategoryDecl(ObjCCategoryDecl *D);
      67                 :     void VisitObjCImplDecl(ObjCImplDecl *D);
      68                 :     void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D);
      69                 :     void VisitObjCImplementationDecl(ObjCImplementationDecl *D);
      70                 :     void VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D);
      71                 :     void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
      72                 :     void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
      73                 :   };
      74                 : }
      75                 : 
      76              517: void PCHDeclReader::VisitDecl(Decl *D) {
      77              517:   D->setDeclContext(cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])));
      78                 :   D->setLexicalDeclContext(
      79              517:                      cast_or_null<DeclContext>(Reader.GetDecl(Record[Idx++])));
      80              517:   D->setLocation(SourceLocation::getFromRawEncoding(Record[Idx++]));
      81              517:   D->setInvalidDecl(Record[Idx++]);
                        6: branch 1 taken
                      511: branch 2 taken
      82              517:   if (Record[Idx++])
      83                6:     D->addAttr(Reader.ReadAttributes());
      84              517:   D->setImplicit(Record[Idx++]);
      85              517:   D->setUsed(Record[Idx++]);
      86              517:   D->setAccess((AccessSpecifier)Record[Idx++]);
      87              517:   D->setPCHLevel(Record[Idx++] + 1);
      88              517: }
      89                 : 
      90               46: void PCHDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
      91               46:   VisitDecl(TU);
      92               46: }
      93                 : 
      94              464: void PCHDeclReader::VisitNamedDecl(NamedDecl *ND) {
      95              464:   VisitDecl(ND);
      96              464:   ND->setDeclName(Reader.ReadDeclarationName(Record, Idx));
      97              464: }
      98                 : 
      99               28: void PCHDeclReader::VisitTypeDecl(TypeDecl *TD) {
     100               28:   VisitNamedDecl(TD);
     101               28:   TD->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
     102               28: }
     103                 : 
     104              133: void PCHDeclReader::VisitTypedefDecl(TypedefDecl *TD) {
     105                 :   // Note that we cannot use VisitTypeDecl here, because we need to
     106                 :   // set the underlying type of the typedef *before* we try to read
     107                 :   // the type associated with the TypedefDecl.
     108              133:   VisitNamedDecl(TD);
     109              133:   uint64_t TypeData = Record[Idx++];
     110              133:   TD->setTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
     111              133:   TD->setTypeForDecl(Reader.GetType(TypeData).getTypePtr());
     112              133: }
     113                 : 
     114               28: void PCHDeclReader::VisitTagDecl(TagDecl *TD) {
     115               28:   VisitTypeDecl(TD);
     116                 :   TD->setPreviousDeclaration(
     117               28:                         cast_or_null<TagDecl>(Reader.GetDecl(Record[Idx++])));
     118               28:   TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
     119               28:   TD->setDefinition(Record[Idx++]);
     120               28:   TD->setDefinedInDeclarator(Record[Idx++]);
     121                 :   TD->setTypedefForAnonDecl(
     122               28:                     cast_or_null<TypedefDecl>(Reader.GetDecl(Record[Idx++])));
     123               28:   TD->setRBraceLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     124               28:   TD->setTagKeywordLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     125               28: }
     126                 : 
     127                5: void PCHDeclReader::VisitEnumDecl(EnumDecl *ED) {
     128                5:   VisitTagDecl(ED);
     129                5:   ED->setIntegerType(Reader.GetType(Record[Idx++]));
     130                5:   ED->setPromotionType(Reader.GetType(Record[Idx++]));
     131                 :   // FIXME: C++ InstantiatedFrom
     132                5: }
     133                 : 
     134               23: void PCHDeclReader::VisitRecordDecl(RecordDecl *RD) {
     135               23:   VisitTagDecl(RD);
     136               23:   RD->setHasFlexibleArrayMember(Record[Idx++]);
     137               23:   RD->setAnonymousStructOrUnion(Record[Idx++]);
     138               23:   RD->setHasObjectMember(Record[Idx++]);
     139               23: }
     140                 : 
     141              238: void PCHDeclReader::VisitValueDecl(ValueDecl *VD) {
     142              238:   VisitNamedDecl(VD);
     143              238:   VD->setType(Reader.GetType(Record[Idx++]));
     144              238: }
     145                 : 
     146                6: void PCHDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) {
     147                6:   VisitValueDecl(ECD);
                        2: branch 1 taken
                        4: branch 2 taken
     148                6:   if (Record[Idx++])
     149                2:     ECD->setInitExpr(Reader.ReadDeclExpr());
     150                6:   ECD->setInitVal(Reader.ReadAPSInt(Record, Idx));
     151                6: }
     152                 : 
     153              232: void PCHDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
     154              232:   VisitValueDecl(DD);
     155              232:   TypeSourceInfo *TInfo = Reader.GetTypeSourceInfo(Record, Idx);
                      225: branch 0 taken
                        7: branch 1 taken
     156              232:   if (TInfo)
     157              225:     DD->setTypeSourceInfo(TInfo);
     158              232: }
     159                 : 
     160               46: void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
     161               46:   VisitDeclaratorDecl(FD);
                       26: branch 1 taken
                       20: branch 2 taken
     162               46:   if (Record[Idx++])
     163               26:     FD->setLazyBody(Reader.getDeclsCursor().GetCurrentBitNo());
     164                 :   FD->setPreviousDeclaration(
     165               46:                    cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
     166               46:   FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]);
     167               46:   FD->setInlineSpecified(Record[Idx++]);
     168               46:   FD->setVirtualAsWritten(Record[Idx++]);
     169               46:   FD->setPure(Record[Idx++]);
     170               46:   FD->setHasInheritedPrototype(Record[Idx++]);
     171               46:   FD->setHasWrittenPrototype(Record[Idx++]);
     172               46:   FD->setDeleted(Record[Idx++]);
     173               46:   FD->setTrivial(Record[Idx++]);
     174               46:   FD->setCopyAssignment(Record[Idx++]);
     175               46:   FD->setHasImplicitReturnZero(Record[Idx++]);
     176               46:   FD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
     177                 :   // FIXME: C++ TemplateOrInstantiation
     178               46:   unsigned NumParams = Record[Idx++];
     179               46:   llvm::SmallVector<ParmVarDecl *, 16> Params;
     180               46:   Params.reserve(NumParams);
                       54: branch 0 taken
                       46: branch 1 taken
     181              100:   for (unsigned I = 0; I != NumParams; ++I)
     182               54:     Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
     183               46:   FD->setParams(*Reader.getContext(), Params.data(), NumParams);
     184               46: }
     185                 : 
     186               25: void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
     187               25:   VisitNamedDecl(MD);
                        0: branch 1 not taken
                       25: branch 2 taken
     188               25:   if (Record[Idx++]) {
     189                 :     // In practice, this won't be executed (since method definitions
     190                 :     // don't occur in header files).
     191                0:     MD->setBody(Reader.ReadDeclStmt());
     192                0:     MD->setSelfDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++])));
     193                0:     MD->setCmdDecl(cast<ImplicitParamDecl>(Reader.GetDecl(Record[Idx++])));
     194                 :   }
     195               25:   MD->setInstanceMethod(Record[Idx++]);
     196               25:   MD->setVariadic(Record[Idx++]);
     197               25:   MD->setSynthesized(Record[Idx++]);
     198               25:   MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
     199               25:   MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
     200               25:   MD->setResultType(Reader.GetType(Record[Idx++]));
     201               25:   MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     202               25:   unsigned NumParams = Record[Idx++];
     203               25:   llvm::SmallVector<ParmVarDecl *, 16> Params;
     204               25:   Params.reserve(NumParams);
                        6: branch 0 taken
                       25: branch 1 taken
     205               31:   for (unsigned I = 0; I != NumParams; ++I)
     206                6:     Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
     207               25:   MD->setMethodParams(*Reader.getContext(), Params.data(), NumParams);
     208               25: }
     209                 : 
     210               38: void PCHDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) {
     211               38:   VisitNamedDecl(CD);
     212               38:   SourceLocation A = SourceLocation::getFromRawEncoding(Record[Idx++]);
     213               38:   SourceLocation B = SourceLocation::getFromRawEncoding(Record[Idx++]);
     214               38:   CD->setAtEndRange(SourceRange(A, B));
     215               38: }
     216                 : 
     217               29: void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
     218               29:   VisitObjCContainerDecl(ID);
     219               29:   ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
     220                 :   ID->setSuperClass(cast_or_null<ObjCInterfaceDecl>
     221               29:                        (Reader.GetDecl(Record[Idx++])));
     222               29:   unsigned NumProtocols = Record[Idx++];
     223               29:   llvm::SmallVector<ObjCProtocolDecl *, 16> Protocols;
     224               29:   Protocols.reserve(NumProtocols);
                        2: branch 0 taken
                       29: branch 1 taken
     225               31:   for (unsigned I = 0; I != NumProtocols; ++I)
     226                2:     Protocols.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
     227               29:   llvm::SmallVector<SourceLocation, 16> ProtoLocs;
     228               29:   ProtoLocs.reserve(NumProtocols);
                        2: branch 0 taken
                       29: branch 1 taken
     229               31:   for (unsigned I = 0; I != NumProtocols; ++I)
     230                2:     ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
     231                 :   ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(),
     232               29:                       *Reader.getContext());
     233               29:   unsigned NumIvars = Record[Idx++];
     234               29:   llvm::SmallVector<ObjCIvarDecl *, 16> IVars;
     235               29:   IVars.reserve(NumIvars);
                        4: branch 0 taken
                       29: branch 1 taken
     236               33:   for (unsigned I = 0; I != NumIvars; ++I)
     237                4:     IVars.push_back(cast<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
     238               29:   ID->setIVarList(IVars.data(), NumIvars, *Reader.getContext());
     239                 :   ID->setCategoryList(
     240               29:                cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++])));
     241               29:   ID->setForwardDecl(Record[Idx++]);
     242               29:   ID->setImplicitInterfaceDecl(Record[Idx++]);
     243               29:   ID->setClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     244               29:   ID->setSuperClassLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     245               29:   ID->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
     246               29: }
     247                 : 
     248                4: void PCHDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
     249                4:   VisitFieldDecl(IVD);
     250                4:   IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]);
     251                4: }
     252                 : 
     253                5: void PCHDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
     254                5:   VisitObjCContainerDecl(PD);
     255                5:   PD->setForwardDecl(Record[Idx++]);
     256                5:   PD->setLocEnd(SourceLocation::getFromRawEncoding(Record[Idx++]));
     257                5:   unsigned NumProtoRefs = Record[Idx++];
     258                5:   llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
     259                5:   ProtoRefs.reserve(NumProtoRefs);
                        2: branch 0 taken
                        5: branch 1 taken
     260                7:   for (unsigned I = 0; I != NumProtoRefs; ++I)
     261                2:     ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
     262                5:   llvm::SmallVector<SourceLocation, 16> ProtoLocs;
     263                5:   ProtoLocs.reserve(NumProtoRefs);
                        2: branch 0 taken
                        5: branch 1 taken
     264                7:   for (unsigned I = 0; I != NumProtoRefs; ++I)
     265                2:     ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
     266                 :   PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
     267                5:                       *Reader.getContext());
     268                5: }
     269                 : 
     270                0: void PCHDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) {
     271                0:   VisitFieldDecl(FD);
     272                0: }
     273                 : 
     274                4: void PCHDeclReader::VisitObjCClassDecl(ObjCClassDecl *CD) {
     275                4:   VisitDecl(CD);
     276                4:   unsigned NumClassRefs = Record[Idx++];
     277                4:   llvm::SmallVector<ObjCInterfaceDecl *, 16> ClassRefs;
     278                4:   ClassRefs.reserve(NumClassRefs);
                        4: branch 0 taken
                        4: branch 1 taken
     279                8:   for (unsigned I = 0; I != NumClassRefs; ++I)
     280                4:     ClassRefs.push_back(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
     281                4:   llvm::SmallVector<SourceLocation, 16> SLocs;
     282                4:   SLocs.reserve(NumClassRefs);
                        4: branch 0 taken
                        4: branch 1 taken
     283                8:   for (unsigned I = 0; I != NumClassRefs; ++I)
     284                4:     SLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
     285                 :   CD->setClassList(*Reader.getContext(), ClassRefs.data(), SLocs.data(),
     286                4:                    NumClassRefs);
     287                4: }
     288                 : 
     289                0: void PCHDeclReader::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *FPD) {
     290                0:   VisitDecl(FPD);
     291                0:   unsigned NumProtoRefs = Record[Idx++];
     292                0:   llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
     293                0:   ProtoRefs.reserve(NumProtoRefs);
                        0: branch 0 not taken
                        0: branch 1 not taken
     294                0:   for (unsigned I = 0; I != NumProtoRefs; ++I)
     295                0:     ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
     296                0:   llvm::SmallVector<SourceLocation, 16> ProtoLocs;
     297                0:   ProtoLocs.reserve(NumProtoRefs);
                        0: branch 0 not taken
                        0: branch 1 not taken
     298                0:   for (unsigned I = 0; I != NumProtoRefs; ++I)
     299                0:     ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
     300                 :   FPD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
     301                0:                        *Reader.getContext());
     302                0: }
     303                 : 
     304                2: void PCHDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) {
     305                2:   VisitObjCContainerDecl(CD);
     306                2:   CD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
     307                2:   unsigned NumProtoRefs = Record[Idx++];
     308                2:   llvm::SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
     309                2:   ProtoRefs.reserve(NumProtoRefs);
                        0: branch 0 not taken
                        2: branch 1 taken
     310                2:   for (unsigned I = 0; I != NumProtoRefs; ++I)
     311                0:     ProtoRefs.push_back(cast<ObjCProtocolDecl>(Reader.GetDecl(Record[Idx++])));
     312                2:   llvm::SmallVector<SourceLocation, 16> ProtoLocs;
     313                2:   ProtoLocs.reserve(NumProtoRefs);
                        0: branch 0 not taken
                        2: branch 1 taken
     314                2:   for (unsigned I = 0; I != NumProtoRefs; ++I)
     315                0:     ProtoLocs.push_back(SourceLocation::getFromRawEncoding(Record[Idx++]));
     316                 :   CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
     317                2:                       *Reader.getContext());
     318                2:   CD->setNextClassCategory(cast_or_null<ObjCCategoryDecl>(Reader.GetDecl(Record[Idx++])));
     319                2:   CD->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     320                2:   CD->setCategoryNameLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     321                2: }
     322                 : 
     323                0: void PCHDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) {
     324                0:   VisitNamedDecl(CAD);
     325                0:   CAD->setClassInterface(cast<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
     326                0: }
     327                 : 
     328                2: void PCHDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
     329                2:   VisitNamedDecl(D);
     330                2:   D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     331                2:   D->setType(Reader.GetType(Record[Idx++]));
     332                 :   // FIXME: stable encoding
     333                 :   D->setPropertyAttributes(
     334                2:                       (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
     335                 :   // FIXME: stable encoding
     336                 :   D->setPropertyImplementation(
     337                2:                             (ObjCPropertyDecl::PropertyControl)Record[Idx++]);
     338                2:   D->setGetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector());
     339                2:   D->setSetterName(Reader.ReadDeclarationName(Record, Idx).getObjCSelector());
     340                 :   D->setGetterMethodDecl(
     341                2:                  cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
     342                 :   D->setSetterMethodDecl(
     343                2:                  cast_or_null<ObjCMethodDecl>(Reader.GetDecl(Record[Idx++])));
     344                 :   D->setPropertyIvarDecl(
     345                2:                    cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
     346                2: }
     347                 : 
     348                2: void PCHDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
     349                2:   VisitObjCContainerDecl(D);
     350                 :   D->setClassInterface(
     351                2:               cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
     352                2: }
     353                 : 
     354                0: void PCHDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
     355                0:   VisitObjCImplDecl(D);
     356                0:   D->setIdentifier(Reader.GetIdentifierInfo(Record, Idx));
     357                0: }
     358                 : 
     359                2: void PCHDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
     360                2:   VisitObjCImplDecl(D);
     361                 :   D->setSuperClass(
     362                2:               cast_or_null<ObjCInterfaceDecl>(Reader.GetDecl(Record[Idx++])));
     363                2: }
     364                 : 
     365                 : 
     366                0: void PCHDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
     367                0:   VisitDecl(D);
     368                0:   D->setAtLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
     369                 :   D->setPropertyDecl(
     370                0:                cast_or_null<ObjCPropertyDecl>(Reader.GetDecl(Record[Idx++])));
     371                 :   D->setPropertyIvarDecl(
     372                0:                    cast_or_null<ObjCIvarDecl>(Reader.GetDecl(Record[Idx++])));
     373                0: }
     374                 : 
     375               32: void PCHDeclReader::VisitFieldDecl(FieldDecl *FD) {
     376               32:   VisitDeclaratorDecl(FD);
     377               32:   FD->setMutable(Record[Idx++]);
                        1: branch 1 taken
                       31: branch 2 taken
     378               32:   if (Record[Idx++])
     379                1:     FD->setBitWidth(Reader.ReadDeclExpr());
     380               32: }
     381                 : 
     382              154: void PCHDeclReader::VisitVarDecl(VarDecl *VD) {
     383              154:   VisitDeclaratorDecl(VD);
     384              154:   VD->setStorageClass((VarDecl::StorageClass)Record[Idx++]);
     385              154:   VD->setThreadSpecified(Record[Idx++]);
     386              154:   VD->setCXXDirectInitializer(Record[Idx++]);
     387              154:   VD->setDeclaredInCondition(Record[Idx++]);
     388                 :   VD->setPreviousDeclaration(
     389              154:                          cast_or_null<VarDecl>(Reader.GetDecl(Record[Idx++])));
                       25: branch 1 taken
                      129: branch 2 taken
     390              154:   if (Record[Idx++])
     391               25:     VD->setInit(*Reader.getContext(), Reader.ReadDeclExpr());
     392              154: }
     393                 : 
     394                0: void PCHDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
     395                0:   VisitVarDecl(PD);
     396                0: }
     397                 : 
     398               72: void PCHDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
     399               72:   VisitVarDecl(PD);
     400               72:   PD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
     401               72: }
     402                 : 
     403                1: void PCHDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) {
     404                1:   VisitDecl(AD);
     405                1:   AD->setAsmString(cast<StringLiteral>(Reader.ReadDeclExpr()));
     406                1: }
     407                 : 
     408                2: void PCHDeclReader::VisitBlockDecl(BlockDecl *BD) {
     409                2:   VisitDecl(BD);
     410                2:   BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadDeclStmt()));
     411                2:   unsigned NumParams = Record[Idx++];
     412                2:   llvm::SmallVector<ParmVarDecl *, 16> Params;
     413                2:   Params.reserve(NumParams);
                        4: branch 0 taken
                        2: branch 1 taken
     414                6:   for (unsigned I = 0; I != NumParams; ++I)
     415                4:     Params.push_back(cast<ParmVarDecl>(Reader.GetDecl(Record[Idx++])));
     416                2:   BD->setParams(*Reader.getContext(), Params.data(), NumParams);
     417                2: }
     418                 : 
     419                 : std::pair<uint64_t, uint64_t>
     420              185: PCHDeclReader::VisitDeclContext(DeclContext *DC) {
     421              185:   uint64_t LexicalOffset = Record[Idx++];
     422              185:   uint64_t VisibleOffset = Record[Idx++];
     423              185:   return std::make_pair(LexicalOffset, VisibleOffset);
     424                 : }
     425                 : 
     426                 : //===----------------------------------------------------------------------===//
     427                 : // Attribute Reading
     428                 : //===----------------------------------------------------------------------===//
     429                 : 
     430                 : /// \brief Reads attributes from the current stream position.
     431                6: Attr *PCHReader::ReadAttributes() {
     432                6:   unsigned Code = DeclsCursor.ReadCode();
     433                 :   assert(Code == llvm::bitc::UNABBREV_RECORD &&
                        0: branch 0 not taken
                        6: branch 1 taken
     434                6:          "Expected unabbreviated record"); (void)Code;
     435                 : 
     436                6:   RecordData Record;
     437                6:   unsigned Idx = 0;
     438                6:   unsigned RecCode = DeclsCursor.ReadRecord(Code, Record);
                        0: branch 0 not taken
                        6: branch 1 taken
     439                6:   assert(RecCode == pch::DECL_ATTR && "Expected attribute record");
     440                 :   (void)RecCode;
     441                 : 
     442                 : #define SIMPLE_ATTR(Name)                       \
     443                 :  case Attr::Name:                               \
     444                 :    New = ::new (*Context) Name##Attr();         \
     445                 :    break
     446                 : 
     447                 : #define STRING_ATTR(Name)                                       \
     448                 :  case Attr::Name:                                               \
     449                 :    New = ::new (*Context) Name##Attr(ReadString(Record, Idx));  \
     450                 :    break
     451                 : 
     452                 : #define UNSIGNED_ATTR(Name)                             \
     453                 :  case Attr::Name:                                       \
     454                 :    New = ::new (*Context) Name##Attr(Record[Idx++]);    \
     455                 :    break
     456                 : 
     457                6:   Attr *Attrs = 0;
                        6: branch 1 taken
                        6: branch 2 taken
     458               18:   while (Idx < Record.size()) {
     459                6:     Attr *New = 0;
     460                6:     Attr::Kind Kind = (Attr::Kind)Record[Idx++];
     461                6:     bool IsInherited = Record[Idx++];
     462                 : 
                        0: branch 0 not taken
                        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
                        1: branch 8 taken
                        0: branch 9 not taken
                        0: branch 10 not taken
                        0: branch 11 not taken
                        0: branch 12 not taken
                        0: branch 13 not taken
                        0: branch 14 not taken
                        0: branch 15 not taken
                        0: branch 16 not taken
                        0: branch 17 not taken
                        0: branch 18 not taken
                        4: branch 19 taken
                        0: branch 20 not taken
                        0: branch 21 not taken
                        0: branch 22 not taken
                        0: branch 23 not taken
                        0: branch 24 not taken
                        0: branch 25 not taken
                        0: branch 26 not taken
                        0: branch 27 not taken
                        0: branch 28 not taken
                        0: branch 29 not taken
                        0: branch 30 not taken
                        0: branch 31 not taken
                        0: branch 32 not taken
                        0: branch 33 not taken
                        0: branch 34 not taken
                        0: branch 35 not taken
                        1: branch 36 taken
                        0: branch 37 not taken
                        0: branch 38 not taken
                        0: branch 39 not taken
                        0: branch 40 not taken
                        0: branch 41 not taken
                        0: branch 42 not taken
                        0: branch 43 not taken
                        0: branch 44 not taken
                        0: branch 45 not taken
                        0: branch 46 not taken
                        0: branch 47 not taken
                        0: branch 48 not taken
                        0: branch 49 not taken
                        0: branch 50 not taken
                        0: branch 51 not taken
     463                6:     switch (Kind) {
     464                 :     default:
     465                0:       assert(0 && "Unknown attribute!");
     466                 :       break;
                        0: branch 3 not taken
                        0: branch 4 not taken
     467                0:     STRING_ATTR(Alias);
                        0: branch 2 not taken
                        0: branch 3 not taken
     468                0:     UNSIGNED_ATTR(Aligned);
                        0: branch 1 not taken
                        0: branch 2 not taken
     469                0:     SIMPLE_ATTR(AlwaysInline);
                        0: branch 1 not taken
                        0: branch 2 not taken
     470                0:     SIMPLE_ATTR(AnalyzerNoReturn);
                        0: branch 3 not taken
                        0: branch 4 not taken
     471                0:     STRING_ATTR(Annotate);
                        0: branch 3 not taken
                        0: branch 4 not taken
     472                0:     STRING_ATTR(AsmLabel);
                        0: branch 1 not taken
                        0: branch 2 not taken
     473                0:     SIMPLE_ATTR(BaseCheck);
     474                 : 
     475                 :     case Attr::Blocks:
     476                 :       New = ::new (*Context) BlocksAttr(
                        1: branch 2 taken
                        0: branch 3 not taken
     477                1:                                   (BlocksAttr::BlocksAttrTypes)Record[Idx++]);
     478                1:       break;
     479                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     480                0:     SIMPLE_ATTR(CDecl);
     481                 : 
     482                 :     case Attr::Cleanup:
     483                 :       New = ::new (*Context) CleanupAttr(
                        0: branch 4 not taken
                        0: branch 5 not taken
     484                0:                                   cast<FunctionDecl>(GetDecl(Record[Idx++])));
     485                0:       break;
     486                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     487                0:     SIMPLE_ATTR(Const);
                        0: branch 2 not taken
                        0: branch 3 not taken
     488                0:     UNSIGNED_ATTR(Constructor);
                        0: branch 1 not taken
                        0: branch 2 not taken
     489                0:     SIMPLE_ATTR(DLLExport);
                        0: branch 1 not taken
                        0: branch 2 not taken
     490                0:     SIMPLE_ATTR(DLLImport);
                        0: branch 1 not taken
                        0: branch 2 not taken
     491                0:     SIMPLE_ATTR(Deprecated);
                        0: branch 2 not taken
                        0: branch 3 not taken
     492                0:     UNSIGNED_ATTR(Destructor);
                        0: branch 1 not taken
                        0: branch 2 not taken
     493                0:     SIMPLE_ATTR(FastCall);
                        0: branch 1 not taken
                        0: branch 2 not taken
     494                0:     SIMPLE_ATTR(Final);
     495                 : 
     496                 :     case Attr::Format: {
     497                4:       std::string Type = ReadString(Record, Idx);
     498                4:       unsigned FormatIdx = Record[Idx++];
     499                4:       unsigned FirstArg = Record[Idx++];
                        4: branch 2 taken
                        0: branch 3 not taken
     500                4:       New = ::new (*Context) FormatAttr(Type, FormatIdx, FirstArg);
     501                4:       break;
     502                 :     }
     503                 : 
     504                 :     case Attr::FormatArg: {
     505                0:       unsigned FormatIdx = Record[Idx++];
                        0: branch 1 not taken
                        0: branch 2 not taken
     506                0:       New = ::new (*Context) FormatArgAttr(FormatIdx);
     507                0:       break;
     508                 :     }
     509                 : 
     510                 :     case Attr::Sentinel: {
     511                0:       int sentinel = Record[Idx++];
     512                0:       int nullPos = Record[Idx++];
                        0: branch 1 not taken
                        0: branch 2 not taken
     513                0:       New = ::new (*Context) SentinelAttr(sentinel, nullPos);
     514                0:       break;
     515                 :     }
     516                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     517                0:     SIMPLE_ATTR(GNUInline);
                        0: branch 1 not taken
                        0: branch 2 not taken
     518                0:     SIMPLE_ATTR(Hiding);
     519                 : 
     520                 :     case Attr::IBOutletKind:
                        0: branch 1 not taken
                        0: branch 2 not taken
     521                0:       New = ::new (*Context) IBOutletAttr();
     522                0:       break;
     523                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     524                0:     SIMPLE_ATTR(Malloc);
                        0: branch 1 not taken
                        0: branch 2 not taken
     525                0:     SIMPLE_ATTR(NoDebug);
                        0: branch 1 not taken
                        0: branch 2 not taken
     526                0:     SIMPLE_ATTR(NoInline);
                        0: branch 1 not taken
                        0: branch 2 not taken
     527                0:     SIMPLE_ATTR(NoReturn);
                        0: branch 1 not taken
                        0: branch 2 not taken
     528                0:     SIMPLE_ATTR(NoThrow);
     529                 : 
     530                 :     case Attr::NonNull: {
     531                0:       unsigned Size = Record[Idx++];
     532                0:       llvm::SmallVector<unsigned, 16> ArgNums;
     533                0:       ArgNums.insert(ArgNums.end(), &Record[Idx], &Record[Idx] + Size);
     534                0:       Idx += Size;
                        0: branch 2 not taken
                        0: branch 3 not taken
     535                0:       New = ::new (*Context) NonNullAttr(ArgNums.data(), Size);
     536                0:       break;
     537                 :     }
     538                 : 
     539                 :     case Attr::ReqdWorkGroupSize: {
     540                0:       unsigned X = Record[Idx++];
     541                0:       unsigned Y = Record[Idx++];
     542                0:       unsigned Z = Record[Idx++];
                        0: branch 1 not taken
                        0: branch 2 not taken
     543                0:       New = ::new (*Context) ReqdWorkGroupSizeAttr(X, Y, Z);
     544                0:       break;
     545                 :     }
     546                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     547                0:     SIMPLE_ATTR(ObjCException);
                        0: branch 1 not taken
                        0: branch 2 not taken
     548                0:     SIMPLE_ATTR(ObjCNSObject);
                        0: branch 1 not taken
                        0: branch 2 not taken
     549                0:     SIMPLE_ATTR(CFReturnsRetained);
                        0: branch 1 not taken
                        0: branch 2 not taken
     550                0:     SIMPLE_ATTR(NSReturnsRetained);
                        1: branch 1 taken
                        0: branch 2 not taken
     551                1:     SIMPLE_ATTR(Overloadable);
                        0: branch 1 not taken
                        0: branch 2 not taken
     552                0:     SIMPLE_ATTR(Override);
                        0: branch 1 not taken
                        0: branch 2 not taken
     553                0:     SIMPLE_ATTR(Packed);
                        0: branch 2 not taken
                        0: branch 3 not taken
     554                0:     UNSIGNED_ATTR(PragmaPack);
                        0: branch 1 not taken
                        0: branch 2 not taken
     555                0:     SIMPLE_ATTR(Pure);
                        0: branch 2 not taken
                        0: branch 3 not taken
     556                0:     UNSIGNED_ATTR(Regparm);
                        0: branch 3 not taken
                        0: branch 4 not taken
     557                0:     STRING_ATTR(Section);
                        0: branch 1 not taken
                        0: branch 2 not taken
     558                0:     SIMPLE_ATTR(StdCall);
                        0: branch 1 not taken
                        0: branch 2 not taken
     559                0:     SIMPLE_ATTR(TransparentUnion);
                        0: branch 1 not taken
                        0: branch 2 not taken
     560                0:     SIMPLE_ATTR(Unavailable);
                        0: branch 1 not taken
                        0: branch 2 not taken
     561                0:     SIMPLE_ATTR(Unused);
                        0: branch 1 not taken
                        0: branch 2 not taken
     562                0:     SIMPLE_ATTR(Used);
     563                 : 
     564                 :     case Attr::Visibility:
     565                 :       New = ::new (*Context) VisibilityAttr(
                        0: branch 2 not taken
                        0: branch 3 not taken
     566                0:                               (VisibilityAttr::VisibilityTypes)Record[Idx++]);
     567                0:       break;
     568                 : 
                        0: branch 1 not taken
                        0: branch 2 not taken
     569                0:     SIMPLE_ATTR(WarnUnusedResult);
                        0: branch 1 not taken
                        0: branch 2 not taken
     570                0:     SIMPLE_ATTR(Weak);
                        0: branch 1 not taken
                        0: branch 2 not taken
     571                0:     SIMPLE_ATTR(WeakImport);
     572                 :     }
     573                 : 
                        0: branch 0 not taken
                        6: branch 1 taken
     574                6:     assert(New && "Unable to decode attribute?");
     575                6:     New->setInherited(IsInherited);
     576                6:     New->setNext(Attrs);
     577                6:     Attrs = New;
     578                 :   }
     579                 : #undef UNSIGNED_ATTR
     580                 : #undef STRING_ATTR
     581                 : #undef SIMPLE_ATTR
     582                 : 
     583                 :   // The list of attributes was built backwards. Reverse the list
     584                 :   // before returning it.
     585                6:   Attr *PrevAttr = 0, *NextAttr = 0;
                        6: branch 0 taken
                        6: branch 1 taken
     586               18:   while (Attrs) {
     587                6:     NextAttr = Attrs->getNext();
     588                6:     Attrs->setNext(PrevAttr);
     589                6:     PrevAttr = Attrs;
     590                6:     Attrs = NextAttr;
     591                 :   }
     592                 : 
     593                6:   return PrevAttr;
     594                 : }
     595                 : 
     596                 : //===----------------------------------------------------------------------===//
     597                 : // PCHReader Implementation
     598                 : //===----------------------------------------------------------------------===//
     599                 : 
     600                 : /// \brief Note that we have loaded the declaration with the given
     601                 : /// Index.
     602                 : ///
     603                 : /// This routine notes that this declaration has already been loaded,
     604                 : /// so that future GetDecl calls will return this declaration rather
     605                 : /// than trying to load a new declaration.
     606              517: inline void PCHReader::LoadedDecl(unsigned Index, Decl *D) {
                      517: branch 1 taken
                        0: branch 2 not taken
     607              517:   assert(!DeclsLoaded[Index] && "Decl loaded twice?");
     608              517:   DeclsLoaded[Index] = D;
     609              517: }
     610                 : 
     611                 : 
     612                 : /// \brief Determine whether the consumer will be interested in seeing
     613                 : /// this declaration (via HandleTopLevelDecl).
     614                 : ///
     615                 : /// This routine should return true for anything that might affect
     616                 : /// code generation, e.g., inline function definitions, Objective-C
     617                 : /// declarations with metadata, etc.
     618              517: static bool isConsumerInterestedIn(Decl *D) {
                        1: branch 1 taken
                      516: branch 2 taken
     619              517:   if (isa<FileScopeAsmDecl>(D))
     620                1:     return true;
                      154: branch 1 taken
                      362: branch 2 taken
     621              516:   if (VarDecl *Var = dyn_cast<VarDecl>(D))
                       58: branch 1 taken
                       96: branch 2 taken
                       13: branch 4 taken
                       45: branch 5 taken
     622              154:     return Var->isFileVarDecl() && Var->getInit();
                       46: branch 1 taken
                      316: branch 2 taken
     623              362:   if (FunctionDecl *Func = dyn_cast<FunctionDecl>(D))
     624               46:     return Func->isThisDeclarationADefinition();
     625              316:   return isa<ObjCProtocolDecl>(D);
     626                 : }
     627                 : 
     628                 : /// \brief Read the declaration at the given offset from the PCH file.
     629              517: Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
     630                 :   // Keep track of where we are in the stream, then jump back there
     631                 :   // after reading this declaration.
     632              517:   SavedStreamPosition SavedPosition(DeclsCursor);
     633                 : 
     634                 :   // Note that we are loading a declaration record.
     635              517:   LoadingTypeOrDecl Loading(*this);
     636                 : 
     637              517:   DeclsCursor.JumpToBit(Offset);
     638              517:   RecordData Record;
     639              517:   unsigned Code = DeclsCursor.ReadCode();
     640              517:   unsigned Idx = 0;
     641              517:   PCHDeclReader Reader(*this, Record, Idx);
     642                 : 
     643              517:   Decl *D = 0;
                        0: branch 1 not taken
                       46: branch 2 taken
                      133: branch 3 taken
                        5: branch 4 taken
                       23: branch 5 taken
                        6: branch 6 taken
                       46: branch 7 taken
                       25: branch 8 taken
                       29: branch 9 taken
                        4: branch 10 taken
                        5: branch 11 taken
                        0: branch 12 not taken
                        4: branch 13 taken
                        0: branch 14 not taken
                        2: branch 15 taken
                        0: branch 16 not taken
                        2: branch 17 taken
                        0: branch 18 not taken
                        2: branch 19 taken
                        0: branch 20 not taken
                       28: branch 21 taken
                       82: branch 22 taken
                        0: branch 23 not taken
                       72: branch 24 taken
                        1: branch 25 taken
                        2: branch 26 taken
                        0: branch 27 not taken
     644              517:   switch ((pch::DeclCode)DeclsCursor.ReadRecord(Code, Record)) {
     645                 :   case pch::DECL_ATTR:
     646                 :   case pch::DECL_CONTEXT_LEXICAL:
     647                 :   case pch::DECL_CONTEXT_VISIBLE:
     648                0:     assert(false && "Record cannot be de-serialized with ReadDeclRecord");
     649                 :     break;
     650                 :   case pch::DECL_TRANSLATION_UNIT:
                        0: branch 0 not taken
                       46: branch 1 taken
     651               46:     assert(Index == 0 && "Translation unit must be at index 0");
     652               46:     D = Context->getTranslationUnitDecl();
     653               46:     break;
     654                 :   case pch::DECL_TYPEDEF:
     655              133:     D = TypedefDecl::Create(*Context, 0, SourceLocation(), 0, 0);
     656              133:     break;
     657                 :   case pch::DECL_ENUM:
     658                5:     D = EnumDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), 0);
     659                5:     break;
     660                 :   case pch::DECL_RECORD:
     661                 :     D = RecordDecl::Create(*Context, TagDecl::TK_struct, 0, SourceLocation(),
     662               23:                            0, SourceLocation(), 0);
     663               23:     break;
     664                 :   case pch::DECL_ENUM_CONSTANT:
     665                 :     D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(),
     666                6:                                  0, llvm::APSInt());
     667                6:     break;
     668                 :   case pch::DECL_FUNCTION:
     669                 :     D = FunctionDecl::Create(*Context, 0, SourceLocation(), DeclarationName(),
     670               46:                              QualType(), 0);
     671               46:     break;
     672                 :   case pch::DECL_OBJC_METHOD:
     673                 :     D = ObjCMethodDecl::Create(*Context, SourceLocation(), SourceLocation(),
     674               25:                                Selector(), QualType(), 0);
     675               25:     break;
     676                 :   case pch::DECL_OBJC_INTERFACE:
     677               29:     D = ObjCInterfaceDecl::Create(*Context, 0, SourceLocation(), 0);
     678               29:     break;
     679                 :   case pch::DECL_OBJC_IVAR:
     680                 :     D = ObjCIvarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
     681                4:                              ObjCIvarDecl::None);
     682                4:     break;
     683                 :   case pch::DECL_OBJC_PROTOCOL:
     684                5:     D = ObjCProtocolDecl::Create(*Context, 0, SourceLocation(), 0);
     685                5:     break;
     686                 :   case pch::DECL_OBJC_AT_DEFS_FIELD:
     687                 :     D = ObjCAtDefsFieldDecl::Create(*Context, 0, SourceLocation(), 0,
     688                0:                                     QualType(), 0);
     689                0:     break;
     690                 :   case pch::DECL_OBJC_CLASS:
     691                4:     D = ObjCClassDecl::Create(*Context, 0, SourceLocation());
     692                4:     break;
     693                 :   case pch::DECL_OBJC_FORWARD_PROTOCOL:
     694                0:     D = ObjCForwardProtocolDecl::Create(*Context, 0, SourceLocation());
     695                0:     break;
     696                 :   case pch::DECL_OBJC_CATEGORY:
     697                 :     D = ObjCCategoryDecl::Create(*Context, 0, SourceLocation(), 
     698                2:                                  SourceLocation(), SourceLocation(), 0);
     699                2:     break;
     700                 :   case pch::DECL_OBJC_CATEGORY_IMPL:
     701                0:     D = ObjCCategoryImplDecl::Create(*Context, 0, SourceLocation(), 0, 0);
     702                0:     break;
     703                 :   case pch::DECL_OBJC_IMPLEMENTATION:
     704                2:     D = ObjCImplementationDecl::Create(*Context, 0, SourceLocation(), 0, 0);
     705                2:     break;
     706                 :   case pch::DECL_OBJC_COMPATIBLE_ALIAS:
     707                0:     D = ObjCCompatibleAliasDecl::Create(*Context, 0, SourceLocation(), 0, 0);
     708                0:     break;
     709                 :   case pch::DECL_OBJC_PROPERTY:
     710                 :     D = ObjCPropertyDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(),
     711                2:                                  QualType());
     712                2:     break;
     713                 :   case pch::DECL_OBJC_PROPERTY_IMPL:
     714                 :     D = ObjCPropertyImplDecl::Create(*Context, 0, SourceLocation(),
     715                 :                                      SourceLocation(), 0,
     716                0:                                      ObjCPropertyImplDecl::Dynamic, 0);
     717                0:     break;
     718                 :   case pch::DECL_FIELD:
     719                 :     D = FieldDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0, 0,
     720               28:                           false);
     721               28:     break;
     722                 :   case pch::DECL_VAR:
     723                 :     D = VarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
     724               82:                         VarDecl::None);
     725               82:     break;
     726                 : 
     727                 :   case pch::DECL_IMPLICIT_PARAM:
     728                0:     D = ImplicitParamDecl::Create(*Context, 0, SourceLocation(), 0, QualType());
     729                0:     break;
     730                 : 
     731                 :   case pch::DECL_PARM_VAR:
     732                 :     D = ParmVarDecl::Create(*Context, 0, SourceLocation(), 0, QualType(), 0,
     733               72:                             VarDecl::None, 0);
     734               72:     break;
     735                 :   case pch::DECL_FILE_SCOPE_ASM:
     736                1:     D = FileScopeAsmDecl::Create(*Context, 0, SourceLocation(), 0);
     737                1:     break;
     738                 :   case pch::DECL_BLOCK:
     739                2:     D = BlockDecl::Create(*Context, 0, SourceLocation());
     740                 :     break;
     741                 :   }
     742                 : 
                        0: branch 0 not taken
                      517: branch 1 taken
     743              517:   assert(D && "Unknown declaration reading PCH file");
     744              517:   LoadedDecl(Index, D);
     745              517:   Reader.Visit(D);
     746                 : 
     747                 :   // If this declaration is also a declaration context, get the
     748                 :   // offsets for its tables of lexical and visible declarations.
                      185: branch 1 taken
                      332: branch 2 taken
     749              517:   if (DeclContext *DC = dyn_cast<DeclContext>(D)) {
     750              185:     std::pair<uint64_t, uint64_t> Offsets = Reader.VisitDeclContext(DC);
                       75: branch 0 taken
                      110: branch 1 taken
                        0: branch 2 not taken
                       75: branch 3 taken
     751              185:     if (Offsets.first || Offsets.second) {
     752              110:       DC->setHasExternalLexicalStorage(Offsets.first != 0);
     753              110:       DC->setHasExternalVisibleStorage(Offsets.second != 0);
     754              110:       DeclContextOffsets[DC] = Offsets;
     755                 :     }
     756                 :   }
                        0: branch 1 not taken
                      517: branch 2 taken
     757              517:   assert(Idx == Record.size());
     758                 : 
     759                 :   // If we have deserialized a declaration that has a definition the
     760                 :   // AST consumer might need to know about, notify the consumer
     761                 :   // about that definition now or queue it for later.
                       45: branch 1 taken
                      472: branch 2 taken
     762              517:   if (isConsumerInterestedIn(D)) {
                       30: branch 0 taken
                       15: branch 1 taken
     763               45:     if (Consumer) {
     764               30:       DeclGroupRef DG(D);
     765               30:       Consumer->HandleTopLevelDecl(DG);
     766                 :     } else {
     767               15:       InterestingDecls.push_back(D);
     768                 :     }
     769                 :   }
     770                 : 
     771              517:   return D;
     772                 : }

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