]> granicus.if.org Git - clang/commitdiff
Pass from the parser the locations of selector identifiers when creating
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 3 Oct 2011 06:36:36 +0000 (06:36 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Mon, 3 Oct 2011 06:36:36 +0000 (06:36 +0000)
objc method decls.

They are not stored in the AST yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140984 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
include/clang/Sema/Sema.h
lib/AST/ASTImporter.cpp
lib/AST/DeclObjC.cpp
lib/CodeGen/CodeGenModule.cpp
lib/Parse/ParseObjc.cpp
lib/Sema/SemaDeclObjC.cpp
lib/Sema/SemaObjCProperty.cpp
lib/Serialization/ASTReaderDecl.cpp

index d4ce117b308eaf1ecd27f63db770a5d6d5a273b5..dc3d818d0029336bfaefcc11459a43a80f40e6f5 100644 (file)
@@ -193,7 +193,9 @@ private:
 public:
   static ObjCMethodDecl *Create(ASTContext &C,
                                 SourceLocation beginLoc,
-                                SourceLocation endLoc, Selector SelInfo,
+                                SourceLocation endLoc,
+                                ArrayRef<SourceLocation> SelLocs,
+                                Selector SelInfo,
                                 QualType T, 
                                 TypeSourceInfo *ResultTInfo,
                                 DeclContext *contextDecl,
index 9c7fb58ad06f066b683639cad3ac819adafac577..5ed595ac587ccac6a28f4c2dae3b233f4dea17c5 100644 (file)
@@ -5209,7 +5209,7 @@ public:
     SourceLocation EndLoc,   // location of the ; or {.
     tok::TokenKind MethodType,
     ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
-    SourceLocation SelectorStartLoc, Selector Sel,
+    ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().
     ObjCArgInfo *ArgInfo,
index 09151a7888e8c8282588786f6f3e00908250077f..7c866cd88c997f9326619f018d9bcedd44c670fc 100644 (file)
@@ -2923,6 +2923,7 @@ Decl *ASTNodeImporter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
     = ObjCMethodDecl::Create(Importer.getToContext(),
                              Loc,
                              Importer.Import(D->getLocEnd()),
+                             /*FIXME:*/ ArrayRef<SourceLocation>(),
                              Name.getObjCSelector(),
                              ResultTy, ResultTInfo, DC,
                              D->isInstanceMethod(),
index a461eaaeaec4d37f1250fb1cf1fba388d4a4c1f4..0e1e833d2fd9ff61661cb4be2229335c08a97cb2 100644 (file)
@@ -332,6 +332,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupPrivateMethod(
 ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
                                        SourceLocation beginLoc,
                                        SourceLocation endLoc,
+                                       ArrayRef<SourceLocation> SelLocs,
                                        Selector SelInfo, QualType T,
                                        TypeSourceInfo *ResultTInfo,
                                        DeclContext *contextDecl,
index cde71e7ed8eae9dd98b3af1fb829c720ff83893f..6e8e439107efa05a7af5ce0067ff528cd44f93ac 100644 (file)
@@ -2134,6 +2134,7 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
     Selector cxxSelector = getContext().Selectors.getSelector(0, &II);
     ObjCMethodDecl *DTORMethod =
       ObjCMethodDecl::Create(getContext(), D->getLocation(), D->getLocation(),
+                             ArrayRef<SourceLocation>(),
                              cxxSelector, getContext().VoidTy, 0, D,
                              /*isInstance=*/true, /*isVariadic=*/false,
                           /*isSynthesized=*/true, /*isImplicitlyDeclared=*/true,
@@ -2153,7 +2154,9 @@ void CodeGenModule::EmitObjCIvarInitializations(ObjCImplementationDecl *D) {
   // The constructor returns 'self'.
   ObjCMethodDecl *CTORMethod = ObjCMethodDecl::Create(getContext(), 
                                                 D->getLocation(),
-                                                D->getLocation(), cxxSelector,
+                                                D->getLocation(),
+                                                ArrayRef<SourceLocation>(),
+                                                cxxSelector,
                                                 getContext().getObjCIdType(), 0, 
                                                 D, /*isInstance=*/true,
                                                 /*isVariadic=*/false,
index 44808c8922443476302f60209e15b8264274f8de..1b48225837342eede43e71d9612cc6b8b5858ece 100644 (file)
@@ -972,6 +972,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
   }
 
   SmallVector<IdentifierInfo *, 12> KeyIdents;
+  SmallVector<SourceLocation, 12> KeyLocs;
   SmallVector<Sema::ObjCArgInfo, 12> ArgInfos;
   ParseScope PrototypeScope(this,
                             Scope::FunctionPrototypeScope|Scope::DeclScope);
@@ -1027,6 +1028,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
 
     ArgInfos.push_back(ArgInfo);
     KeyIdents.push_back(SelIdent);
+    KeyLocs.push_back(selLoc);
 
     // Make sure the attributes persist.
     allParamAttrs.takeAllFrom(paramAttrs.getPool());
@@ -1044,8 +1046,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
     }
     
     // Check for another keyword selector.
-    SourceLocation Loc;
-    SelIdent = ParseObjCSelectorPiece(Loc);
+    SelIdent = ParseObjCSelectorPiece(selLoc);
     if (!SelIdent && Tok.isNot(tok::colon))
       break;
     // We have a selector or a colon, continue parsing.
@@ -1088,7 +1089,7 @@ Decl *Parser::ParseObjCMethodDecl(SourceLocation mLoc,
   Decl *Result
        = Actions.ActOnMethodDeclaration(getCurScope(), mLoc, Tok.getLocation(),
                                         mType, DSRet, ReturnType, 
-                                        selLoc, Sel, &ArgInfos[0], 
+                                        KeyLocs, Sel, &ArgInfos[0], 
                                         CParamInfo.data(), CParamInfo.size(),
                                         methodAttrs.getList(),
                                         MethodImplKind, isVariadic, MethodDefinition);
index 23e44748c8afc129452174bc5b5b90275baa1ab4..3a34ffb5433e2d2342600529dc9ee817ef746077 100644 (file)
@@ -2489,7 +2489,7 @@ Decl *Sema::ActOnMethodDeclaration(
     SourceLocation MethodLoc, SourceLocation EndLoc,
     tok::TokenKind MethodType, 
     ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
-    SourceLocation SelectorStartLoc,
+    ArrayRef<SourceLocation> SelectorLocs,
     Selector Sel,
     // optional arguments. The number of types/arguments is obtained
     // from the Sel.getNumArgs().
@@ -2523,11 +2523,12 @@ Decl *Sema::ActOnMethodDeclaration(
   } else { // get the type for "id".
     resultDeclType = Context.getObjCIdType();
     Diag(MethodLoc, diag::warn_missing_method_return_type)
-      << FixItHint::CreateInsertion(SelectorStartLoc, "(id)");
+      << FixItHint::CreateInsertion(SelectorLocs.front(), "(id)");
   }
 
   ObjCMethodDecl* ObjCMethod =
-    ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, Sel, resultDeclType,
+    ObjCMethodDecl::Create(Context, MethodLoc, EndLoc, SelectorLocs, Sel,
+                           resultDeclType,
                            ResultTInfo,
                            CurContext,
                            MethodType == tok::minus, isVariadic,
index 655adde37e208ce4ae0c9f287fd517d710e7c52e..a6f21fbf96399641f7c8ce86039bab350f5d5075 100644 (file)
@@ -1518,6 +1518,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
       property->getLocation();
 
     GetterMethod = ObjCMethodDecl::Create(Context, Loc, Loc,
+                             ArrayRef<SourceLocation>(),
                              property->getGetterName(),
                              property->getType(), 0, CD, /*isInstance=*/true,
                              /*isVariadic=*/false, /*isSynthesized=*/true,
@@ -1555,7 +1556,7 @@ void Sema::ProcessPropertyDecl(ObjCPropertyDecl *property,
         property->getLocation();
 
       SetterMethod =
-        ObjCMethodDecl::Create(Context, Loc, Loc,
+        ObjCMethodDecl::Create(Context, Loc, Loc, ArrayRef<SourceLocation>(),
                                property->getSetterName(), Context.VoidTy, 0,
                                CD, /*isInstance=*/true, /*isVariadic=*/false,
                                /*isSynthesized=*/true,
index 53155b118e637c93445219e3ab2b45413bb4cda9..f370f866867913bb83196621062d127526dd7120 100644 (file)
@@ -1614,6 +1614,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
 
   case DECL_OBJC_METHOD:
     D = ObjCMethodDecl::Create(Context, SourceLocation(), SourceLocation(),
+                               ArrayRef<SourceLocation>(),
                                Selector(), QualType(), 0, 0);
     break;
   case DECL_OBJC_INTERFACE: