diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-04 06:12:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-04 06:12:32 +0000 |
commit | c5ffed4a66c7d586deb16f741dc41b8ae16c2e55 (patch) | |
tree | 2a8fe831594557649a77d6a5d04dd8dcb8e7edd7 /clang/lib/Sema/SemaDeclObjC.cpp | |
parent | 318d3ef88e3ae765ffa5b9d5b477a1b2bf41d371 (diff) | |
download | bcm5719-llvm-c5ffed4a66c7d586deb16f741dc41b8ae16c2e55.tar.gz bcm5719-llvm-c5ffed4a66c7d586deb16f741dc41b8ae16c2e55.zip |
Introduce ContextDecl, patch by Argiris Kirtzidis!
-Added ContextDecl (no TranslationUnitDecl)
-ScopedDecl class has a ContextDecl member
-FieldDecl class has a ContextDecl member, so that a Field or a ObjCIvar can be traced back to their RecordDecl/ObjCInterfaceDecl easily
-FunctionDecl, ObjCMethodDecl, TagDecl, ObjCInterfaceDecl inherit from ContextDecl. With TagDecl as ContextDecl, enum constants have a EnumDecl as their context.
-Moved Decl class to a "DeclBase.h" along with ContextDecl class
-CurContext is handled by Sema
llvm-svn: 49208
Diffstat (limited to 'clang/lib/Sema/SemaDeclObjC.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 69a102203f4..6b9b9e2d431 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -33,6 +33,7 @@ void Sema::ObjCActOnStartOfMethodDef(Scope *FnBodyScope, DeclTy *D) { // Allow all of Sema to see that we are entering a method definition. CurMethodDecl = MDecl; + PushContextDecl(MDecl); // Create Decl objects for each parameter, entrring them in the scope for // binding to their use. @@ -813,6 +814,21 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( Diag(MethodLoc, diag::error_missing_method_context); return 0; } + QualType resultDeclType; + + if (ReturnType) + resultDeclType = QualType::getFromOpaquePtr(ReturnType); + else // get the type for "id". + resultDeclType = Context.getObjCIdType(); + + ObjCMethodDecl* ObjCMethod = + ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType, + ClassDecl, AttrList, + MethodType == tok::minus, isVariadic, + MethodDeclKind == tok::objc_optional ? + ObjCMethodDecl::Optional : + ObjCMethodDecl::Required); + llvm::SmallVector<ParmVarDecl*, 16> Params; for (unsigned i = 0; i < Sel.getNumArgs(); i++) { @@ -823,28 +839,15 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( argType = QualType::getFromOpaquePtr(ArgTypes[i]); else argType = Context.getObjCIdType(); - ParmVarDecl* Param = ParmVarDecl::Create(Context, SourceLocation(/*FIXME*/), + ParmVarDecl* Param = ParmVarDecl::Create(Context, ObjCMethod, + SourceLocation(/*FIXME*/), ArgNames[i], argType, VarDecl::None, 0); Param->setObjCDeclQualifier( CvtQTToAstBitMask(ArgQT[i].getObjCDeclQualifier())); Params.push_back(Param); } - QualType resultDeclType; - - if (ReturnType) - resultDeclType = QualType::getFromOpaquePtr(ReturnType); - else // get the type for "id". - resultDeclType = Context.getObjCIdType(); - - ObjCMethodDecl* ObjCMethod = - ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType, - ClassDecl, AttrList, - MethodType == tok::minus, isVariadic, - MethodDeclKind == tok::objc_optional ? - ObjCMethodDecl::Optional : - ObjCMethodDecl::Required); - + ObjCMethod->setMethodParams(&Params[0], Sel.getNumArgs()); ObjCMethod->setObjCDeclQualifier( CvtQTToAstBitMask(ReturnQT.getObjCDeclQualifier())); |