mirror of
https://github.com/intel/llvm.git
synced 2026-01-27 06:06:34 +08:00
Implement method type encoding in the presense
of c-style arguments. Completes radar 7445205. llvm-svn: 100813
This commit is contained in:
@@ -136,6 +136,9 @@ private:
|
||||
/// in, inout, etc.
|
||||
unsigned objcDeclQualifier : 6;
|
||||
|
||||
// Number of args separated by ':' in a method declaration.
|
||||
unsigned NumSelectorArgs;
|
||||
|
||||
// Result type of this method.
|
||||
QualType MethodDeclType;
|
||||
|
||||
@@ -167,13 +170,15 @@ private:
|
||||
bool isInstance = true,
|
||||
bool isVariadic = false,
|
||||
bool isSynthesized = false,
|
||||
ImplementationControl impControl = None)
|
||||
ImplementationControl impControl = None,
|
||||
unsigned numSelectorArgs = 0)
|
||||
: NamedDecl(ObjCMethod, contextDecl, beginLoc, SelInfo),
|
||||
DeclContext(ObjCMethod),
|
||||
IsInstance(isInstance), IsVariadic(isVariadic),
|
||||
IsSynthesized(isSynthesized),
|
||||
DeclImplementation(impControl), objcDeclQualifier(OBJC_TQ_None),
|
||||
MethodDeclType(T), ResultTInfo(ResultTInfo),
|
||||
NumSelectorArgs(numSelectorArgs), MethodDeclType(T),
|
||||
ResultTInfo(ResultTInfo),
|
||||
EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
|
||||
|
||||
virtual ~ObjCMethodDecl() {}
|
||||
@@ -197,7 +202,8 @@ public:
|
||||
bool isInstance = true,
|
||||
bool isVariadic = false,
|
||||
bool isSynthesized = false,
|
||||
ImplementationControl impControl = None);
|
||||
ImplementationControl impControl = None,
|
||||
unsigned numSelectorArgs = 0);
|
||||
|
||||
virtual ObjCMethodDecl *getCanonicalDecl();
|
||||
const ObjCMethodDecl *getCanonicalDecl() const {
|
||||
@@ -209,6 +215,11 @@ public:
|
||||
}
|
||||
void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }
|
||||
|
||||
unsigned getNumSelectorArgs() const { return NumSelectorArgs; }
|
||||
void setNumSelectorArgs(unsigned numSelectorArgs) {
|
||||
NumSelectorArgs = numSelectorArgs;
|
||||
}
|
||||
|
||||
// Location information, modeled after the Stmt API.
|
||||
SourceLocation getLocStart() const { return getLocation(); }
|
||||
SourceLocation getLocEnd() const { return EndLoc; }
|
||||
@@ -235,6 +246,11 @@ public:
|
||||
typedef ObjCList<ParmVarDecl>::iterator param_iterator;
|
||||
param_iterator param_begin() const { return ParamInfo.begin(); }
|
||||
param_iterator param_end() const { return ParamInfo.end(); }
|
||||
// This method returns and of the parameters which are part of the selector
|
||||
// name mangling requirements.
|
||||
param_iterator sel_param_end() const {
|
||||
return ParamInfo.begin() + NumSelectorArgs;
|
||||
}
|
||||
|
||||
void setMethodParams(ASTContext &C, ParmVarDecl *const *List, unsigned Num) {
|
||||
ParamInfo.set(List, Num, C);
|
||||
|
||||
@@ -3258,7 +3258,7 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
|
||||
// their size.
|
||||
CharUnits ParmOffset = 2 * PtrSize;
|
||||
for (ObjCMethodDecl::param_iterator PI = Decl->param_begin(),
|
||||
E = Decl->param_end(); PI != E; ++PI) {
|
||||
E = Decl->sel_param_end(); PI != E; ++PI) {
|
||||
QualType PType = (*PI)->getType();
|
||||
CharUnits sz = getObjCEncodingTypeSize(PType);
|
||||
assert (sz.isPositive() &&
|
||||
@@ -3272,7 +3272,7 @@ void ASTContext::getObjCEncodingForMethodDecl(const ObjCMethodDecl *Decl,
|
||||
// Argument types.
|
||||
ParmOffset = 2 * PtrSize;
|
||||
for (ObjCMethodDecl::param_iterator PI = Decl->param_begin(),
|
||||
E = Decl->param_end(); PI != E; ++PI) {
|
||||
E = Decl->sel_param_end(); PI != E; ++PI) {
|
||||
ParmVarDecl *PVDecl = *PI;
|
||||
QualType PType = PVDecl->getOriginalType();
|
||||
if (const ArrayType *AT =
|
||||
|
||||
@@ -330,11 +330,13 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
|
||||
bool isInstance,
|
||||
bool isVariadic,
|
||||
bool isSynthesized,
|
||||
ImplementationControl impControl) {
|
||||
ImplementationControl impControl,
|
||||
unsigned numSelectorArgs) {
|
||||
return new (C) ObjCMethodDecl(beginLoc, endLoc,
|
||||
SelInfo, T, ResultTInfo, contextDecl,
|
||||
isInstance,
|
||||
isVariadic, isSynthesized, impControl);
|
||||
isVariadic, isSynthesized, impControl,
|
||||
numSelectorArgs);
|
||||
}
|
||||
|
||||
void ObjCMethodDecl::Destroy(ASTContext &C) {
|
||||
|
||||
@@ -212,6 +212,7 @@ void PCHDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
|
||||
MD->setSynthesized(Record[Idx++]);
|
||||
MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
|
||||
MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
|
||||
MD->setNumSelectorArgs(unsigned(Record[Idx++]));
|
||||
MD->setResultType(Reader.GetType(Record[Idx++]));
|
||||
MD->setResultTypeSourceInfo(Reader.GetTypeSourceInfo(Record, Idx));
|
||||
MD->setEndLoc(SourceLocation::getFromRawEncoding(Record[Idx++]));
|
||||
|
||||
@@ -211,6 +211,7 @@ void PCHDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
|
||||
Record.push_back(D->getImplementationControl());
|
||||
// FIXME: stable encoding for in/out/inout/bycopy/byref/oneway
|
||||
Record.push_back(D->getObjCDeclQualifier());
|
||||
Record.push_back(D->getNumSelectorArgs());
|
||||
Writer.AddTypeRef(D->getResultType(), Record);
|
||||
Writer.AddTypeSourceInfo(D->getResultTypeSourceInfo(), Record);
|
||||
Writer.AddSourceLocation(D->getLocEnd(), Record);
|
||||
|
||||
@@ -1588,6 +1588,7 @@ Sema::DeclPtrTy Sema::ActOnMethodDeclaration(
|
||||
}
|
||||
|
||||
ObjCMethod->setMethodParams(Context, Params.data(), Params.size());
|
||||
ObjCMethod->setNumSelectorArgs(Sel.getNumArgs());
|
||||
ObjCMethod->setObjCDeclQualifier(
|
||||
CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier()));
|
||||
const ObjCMethodDecl *PrevMethod = 0;
|
||||
|
||||
11
clang/test/CodeGenObjC/encode-cstyle-method.m
Normal file
11
clang/test/CodeGenObjC/encode-cstyle-method.m
Normal file
@@ -0,0 +1,11 @@
|
||||
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
|
||||
// rdar: // 7445205
|
||||
|
||||
@interface Foo
|
||||
- (id)test:(id)one, id two;
|
||||
@end
|
||||
|
||||
@implementation Foo
|
||||
- (id)test:(id )one, id two {return two; } @end
|
||||
|
||||
// CHECK-LP64: internal global [11 x i8] c"@24@0:8@16
|
||||
Reference in New Issue
Block a user