mirror of https://github.com/microsoft/clang.git
modern objective-c translation of private ivars.
// rdar://11351299 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155921 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2a7b09db93
commit
b68258fba6
|
@ -346,7 +346,7 @@ namespace {
|
|||
std::string &Result);
|
||||
|
||||
void RewriteObjCFieldDecl(FieldDecl *fieldDecl, std::string &Result);
|
||||
bool IsTagDefinedInsideClass(ObjCInterfaceDecl *IDecl, TagDecl *Tag,
|
||||
bool IsTagDefinedInsideClass(ObjCContainerDecl *IDecl, TagDecl *Tag,
|
||||
bool &IsNamedDefinition);
|
||||
void RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDecl,
|
||||
std::string &Result);
|
||||
|
@ -988,17 +988,13 @@ void RewriteModernObjC::RewriteCategoryDecl(ObjCCategoryDecl *CatDecl) {
|
|||
SourceLocation LocStart = CatDecl->getLocStart();
|
||||
|
||||
// FIXME: handle category headers that are declared across multiple lines.
|
||||
ReplaceText(LocStart, 0, "// ");
|
||||
if (CatDecl->getIvarLBraceLoc().isValid())
|
||||
InsertText(CatDecl->getIvarLBraceLoc(), "// ");
|
||||
for (ObjCCategoryDecl::ivar_iterator
|
||||
I = CatDecl->ivar_begin(), E = CatDecl->ivar_end(); I != E; ++I) {
|
||||
ObjCIvarDecl *Ivar = &*I;
|
||||
SourceLocation LocStart = Ivar->getLocStart();
|
||||
if (CatDecl->getIvarRBraceLoc().isValid()) {
|
||||
ReplaceText(LocStart, 1, "/** ");
|
||||
ReplaceText(CatDecl->getIvarRBraceLoc(), 1, "**/ ");
|
||||
}
|
||||
else {
|
||||
ReplaceText(LocStart, 0, "// ");
|
||||
}
|
||||
if (CatDecl->getIvarRBraceLoc().isValid())
|
||||
InsertText(CatDecl->getIvarRBraceLoc(), "// ");
|
||||
}
|
||||
|
||||
for (ObjCCategoryDecl::prop_iterator I = CatDecl->prop_begin(),
|
||||
E = CatDecl->prop_end(); I != E; ++I)
|
||||
|
@ -1224,17 +1220,13 @@ void RewriteModernObjC::RewriteImplementationDecl(Decl *OID) {
|
|||
ObjCCategoryImplDecl *CID = dyn_cast<ObjCCategoryImplDecl>(OID);
|
||||
|
||||
if (IMD) {
|
||||
InsertText(IMD->getLocStart(), "// ");
|
||||
if (IMD->getIvarLBraceLoc().isValid())
|
||||
InsertText(IMD->getIvarLBraceLoc(), "// ");
|
||||
for (ObjCImplementationDecl::ivar_iterator
|
||||
I = IMD->ivar_begin(), E = IMD->ivar_end(); I != E; ++I) {
|
||||
ObjCIvarDecl *Ivar = &*I;
|
||||
SourceLocation LocStart = Ivar->getLocStart();
|
||||
ReplaceText(LocStart, 0, "// ");
|
||||
if (IMD->getIvarRBraceLoc().isValid()) {
|
||||
ReplaceText(IMD->getLocStart(), 1, "/** ");
|
||||
ReplaceText(IMD->getIvarRBraceLoc(), 1, "**/ ");
|
||||
}
|
||||
else {
|
||||
InsertText(IMD->getLocStart(), "// ");
|
||||
}
|
||||
if (IMD->getIvarRBraceLoc().isValid())
|
||||
InsertText(IMD->getIvarRBraceLoc(), "// ");
|
||||
}
|
||||
else
|
||||
InsertText(CID->getLocStart(), "// ");
|
||||
|
@ -3500,7 +3492,7 @@ bool RewriteModernObjC::BufferContainsPPDirectives(const char *startBuf,
|
|||
|
||||
/// IsTagDefinedInsideClass - This routine checks that a named tagged type
|
||||
/// is defined inside an objective-c class. If so, it returns true.
|
||||
bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCInterfaceDecl *IDecl,
|
||||
bool RewriteModernObjC::IsTagDefinedInsideClass(ObjCContainerDecl *IDecl,
|
||||
TagDecl *Tag,
|
||||
bool &IsNamedDefinition) {
|
||||
if (!IDecl)
|
||||
|
@ -3628,8 +3620,8 @@ void RewriteModernObjC::RewriteLocallyDefinedNamedAggregates(FieldDecl *fieldDec
|
|||
QualType Type = fieldDecl->getType();
|
||||
if (Type->isArrayType())
|
||||
Type = Context->getBaseElementType(Type);
|
||||
ObjCInterfaceDecl *IDecl =
|
||||
dyn_cast<ObjCInterfaceDecl>(fieldDecl->getDeclContext());
|
||||
ObjCContainerDecl *IDecl =
|
||||
dyn_cast<ObjCContainerDecl>(fieldDecl->getDeclContext());
|
||||
|
||||
TagDecl *TD = 0;
|
||||
if (Type->isRecordType()) {
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp
|
||||
// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp
|
||||
// rdar://11351299
|
||||
|
||||
struct Q {
|
||||
int x;
|
||||
};
|
||||
|
||||
@interface I
|
||||
@end
|
||||
|
||||
@interface I() {
|
||||
|
||||
struct {
|
||||
int x;
|
||||
} unnamed;
|
||||
|
||||
struct S {
|
||||
int x;
|
||||
} foo;
|
||||
|
||||
double dd;
|
||||
|
||||
struct S foo1;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation I
|
||||
{
|
||||
struct P {
|
||||
int x;
|
||||
} bar;
|
||||
|
||||
double ee;
|
||||
|
||||
struct Q bar1;
|
||||
|
||||
struct {
|
||||
int x;
|
||||
} noname;
|
||||
}
|
||||
|
||||
- (void) Meth {
|
||||
foo.x = 1;
|
||||
bar.x = 2;
|
||||
dd = 1.23;
|
||||
ee = 0.0;
|
||||
foo1.x = 3;
|
||||
bar1.x = 4;
|
||||
noname.x = 3;
|
||||
unnamed.x = 10;
|
||||
}
|
||||
@end
|
Loading…
Reference in New Issue