From 9e6c20bae697c908b7d368c0f79f5510d1006a65 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 21 Apr 2009 00:41:40 +0000 Subject: [PATCH] Assert on a few conditions that (I believe) should hold w.r.t. ASTContext::[gs]etFieldDecl, and the Field argument to EmitObjCValueForIvar). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69639 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/ASTContext.cpp | 2 ++ lib/CodeGen/CGObjCGNU.cpp | 1 + lib/CodeGen/CGObjCMac.cpp | 2 ++ 3 files changed, 5 insertions(+) diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 48d9fe4ea9..e266774dde 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -18,6 +18,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExternalASTSource.h" #include "clang/AST/RecordLayout.h" +#include "clang/AST/ExprObjC.h" #include "clang/Basic/SourceManager.h" #include "clang/Basic/TargetInfo.h" #include "llvm/ADT/StringExtras.h" @@ -684,6 +685,7 @@ const RecordDecl *ASTContext::addRecordToClass(const ObjCInterfaceDecl *D) { void ASTContext::setFieldDecl(const ObjCInterfaceDecl *OI, const ObjCIvarDecl *Ivar, const ObjCIvarRefExpr *MRef) { + assert(MRef->getDecl() == Ivar); ASTFieldForIvarRef[MRef] = OI->lookupFieldDeclForIvar(*this, Ivar); } diff --git a/lib/CodeGen/CGObjCGNU.cpp b/lib/CodeGen/CGObjCGNU.cpp index 2bbb15f017..b5cd36061f 100644 --- a/lib/CodeGen/CGObjCGNU.cpp +++ b/lib/CodeGen/CGObjCGNU.cpp @@ -1086,6 +1086,7 @@ LValue CGObjCGNU::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, const ObjCIvarDecl *Ivar, const FieldDecl *Field, unsigned CVRQualifiers) { + assert(Field == ObjectTy->getAsObjCInterfaceType()->getDecl()->lookupFieldDeclForIvar(CGM.getContext(), Ivar)); if (Ivar->isBitField()) return CGF.EmitLValueForBitfield(BaseValue, const_cast(Field), CVRQualifiers); diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index d1623075d5..3b5e0c5504 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -2368,6 +2368,7 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, const ObjCIvarDecl *Ivar, const FieldDecl *Field, unsigned CVRQualifiers) { + assert(Field == ObjectTy->getAsObjCInterfaceType()->getDecl()->lookupFieldDeclForIvar(CGM.getContext(), Ivar)); if (Ivar->isBitField()) return CGF.EmitLValueForBitfield(BaseValue, const_cast(Field), CVRQualifiers); @@ -4888,6 +4889,7 @@ LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar( const ObjCIvarDecl *Ivar, const FieldDecl *Field, unsigned CVRQualifiers) { + assert(Field == ObjectTy->getAsObjCInterfaceType()->getDecl()->lookupFieldDeclForIvar(CGM.getContext(), Ivar)); assert(ObjectTy->isObjCInterfaceType() && "CGObjCNonFragileABIMac::EmitObjCValueForIvar"); ObjCInterfaceDecl *ID = ObjectTy->getAsObjCInterfaceType()->getDecl(); -- 2.50.1