forked from OSchip/llvm-project
Save category name loc in ObjCCategoryImplDecl, patch by Jason Haslam!
llvm-svn: 146213
This commit is contained in:
parent
7487a0ae1f
commit
4996f5fba2
|
@ -1283,17 +1283,22 @@ class ObjCCategoryImplDecl : public ObjCImplDecl {
|
||||||
// Category name
|
// Category name
|
||||||
IdentifierInfo *Id;
|
IdentifierInfo *Id;
|
||||||
|
|
||||||
|
// Category name location
|
||||||
|
SourceLocation CategoryNameLoc;
|
||||||
|
|
||||||
ObjCCategoryImplDecl(DeclContext *DC, IdentifierInfo *Id,
|
ObjCCategoryImplDecl(DeclContext *DC, IdentifierInfo *Id,
|
||||||
ObjCInterfaceDecl *classInterface,
|
ObjCInterfaceDecl *classInterface,
|
||||||
SourceLocation nameLoc, SourceLocation atStartLoc)
|
SourceLocation nameLoc, SourceLocation atStartLoc,
|
||||||
|
SourceLocation CategoryNameLoc)
|
||||||
: ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, nameLoc, atStartLoc),
|
: ObjCImplDecl(ObjCCategoryImpl, DC, classInterface, nameLoc, atStartLoc),
|
||||||
Id(Id) {}
|
Id(Id), CategoryNameLoc(CategoryNameLoc) {}
|
||||||
public:
|
public:
|
||||||
static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC,
|
static ObjCCategoryImplDecl *Create(ASTContext &C, DeclContext *DC,
|
||||||
IdentifierInfo *Id,
|
IdentifierInfo *Id,
|
||||||
ObjCInterfaceDecl *classInterface,
|
ObjCInterfaceDecl *classInterface,
|
||||||
SourceLocation nameLoc,
|
SourceLocation nameLoc,
|
||||||
SourceLocation atStartLoc);
|
SourceLocation atStartLoc,
|
||||||
|
SourceLocation CategoryNameLoc);
|
||||||
|
|
||||||
/// getIdentifier - Get the identifier that names the category
|
/// getIdentifier - Get the identifier that names the category
|
||||||
/// interface associated with this implementation.
|
/// interface associated with this implementation.
|
||||||
|
@ -1310,6 +1315,8 @@ public:
|
||||||
|
|
||||||
ObjCCategoryDecl *getCategoryDecl() const;
|
ObjCCategoryDecl *getCategoryDecl() const;
|
||||||
|
|
||||||
|
SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
|
||||||
|
|
||||||
/// getName - Get the name of identifier for the class interface associated
|
/// getName - Get the name of identifier for the class interface associated
|
||||||
/// with this implementation as a StringRef.
|
/// with this implementation as a StringRef.
|
||||||
//
|
//
|
||||||
|
@ -1338,6 +1345,9 @@ public:
|
||||||
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
|
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
|
||||||
static bool classof(const ObjCCategoryImplDecl *D) { return true; }
|
static bool classof(const ObjCCategoryImplDecl *D) { return true; }
|
||||||
static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
|
static bool classofKind(Kind K) { return K == ObjCCategoryImpl;}
|
||||||
|
|
||||||
|
friend class ASTDeclReader;
|
||||||
|
friend class ASTDeclWriter;
|
||||||
};
|
};
|
||||||
|
|
||||||
raw_ostream &operator<<(raw_ostream &OS,
|
raw_ostream &operator<<(raw_ostream &OS,
|
||||||
|
|
|
@ -3303,11 +3303,13 @@ Decl *ASTNodeImporter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
||||||
if (!DC)
|
if (!DC)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
SourceLocation CategoryNameLoc = Importer.Import(D->getCategoryNameLoc());
|
||||||
ToImpl = ObjCCategoryImplDecl::Create(Importer.getToContext(), DC,
|
ToImpl = ObjCCategoryImplDecl::Create(Importer.getToContext(), DC,
|
||||||
Importer.Import(D->getIdentifier()),
|
Importer.Import(D->getIdentifier()),
|
||||||
Category->getClassInterface(),
|
Category->getClassInterface(),
|
||||||
Importer.Import(D->getLocation()),
|
Importer.Import(D->getLocation()),
|
||||||
Importer.Import(D->getAtStartLoc()));
|
Importer.Import(D->getAtStartLoc()),
|
||||||
|
CategoryNameLoc);
|
||||||
|
|
||||||
DeclContext *LexicalDC = DC;
|
DeclContext *LexicalDC = DC;
|
||||||
if (D->getDeclContext() != D->getLexicalDeclContext()) {
|
if (D->getDeclContext() != D->getLexicalDeclContext()) {
|
||||||
|
|
|
@ -1039,9 +1039,10 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
|
||||||
IdentifierInfo *Id,
|
IdentifierInfo *Id,
|
||||||
ObjCInterfaceDecl *ClassInterface,
|
ObjCInterfaceDecl *ClassInterface,
|
||||||
SourceLocation nameLoc,
|
SourceLocation nameLoc,
|
||||||
SourceLocation atStartLoc) {
|
SourceLocation atStartLoc,
|
||||||
|
SourceLocation CategoryNameLoc) {
|
||||||
return new (C) ObjCCategoryImplDecl(DC, Id, ClassInterface,
|
return new (C) ObjCCategoryImplDecl(DC, Id, ClassInterface,
|
||||||
nameLoc, atStartLoc);
|
nameLoc, atStartLoc, CategoryNameLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
|
ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
|
||||||
|
|
|
@ -831,7 +831,7 @@ Decl *Sema::ActOnStartCategoryImplementation(
|
||||||
|
|
||||||
ObjCCategoryImplDecl *CDecl =
|
ObjCCategoryImplDecl *CDecl =
|
||||||
ObjCCategoryImplDecl::Create(Context, CurContext, CatName, IDecl,
|
ObjCCategoryImplDecl::Create(Context, CurContext, CatName, IDecl,
|
||||||
ClassLoc, AtCatImplLoc);
|
ClassLoc, AtCatImplLoc, CatLoc);
|
||||||
/// Check that class of this category is already completely declared.
|
/// Check that class of this category is already completely declared.
|
||||||
if (!IDecl) {
|
if (!IDecl) {
|
||||||
Diag(ClassLoc, diag::err_undef_interface) << ClassName;
|
Diag(ClassLoc, diag::err_undef_interface) << ClassName;
|
||||||
|
|
|
@ -700,6 +700,7 @@ void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
|
||||||
void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
||||||
VisitObjCImplDecl(D);
|
VisitObjCImplDecl(D);
|
||||||
D->setIdentifier(Reader.GetIdentifierInfo(F, Record, Idx));
|
D->setIdentifier(Reader.GetIdentifierInfo(F, Record, Idx));
|
||||||
|
D->CategoryNameLoc = ReadSourceLocation(Record, Idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
|
void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
|
||||||
|
@ -1725,7 +1726,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
|
||||||
break;
|
break;
|
||||||
case DECL_OBJC_CATEGORY_IMPL:
|
case DECL_OBJC_CATEGORY_IMPL:
|
||||||
D = ObjCCategoryImplDecl::Create(Context, 0, 0, 0, SourceLocation(),
|
D = ObjCCategoryImplDecl::Create(Context, 0, 0, 0, SourceLocation(),
|
||||||
SourceLocation());
|
SourceLocation(), SourceLocation());
|
||||||
break;
|
break;
|
||||||
case DECL_OBJC_IMPLEMENTATION:
|
case DECL_OBJC_IMPLEMENTATION:
|
||||||
D = ObjCImplementationDecl::Create(Context, 0, 0, 0, SourceLocation(),
|
D = ObjCImplementationDecl::Create(Context, 0, 0, 0, SourceLocation(),
|
||||||
|
|
|
@ -593,6 +593,7 @@ void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) {
|
||||||
void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
|
||||||
VisitObjCImplDecl(D);
|
VisitObjCImplDecl(D);
|
||||||
Writer.AddIdentifierRef(D->getIdentifier(), Record);
|
Writer.AddIdentifierRef(D->getIdentifier(), Record);
|
||||||
|
Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
|
||||||
Code = serialization::DECL_OBJC_CATEGORY_IMPL;
|
Code = serialization::DECL_OBJC_CATEGORY_IMPL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -393,7 +393,7 @@ bool IndexingContext::handleObjCCategoryImpl(const ObjCCategoryImplDecl *D) {
|
||||||
StrAdapter SA(*this);
|
StrAdapter SA(*this);
|
||||||
const ObjCInterfaceDecl *IFaceD = CatD->getClassInterface();
|
const ObjCInterfaceDecl *IFaceD = CatD->getClassInterface();
|
||||||
SourceLocation ClassLoc = D->getLocation();
|
SourceLocation ClassLoc = D->getLocation();
|
||||||
SourceLocation CategoryLoc = ClassLoc; //FIXME: D->getCategoryNameLoc();
|
SourceLocation CategoryLoc = D->getCategoryNameLoc();
|
||||||
getEntityInfo(IFaceD, ClassEntity, SA);
|
getEntityInfo(IFaceD, ClassEntity, SA);
|
||||||
|
|
||||||
CatDInfo.ObjCCatDeclInfo.containerInfo = &CatDInfo.ObjCContDeclInfo;
|
CatDInfo.ObjCCatDeclInfo.containerInfo = &CatDInfo.ObjCContDeclInfo;
|
||||||
|
|
Loading…
Reference in New Issue