[cfe-commits] r100813 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/ASTContext.cpp lib/AST/DeclObjC.cpp lib/Frontend/PCHReaderDecl.cpp lib/Frontend/PCHWriterDecl.cpp lib/Sema/SemaDeclObjC.cpp test/CodeGenObjC/encode-cstyle-method.m
Fariborz Jahanian
fjahanian at apple.com
Thu Apr 8 14:29:11 PDT 2010
Author: fjahanian
Date: Thu Apr 8 16:29:11 2010
New Revision: 100813
URL: http://llvm.org/viewvc/llvm-project?rev=100813&view=rev
Log:
Implement method type encoding in the presense
of c-style arguments. Completes radar 7445205.
Added:
cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/DeclObjC.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=100813&r1=100812&r2=100813&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Thu Apr 8 16:29:11 2010
@@ -136,6 +136,9 @@
/// 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 @@
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 @@
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 @@
}
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 @@
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);
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=100813&r1=100812&r2=100813&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Apr 8 16:29:11 2010
@@ -3258,7 +3258,7 @@
// 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 @@
// 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 =
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=100813&r1=100812&r2=100813&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Thu Apr 8 16:29:11 2010
@@ -330,11 +330,13 @@
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) {
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=100813&r1=100812&r2=100813&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Thu Apr 8 16:29:11 2010
@@ -212,6 +212,7 @@
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++]));
Modified: cfe/trunk/lib/Frontend/PCHWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriterDecl.cpp?rev=100813&r1=100812&r2=100813&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriterDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriterDecl.cpp Thu Apr 8 16:29:11 2010
@@ -211,6 +211,7 @@
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);
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=100813&r1=100812&r2=100813&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr 8 16:29:11 2010
@@ -1588,6 +1588,7 @@
}
ObjCMethod->setMethodParams(Context, Params.data(), Params.size());
+ ObjCMethod->setNumSelectorArgs(Sel.getNumArgs());
ObjCMethod->setObjCDeclQualifier(
CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier()));
const ObjCMethodDecl *PrevMethod = 0;
Added: cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m?rev=100813&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m (added)
+++ cfe/trunk/test/CodeGenObjC/encode-cstyle-method.m Thu Apr 8 16:29:11 2010
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s
+// rdar: // 7445205
+
+ at interface Foo
+- (id)test:(id)one, id two;
+ at end
+
+ at implementation Foo
+- (id)test:(id )one, id two {return two; } @end
+
+// CHECK-LP64: internal global [11 x i8] c"@24 at 0:8 at 16
More information about the cfe-commits
mailing list