[cfe-commits] r100213 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/ASTImporter.cpp lib/AST/DeclObjC.cpp
Fariborz Jahanian
fjahanian at apple.com
Mon Apr 5 08:57:04 PDT 2010
On Apr 4, 2010, at 7:49 PM, Daniel Dunbar wrote:
> On Fri, Apr 2, 2010 at 1:19 PM, Fariborz Jahanian
> <fjahanian at apple.com> wrote:
>>
>> On Apr 2, 2010, at 1:10 PM, Daniel Dunbar wrote:
>>
>>> Author: ddunbar
>>> Date: Fri Apr 2 15:10:03 2010
>>> New Revision: 100213
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=100213&view=rev
>>> Log:
>>> Sema/Obj-C: Narrow type of ObjCIvarDecl::Create, and check
>>> additional
>>> invariants on the provided DeclContext.
>>> - Doug, please see the FIXME in DeclObjC.cpp -- I am not sure what
>>> the
>>> right fix is.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/AST/DeclObjC.h
>>> cfe/trunk/lib/AST/ASTImporter.cpp
>>> cfe/trunk/lib/AST/DeclObjC.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/DeclObjC.h
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=100213&r1=100212&r2=100213&view=diff
>>>
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- cfe/trunk/include/clang/AST/DeclObjC.h (original)
>>> +++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Apr 2 15:10:03 2010
>>> @@ -624,14 +624,14 @@
>>> };
>>>
>>> private:
>>> - ObjCIvarDecl(DeclContext *DC, SourceLocation L, IdentifierInfo
>>> *Id,
>>> + ObjCIvarDecl(ObjCContainerDecl *DC, SourceLocation L,
>>> IdentifierInfo
>>> *Id,
>>> QualType T, TypeSourceInfo *TInfo, AccessControl ac,
>>> Expr
>>> *BW)
>>> : FieldDecl(ObjCIvar, DC, L, Id, T, TInfo, BW, /*Mutable=*/
>>> false),
>>> DeclAccess(ac) {}
>>>
>>> public:
>>> - static ObjCIvarDecl *Create(ASTContext &C, DeclContext *DC,
>>> SourceLocation L,
>>> - IdentifierInfo *Id, QualType T,
>>> + static ObjCIvarDecl *Create(ASTContext &C, ObjCContainerDecl *DC,
>>> + SourceLocation L, IdentifierInfo *Id,
>>> QualType T,
>>> TypeSourceInfo *TInfo,
>>> AccessControl ac, Expr *BW = NULL);
>>>
>>>
>>> Modified: cfe/trunk/lib/AST/ASTImporter.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=100213&r1=100212&r2=100213&view=diff
>>>
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- cfe/trunk/lib/AST/ASTImporter.cpp (original)
>>> +++ cfe/trunk/lib/AST/ASTImporter.cpp Fri Apr 2 15:10:03 2010
>>> @@ -2013,7 +2013,8 @@
>>> if (!BitWidth && D->getBitWidth())
>>> return 0;
>>>
>>> - ObjCIvarDecl *ToIvar = ObjCIvarDecl::Create
>>> (Importer.getToContext(),
>>> DC,
>>> + ObjCIvarDecl *ToIvar = ObjCIvarDecl::Create
>>> (Importer.getToContext(),
>>> +
>>> cast<ObjCContainerDecl>(DC),
>>> Loc,
>>> Name.getAsIdentifierInfo(),
>>> T, TInfo,
>>> D->getAccessControl(),
>>> BitWidth);
>>>
>>> Modified: cfe/trunk/lib/AST/DeclObjC.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=100213&r1=100212&r2=100213&view=diff
>>>
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> =
>>> ====================================================================
>>> --- cfe/trunk/lib/AST/DeclObjC.cpp (original)
>>> +++ cfe/trunk/lib/AST/DeclObjC.cpp Fri Apr 2 15:10:03 2010
>>> @@ -561,10 +561,26 @@
>>> // ObjCIvarDecl
>>>
>>> //
>>> =
>>> =
>>> =
>>> ----------------------------------------------------------------------=
>>> ==//
>>>
>>> -ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, DeclContext *DC,
>>> +ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C,
>>> ObjCContainerDecl *DC,
>>> SourceLocation L, IdentifierInfo
>>> *Id,
>>> QualType T, TypeSourceInfo *TInfo,
>>> AccessControl ac, Expr *BW) {
>>> + if (DC) {
>>> + // Ivar's can only appear in interfaces, implementations (via
>>> synthesized
>>> + // properties), and class extensions (via direct declaration,
>>> or
>>> synthesized
>>> + // properties).
>>> + //
>>> + // FIXME: This should really be asserting this:
>>> + // (isa<ObjCCategoryDecl>(DC) &&
>>> + // cast<ObjCCategoryDecl>(DC)->IsClassExtension()))
>>
>> This should be enough as long as:
>>>
>>> + // but unfortunately we sometimes place ivars into non-class
>>> extension
>>> + // categories on error. This breaks an AST invariant, and
>>> should not
>>> be
>>
>> We check for category case and error before attempting to create an
>> 'ivar'
>> for it.
>
> Right. Currently we don't though, and I'm not familiar enough with the
> Sema kind to fix.
I will take a look when I get back.
- fariborz
>
> - Daniel
>
>> - fariborz
>>
>>>
>>> + // fixed.
>>> + assert((isa<ObjCInterfaceDecl>(DC) ||
>>> isa<ObjCImplementationDecl>(DC)
>>> ||
>>> + isa<ObjCCategoryDecl>(DC)) &&
>>> + "Invalid ivar decl context!");
>>> + }
>>> +
>>> return new (C) ObjCIvarDecl(DC, L, Id, T, TInfo, ac, BW);
>>> }
>>>
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
More information about the cfe-commits
mailing list