[cfe-commits] r110610 - in /cfe/trunk: include/clang/AST/ lib/AST/ lib/Frontend/ lib/Sema/ test/Index/

Argyrios Kyrtzidis kyrtzidis at apple.com
Mon Aug 9 16:28:54 PDT 2010


On Aug 9, 2010, at 10:55 PM, Sebastian Redl wrote:

> Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=110610&r1=110609&r2=110610&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
> +++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Mon Aug  9 16:55:28 2010
> @@ -34,7 +34,7 @@
>     const pch::DeclID ThisDeclID;
>     const PCHReader::RecordData &Record;
>     unsigned &Idx;
> -    pch::TypeID TypeIDForTypeDecl;
> +    pch::TypeID TypeIDForDecl;
> 
>     uint64_t GetCurrentCursorOffset();
> 
> @@ -43,7 +43,7 @@
>                   pch::DeclID thisDeclID, const PCHReader::RecordData &Record,
>                   unsigned &Idx)
>       : Reader(Reader), Cursor(Cursor), ThisDeclID(thisDeclID), Record(Record),
> -        Idx(Idx), TypeIDForTypeDecl(0) { }
> +        Idx(Idx), TypeIDForDecl(0) { }
> 
>     void Visit(Decl *D);
> 
> @@ -132,9 +132,11 @@
> void PCHDeclReader::Visit(Decl *D) {
>   DeclVisitor<PCHDeclReader, void>::Visit(D);
> 
> +  // if we have a fully initialized Decl, we can safely read its type now.
>   if (TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
> -    // if we have a fully initialized TypeDecl, we can safely read its type now.
> -    TD->setTypeForDecl(Reader.GetType(TypeIDForTypeDecl).getTypePtr());
> +    TD->setTypeForDecl(Reader.GetType(TypeIDForDecl).getTypePtr());
> +  } else if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D)) {
> +    ID->setTypeForDecl(Reader.GetType(TypeIDForDecl).getTypePtr());
>   } else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
>     // FunctionDecl's body was written last after all other Stmts/Exprs.
>     if (Record[Idx++])
> @@ -170,7 +172,7 @@
> void PCHDeclReader::VisitTypeDecl(TypeDecl *TD) {
>   VisitNamedDecl(TD);
>   // Delay type reading until after we have fully initialized the decl.
> -  TypeIDForTypeDecl = Record[Idx++];
> +  TypeIDForDecl = Record[Idx++];
> }
> 
> void PCHDeclReader::VisitTypedefDecl(TypedefDecl *TD) {
> @@ -367,7 +369,11 @@
> 
> void PCHDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
>   VisitObjCContainerDecl(ID);
> -  ID->setTypeForDecl(Reader.GetType(Record[Idx++]).getTypePtr());
> +  ID->setForwardDecl(Record[Idx++]);
> +  ID->setImplicitInterfaceDecl(Record[Idx++]);
> +  VisitRedeclarable(ID);
> +  // Must delay type reading until the redecl chain is complete.
> +  TypeIDForDecl = Record[Idx++];

Is delayed type reading necessary ? The redecl chain should be in place after the VisitRedeclarable call.

-Argiris



More information about the cfe-commits mailing list