aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteObjC.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-17 14:58:09 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-17 14:58:09 +0000
commit2e1cd4264d363ca869bf37ef160902f211d21b8c (patch)
treeb4e6314529ad811be3463a668f8b4e515f66fbcc /Driver/RewriteObjC.cpp
parentb8abbdc90f902a2c09c566193b900c2c45a46672 (diff)
Introduction the DeclarationName class, as a single, general method of
representing the names of declarations in the C family of languages. DeclarationName is used in NamedDecl to store the name of the declaration (naturally), and ObjCMethodDecl is now a NamedDecl. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59441 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteObjC.cpp')
-rw-r--r--Driver/RewriteObjC.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 2903f998a0..69aedcc2dd 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -506,7 +506,7 @@ void RewriteObjC::HandleTopLevelDecl(Decl *D) {
RewriteFunctionDecl(FD);
} else if (VarDecl *FVD = dyn_cast<VarDecl>(D)) {
// declared in <Foundation/NSString.h>
- if (strcmp(FVD->getName(), "_NSConstantStringClassReference") == 0) {
+ if (strcmp(FVD->getIdentifierName(), "_NSConstantStringClassReference") == 0) {
ConstantStringClassReference = FVD;
return;
}
@@ -1088,13 +1088,13 @@ Stmt *RewriteObjC::RewriteObjCForCollectionStmt(ObjCForCollectionStmt *S,
elementTypeAsString = ElementType.getAsString();
buf += elementTypeAsString;
buf += " ";
- elementName = D->getName();
+ elementName = D->getIdentifierName();
buf += elementName;
buf += ";\n\t";
}
else {
DeclRefExpr *DR = cast<DeclRefExpr>(S->getElement());
- elementName = DR->getDecl()->getName();
+ elementName = DR->getDecl()->getIdentifierName();
elementTypeAsString
= cast<ValueDecl>(DR->getDecl())->getType().getAsString();
}
@@ -1694,7 +1694,7 @@ void RewriteObjC::SynthGetProtocolFunctionDecl() {
void RewriteObjC::RewriteFunctionDecl(FunctionDecl *FD) {
// declared in <objc/objc.h>
- if (strcmp(FD->getName(), "sel_registerName") == 0) {
+ if (strcmp(FD->getIdentifierName(), "sel_registerName") == 0) {
SelGetUidFunctionDecl = FD;
return;
}
@@ -2299,8 +2299,8 @@ Stmt *RewriteObjC::RewriteObjCProtocolExpr(ObjCProtocolExpr *Exp) {
// Create a call to objc_getProtocol("ProtocolName").
llvm::SmallVector<Expr*, 8> ProtoExprs;
QualType argType = Context->getPointerType(Context->CharTy);
- ProtoExprs.push_back(new StringLiteral(Exp->getProtocol()->getName(),
- strlen(Exp->getProtocol()->getName()),
+ ProtoExprs.push_back(new StringLiteral(Exp->getProtocol()->getIdentifierName(),
+ strlen(Exp->getProtocol()->getIdentifierName()),
false, argType, SourceLocation(),
SourceLocation()));
CallExpr *ProtoExp = SynthesizeCallToFunctionDecl(GetProtocolFunctionDecl,
@@ -2343,7 +2343,8 @@ bool RewriteObjC::BufferContainsPPDirectives(const char *startBuf,
void RewriteObjC::SynthesizeObjCInternalStruct(ObjCInterfaceDecl *CDecl,
std::string &Result) {
assert(CDecl && "Class missing in SynthesizeObjCInternalStruct");
- assert(CDecl->getName() && "Name missing in SynthesizeObjCInternalStruct");
+ assert(CDecl->getIdentifierName() &&
+ "Name missing in SynthesizeObjCInternalStruct");
// Do not synthesize more than once.
if (ObjCSynthesizedStructs.count(CDecl))
return;
@@ -2922,15 +2923,15 @@ void RewriteObjC::RewriteObjCClassMetaData(ObjCImplementationDecl *IDecl,
// Build _objc_method_list for class's instance methods if needed
RewriteObjCMethodsMetaData(IDecl->instmeth_begin(), IDecl->instmeth_end(),
- true, "", IDecl->getName(), Result);
+ true, "", IDecl->getIdentifierName(), Result);
// Build _objc_method_list for class's class methods if needed
RewriteObjCMethodsMetaData(IDecl->classmeth_begin(), IDecl->classmeth_end(),
- false, "", IDecl->getName(), Result);
+ false, "", IDecl->getIdentifierName(), Result);
// Protocols referenced in class declaration?
RewriteObjCProtocolsMetaData(CDecl->getReferencedProtocols(),
- "CLASS", CDecl->getName(), Result);
+ "CLASS", CDecl->getIdentifierName(), Result);
// Declaration of class/meta-class metadata
@@ -3429,7 +3430,7 @@ void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
void RewriteObjC::InsertBlockLiteralsWithinFunction(FunctionDecl *FD) {
SourceLocation FunLocStart = FD->getTypeSpecStartLoc();
- const char *FuncName = FD->getName();
+ const char *FuncName = FD->getIdentifierName();
SynthesizeBlockLiterals(FunLocStart, FuncName);
}
@@ -3489,13 +3490,13 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp) {
const BlockPointerType *CPT = 0;
if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Exp->getCallee())) {
- closureName = DRE->getDecl()->getName();
+ closureName = DRE->getDecl()->getIdentifierName();
CPT = DRE->getType()->getAsBlockPointerType();
} else if (BlockDeclRefExpr *CDRE = dyn_cast<BlockDeclRefExpr>(Exp->getCallee())) {
- closureName = CDRE->getDecl()->getName();
+ closureName = CDRE->getDecl()->getIdentifierName();
CPT = CDRE->getType()->getAsBlockPointerType();
} else if (MemberExpr *MExpr = dyn_cast<MemberExpr>(Exp->getCallee())) {
- closureName = MExpr->getMemberDecl()->getName();
+ closureName = MExpr->getMemberDecl()->getIdentifierName();
CPT = MExpr->getType()->getAsBlockPointerType();
} else {
assert(1 && "RewriteBlockClass: Bad type");
@@ -3812,15 +3813,15 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
E = BlockByCopyDecls.end(); I != E; ++I) {
if (isObjCType((*I)->getType())) {
// FIXME: Conform to ABI ([[obj retain] autorelease]).
- FD = SynthBlockInitFunctionDecl((*I)->getName());
+ FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
} else if (isBlockPointerType((*I)->getType())) {
- FD = SynthBlockInitFunctionDecl((*I)->getName());
+ FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
Arg = new DeclRefExpr(FD, FD->getType(), SourceLocation());
Exp = new CStyleCastExpr(Context->VoidPtrTy, Arg,
Context->VoidPtrTy, SourceLocation(), SourceLocation());
} else {
- FD = SynthBlockInitFunctionDecl((*I)->getName());
+ FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
}
InitExprs.push_back(Exp);
@@ -3828,7 +3829,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp) {
// Output all "by ref" declarations.
for (llvm::SmallPtrSet<ValueDecl*,8>::iterator I = BlockByRefDecls.begin(),
E = BlockByRefDecls.end(); I != E; ++I) {
- FD = SynthBlockInitFunctionDecl((*I)->getName());
+ FD = SynthBlockInitFunctionDecl((*I)->getIdentifierName());
Exp = new DeclRefExpr(FD, FD->getType(), SourceLocation());
Exp = new UnaryOperator(Exp, UnaryOperator::AddrOf,
Context->getPointerType(Exp->getType()),
@@ -4064,7 +4065,8 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) {
if (VD->getInit()) {
GlobalVarDecl = VD;
RewriteFunctionBodyOrGlobalInitializer(VD->getInit());
- SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(), VD->getName());
+ SynthesizeBlockLiterals(VD->getTypeSpecStartLoc(),
+ VD->getIdentifierName());
GlobalVarDecl = 0;
// This is needed for blocks.