Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the Sema class, which performs semantic analysis and |
| 11 | // builds ASTs. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_AST_SEMA_H |
| 16 | #define LLVM_CLANG_AST_SEMA_H |
| 17 | |
Chris Lattner | 7f925cc | 2008-04-11 07:00:53 +0000 | [diff] [blame] | 18 | #include "IdentifierResolver.h" |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 19 | #include "CXXFieldCollector.h" |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 20 | #include "SemaOverload.h" |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 21 | #include "clang/AST/DeclBase.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 22 | #include "clang/Parse/Action.h" |
Chris Lattner | 500d329 | 2009-01-29 05:15:15 +0000 | [diff] [blame] | 23 | #include "clang/Sema/SemaDiagnostic.h" |
Anders Carlsson | c1fcb77 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 24 | #include "llvm/ADT/SmallVector.h" |
Fariborz Jahanian | 85ff264 | 2007-10-05 18:00:57 +0000 | [diff] [blame] | 25 | #include "llvm/ADT/DenseSet.h" |
Chris Lattner | f387668 | 2007-10-07 01:13:46 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/SmallPtrSet.h" |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 27 | #include "llvm/ADT/OwningPtr.h" |
Steve Naroff | 61d6852 | 2009-03-05 15:22:01 +0000 | [diff] [blame] | 28 | #include "clang/AST/DeclObjC.h" |
Douglas Gregor | 4dc6b1c | 2009-01-16 00:38:09 +0000 | [diff] [blame] | 29 | #include <string> |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 30 | #include <vector> |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 31 | |
Chris Lattner | f4021e7 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 32 | namespace llvm { |
| 33 | class APSInt; |
| 34 | } |
| 35 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 36 | namespace clang { |
| 37 | class ASTContext; |
Chris Lattner | 2ae34ed | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 38 | class ASTConsumer; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 39 | class Preprocessor; |
| 40 | class Decl; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 41 | class DeclContext; |
Daniel Dunbar | 12bc692 | 2008-08-11 03:27:53 +0000 | [diff] [blame] | 42 | class DeclSpec; |
Steve Naroff | e8043c3 | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 43 | class NamedDecl; |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 44 | class Stmt; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 45 | class Expr; |
Steve Naroff | 6f9f307 | 2007-09-02 15:34:30 +0000 | [diff] [blame] | 46 | class InitListExpr; |
Douglas Gregor | 05c13a3 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 47 | class DesignatedInitExpr; |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 48 | class CallExpr; |
Douglas Gregor | 1a49af9 | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 49 | class DeclRefExpr; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 50 | class VarDecl; |
| 51 | class ParmVarDecl; |
| 52 | class TypedefDecl; |
| 53 | class FunctionDecl; |
| 54 | class QualType; |
Sebastian Redl | 43af76e | 2009-03-07 12:16:37 +0000 | [diff] [blame] | 55 | class LangOptions; |
Chris Lattner | d217773 | 2007-07-20 16:59:19 +0000 | [diff] [blame] | 56 | class Token; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 57 | class IntegerLiteral; |
Steve Naroff | a49e1fa | 2008-01-22 00:55:40 +0000 | [diff] [blame] | 58 | class StringLiteral; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 59 | class ArrayType; |
| 60 | class LabelStmt; |
Anders Carlsson | c1fcb77 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 61 | class SwitchStmt; |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 62 | class ExtVectorType; |
Steve Naroff | bea0b34 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 63 | class TypedefDecl; |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 64 | class TemplateDecl; |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 65 | class TemplateArgument; |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 66 | class TemplateParameterList; |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 67 | class TemplateTemplateParmDecl; |
Douglas Gregor | 88b7094 | 2009-02-25 22:02:03 +0000 | [diff] [blame] | 68 | class ClassTemplateDecl; |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 69 | class ObjCInterfaceDecl; |
Steve Naroff | e8043c3 | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 70 | class ObjCCompatibleAliasDecl; |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 71 | class ObjCProtocolDecl; |
Chris Lattner | cddc888 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 72 | class ObjCImplDecl; |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 73 | class ObjCImplementationDecl; |
| 74 | class ObjCCategoryImplDecl; |
| 75 | class ObjCCategoryDecl; |
| 76 | class ObjCIvarDecl; |
| 77 | class ObjCMethodDecl; |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 78 | class ObjCPropertyDecl; |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 79 | class ObjCContainerDecl; |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 80 | struct BlockSemaInfo; |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 81 | class BasePaths; |
Sebastian Redl | 43af76e | 2009-03-07 12:16:37 +0000 | [diff] [blame] | 82 | struct MemberLookupCriteria; |
Steve Naroff | bea0b34 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 83 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 84 | /// Sema - This implements semantic analysis and AST building for C. |
| 85 | class Sema : public Action { |
Chris Lattner | f50adff | 2009-02-17 00:58:30 +0000 | [diff] [blame] | 86 | Sema(const Sema&); // DO NOT IMPLEMENT |
| 87 | void operator=(const Sema&); // DO NOT IMPLEMENT |
Chris Lattner | 0b2f4da | 2008-06-29 00:28:59 +0000 | [diff] [blame] | 88 | public: |
Chris Lattner | 53ebff3 | 2009-01-22 19:21:44 +0000 | [diff] [blame] | 89 | const LangOptions &LangOpts; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 90 | Preprocessor &PP; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 91 | ASTContext &Context; |
Chris Lattner | 2ae34ed | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 92 | ASTConsumer &Consumer; |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 93 | Diagnostic &Diags; |
| 94 | SourceManager &SourceMgr; |
Steve Naroff | 0330071 | 2007-11-12 13:56:41 +0000 | [diff] [blame] | 95 | |
Argyrios Kyrtzidis | 53d0ea5 | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 96 | /// CurContext - This is the current declaration context of parsing. |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 97 | DeclContext *CurContext; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 98 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 99 | /// PreDeclaratorDC - Keeps the declaration context before switching to the |
| 100 | /// context of a declarator's nested-name-specifier. |
| 101 | DeclContext *PreDeclaratorDC; |
| 102 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 103 | /// CurBlock - If inside of a block definition, this contains a pointer to |
| 104 | /// the active block object that represents it. |
| 105 | BlockSemaInfo *CurBlock; |
| 106 | |
Steve Naroff | f3cf897 | 2009-02-28 16:48:43 +0000 | [diff] [blame] | 107 | /// ActiveScope - If inside of a function, method, or block definition, |
| 108 | /// this contains a pointer to the active scope that represents it. |
| 109 | Scope *ActiveScope; |
| 110 | |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 111 | /// PackContext - Manages the stack for #pragma pack. An alignment |
| 112 | /// of 0 indicates default alignment. |
Chris Lattner | 574aa40 | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 113 | void *PackContext; // Really a "PragmaPackStack*" |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 114 | |
Anders Carlsson | c1fcb77 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 115 | llvm::SmallVector<SwitchStmt*, 8> SwitchStack; |
Steve Naroff | bea0b34 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 116 | |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 117 | /// ExtVectorDecls - This is a list all the extended vector types. This allows |
| 118 | /// us to associate a raw vector type with one of the ext_vector type names. |
Steve Naroff | bea0b34 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 119 | /// This is only necessary for issuing pretty diagnostics. |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 120 | llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls; |
Chris Lattner | 59907c4 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 121 | |
Steve Naroff | e84a864 | 2008-09-28 14:55:53 +0000 | [diff] [blame] | 122 | /// ObjCImplementations - Keep track of all class @implementations |
| 123 | /// so we can emit errors on duplicates. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 124 | llvm::DenseMap<IdentifierInfo*, ObjCImplementationDecl*> ObjCImplementations; |
Chris Lattner | f387668 | 2007-10-07 01:13:46 +0000 | [diff] [blame] | 125 | |
Steve Naroff | e84a864 | 2008-09-28 14:55:53 +0000 | [diff] [blame] | 126 | /// ObjCCategoryImpls - Maintain a list of category implementations so |
| 127 | /// we can check for duplicates and find local method declarations. |
| 128 | llvm::SmallVector<ObjCCategoryImplDecl*, 8> ObjCCategoryImpls; |
| 129 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 130 | /// ObjCProtocols - Keep track of all protocol declarations declared |
Fariborz Jahanian | 05672a0 | 2007-10-09 18:03:53 +0000 | [diff] [blame] | 131 | /// with @protocol keyword, so that we can emit errors on duplicates and |
Chris Lattner | 4de884d | 2007-10-09 18:18:24 +0000 | [diff] [blame] | 132 | /// find the declarations when needed. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 133 | llvm::DenseMap<IdentifierInfo*, ObjCProtocolDecl*> ObjCProtocols; |
Steve Naroff | 3110251 | 2008-04-02 18:30:49 +0000 | [diff] [blame] | 134 | |
| 135 | /// ObjCInterfaceDecls - Keep track of all class declarations declared |
| 136 | /// with @interface, so that we can emit errors on duplicates and |
| 137 | /// find the declarations when needed. |
| 138 | typedef llvm::DenseMap<const IdentifierInfo*, |
| 139 | ObjCInterfaceDecl*> ObjCInterfaceDeclsTy; |
| 140 | ObjCInterfaceDeclsTy ObjCInterfaceDecls; |
| 141 | |
Steve Naroff | e8043c3 | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 142 | /// ObjCAliasDecls - Keep track of all class declarations declared |
| 143 | /// with @compatibility_alias, so that we can emit errors on duplicates and |
| 144 | /// find the declarations when needed. This construct is ancient and will |
| 145 | /// likely never be seen. Nevertheless, it is here for compatibility. |
Steve Naroff | c822ff4 | 2008-04-02 00:39:51 +0000 | [diff] [blame] | 146 | typedef llvm::DenseMap<const IdentifierInfo*, |
| 147 | ObjCCompatibleAliasDecl*> ObjCAliasTy; |
Steve Naroff | e8043c3 | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 148 | ObjCAliasTy ObjCAliasDecls; |
Steve Naroff | 3110251 | 2008-04-02 18:30:49 +0000 | [diff] [blame] | 149 | |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 150 | /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes. |
| 151 | llvm::OwningPtr<CXXFieldCollector> FieldCollector; |
| 152 | |
Douglas Gregor | 6393519 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 153 | /// \brief A mapping from external names to the most recent |
| 154 | /// locally-scoped external declaration with that name. |
| 155 | /// |
| 156 | /// This map contains external declarations introduced in local |
| 157 | /// scoped, e.g., |
| 158 | /// |
| 159 | /// \code |
| 160 | /// void f() { |
| 161 | /// void foo(int, int); |
| 162 | /// } |
| 163 | /// \endcode |
| 164 | /// |
| 165 | /// Here, the name "foo" will be associated with the declaration on |
| 166 | /// "foo" within f. This name is not visible outside of |
| 167 | /// "f". However, we still find it in two cases: |
| 168 | /// |
| 169 | /// - If we are declaring another external with the name "foo", we |
| 170 | /// can find "foo" as a previous declaration, so that the types |
| 171 | /// of this external declaration can be checked for |
| 172 | /// compatibility. |
| 173 | /// |
| 174 | /// - If we would implicitly declare "foo" (e.g., due to a call to |
| 175 | /// "foo" in C when no prototype or definition is visible), then |
| 176 | /// we find this declaration of "foo" and complain that it is |
| 177 | /// not visible. |
| 178 | llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls; |
| 179 | |
Chris Lattner | 7f925cc | 2008-04-11 07:00:53 +0000 | [diff] [blame] | 180 | IdentifierResolver IdResolver; |
| 181 | |
Chris Lattner | 59907c4 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 182 | // Enum values used by KnownFunctionIDs (see below). |
| 183 | enum { |
Ted Kremenek | 7ff22b2 | 2008-06-16 18:00:42 +0000 | [diff] [blame] | 184 | id_NSLog, |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 185 | id_NSLogv, |
Daniel Dunbar | de45428 | 2008-10-02 18:44:07 +0000 | [diff] [blame] | 186 | id_asprintf, |
Chris Lattner | 59907c4 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 187 | id_vasprintf, |
Chris Lattner | 59907c4 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 188 | id_num_known_functions |
| 189 | }; |
| 190 | |
| 191 | /// KnownFunctionIDs - This is a list of IdentifierInfo objects to a set |
| 192 | /// of known functions used by the semantic analysis to do various |
| 193 | /// kinds of checking (e.g. checking format string errors in printf calls). |
| 194 | /// This list is populated upon the creation of a Sema object. |
Chris Lattner | 06f5485 | 2008-08-23 02:00:52 +0000 | [diff] [blame] | 195 | IdentifierInfo* KnownFunctionIDs[id_num_known_functions]; |
Daniel Dunbar | 662e8b5 | 2008-08-14 22:04:54 +0000 | [diff] [blame] | 196 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 197 | /// Translation Unit Scope - useful to Objective-C actions that need |
| 198 | /// to lookup file scope declarations in the "ordinary" C decl namespace. |
| 199 | /// For example, user-defined classes, built-in "id" type, etc. |
Steve Naroff | b216c88 | 2007-10-09 22:01:59 +0000 | [diff] [blame] | 200 | Scope *TUScope; |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 201 | |
| 202 | /// The C++ "std" namespace, where the standard library resides. Cached here |
| 203 | /// by GetStdNamespace |
| 204 | NamespaceDecl *StdNamespace; |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 205 | |
| 206 | /// A flag to remember whether the implicit forms of operator new and delete |
| 207 | /// have been declared. |
| 208 | bool GlobalNewDeleteDeclared; |
Steve Naroff | 3b95017 | 2007-10-10 21:53:07 +0000 | [diff] [blame] | 209 | |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 210 | /// ObjCMethodList - a linked list of methods with different signatures. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 211 | struct ObjCMethodList { |
| 212 | ObjCMethodDecl *Method; |
| 213 | ObjCMethodList *Next; |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 214 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 215 | ObjCMethodList() { |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 216 | Method = 0; |
| 217 | Next = 0; |
| 218 | } |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 219 | ObjCMethodList(ObjCMethodDecl *M, ObjCMethodList *C) { |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 220 | Method = M; |
| 221 | Next = C; |
| 222 | } |
| 223 | }; |
| 224 | /// Instance/Factory Method Pools - allows efficient lookup when typechecking |
| 225 | /// messages to "id". We need to maintain a list, since selectors can have |
| 226 | /// differing signatures across classes. In Cocoa, this happens to be |
| 227 | /// extremely uncommon (only 1% of selectors are "overloaded"). |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 228 | llvm::DenseMap<Selector, ObjCMethodList> InstanceMethodPool; |
| 229 | llvm::DenseMap<Selector, ObjCMethodList> FactoryMethodPool; |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 230 | |
| 231 | /// Private Helper predicate to check for 'self'. |
| 232 | bool isSelfExpr(Expr *RExpr); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 233 | public: |
Chris Lattner | 2ae34ed | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 234 | Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer); |
Chris Lattner | 574aa40 | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 235 | ~Sema() { |
| 236 | if (PackContext) FreePackedContext(); |
| 237 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 238 | |
Chris Lattner | 53ebff3 | 2009-01-22 19:21:44 +0000 | [diff] [blame] | 239 | const LangOptions &getLangOptions() const { return LangOpts; } |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 240 | Diagnostic &getDiagnostics() const { return Diags; } |
| 241 | SourceManager &getSourceManager() const { return SourceMgr; } |
| 242 | |
Chris Lattner | ebf5ddf | 2008-11-18 21:53:24 +0000 | [diff] [blame] | 243 | /// The primitive diagnostic helpers. |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 244 | DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) { |
Douglas Gregor | ee1828a | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 245 | DiagnosticBuilder DB = Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID); |
Douglas Gregor | 27b152f | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 246 | if (!Diags.isBuiltinNote(DiagID) && |
| 247 | !ActiveTemplateInstantiations.empty() && |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 248 | ActiveTemplateInstantiations.back() |
Douglas Gregor | 27b152f | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 249 | != LastTemplateInstantiationErrorContext) |
Douglas Gregor | ee1828a | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 250 | DB << PostDiagnosticHook(PrintInstantiationStackHook, this); |
| 251 | return DB; |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 252 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 253 | |
Chris Lattner | 394a3fd | 2007-08-31 04:53:24 +0000 | [diff] [blame] | 254 | virtual void DeleteExpr(ExprTy *E); |
| 255 | virtual void DeleteStmt(StmtTy *S); |
| 256 | |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 257 | OwningExprResult Owned(Expr* E) { return OwningExprResult(*this, E); } |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 258 | OwningExprResult Owned(ExprResult R) { |
Douglas Gregor | 5ac8aff | 2009-01-26 22:44:13 +0000 | [diff] [blame] | 259 | if (R.isInvalid()) |
Steve Naroff | 872b9ac | 2009-01-21 22:32:33 +0000 | [diff] [blame] | 260 | return ExprError(); |
Douglas Gregor | 5ac8aff | 2009-01-26 22:44:13 +0000 | [diff] [blame] | 261 | return OwningExprResult(*this, R.get()); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 262 | } |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 263 | OwningStmtResult Owned(Stmt* S) { return OwningStmtResult(*this, S); } |
| 264 | |
Chris Lattner | 9299f3f | 2008-08-23 03:19:52 +0000 | [diff] [blame] | 265 | virtual void ActOnEndOfTranslationUnit(); |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 266 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 267 | //===--------------------------------------------------------------------===// |
| 268 | // Type Analysis / Processing: SemaType.cpp. |
| 269 | // |
Chris Lattner | fca0ddd | 2008-06-26 06:27:57 +0000 | [diff] [blame] | 270 | QualType ConvertDeclSpecToType(const DeclSpec &DS); |
Chris Lattner | c9b346d | 2008-06-29 00:50:08 +0000 | [diff] [blame] | 271 | void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL); |
Douglas Gregor | cd281c3 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 272 | QualType BuildPointerType(QualType T, unsigned Quals, |
| 273 | SourceLocation Loc, DeclarationName Entity); |
| 274 | QualType BuildReferenceType(QualType T, unsigned Quals, |
| 275 | SourceLocation Loc, DeclarationName Entity); |
| 276 | QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, |
| 277 | Expr *ArraySize, unsigned Quals, |
| 278 | SourceLocation Loc, DeclarationName Entity); |
Douglas Gregor | 724651c | 2009-02-28 01:04:19 +0000 | [diff] [blame] | 279 | QualType BuildFunctionType(QualType T, |
| 280 | QualType *ParamTypes, unsigned NumParamTypes, |
| 281 | bool Variadic, unsigned Quals, |
| 282 | SourceLocation Loc, DeclarationName Entity); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 283 | QualType GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip = 0); |
Douglas Gregor | 10bd368 | 2008-11-17 22:58:34 +0000 | [diff] [blame] | 284 | DeclarationName GetNameForDeclarator(Declarator &D); |
| 285 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 286 | QualType ObjCGetTypeForMethodDefinition(DeclTy *D); |
Fariborz Jahanian | 306d68f | 2007-11-08 23:49:49 +0000 | [diff] [blame] | 287 | |
Douglas Gregor | 5737326 | 2008-10-22 14:17:15 +0000 | [diff] [blame] | 288 | bool UnwrapSimilarPointerTypes(QualType& T1, QualType& T2); |
| 289 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 290 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D); |
Sebastian Redl | 37d6de3 | 2008-11-08 13:00:26 +0000 | [diff] [blame] | 291 | |
Douglas Gregor | 86447ec | 2009-03-09 16:13:40 +0000 | [diff] [blame] | 292 | bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, |
Douglas Gregor | 4ec339f | 2009-01-19 19:26:10 +0000 | [diff] [blame] | 293 | SourceRange Range1 = SourceRange(), |
| 294 | SourceRange Range2 = SourceRange(), |
| 295 | QualType PrintType = QualType()); |
| 296 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 297 | //===--------------------------------------------------------------------===// |
| 298 | // Symbol table / Decl tracking callbacks: SemaDecl.cpp. |
| 299 | // |
Chris Lattner | 21ff9c9 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 300 | |
| 301 | /// getDeclName - Return a pretty name for the specified decl if possible, or |
| 302 | /// an empty string if not. This is used for pretty crash reporting. |
| 303 | virtual std::string getDeclName(DeclTy *D); |
| 304 | |
Douglas Gregor | 1a51b4a | 2009-02-09 15:09:02 +0000 | [diff] [blame] | 305 | virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc, |
Douglas Gregor | b696ea3 | 2009-02-04 17:00:24 +0000 | [diff] [blame] | 306 | Scope *S, const CXXScopeSpec *SS); |
Chris Lattner | 76a642f | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 307 | virtual DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup){ |
Douglas Gregor | 584049d | 2008-12-15 23:53:10 +0000 | [diff] [blame] | 308 | return ActOnDeclarator(S, D, LastInGroup, false); |
| 309 | } |
| 310 | DeclTy *ActOnDeclarator(Scope *S, Declarator &D, DeclTy *LastInGroup, |
| 311 | bool IsFunctionDefinition); |
Douglas Gregor | 6393519 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 312 | void RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl, |
| 313 | Scope *S); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 314 | NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
| 315 | QualType R, Decl* LastDeclarator, |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 316 | Decl* PrevDecl, bool& InvalidDecl, |
| 317 | bool &Redeclaration); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 318 | NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 319 | QualType R, Decl* LastDeclarator, |
Douglas Gregor | 8f30105 | 2009-02-24 19:23:27 +0000 | [diff] [blame] | 320 | NamedDecl* PrevDecl, bool& InvalidDecl, |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 321 | bool &Redeclaration); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 322 | NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
| 323 | QualType R, Decl *LastDeclarator, |
Douglas Gregor | 04495c8 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 324 | NamedDecl* PrevDecl, |
| 325 | bool IsFunctionDefinition, |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 326 | bool& InvalidDecl, bool &Redeclaration); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 327 | virtual DeclTy *ActOnParamDeclarator(Scope *S, Declarator &D); |
| 328 | virtual void ActOnParamDefaultArgument(DeclTy *param, |
| 329 | SourceLocation EqualLoc, |
| 330 | ExprTy *defarg); |
Douglas Gregor | 61366e9 | 2008-12-24 00:01:03 +0000 | [diff] [blame] | 331 | virtual void ActOnParamUnparsedDefaultArgument(DeclTy *param, |
| 332 | SourceLocation EqualLoc); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 333 | virtual void ActOnParamDefaultArgumentError(DeclTy *param); |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 334 | virtual void AddInitializerToDecl(DeclTy *dcl, ExprArg init); |
| 335 | void AddInitializerToDecl(DeclTy *dcl, ExprArg init, bool DirectInit); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 336 | void ActOnUninitializedDecl(DeclTy *dcl); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 337 | virtual DeclTy *FinalizeDeclaratorGroup(Scope *S, DeclTy *Group); |
| 338 | |
Douglas Gregor | be109b3 | 2009-01-23 16:23:13 +0000 | [diff] [blame] | 339 | virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D); |
Chris Lattner | b652cea | 2007-10-09 17:14:05 +0000 | [diff] [blame] | 340 | virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, Declarator &D); |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 341 | virtual DeclTy *ActOnStartOfFunctionDef(Scope *S, DeclTy *D); |
Steve Naroff | ebf6443 | 2009-02-28 16:59:13 +0000 | [diff] [blame] | 342 | virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclTy *D); |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 343 | |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 344 | virtual DeclTy *ActOnFinishFunctionBody(DeclTy *Decl, StmtArg Body); |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 345 | virtual DeclTy *ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr); |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 346 | |
Steve Naroff | b216c88 | 2007-10-09 22:01:59 +0000 | [diff] [blame] | 347 | /// Scope actions. |
| 348 | virtual void ActOnPopScope(SourceLocation Loc, Scope *S); |
| 349 | virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 350 | |
| 351 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 352 | /// no declarator (e.g. "struct foo;") is parsed. |
Sebastian Redl | a4ed0d8 | 2008-12-28 15:28:59 +0000 | [diff] [blame] | 353 | virtual DeclTy *ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 354 | |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 355 | bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, |
| 356 | RecordDecl *AnonRecord); |
| 357 | virtual DeclTy *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, |
| 358 | RecordDecl *Record); |
| 359 | |
Douglas Gregor | 0b7a158 | 2009-01-17 00:42:38 +0000 | [diff] [blame] | 360 | virtual DeclTy *ActOnTag(Scope *S, unsigned TagSpec, TagKind TK, |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 361 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 362 | IdentifierInfo *Name, SourceLocation NameLoc, |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 363 | AttributeList *Attr); |
Ted Kremenek | 4b7c983 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 364 | |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 365 | virtual void ActOnDefs(Scope *S, DeclTy *TagD, SourceLocation DeclStart, |
Chris Lattner | 06f5485 | 2008-08-23 02:00:52 +0000 | [diff] [blame] | 366 | IdentifierInfo *ClassName, |
| 367 | llvm::SmallVectorImpl<DeclTy*> &Decls); |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 368 | virtual DeclTy *ActOnField(Scope *S, DeclTy *TagD, SourceLocation DeclStart, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 369 | Declarator &D, ExprTy *BitfieldWidth); |
Chris Lattner | 2479366 | 2009-03-05 22:45:59 +0000 | [diff] [blame] | 370 | |
| 371 | FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, |
Douglas Gregor | 4dd55f5 | 2009-03-11 20:50:30 +0000 | [diff] [blame^] | 372 | Declarator &D, Expr *BitfieldWidth, |
| 373 | AccessSpecifier AS); |
Chris Lattner | 2479366 | 2009-03-05 22:45:59 +0000 | [diff] [blame] | 374 | |
Douglas Gregor | 3cf538d | 2009-03-11 18:59:21 +0000 | [diff] [blame] | 375 | FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, |
| 376 | RecordDecl *Record, SourceLocation Loc, |
| 377 | bool Mutable, Expr *BitfieldWidth, |
Douglas Gregor | 4dd55f5 | 2009-03-11 20:50:30 +0000 | [diff] [blame^] | 378 | AccessSpecifier AS, NamedDecl *PrevDecl, |
Douglas Gregor | 3cf538d | 2009-03-11 18:59:21 +0000 | [diff] [blame] | 379 | Declarator *D = 0); |
Fariborz Jahanian | 1d78cc4 | 2008-04-10 23:32:45 +0000 | [diff] [blame] | 380 | |
| 381 | virtual DeclTy *ActOnIvar(Scope *S, SourceLocation DeclStart, |
| 382 | Declarator &D, ExprTy *BitfieldWidth, |
Fariborz Jahanian | 45bc03f | 2008-04-11 16:55:42 +0000 | [diff] [blame] | 383 | tok::ObjCKeywordKind visibility); |
Fariborz Jahanian | 1d78cc4 | 2008-04-10 23:32:45 +0000 | [diff] [blame] | 384 | |
Steve Naroff | f13271f | 2007-09-14 23:09:53 +0000 | [diff] [blame] | 385 | // This is used for both record definitions and ObjC interface declarations. |
Fariborz Jahanian | 9d048ff | 2007-09-29 00:54:24 +0000 | [diff] [blame] | 386 | virtual void ActOnFields(Scope* S, |
Steve Naroff | 60fccee | 2007-10-29 21:38:07 +0000 | [diff] [blame] | 387 | SourceLocation RecLoc, DeclTy *TagDecl, |
| 388 | DeclTy **Fields, unsigned NumFields, |
Daniel Dunbar | 1bfe1c2 | 2008-10-03 02:03:53 +0000 | [diff] [blame] | 389 | SourceLocation LBrac, SourceLocation RBrac, |
| 390 | AttributeList *AttrList); |
Douglas Gregor | 72de667 | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 391 | |
| 392 | /// ActOnTagStartDefinition - Invoked when we have entered the |
| 393 | /// scope of a tag's definition (e.g., for an enumeration, class, |
| 394 | /// struct, or union). |
| 395 | virtual void ActOnTagStartDefinition(Scope *S, DeclTy *TagDecl); |
| 396 | |
| 397 | /// ActOnTagFinishDefinition - Invoked once we have finished parsing |
| 398 | /// the definition of a tag (enumeration, class, struct, or union). |
| 399 | virtual void ActOnTagFinishDefinition(Scope *S, DeclTy *TagDecl); |
| 400 | |
Steve Naroff | 08d92e4 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 401 | virtual DeclTy *ActOnEnumConstant(Scope *S, DeclTy *EnumDecl, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 402 | DeclTy *LastEnumConstant, |
| 403 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 404 | SourceLocation EqualLoc, ExprTy *Val); |
Steve Naroff | 08d92e4 | 2007-09-15 18:49:24 +0000 | [diff] [blame] | 405 | virtual void ActOnEnumBody(SourceLocation EnumLoc, DeclTy *EnumDecl, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 406 | DeclTy **Elements, unsigned NumElements); |
Sebastian Redl | 37d6de3 | 2008-11-08 13:00:26 +0000 | [diff] [blame] | 407 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 408 | DeclContext *getContainingDC(DeclContext *DC); |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 409 | |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 410 | /// Set the current declaration context until it gets popped. |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 411 | void PushDeclContext(Scope *S, DeclContext *DC); |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 412 | void PopDeclContext(); |
Argyrios Kyrtzidis | 53d0ea5 | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 413 | |
Chris Lattner | 371f258 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 414 | /// getCurFunctionDecl - If inside of a function body, this returns a pointer |
| 415 | /// to the function decl for the function being parsed. If we're currently |
| 416 | /// in a 'block', this returns the containing context. |
| 417 | FunctionDecl *getCurFunctionDecl(); |
| 418 | |
| 419 | /// getCurMethodDecl - If inside of a method body, this returns a pointer to |
| 420 | /// the method decl for the method being parsed. If we're currently |
| 421 | /// in a 'block', this returns the containing context. |
Daniel Dunbar | c4a1dea | 2008-08-11 05:35:13 +0000 | [diff] [blame] | 422 | ObjCMethodDecl *getCurMethodDecl(); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 423 | |
Chris Lattner | 371f258 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 424 | /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method |
| 425 | /// or C function we're in, otherwise return null. If we're currently |
| 426 | /// in a 'block', this returns the containing context. |
| 427 | NamedDecl *getCurFunctionOrMethodDecl(); |
| 428 | |
Argyrios Kyrtzidis | 87f3ff0 | 2008-04-12 00:47:19 +0000 | [diff] [blame] | 429 | /// Add this decl to the scope shadowed decl chains. |
| 430 | void PushOnScopeChains(NamedDecl *D, Scope *S); |
| 431 | |
Argyrios Kyrtzidis | 15a12d0 | 2008-09-09 21:18:04 +0000 | [diff] [blame] | 432 | /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true |
| 433 | /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns |
| 434 | /// true if 'D' belongs to the given declaration context. |
| 435 | bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S = 0) { |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 436 | return IdResolver.isDeclInScope(D, Ctx, Context, S); |
Argyrios Kyrtzidis | 15a12d0 | 2008-09-09 21:18:04 +0000 | [diff] [blame] | 437 | } |
| 438 | |
Eli Friedman | 8f17b66 | 2009-02-28 05:41:13 +0000 | [diff] [blame] | 439 | |
| 440 | void RecursiveCalcJumpScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap, |
| 441 | llvm::DenseMap<void*, Stmt*>& PopScopeMap, |
| 442 | llvm::DenseMap<Stmt*, void*>& GotoScopeMap, |
| 443 | std::vector<void*>& ScopeStack, |
| 444 | Stmt* CurStmt); |
| 445 | |
| 446 | void RecursiveCalcLabelScopes(llvm::DenseMap<Stmt*, void*>& LabelScopeMap, |
| 447 | llvm::DenseMap<void*, Stmt*>& PopScopeMap, |
| 448 | std::vector<void*>& ScopeStack, |
| 449 | Stmt* CurStmt, |
| 450 | Stmt* ParentCompoundStmt); |
| 451 | |
Chris Lattner | f1d705c | 2008-02-21 01:07:18 +0000 | [diff] [blame] | 452 | /// Subroutines of ActOnDeclarator(). |
Chris Lattner | 41af093 | 2007-11-14 06:34:38 +0000 | [diff] [blame] | 453 | TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T, |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 454 | Decl *LastDecl); |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 455 | bool MergeTypeDefDecl(TypedefDecl *New, Decl *Old); |
| 456 | bool MergeFunctionDecl(FunctionDecl *New, Decl *Old); |
Douglas Gregor | 04495c8 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 457 | bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old); |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 458 | bool MergeVarDecl(VarDecl *New, Decl *Old); |
| 459 | bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 460 | |
| 461 | /// C++ Overloading. |
| 462 | bool IsOverload(FunctionDecl *New, Decl* OldD, |
| 463 | OverloadedFunctionDecl::function_iterator &MatchedDecl); |
Douglas Gregor | 225c41e | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 464 | ImplicitConversionSequence |
| 465 | TryImplicitConversion(Expr* From, QualType ToType, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 466 | bool SuppressUserConversions = false, |
| 467 | bool AllowExplicit = false); |
Douglas Gregor | 60d62c2 | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 468 | bool IsStandardConversion(Expr *From, QualType ToType, |
| 469 | StandardConversionSequence& SCS); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 470 | bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType); |
| 471 | bool IsFloatingPointPromotion(QualType FromType, QualType ToType); |
Douglas Gregor | 5cdf821 | 2009-02-12 00:15:05 +0000 | [diff] [blame] | 472 | bool IsComplexPromotion(QualType FromType, QualType ToType); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 473 | bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, |
Douglas Gregor | 45920e8 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 474 | QualType& ConvertedType, bool &IncompatibleObjC); |
Douglas Gregor | c788751 | 2008-12-19 19:13:09 +0000 | [diff] [blame] | 475 | bool isObjCPointerConversion(QualType FromType, QualType ToType, |
| 476 | QualType& ConvertedType, bool &IncompatibleObjC); |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 477 | bool CheckPointerConversion(Expr *From, QualType ToType); |
Sebastian Redl | 4433aaf | 2009-01-25 19:43:20 +0000 | [diff] [blame] | 478 | bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, |
| 479 | QualType &ConvertedType); |
| 480 | bool CheckMemberPointerConversion(Expr *From, QualType ToType); |
Douglas Gregor | 98cd599 | 2008-10-21 23:43:52 +0000 | [diff] [blame] | 481 | bool IsQualificationConversion(QualType FromType, QualType ToType); |
Douglas Gregor | 60d62c2 | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 482 | bool IsUserDefinedConversion(Expr *From, QualType ToType, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 483 | UserDefinedConversionSequence& User, |
Douglas Gregor | 734d986 | 2009-01-30 23:27:23 +0000 | [diff] [blame] | 484 | bool AllowConversionFunctions, |
| 485 | bool AllowExplicit); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 486 | |
| 487 | ImplicitConversionSequence::CompareKind |
| 488 | CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1, |
| 489 | const ImplicitConversionSequence& ICS2); |
| 490 | |
| 491 | ImplicitConversionSequence::CompareKind |
| 492 | CompareStandardConversionSequences(const StandardConversionSequence& SCS1, |
| 493 | const StandardConversionSequence& SCS2); |
| 494 | |
Douglas Gregor | 5737326 | 2008-10-22 14:17:15 +0000 | [diff] [blame] | 495 | ImplicitConversionSequence::CompareKind |
| 496 | CompareQualificationConversions(const StandardConversionSequence& SCS1, |
| 497 | const StandardConversionSequence& SCS2); |
| 498 | |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 499 | ImplicitConversionSequence::CompareKind |
| 500 | CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1, |
| 501 | const StandardConversionSequence& SCS2); |
| 502 | |
Douglas Gregor | 225c41e | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 503 | ImplicitConversionSequence |
| 504 | TryCopyInitialization(Expr* From, QualType ToType, |
| 505 | bool SuppressUserConversions = false); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 506 | bool PerformCopyInitialization(Expr *&From, QualType ToType, |
| 507 | const char *Flavor); |
| 508 | |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 509 | ImplicitConversionSequence |
| 510 | TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method); |
| 511 | bool PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method); |
| 512 | |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 513 | ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From); |
| 514 | bool PerformContextuallyConvertToBool(Expr *&From); |
| 515 | |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 516 | /// OverloadingResult - Capture the result of performing overload |
| 517 | /// resolution. |
| 518 | enum OverloadingResult { |
| 519 | OR_Success, ///< Overload resolution succeeded. |
| 520 | OR_No_Viable_Function, ///< No viable function found. |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 521 | OR_Ambiguous, ///< Ambiguous candidates found. |
| 522 | OR_Deleted ///< Overload resoltuion refers to a deleted function. |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 523 | }; |
| 524 | |
| 525 | void AddOverloadCandidate(FunctionDecl *Function, |
| 526 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 225c41e | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 527 | OverloadCandidateSet& CandidateSet, |
| 528 | bool SuppressUserConversions = false); |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 529 | void AddMethodCandidate(CXXMethodDecl *Method, |
| 530 | Expr *Object, Expr **Args, unsigned NumArgs, |
| 531 | OverloadCandidateSet& CandidateSet, |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 532 | bool SuppressUserConversions = false); |
Douglas Gregor | f1991ea | 2008-11-07 22:36:19 +0000 | [diff] [blame] | 533 | void AddConversionCandidate(CXXConversionDecl *Conversion, |
| 534 | Expr *From, QualType ToType, |
| 535 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | 106c6eb | 2008-11-19 22:57:39 +0000 | [diff] [blame] | 536 | void AddSurrogateCandidate(CXXConversionDecl *Conversion, |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 537 | const FunctionProtoType *Proto, |
Douglas Gregor | 106c6eb | 2008-11-19 22:57:39 +0000 | [diff] [blame] | 538 | Expr *Object, Expr **Args, unsigned NumArgs, |
| 539 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 540 | bool AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S, |
| 541 | SourceLocation OpLoc, |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 542 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 543 | OverloadCandidateSet& CandidateSet, |
| 544 | SourceRange OpRange = SourceRange()); |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 545 | void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, |
| 546 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 88b4bf2 | 2009-01-13 00:52:54 +0000 | [diff] [blame] | 547 | OverloadCandidateSet& CandidateSet, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 548 | bool IsAssignmentOperator = false, |
| 549 | unsigned NumContextualBoolArguments = 0); |
Douglas Gregor | 7425373 | 2008-11-19 15:42:04 +0000 | [diff] [blame] | 550 | void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, |
| 551 | Expr **Args, unsigned NumArgs, |
| 552 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 553 | void AddArgumentDependentLookupCandidates(DeclarationName Name, |
| 554 | Expr **Args, unsigned NumArgs, |
| 555 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 556 | bool isBetterOverloadCandidate(const OverloadCandidate& Cand1, |
| 557 | const OverloadCandidate& Cand2); |
| 558 | OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet, |
| 559 | OverloadCandidateSet::iterator& Best); |
| 560 | void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet, |
| 561 | bool OnlyViable); |
| 562 | |
Douglas Gregor | 904eed3 | 2008-11-10 20:40:00 +0000 | [diff] [blame] | 563 | FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, |
| 564 | bool Complain); |
| 565 | void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn); |
| 566 | |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 567 | FunctionDecl *ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee, |
| 568 | DeclarationName UnqualifiedName, |
Douglas Gregor | 0a39668 | 2008-11-26 06:01:48 +0000 | [diff] [blame] | 569 | SourceLocation LParenLoc, |
| 570 | Expr **Args, unsigned NumArgs, |
| 571 | SourceLocation *CommaLocs, |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 572 | SourceLocation RParenLoc, |
Douglas Gregor | 1733001 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 573 | bool &ArgumentDependentLookup); |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 574 | ExprResult |
| 575 | BuildCallToMemberFunction(Scope *S, Expr *MemExpr, |
| 576 | SourceLocation LParenLoc, Expr **Args, |
| 577 | unsigned NumArgs, SourceLocation *CommaLocs, |
| 578 | SourceLocation RParenLoc); |
Douglas Gregor | f9eb905 | 2008-11-19 21:05:33 +0000 | [diff] [blame] | 579 | ExprResult |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 580 | BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, |
Douglas Gregor | f9eb905 | 2008-11-19 21:05:33 +0000 | [diff] [blame] | 581 | Expr **Args, unsigned NumArgs, |
| 582 | SourceLocation *CommaLocs, |
| 583 | SourceLocation RParenLoc); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 584 | |
Douglas Gregor | 3fc749d | 2008-12-23 00:26:44 +0000 | [diff] [blame] | 585 | ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, |
Douglas Gregor | 8ba1074 | 2008-11-20 16:27:02 +0000 | [diff] [blame] | 586 | SourceLocation MemberLoc, |
| 587 | IdentifierInfo &Member); |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 588 | |
Chris Lattner | 823c44e | 2009-01-06 07:27:21 +0000 | [diff] [blame] | 589 | /// Helpers for dealing with function parameters. |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 590 | bool CheckParmsForFunctionDef(FunctionDecl *FD); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 591 | void CheckCXXDefaultArguments(FunctionDecl *FD); |
Douglas Gregor | 6d6eb57 | 2008-05-07 04:49:29 +0000 | [diff] [blame] | 592 | void CheckExtraCXXDefaultArguments(Declarator &D); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 593 | |
Douglas Gregor | 1a0d31a | 2009-01-12 18:45:55 +0000 | [diff] [blame] | 594 | Scope *getNonFieldDeclScope(Scope *S); |
| 595 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 596 | /// \name Name lookup |
| 597 | /// |
| 598 | /// These routines provide name lookup that is used during semantic |
| 599 | /// analysis to resolve the various kinds of names (identifiers, |
| 600 | /// overloaded operator names, constructor names, etc.) into zero or |
| 601 | /// more declarations within a particular scope. The major entry |
| 602 | /// points are LookupName, which performs unqualified name lookup, |
| 603 | /// and LookupQualifiedName, which performs qualified name lookup. |
| 604 | /// |
| 605 | /// All name lookup is performed based on some specific criteria, |
| 606 | /// which specify what names will be visible to name lookup and how |
| 607 | /// far name lookup should work. These criteria are important both |
| 608 | /// for capturing language semantics (certain lookups will ignore |
| 609 | /// certain names, for example) and for performance, since name |
| 610 | /// lookup is often a bottleneck in the compilation of C++. Name |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 611 | /// lookup criteria is specified via the LookupCriteria enumeration. |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 612 | /// |
| 613 | /// The results of name lookup can vary based on the kind of name |
| 614 | /// lookup performed, the current language, and the translation |
| 615 | /// unit. In C, for example, name lookup will either return nothing |
| 616 | /// (no entity found) or a single declaration. In C++, name lookup |
| 617 | /// can additionally refer to a set of overloaded functions or |
| 618 | /// result in an ambiguity. All of the possible results of name |
| 619 | /// lookup are captured by the LookupResult class, which provides |
| 620 | /// the ability to distinguish among them. |
| 621 | //@{ |
Douglas Gregor | f780abc | 2008-12-30 03:27:21 +0000 | [diff] [blame] | 622 | |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 623 | /// @brief Describes the kind of name lookup to perform. |
| 624 | enum LookupNameKind { |
| 625 | /// Ordinary name lookup, which finds ordinary names (functions, |
| 626 | /// variables, typedefs, etc.) in C and most kinds of names |
| 627 | /// (functions, variables, members, types, etc.) in C++. |
| 628 | LookupOrdinaryName = 0, |
| 629 | /// Tag name lookup, which finds the names of enums, classes, |
| 630 | /// structs, and unions. |
| 631 | LookupTagName, |
| 632 | /// Member name lookup, which finds the names of |
| 633 | /// class/struct/union members. |
| 634 | LookupMemberName, |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 635 | // Look up of an operator name (e.g., operator+) for use with |
| 636 | // operator overloading. This lookup is similar to ordinary name |
| 637 | // lookup, but will ignore any declarations that are class |
| 638 | // members. |
| 639 | LookupOperatorName, |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 640 | /// Look up of a name that precedes the '::' scope resolution |
| 641 | /// operator in C++. This lookup completely ignores operator, |
| 642 | /// function, and enumerator names (C++ [basic.lookup.qual]p1). |
| 643 | LookupNestedNameSpecifierName, |
| 644 | /// Look up a namespace name within a C++ using directive or |
| 645 | /// namespace alias definition, ignoring non-namespace names (C++ |
| 646 | /// [basic.lookup.udir]p1). |
Douglas Gregor | d6f7e9d | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 647 | LookupNamespaceName, |
| 648 | // Look up an ordinary name that is going to be redeclared as a |
| 649 | // name with linkage. This lookup ignores any declarations that |
| 650 | // are outside of the current scope unless they have linkage. See |
| 651 | // C99 6.2.2p4-5 and C++ [basic.link]p6. |
| 652 | LookupRedeclarationWithLinkage |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 653 | }; |
| 654 | |
| 655 | /// @brief Represents the results of name lookup. |
| 656 | /// |
| 657 | /// An instance of the LookupResult class captures the results of a |
| 658 | /// single name lookup, which can return no result (nothing found), |
| 659 | /// a single declaration, a set of overloaded functions, or an |
| 660 | /// ambiguity. Use the getKind() method to determine which of these |
| 661 | /// results occurred for a given lookup. |
| 662 | /// |
| 663 | /// Any non-ambiguous lookup can be converted into a single |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 664 | /// (possibly NULL) @c NamedDecl* via a conversion function or the |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 665 | /// getAsDecl() method. This conversion permits the common-case |
| 666 | /// usage in C and Objective-C where name lookup will always return |
| 667 | /// a single declaration. |
Douglas Gregor | 69d993a | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 668 | struct LookupResult { |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 669 | /// The kind of entity that is actually stored within the |
| 670 | /// LookupResult object. |
Douglas Gregor | 69d993a | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 671 | enum { |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 672 | /// First is a single declaration (a NamedDecl*), which may be NULL. |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 673 | SingleDecl, |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 674 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 675 | /// First is a single declaration (an OverloadedFunctionDecl*). |
| 676 | OverloadedDeclSingleDecl, |
| 677 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 678 | /// [First, Last) is an iterator range represented as opaque |
| 679 | /// pointers used to reconstruct IdentifierResolver::iterators. |
| 680 | OverloadedDeclFromIdResolver, |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 681 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 682 | /// [First, Last) is an iterator range represented as opaque |
| 683 | /// pointers used to reconstruct DeclContext::lookup_iterators. |
| 684 | OverloadedDeclFromDeclContext, |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 685 | |
| 686 | /// First is a pointer to a BasePaths structure, which is owned |
| 687 | /// by the LookupResult. Last is non-zero to indicate that the |
| 688 | /// ambiguity is caused by two names found in base class |
| 689 | /// subobjects of different types. |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 690 | AmbiguousLookupStoresBasePaths, |
| 691 | |
| 692 | /// [First, Last) is an iterator range represented as opaque |
| 693 | /// pointers used to reconstruct new'ed Decl*[] array containing |
| 694 | /// found ambiguous decls. LookupResult is owner of this array. |
| 695 | AmbiguousLookupStoresDecls |
| 696 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 697 | } StoredKind; |
| 698 | |
| 699 | /// The first lookup result, whose contents depend on the kind of |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 700 | /// lookup result. This may be a NamedDecl* (if StoredKind == |
| 701 | /// SingleDecl), OverloadedFunctionDecl* (if StoredKind == |
| 702 | /// OverloadedDeclSingleDecl), the opaque pointer from an |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 703 | /// IdentifierResolver::iterator (if StoredKind == |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 704 | /// OverloadedDeclFromIdResolver), a DeclContext::lookup_iterator |
| 705 | /// (if StoredKind == OverloadedDeclFromDeclContext), or a |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 706 | /// BasePaths pointer (if StoredKind == AmbiguousLookupStoresBasePaths). |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 707 | mutable uintptr_t First; |
| 708 | |
| 709 | /// The last lookup result, whose contents depend on the kind of |
| 710 | /// lookup result. This may be unused (if StoredKind == |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 711 | /// SingleDecl), it may have the same type as First (for |
| 712 | /// overloaded function declarations), or is may be used as a |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 713 | /// Boolean value (if StoredKind == AmbiguousLookupStoresBasePaths). |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 714 | mutable uintptr_t Last; |
| 715 | |
| 716 | /// Context - The context in which we will build any |
| 717 | /// OverloadedFunctionDecl nodes needed by the conversion to |
| 718 | /// Decl*. |
| 719 | ASTContext *Context; |
| 720 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 721 | /// @brief The kind of entity found by name lookup. |
| 722 | enum LookupKind { |
| 723 | /// @brief No entity found met the criteria. |
| 724 | NotFound = 0, |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 725 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 726 | /// @brief Name lookup found a single declaration that met the |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 727 | /// criteria. getAsDecl will return this declaration. |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 728 | Found, |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 729 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 730 | /// @brief Name lookup found a set of overloaded functions that |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 731 | /// met the criteria. getAsDecl will turn this set of overloaded |
| 732 | /// functions into an OverloadedFunctionDecl. |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 733 | FoundOverloaded, |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 734 | |
| 735 | /// Name lookup results in an ambiguity because multiple |
| 736 | /// entities that meet the lookup criteria were found in |
| 737 | /// subobjects of different types. For example: |
| 738 | /// @code |
| 739 | /// struct A { void f(int); } |
| 740 | /// struct B { void f(double); } |
| 741 | /// struct C : A, B { }; |
| 742 | /// void test(C c) { |
| 743 | /// c.f(0); // error: A::f and B::f come from subobjects of different |
| 744 | /// // types. overload resolution is not performed. |
| 745 | /// } |
| 746 | /// @endcode |
| 747 | AmbiguousBaseSubobjectTypes, |
| 748 | |
| 749 | /// Name lookup results in an ambiguity because multiple |
| 750 | /// nonstatic entities that meet the lookup criteria were found |
| 751 | /// in different subobjects of the same type. For example: |
| 752 | /// @code |
| 753 | /// struct A { int x; }; |
| 754 | /// struct B : A { }; |
| 755 | /// struct C : A { }; |
| 756 | /// struct D : B, C { }; |
| 757 | /// int test(D d) { |
| 758 | /// return d.x; // error: 'x' is found in two A subobjects (of B and C) |
| 759 | /// } |
| 760 | /// @endcode |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 761 | AmbiguousBaseSubobjects, |
| 762 | |
| 763 | /// Name lookup results in an ambiguity because multiple definitions |
| 764 | /// of entity that meet the lookup criteria were found in different |
| 765 | /// declaration contexts. |
| 766 | /// @code |
| 767 | /// namespace A { |
| 768 | /// int i; |
| 769 | /// namespace B { int i; } |
| 770 | /// int test() { |
| 771 | /// using namespace B; |
| 772 | /// return i; // error 'i' is found in namespace A and A::B |
| 773 | /// } |
| 774 | /// } |
| 775 | /// @endcode |
| 776 | AmbiguousReference |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 777 | }; |
| 778 | |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 779 | static LookupResult CreateLookupResult(ASTContext &Context, NamedDecl *D); |
Douglas Gregor | 4bb64e7 | 2009-01-15 02:19:31 +0000 | [diff] [blame] | 780 | |
Douglas Gregor | 69d993a | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 781 | static LookupResult CreateLookupResult(ASTContext &Context, |
| 782 | IdentifierResolver::iterator F, |
| 783 | IdentifierResolver::iterator L); |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 784 | |
Douglas Gregor | 69d993a | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 785 | static LookupResult CreateLookupResult(ASTContext &Context, |
| 786 | DeclContext::lookup_iterator F, |
| 787 | DeclContext::lookup_iterator L); |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 788 | |
Douglas Gregor | 69d993a | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 789 | static LookupResult CreateLookupResult(ASTContext &Context, BasePaths *Paths, |
| 790 | bool DifferentSubobjectTypes) { |
| 791 | LookupResult Result; |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 792 | Result.StoredKind = AmbiguousLookupStoresBasePaths; |
Douglas Gregor | 69d993a | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 793 | Result.First = reinterpret_cast<uintptr_t>(Paths); |
| 794 | Result.Last = DifferentSubobjectTypes? 1 : 0; |
| 795 | Result.Context = &Context; |
| 796 | return Result; |
| 797 | } |
Douglas Gregor | 4bb64e7 | 2009-01-15 02:19:31 +0000 | [diff] [blame] | 798 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 799 | template <typename Iterator> |
| 800 | static LookupResult CreateLookupResult(ASTContext &Context, |
| 801 | Iterator B, std::size_t Len) { |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 802 | NamedDecl ** Array = new NamedDecl*[Len]; |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 803 | for (std::size_t Idx = 0; Idx < Len; ++Idx, ++B) |
| 804 | Array[Idx] = *B; |
| 805 | LookupResult Result; |
| 806 | Result.StoredKind = AmbiguousLookupStoresDecls; |
| 807 | Result.First = reinterpret_cast<uintptr_t>(Array); |
| 808 | Result.Last = reinterpret_cast<uintptr_t>(Array + Len); |
| 809 | Result.Context = &Context; |
| 810 | return Result; |
| 811 | } |
| 812 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 813 | LookupKind getKind() const; |
| 814 | |
| 815 | /// @brief Determine whether name look found something. |
| 816 | operator bool() const { return getKind() != NotFound; } |
| 817 | |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 818 | /// @brief Determines whether the lookup resulted in an ambiguity. |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 819 | bool isAmbiguous() const { |
| 820 | return StoredKind == AmbiguousLookupStoresBasePaths || |
| 821 | StoredKind == AmbiguousLookupStoresDecls; |
| 822 | } |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 823 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 824 | /// @brief Allows conversion of a lookup result into a |
| 825 | /// declaration, with the same behavior as getAsDecl. |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 826 | operator NamedDecl*() const { return getAsDecl(); } |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 827 | |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 828 | NamedDecl* getAsDecl() const; |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 829 | |
| 830 | BasePaths *getBasePaths() const; |
Douglas Gregor | d863517 | 2009-02-02 21:35:47 +0000 | [diff] [blame] | 831 | |
| 832 | /// \brief Iterate over the results of name lookup. |
| 833 | /// |
| 834 | /// The @c iterator class provides iteration over the results of a |
| 835 | /// non-ambiguous name lookup. |
| 836 | class iterator { |
| 837 | /// The LookupResult structure we're iterating through. |
| 838 | LookupResult *Result; |
| 839 | |
| 840 | /// The current position of this iterator within the sequence of |
| 841 | /// results. This value will have the same representation as the |
| 842 | /// @c First field in the LookupResult structure. |
| 843 | mutable uintptr_t Current; |
| 844 | |
| 845 | public: |
Douglas Gregor | 47b9a1c | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 846 | typedef NamedDecl * value_type; |
| 847 | typedef NamedDecl * reference; |
| 848 | typedef NamedDecl * pointer; |
Douglas Gregor | d863517 | 2009-02-02 21:35:47 +0000 | [diff] [blame] | 849 | typedef std::ptrdiff_t difference_type; |
| 850 | typedef std::forward_iterator_tag iterator_category; |
| 851 | |
| 852 | iterator() : Result(0), Current(0) { } |
| 853 | |
| 854 | iterator(LookupResult *Res, uintptr_t Cur) : Result(Res), Current(Cur) { } |
| 855 | |
| 856 | reference operator*() const; |
| 857 | |
| 858 | pointer operator->() const { return **this; } |
| 859 | |
| 860 | iterator &operator++(); |
| 861 | |
| 862 | iterator operator++(int) { |
| 863 | iterator tmp(*this); |
| 864 | ++(*this); |
| 865 | return tmp; |
| 866 | } |
| 867 | |
| 868 | friend inline bool operator==(iterator const& x, iterator const& y) { |
| 869 | return x.Current == y.Current; |
| 870 | } |
| 871 | |
| 872 | friend inline bool operator!=(iterator const& x, iterator const& y) { |
| 873 | return x.Current != y.Current; |
| 874 | } |
| 875 | }; |
| 876 | friend class iterator; |
| 877 | |
| 878 | iterator begin(); |
| 879 | iterator end(); |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 880 | }; |
| 881 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 882 | private: |
| 883 | typedef llvm::SmallVector<LookupResult, 3> LookupResultsVecTy; |
| 884 | |
| 885 | std::pair<bool, LookupResult> CppLookupName(Scope *S, DeclarationName Name, |
| 886 | LookupNameKind NameKind, |
| 887 | bool RedeclarationOnly); |
| 888 | |
| 889 | public: |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 890 | /// Determines whether D is a suitable lookup result according to the |
| 891 | /// lookup criteria. |
Douglas Gregor | d6f7e9d | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 892 | static bool isAcceptableLookupResult(NamedDecl *D, LookupNameKind NameKind, |
Douglas Gregor | 7dda67d | 2009-02-05 19:25:20 +0000 | [diff] [blame] | 893 | unsigned IDNS) { |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 894 | switch (NameKind) { |
| 895 | case Sema::LookupOrdinaryName: |
| 896 | case Sema::LookupTagName: |
| 897 | case Sema::LookupMemberName: |
Douglas Gregor | d6f7e9d | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 898 | case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 899 | return D->isInIdentifierNamespace(IDNS); |
| 900 | |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 901 | case Sema::LookupOperatorName: |
| 902 | return D->isInIdentifierNamespace(IDNS) && |
| 903 | !D->getDeclContext()->isRecord(); |
| 904 | |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 905 | case Sema::LookupNestedNameSpecifierName: |
| 906 | return isa<TypedefDecl>(D) || D->isInIdentifierNamespace(Decl::IDNS_Tag); |
| 907 | |
| 908 | case Sema::LookupNamespaceName: |
| 909 | return isa<NamespaceDecl>(D); |
| 910 | } |
| 911 | |
| 912 | assert(false && |
Douglas Gregor | 7dda67d | 2009-02-05 19:25:20 +0000 | [diff] [blame] | 913 | "isAcceptableLookupResult always returns before this point"); |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 914 | return false; |
| 915 | } |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 916 | |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 917 | LookupResult LookupName(Scope *S, DeclarationName Name, |
| 918 | LookupNameKind NameKind, |
Douglas Gregor | 3e41d60 | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 919 | bool RedeclarationOnly = false, |
| 920 | bool AllowBuiltinCreation = true, |
| 921 | SourceLocation Loc = SourceLocation()); |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 922 | LookupResult LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name, |
| 923 | LookupNameKind NameKind, |
| 924 | bool RedeclarationOnly = false); |
| 925 | LookupResult LookupParsedName(Scope *S, const CXXScopeSpec *SS, |
| 926 | DeclarationName Name, |
| 927 | LookupNameKind NameKind, |
Douglas Gregor | 3e41d60 | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 928 | bool RedeclarationOnly = false, |
| 929 | bool AllowBuiltinCreation = true, |
| 930 | SourceLocation Loc = SourceLocation()); |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 931 | |
| 932 | typedef llvm::SmallPtrSet<NamespaceDecl *, 16> AssociatedNamespaceSet; |
| 933 | typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet; |
| 934 | |
| 935 | void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs, |
| 936 | AssociatedNamespaceSet &AssociatedNamespaces, |
| 937 | AssociatedClassSet &AssociatedClasses); |
| 938 | |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 939 | bool DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name, |
| 940 | SourceLocation NameLoc, |
| 941 | SourceRange LookupRange = SourceRange()); |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 942 | //@} |
| 943 | |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 944 | ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 945 | NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, |
Douglas Gregor | 3e41d60 | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 946 | Scope *S, bool ForRedeclaration, |
| 947 | SourceLocation Loc); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 948 | NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, |
| 949 | Scope *S); |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 950 | void AddKnownFunctionAttributes(FunctionDecl *FD); |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 951 | |
| 952 | // More parsing and symbol table subroutines. |
| 953 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 954 | // Decl attributes - this routine is the top level dispatcher. |
Chris Lattner | e5c5ee1 | 2008-06-29 00:16:31 +0000 | [diff] [blame] | 955 | void ProcessDeclAttributes(Decl *D, const Declarator &PD); |
Chris Lattner | f2e4bd5 | 2008-06-28 23:58:55 +0000 | [diff] [blame] | 956 | void ProcessDeclAttributeList(Decl *D, const AttributeList *AttrList); |
Christopher Lamb | ebb97e9 | 2008-02-04 02:31:56 +0000 | [diff] [blame] | 957 | |
Steve Naroff | 3c2eb66 | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 958 | void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, |
| 959 | bool &IncompleteImpl); |
Fariborz Jahanian | 8daab97 | 2008-12-05 18:18:52 +0000 | [diff] [blame] | 960 | void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod, |
| 961 | ObjCMethodDecl *IntfMethod); |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 962 | |
| 963 | NamespaceDecl *GetStdNamespace(); |
Fariborz Jahanian | d1fa644 | 2009-01-12 19:55:42 +0000 | [diff] [blame] | 964 | |
| 965 | bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl, |
Steve Naroff | 22dc0b0 | 2009-02-26 19:11:32 +0000 | [diff] [blame] | 966 | ObjCInterfaceDecl *IDecl); |
Steve Naroff | 3c2eb66 | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 967 | |
Chris Lattner | 823c44e | 2009-01-06 07:27:21 +0000 | [diff] [blame] | 968 | /// CheckProtocolMethodDefs - This routine checks unimplemented |
Daniel Dunbar | 7ad1b1f | 2008-09-04 20:01:15 +0000 | [diff] [blame] | 969 | /// methods declared in protocol, and those referenced by it. |
| 970 | /// \param IDecl - Used for checking for methods which may have been |
| 971 | /// inherited. |
Steve Naroff | efe7f36 | 2008-02-08 22:06:17 +0000 | [diff] [blame] | 972 | void CheckProtocolMethodDefs(SourceLocation ImpLoc, |
| 973 | ObjCProtocolDecl *PDecl, |
Fariborz Jahanian | ca3adf7 | 2007-10-02 20:06:01 +0000 | [diff] [blame] | 974 | bool& IncompleteImpl, |
Steve Naroff | eefc418 | 2007-10-08 21:05:34 +0000 | [diff] [blame] | 975 | const llvm::DenseSet<Selector> &InsMap, |
Daniel Dunbar | 7ad1b1f | 2008-09-04 20:01:15 +0000 | [diff] [blame] | 976 | const llvm::DenseSet<Selector> &ClsMap, |
| 977 | ObjCInterfaceDecl *IDecl); |
Fariborz Jahanian | 8c74fa4 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 978 | |
Steve Naroff | a5997c4 | 2007-10-02 21:43:37 +0000 | [diff] [blame] | 979 | /// CheckImplementationIvars - This routine checks if the instance variables |
| 980 | /// listed in the implelementation match those listed in the interface. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 981 | void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, |
| 982 | ObjCIvarDecl **Fields, unsigned nIvars, |
Steve Naroff | 3c2eb66 | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 983 | SourceLocation Loc); |
Steve Naroff | a5997c4 | 2007-10-02 21:43:37 +0000 | [diff] [blame] | 984 | |
Fariborz Jahanian | 8c74fa4 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 985 | /// ImplMethodsVsClassMethods - This is main routine to warn if any method |
Chris Lattner | cddc888 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 986 | /// remains unimplemented in the class or category @implementation. |
| 987 | void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, |
| 988 | ObjCContainerDecl* IDecl, |
| 989 | bool IncompleteImpl = false); |
Fariborz Jahanian | 8c74fa4 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 990 | |
Fariborz Jahanian | 85ff264 | 2007-10-05 18:00:57 +0000 | [diff] [blame] | 991 | /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns |
| 992 | /// true, or false, accordingly. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 993 | bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, |
Steve Naroff | fe6b0dc | 2008-10-21 10:37:50 +0000 | [diff] [blame] | 994 | const ObjCMethodDecl *PrevMethod, |
| 995 | bool matchBasedOnSizeAndAlignment = false); |
Steve Naroff | 3b95017 | 2007-10-10 21:53:07 +0000 | [diff] [blame] | 996 | |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 997 | /// AddInstanceMethodToGlobalPool - All instance methods in a translation |
| 998 | /// unit are added to a global pool. This allows us to efficiently associate |
| 999 | /// a selector with a method declaraation for purposes of typechecking |
| 1000 | /// messages sent to "id" (where the class of the object is unknown). |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1001 | void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method); |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1002 | |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 1003 | /// LookupInstanceMethodInGlobalPool - Returns the method and warns if |
| 1004 | /// there are multiple signatures. |
| 1005 | ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R); |
| 1006 | |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1007 | /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1008 | void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1009 | //===--------------------------------------------------------------------===// |
| 1010 | // Statement Parsing Callbacks: SemaStmt.cpp. |
| 1011 | public: |
Sebastian Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 1012 | virtual OwningStmtResult ActOnExprStmt(ExprArg Expr); |
| 1013 | |
| 1014 | virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc); |
| 1015 | virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, |
| 1016 | MultiStmtArg Elts, |
| 1017 | bool isStmtExpr); |
| 1018 | virtual OwningStmtResult ActOnDeclStmt(DeclTy *Decl, SourceLocation StartLoc, |
| 1019 | SourceLocation EndLoc); |
Sebastian Redl | 117054a | 2008-12-28 16:13:43 +0000 | [diff] [blame] | 1020 | virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal, |
| 1021 | SourceLocation DotDotDotLoc, ExprArg RHSVal, |
Chris Lattner | 24e1e70 | 2009-03-04 04:23:07 +0000 | [diff] [blame] | 1022 | SourceLocation ColonLoc); |
| 1023 | virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt); |
| 1024 | |
Sebastian Redl | 117054a | 2008-12-28 16:13:43 +0000 | [diff] [blame] | 1025 | virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
| 1026 | SourceLocation ColonLoc, |
| 1027 | StmtArg SubStmt, Scope *CurScope); |
Sebastian Redl | de30747 | 2009-01-11 00:38:46 +0000 | [diff] [blame] | 1028 | virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc, |
| 1029 | IdentifierInfo *II, |
| 1030 | SourceLocation ColonLoc, |
| 1031 | StmtArg SubStmt); |
| 1032 | virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, ExprArg CondVal, |
| 1033 | StmtArg ThenVal, SourceLocation ElseLoc, |
| 1034 | StmtArg ElseVal); |
| 1035 | virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond); |
| 1036 | virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, |
| 1037 | StmtArg Switch, StmtArg Body); |
Sebastian Redl | f05b152 | 2009-01-16 23:28:06 +0000 | [diff] [blame] | 1038 | virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, ExprArg Cond, |
| 1039 | StmtArg Body); |
| 1040 | virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, |
| 1041 | SourceLocation WhileLoc, ExprArg Cond); |
| 1042 | |
| 1043 | virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc, |
| 1044 | SourceLocation LParenLoc, |
| 1045 | StmtArg First, ExprArg Second, |
| 1046 | ExprArg Third, SourceLocation RParenLoc, |
| 1047 | StmtArg Body); |
| 1048 | virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, |
| 1049 | SourceLocation LParenLoc, |
| 1050 | StmtArg First, ExprArg Second, |
| 1051 | SourceLocation RParenLoc, StmtArg Body); |
Sebastian Redl | 4cffe2f | 2009-01-18 13:19:59 +0000 | [diff] [blame] | 1052 | |
| 1053 | virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
| 1054 | SourceLocation LabelLoc, |
| 1055 | IdentifierInfo *LabelII); |
| 1056 | virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
| 1057 | SourceLocation StarLoc, |
| 1058 | ExprArg DestExp); |
| 1059 | virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
| 1060 | Scope *CurScope); |
| 1061 | virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc, |
| 1062 | Scope *CurScope); |
| 1063 | |
| 1064 | virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
| 1065 | ExprArg RetValExp); |
| 1066 | OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc, |
| 1067 | Expr *RetValExp); |
| 1068 | |
Sebastian Redl | 3037ed0 | 2009-01-18 16:53:17 +0000 | [diff] [blame] | 1069 | virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc, |
| 1070 | bool IsSimple, |
| 1071 | bool IsVolatile, |
| 1072 | unsigned NumOutputs, |
| 1073 | unsigned NumInputs, |
| 1074 | std::string *Names, |
| 1075 | MultiExprArg Constraints, |
| 1076 | MultiExprArg Exprs, |
| 1077 | ExprArg AsmString, |
| 1078 | MultiExprArg Clobbers, |
| 1079 | SourceLocation RParenLoc); |
Sebastian Redl | 431e90e | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1080 | |
| 1081 | virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, |
| 1082 | SourceLocation RParen, |
Steve Naroff | 7ba138a | 2009-03-03 19:52:17 +0000 | [diff] [blame] | 1083 | DeclTy *Parm, StmtArg Body, |
Sebastian Redl | 431e90e | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1084 | StmtArg CatchList); |
| 1085 | |
| 1086 | virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, |
| 1087 | StmtArg Body); |
| 1088 | |
| 1089 | virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, |
| 1090 | StmtArg Try, |
| 1091 | StmtArg Catch, StmtArg Finally); |
| 1092 | |
| 1093 | virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, |
Steve Naroff | e21dd6f | 2009-02-11 20:05:44 +0000 | [diff] [blame] | 1094 | ExprArg Throw, |
| 1095 | Scope *CurScope); |
Sebastian Redl | 431e90e | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1096 | virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| 1097 | ExprArg SynchExpr, |
| 1098 | StmtArg SynchBody); |
Sebastian Redl | a0fd865 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 1099 | |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1100 | virtual DeclTy *ActOnExceptionDeclarator(Scope *S, Declarator &D); |
| 1101 | virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, |
| 1102 | DeclTy *ExDecl, |
| 1103 | StmtArg HandlerBlock); |
Sebastian Redl | 8351da0 | 2008-12-22 21:35:02 +0000 | [diff] [blame] | 1104 | virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc, |
| 1105 | StmtArg TryBlock, |
| 1106 | MultiStmtArg Handlers); |
Sebastian Redl | a0fd865 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 1107 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1108 | //===--------------------------------------------------------------------===// |
| 1109 | // Expression Parsing Callbacks: SemaExpr.cpp. |
| 1110 | |
Douglas Gregor | 48f3bb9 | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 1111 | bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc); |
Chris Lattner | 76a642f | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 1112 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1113 | // Primary Expressions. |
Douglas Gregor | 4b2d3f7 | 2009-02-26 21:00:50 +0000 | [diff] [blame] | 1114 | virtual SourceRange getExprRange(ExprTy *E) const; |
| 1115 | |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1116 | virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc, |
| 1117 | IdentifierInfo &II, |
| 1118 | bool HasTrailingLParen, |
Sebastian Redl | ebc07d5 | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1119 | const CXXScopeSpec *SS = 0, |
| 1120 | bool isAddressOfOperand = false); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1121 | virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr(Scope *S, |
Douglas Gregor | 487a75a | 2008-11-19 19:09:45 +0000 | [diff] [blame] | 1122 | SourceLocation OperatorLoc, |
| 1123 | OverloadedOperatorKind Op, |
| 1124 | bool HasTrailingLParen, |
Sebastian Redl | ebc07d5 | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1125 | const CXXScopeSpec &SS, |
| 1126 | bool isAddressOfOperand); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1127 | virtual OwningExprResult ActOnCXXConversionFunctionExpr(Scope *S, |
Douglas Gregor | 487a75a | 2008-11-19 19:09:45 +0000 | [diff] [blame] | 1128 | SourceLocation OperatorLoc, |
| 1129 | TypeTy *Ty, |
| 1130 | bool HasTrailingLParen, |
Sebastian Redl | ebc07d5 | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1131 | const CXXScopeSpec &SS, |
| 1132 | bool isAddressOfOperand); |
Douglas Gregor | 1a49af9 | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 1133 | DeclRefExpr *BuildDeclRefExpr(NamedDecl *D, QualType Ty, SourceLocation Loc, |
| 1134 | bool TypeDependent, bool ValueDependent, |
| 1135 | const CXXScopeSpec *SS = 0); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1136 | OwningExprResult |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 1137 | BuildAnonymousStructUnionMemberReference(SourceLocation Loc, |
| 1138 | FieldDecl *Field, |
| 1139 | Expr *BaseObjectExpr = 0, |
| 1140 | SourceLocation OpLoc = SourceLocation()); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1141 | OwningExprResult ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, |
| 1142 | DeclarationName Name, |
| 1143 | bool HasTrailingLParen, |
| 1144 | const CXXScopeSpec *SS, |
Sebastian Redl | ebc07d5 | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1145 | bool isAddressOfOperand = false); |
Douglas Gregor | 10c4262 | 2008-11-18 15:03:34 +0000 | [diff] [blame] | 1146 | |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1147 | virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc, |
| 1148 | tok::TokenKind Kind); |
| 1149 | virtual OwningExprResult ActOnNumericConstant(const Token &); |
| 1150 | virtual OwningExprResult ActOnCharacterConstant(const Token &); |
| 1151 | virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
| 1152 | ExprArg Val); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1153 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1154 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1155 | /// fragments (e.g. "foo" "bar" L"baz"). |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1156 | virtual OwningExprResult ActOnStringLiteral(const Token *Toks, |
| 1157 | unsigned NumToks); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1158 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1159 | // Binary/Unary Operators. 'Tok' is the token for the operator. |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1160 | virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1161 | tok::TokenKind Op, ExprArg Input); |
| 1162 | virtual OwningExprResult |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 1163 | ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, |
| 1164 | void *TyOrEx, const SourceRange &ArgRange); |
| 1165 | |
Chris Lattner | 31e21e0 | 2009-01-24 20:17:12 +0000 | [diff] [blame] | 1166 | bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 1167 | bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc, |
| 1168 | const SourceRange &R, bool isSizeof); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1169 | |
| 1170 | virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1171 | tok::TokenKind Kind, |
| 1172 | ExprArg Input); |
| 1173 | |
| 1174 | virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base, |
| 1175 | SourceLocation LLoc, |
| 1176 | ExprArg Idx, |
| 1177 | SourceLocation RLoc); |
| 1178 | virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base, |
| 1179 | SourceLocation OpLoc, |
| 1180 | tok::TokenKind OpKind, |
| 1181 | SourceLocation MemberLoc, |
Fariborz Jahanian | a6e3ac5 | 2009-03-04 22:30:12 +0000 | [diff] [blame] | 1182 | IdentifierInfo &Member, |
| 1183 | DeclTy *ImplDecl=0); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1184 | bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1185 | FunctionDecl *FDecl, |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 1186 | const FunctionProtoType *Proto, |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1187 | Expr **Args, unsigned NumArgs, |
| 1188 | SourceLocation RParenLoc); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1189 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1190 | /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1191 | /// This provides the location of the left/right parens and a list of comma |
| 1192 | /// locations. |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1193 | virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn, |
| 1194 | SourceLocation LParenLoc, |
| 1195 | MultiExprArg Args, |
| 1196 | SourceLocation *CommaLocs, |
| 1197 | SourceLocation RParenLoc); |
| 1198 | |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1199 | virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, |
| 1200 | SourceLocation RParenLoc, ExprArg Op); |
| 1201 | |
| 1202 | virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, |
| 1203 | TypeTy *Ty, |
| 1204 | SourceLocation RParenLoc, |
| 1205 | ExprArg Op); |
| 1206 | |
| 1207 | virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc, |
| 1208 | MultiExprArg InitList, |
| 1209 | InitListDesignations &Designators, |
| 1210 | SourceLocation RParenLoc); |
| 1211 | |
Douglas Gregor | 05c13a3 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 1212 | virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig, |
| 1213 | SourceLocation Loc, |
| 1214 | bool UsedColonSyntax, |
| 1215 | OwningExprResult Init); |
| 1216 | |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1217 | virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, |
| 1218 | tok::TokenKind Kind, |
| 1219 | ExprArg LHS, ExprArg RHS); |
| 1220 | OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc, |
| 1221 | unsigned Opc, Expr *lhs, Expr *rhs); |
Douglas Gregor | eaebc75 | 2008-11-06 23:29:22 +0000 | [diff] [blame] | 1222 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1223 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1224 | /// in the case of a the GNU conditional expr extension. |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1225 | virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
| 1226 | SourceLocation ColonLoc, |
| 1227 | ExprArg Cond, ExprArg LHS, |
| 1228 | ExprArg RHS); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1229 | |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1230 | /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". |
| 1231 | virtual ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1232 | IdentifierInfo *LabelII); |
| 1233 | |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1234 | virtual ExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtTy *SubStmt, |
Chris Lattner | ab18c4c | 2007-07-24 16:58:17 +0000 | [diff] [blame] | 1235 | SourceLocation RPLoc); // "({..})" |
Chris Lattner | 73d0d4f | 2007-08-30 17:45:32 +0000 | [diff] [blame] | 1236 | |
| 1237 | /// __builtin_offsetof(type, a.b[123][456].c) |
Douglas Gregor | 3fc749d | 2008-12-23 00:26:44 +0000 | [diff] [blame] | 1238 | virtual ExprResult ActOnBuiltinOffsetOf(Scope *S, |
| 1239 | SourceLocation BuiltinLoc, |
Chris Lattner | 73d0d4f | 2007-08-30 17:45:32 +0000 | [diff] [blame] | 1240 | SourceLocation TypeLoc, TypeTy *Arg1, |
| 1241 | OffsetOfComponent *CompPtr, |
| 1242 | unsigned NumComponents, |
| 1243 | SourceLocation RParenLoc); |
| 1244 | |
Steve Naroff | d34e915 | 2007-08-01 22:05:33 +0000 | [diff] [blame] | 1245 | // __builtin_types_compatible_p(type1, type2) |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1246 | virtual ExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
Steve Naroff | d34e915 | 2007-08-01 22:05:33 +0000 | [diff] [blame] | 1247 | TypeTy *arg1, TypeTy *arg2, |
| 1248 | SourceLocation RPLoc); |
Steve Naroff | d04fdd5 | 2007-08-03 21:21:27 +0000 | [diff] [blame] | 1249 | |
| 1250 | // __builtin_choose_expr(constExpr, expr1, expr2) |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1251 | virtual ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
Steve Naroff | d04fdd5 | 2007-08-03 21:21:27 +0000 | [diff] [blame] | 1252 | ExprTy *cond, ExprTy *expr1, ExprTy *expr2, |
| 1253 | SourceLocation RPLoc); |
Chris Lattner | ab18c4c | 2007-07-24 16:58:17 +0000 | [diff] [blame] | 1254 | |
Anders Carlsson | 7c50aca | 2007-10-15 20:28:48 +0000 | [diff] [blame] | 1255 | // __builtin_va_arg(expr, type) |
| 1256 | virtual ExprResult ActOnVAArg(SourceLocation BuiltinLoc, |
| 1257 | ExprTy *expr, TypeTy *type, |
| 1258 | SourceLocation RPLoc); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1259 | |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 1260 | // __null |
| 1261 | virtual ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc); |
| 1262 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1263 | //===------------------------- "Block" Extension ------------------------===// |
| 1264 | |
| 1265 | /// ActOnBlockStart - This callback is invoked when a block literal is |
| 1266 | /// started. |
Steve Naroff | 090276f | 2008-10-10 01:28:17 +0000 | [diff] [blame] | 1267 | virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope); |
| 1268 | |
| 1269 | /// ActOnBlockArguments - This callback allows processing of block arguments. |
| 1270 | /// If there are no arguments, this is still invoked. |
Mike Stump | 98eb8a7 | 2009-02-04 22:31:32 +0000 | [diff] [blame] | 1271 | virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1272 | |
| 1273 | /// ActOnBlockError - If there is an error parsing a block, this callback |
| 1274 | /// is invoked to pop the information about the block from the action impl. |
| 1275 | virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope); |
| 1276 | |
| 1277 | /// ActOnBlockStmtExpr - This is called when the body of a block statement |
| 1278 | /// literal was successfully completed. ^(int x){...} |
| 1279 | virtual ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, StmtTy *Body, |
| 1280 | Scope *CurScope); |
| 1281 | |
Chris Lattner | 76a642f | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 1282 | //===---------------------------- C++ Features --------------------------===// |
| 1283 | |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 1284 | // Act on C++ namespaces |
| 1285 | virtual DeclTy *ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc, |
| 1286 | IdentifierInfo *Ident, |
| 1287 | SourceLocation LBrace); |
| 1288 | virtual void ActOnFinishNamespaceDef(DeclTy *Dcl, SourceLocation RBrace); |
| 1289 | |
Douglas Gregor | f780abc | 2008-12-30 03:27:21 +0000 | [diff] [blame] | 1290 | virtual DeclTy *ActOnUsingDirective(Scope *CurScope, |
| 1291 | SourceLocation UsingLoc, |
| 1292 | SourceLocation NamespcLoc, |
| 1293 | const CXXScopeSpec &SS, |
| 1294 | SourceLocation IdentLoc, |
| 1295 | IdentifierInfo *NamespcName, |
| 1296 | AttributeList *AttrList); |
| 1297 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1298 | void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir); |
| 1299 | |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1300 | /// AddCXXDirectInitializerToDecl - This action is called immediately after |
| 1301 | /// ActOnDeclarator, when a C++ direct initializer is present. |
| 1302 | /// e.g: "int x(1);" |
| 1303 | virtual void AddCXXDirectInitializerToDecl(DeclTy *Dcl, |
| 1304 | SourceLocation LParenLoc, |
| 1305 | ExprTy **Exprs, unsigned NumExprs, |
| 1306 | SourceLocation *CommaLocs, |
| 1307 | SourceLocation RParenLoc); |
| 1308 | |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1309 | /// InitializationKind - Represents which kind of C++ initialization |
| 1310 | /// [dcl.init] a routine is to perform. |
| 1311 | enum InitializationKind { |
| 1312 | IK_Direct, ///< Direct initialization |
| 1313 | IK_Copy, ///< Copy initialization |
| 1314 | IK_Default ///< Default initialization |
| 1315 | }; |
| 1316 | |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 1317 | CXXConstructorDecl * |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1318 | PerformInitializationByConstructor(QualType ClassType, |
| 1319 | Expr **Args, unsigned NumArgs, |
| 1320 | SourceLocation Loc, SourceRange Range, |
Chris Lattner | d9d22dd | 2008-11-24 05:29:24 +0000 | [diff] [blame] | 1321 | DeclarationName InitEntity, |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1322 | InitializationKind Kind); |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 1323 | |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1324 | /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's. |
| 1325 | virtual ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, tok::TokenKind Kind, |
| 1326 | SourceLocation LAngleBracketLoc, TypeTy *Ty, |
| 1327 | SourceLocation RAngleBracketLoc, |
| 1328 | SourceLocation LParenLoc, ExprTy *E, |
| 1329 | SourceLocation RParenLoc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1330 | |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1331 | /// ActOnCXXTypeidOfType - Parse typeid( type-id ). |
| 1332 | virtual ExprResult ActOnCXXTypeid(SourceLocation OpLoc, |
| 1333 | SourceLocation LParenLoc, bool isType, |
| 1334 | void *TyOrExpr, SourceLocation RParenLoc); |
| 1335 | |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1336 | //// ActOnCXXThis - Parse 'this' pointer. |
| 1337 | virtual ExprResult ActOnCXXThis(SourceLocation ThisLoc); |
| 1338 | |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1339 | /// ActOnCXXBoolLiteral - Parse {true,false} literals. |
| 1340 | virtual ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1341 | tok::TokenKind Kind); |
Anders Carlsson | 5508518 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 1342 | |
Chris Lattner | 50dd289 | 2008-02-26 00:51:44 +0000 | [diff] [blame] | 1343 | //// ActOnCXXThrow - Parse throw expressions. |
| 1344 | virtual ExprResult ActOnCXXThrow(SourceLocation OpLoc, |
| 1345 | ExprTy *expr); |
| 1346 | |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1347 | /// ActOnCXXTypeConstructExpr - Parse construction of a specified type. |
| 1348 | /// Can be interpreted either as function-style casting ("int(x)") |
| 1349 | /// or class type construction ("ClassType(x,y,z)") |
| 1350 | /// or creation of a value-initialized type ("int()"). |
| 1351 | virtual ExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange, |
| 1352 | TypeTy *TypeRep, |
| 1353 | SourceLocation LParenLoc, |
| 1354 | ExprTy **Exprs, |
| 1355 | unsigned NumExprs, |
| 1356 | SourceLocation *CommaLocs, |
| 1357 | SourceLocation RParenLoc); |
| 1358 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1359 | /// ActOnCXXNew - Parsed a C++ 'new' expression. |
| 1360 | virtual ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, |
| 1361 | SourceLocation PlacementLParen, |
| 1362 | ExprTy **PlacementArgs, unsigned NumPlaceArgs, |
| 1363 | SourceLocation PlacementRParen, |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1364 | bool ParenTypeId, Declarator &D, |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1365 | SourceLocation ConstructorLParen, |
| 1366 | ExprTy **ConstructorArgs, unsigned NumConsArgs, |
| 1367 | SourceLocation ConstructorRParen); |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 1368 | bool CheckAllocatedType(QualType AllocType, const Declarator &D); |
Sebastian Redl | 00e68e2 | 2009-02-09 18:24:27 +0000 | [diff] [blame] | 1369 | bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, |
| 1370 | bool UseGlobal, QualType AllocType, bool IsArray, |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 1371 | Expr **PlaceArgs, unsigned NumPlaceArgs, |
| 1372 | FunctionDecl *&OperatorNew, |
| 1373 | FunctionDecl *&OperatorDelete); |
Sebastian Redl | 00e68e2 | 2009-02-09 18:24:27 +0000 | [diff] [blame] | 1374 | bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, |
| 1375 | DeclarationName Name, Expr** Args, |
| 1376 | unsigned NumArgs, DeclContext *Ctx, |
Sebastian Redl | 7f66239 | 2008-12-04 22:20:51 +0000 | [diff] [blame] | 1377 | bool AllowMissing, FunctionDecl *&Operator); |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 1378 | void DeclareGlobalNewDelete(); |
| 1379 | void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, |
| 1380 | QualType Argument); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1381 | |
| 1382 | /// ActOnCXXDelete - Parsed a C++ 'delete' expression |
| 1383 | virtual ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, |
| 1384 | bool ArrayForm, ExprTy *Operand); |
| 1385 | |
Argyrios Kyrtzidis | 5921093 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 1386 | /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a |
| 1387 | /// C++ if/switch/while/for statement. |
| 1388 | /// e.g: "if (int x = f()) {...}" |
| 1389 | virtual ExprResult ActOnCXXConditionDeclarationExpr(Scope *S, |
| 1390 | SourceLocation StartLoc, |
| 1391 | Declarator &D, |
| 1392 | SourceLocation EqualLoc, |
| 1393 | ExprTy *AssignExprVal); |
| 1394 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 1395 | /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support |
| 1396 | /// pseudo-functions. |
| 1397 | virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, |
| 1398 | SourceLocation KWLoc, |
| 1399 | SourceLocation LParen, |
| 1400 | TypeTy *Ty, |
| 1401 | SourceLocation RParen); |
| 1402 | |
Douglas Gregor | 4fdf1fa | 2009-03-11 16:48:53 +0000 | [diff] [blame] | 1403 | bool RequireCompleteDeclContext(const CXXScopeSpec &SS); |
| 1404 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1405 | /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the |
| 1406 | /// global scope ('::'). |
| 1407 | virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S, |
| 1408 | SourceLocation CCLoc); |
| 1409 | |
| 1410 | /// ActOnCXXNestedNameSpecifier - Called during parsing of a |
| 1411 | /// nested-name-specifier. e.g. for "foo::bar::" we parsed "foo::" and now |
| 1412 | /// we want to resolve "bar::". 'SS' is empty or the previously parsed |
| 1413 | /// nested-name part ("foo::"), 'IdLoc' is the source location of 'bar', |
| 1414 | /// 'CCLoc' is the location of '::' and 'II' is the identifier for 'bar'. |
| 1415 | /// Returns a CXXScopeTy* object representing the C++ scope. |
| 1416 | virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, |
| 1417 | const CXXScopeSpec &SS, |
| 1418 | SourceLocation IdLoc, |
| 1419 | SourceLocation CCLoc, |
Douglas Gregor | 2def483 | 2008-11-17 20:34:05 +0000 | [diff] [blame] | 1420 | IdentifierInfo &II); |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1421 | |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 1422 | /// ActOnCXXNestedNameSpecifier - Called during parsing of a |
| 1423 | /// nested-name-specifier that involves a template-id, e.g., |
| 1424 | /// "foo::bar<int, float>::", and now we need to build a scope |
| 1425 | /// specifier. \p SS is empty or the previously parsed nested-name |
| 1426 | /// part ("foo::"), \p Type is the already-parsed class template |
| 1427 | /// specialization (or other template-id that names a type), \p |
| 1428 | /// TypeRange is the source range where the type is located, and \p |
| 1429 | /// CCLoc is the location of the trailing '::'. |
| 1430 | virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, |
| 1431 | const CXXScopeSpec &SS, |
| 1432 | TypeTy *Type, |
| 1433 | SourceRange TypeRange, |
| 1434 | SourceLocation CCLoc); |
| 1435 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1436 | /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global |
| 1437 | /// scope or nested-name-specifier) is parsed, part of a declarator-id. |
| 1438 | /// After this method is called, according to [C++ 3.4.3p3], names should be |
| 1439 | /// looked up in the declarator-id's scope, until the declarator is parsed and |
| 1440 | /// ActOnCXXExitDeclaratorScope is called. |
| 1441 | /// The 'SS' should be a non-empty valid CXXScopeSpec. |
| 1442 | virtual void ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
| 1443 | |
| 1444 | /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously |
| 1445 | /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same |
| 1446 | /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. |
| 1447 | /// Used to indicate that names should revert to being looked up in the |
| 1448 | /// defining scope. |
Douglas Gregor | 0a59acb | 2008-12-16 00:38:16 +0000 | [diff] [blame] | 1449 | virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1450 | |
Anders Carlsson | 5508518 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 1451 | // ParseObjCStringLiteral - Parse Objective-C string literals. |
Chris Lattner | b3a99cd | 2007-12-12 01:04:12 +0000 | [diff] [blame] | 1452 | virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, |
| 1453 | ExprTy **Strings, |
| 1454 | unsigned NumStrings); |
Anders Carlsson | f9bcf01 | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 1455 | virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, |
Chris Lattner | 674af95 | 2007-10-16 22:51:17 +0000 | [diff] [blame] | 1456 | SourceLocation EncodeLoc, |
Anders Carlsson | f9bcf01 | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 1457 | SourceLocation LParenLoc, |
| 1458 | TypeTy *Ty, |
| 1459 | SourceLocation RParenLoc); |
| 1460 | |
Fariborz Jahanian | b62f681 | 2007-10-16 20:40:23 +0000 | [diff] [blame] | 1461 | // ParseObjCSelectorExpression - Build selector expression for @selector |
| 1462 | virtual ExprResult ParseObjCSelectorExpression(Selector Sel, |
| 1463 | SourceLocation AtLoc, |
Fariborz Jahanian | 2a35fa9 | 2007-10-16 23:21:02 +0000 | [diff] [blame] | 1464 | SourceLocation SelLoc, |
Fariborz Jahanian | b62f681 | 2007-10-16 20:40:23 +0000 | [diff] [blame] | 1465 | SourceLocation LParenLoc, |
| 1466 | SourceLocation RParenLoc); |
| 1467 | |
Fariborz Jahanian | 390d50a | 2007-10-17 16:58:11 +0000 | [diff] [blame] | 1468 | // ParseObjCProtocolExpression - Build protocol expression for @protocol |
| 1469 | virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, |
| 1470 | SourceLocation AtLoc, |
| 1471 | SourceLocation ProtoLoc, |
| 1472 | SourceLocation LParenLoc, |
| 1473 | SourceLocation RParenLoc); |
Douglas Gregor | e37ac4f | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 1474 | |
| 1475 | //===--------------------------------------------------------------------===// |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 1476 | // C++ Declarations |
| 1477 | // |
| 1478 | virtual DeclTy *ActOnStartLinkageSpecification(Scope *S, |
| 1479 | SourceLocation ExternLoc, |
| 1480 | SourceLocation LangLoc, |
| 1481 | const char *Lang, |
| 1482 | unsigned StrSize, |
| 1483 | SourceLocation LBraceLoc); |
| 1484 | virtual DeclTy *ActOnFinishLinkageSpecification(Scope *S, |
| 1485 | DeclTy *LinkageSpec, |
| 1486 | SourceLocation RBraceLoc); |
| 1487 | |
| 1488 | |
| 1489 | //===--------------------------------------------------------------------===// |
Douglas Gregor | e37ac4f | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 1490 | // C++ Classes |
| 1491 | // |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 1492 | virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S, |
| 1493 | const CXXScopeSpec *SS); |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 1494 | |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1495 | virtual DeclTy *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, |
| 1496 | Declarator &D, ExprTy *BitfieldWidth, |
| 1497 | ExprTy *Init, DeclTy *LastInGroup); |
| 1498 | |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 1499 | virtual MemInitResult ActOnMemInitializer(DeclTy *ConstructorD, |
| 1500 | Scope *S, |
| 1501 | IdentifierInfo *MemberOrBase, |
| 1502 | SourceLocation IdLoc, |
| 1503 | SourceLocation LParenLoc, |
| 1504 | ExprTy **Args, unsigned NumArgs, |
| 1505 | SourceLocation *CommaLocs, |
| 1506 | SourceLocation RParenLoc); |
| 1507 | |
Douglas Gregor | 396b7cd | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 1508 | void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl); |
| 1509 | |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1510 | virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, |
| 1511 | DeclTy *TagDecl, |
| 1512 | SourceLocation LBrac, |
| 1513 | SourceLocation RBrac); |
| 1514 | |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 1515 | virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method); |
| 1516 | virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclTy *Param); |
| 1517 | virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, DeclTy *Method); |
| 1518 | |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 1519 | bool CheckConstructorDeclarator(Declarator &D, QualType &R, |
| 1520 | FunctionDecl::StorageClass& SC); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 1521 | bool CheckConstructor(CXXConstructorDecl *Constructor); |
Douglas Gregor | 42a552f | 2008-11-05 20:51:48 +0000 | [diff] [blame] | 1522 | bool CheckDestructorDeclarator(Declarator &D, QualType &R, |
| 1523 | FunctionDecl::StorageClass& SC); |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 1524 | bool CheckConversionDeclarator(Declarator &D, QualType &R, |
| 1525 | FunctionDecl::StorageClass& SC); |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 1526 | DeclTy *ActOnConversionDeclarator(CXXConversionDecl *Conversion); |
Douglas Gregor | b48fe38 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 1527 | |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1528 | //===--------------------------------------------------------------------===// |
| 1529 | // C++ Derived Classes |
| 1530 | // |
| 1531 | |
| 1532 | /// ActOnBaseSpecifier - Parsed a base specifier |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1533 | CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class, |
| 1534 | SourceRange SpecifierRange, |
| 1535 | bool Virtual, AccessSpecifier Access, |
| 1536 | QualType BaseType, |
| 1537 | SourceLocation BaseLoc); |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1538 | virtual BaseResult ActOnBaseSpecifier(DeclTy *classdecl, |
| 1539 | SourceRange SpecifierRange, |
| 1540 | bool Virtual, AccessSpecifier Access, |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1541 | TypeTy *basetype, SourceLocation |
| 1542 | BaseLoc); |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1543 | |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1544 | bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, |
| 1545 | unsigned NumBases); |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1546 | virtual void ActOnBaseSpecifiers(DeclTy *ClassDecl, BaseTy **Bases, |
| 1547 | unsigned NumBases); |
| 1548 | |
| 1549 | bool IsDerivedFrom(QualType Derived, QualType Base); |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 1550 | bool IsDerivedFrom(QualType Derived, QualType Base, BasePaths &Paths); |
Douglas Gregor | 7176fff | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1551 | bool LookupInBases(CXXRecordDecl *Class, const MemberLookupCriteria& Criteria, |
| 1552 | BasePaths &Paths); |
Douglas Gregor | 0575d4a | 2008-10-24 16:17:19 +0000 | [diff] [blame] | 1553 | bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, |
| 1554 | SourceLocation Loc, SourceRange Range); |
Douglas Gregor | 4dc6b1c | 2009-01-16 00:38:09 +0000 | [diff] [blame] | 1555 | std::string getAmbiguousPathsDisplayString(BasePaths &Paths); |
Douglas Gregor | e37ac4f | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 1556 | |
Douglas Gregor | 1cd1b1e | 2008-11-06 22:13:31 +0000 | [diff] [blame] | 1557 | //===--------------------------------------------------------------------===// |
| 1558 | // C++ Overloaded Operators [C++ 13.5] |
| 1559 | // |
| 1560 | |
| 1561 | bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl); |
| 1562 | |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 1563 | //===--------------------------------------------------------------------===// |
| 1564 | // C++ Templates [C++ 14] |
| 1565 | // |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 1566 | virtual TemplateNameKind isTemplateName(IdentifierInfo &II, Scope *S, |
| 1567 | DeclTy *&TemplateDecl, |
| 1568 | const CXXScopeSpec *SS = 0); |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 1569 | bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 1570 | TemplateDecl *AdjustDeclIfTemplate(DeclTy *&Decl); |
| 1571 | |
| 1572 | virtual DeclTy *ActOnTypeParameter(Scope *S, bool Typename, |
| 1573 | SourceLocation KeyLoc, |
| 1574 | IdentifierInfo *ParamName, |
| 1575 | SourceLocation ParamNameLoc, |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 1576 | unsigned Depth, unsigned Position); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 1577 | virtual void ActOnTypeParameterDefault(DeclTy *TypeParam, |
| 1578 | SourceLocation EqualLoc, |
| 1579 | SourceLocation DefaultLoc, |
| 1580 | TypeTy *Default); |
| 1581 | |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1582 | QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc); |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 1583 | virtual DeclTy *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 1584 | unsigned Depth, |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 1585 | unsigned Position); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 1586 | virtual void ActOnNonTypeTemplateParameterDefault(DeclTy *TemplateParam, |
| 1587 | SourceLocation EqualLoc, |
| 1588 | ExprArg Default); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 1589 | virtual DeclTy *ActOnTemplateTemplateParameter(Scope *S, |
| 1590 | SourceLocation TmpLoc, |
| 1591 | TemplateParamsTy *Params, |
| 1592 | IdentifierInfo *ParamName, |
| 1593 | SourceLocation ParamNameLoc, |
| 1594 | unsigned Depth, |
| 1595 | unsigned Position); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 1596 | virtual void ActOnTemplateTemplateParameterDefault(DeclTy *TemplateParam, |
| 1597 | SourceLocation EqualLoc, |
| 1598 | ExprArg Default); |
| 1599 | |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 1600 | virtual TemplateParamsTy * |
| 1601 | ActOnTemplateParameterList(unsigned Depth, |
| 1602 | SourceLocation ExportLoc, |
| 1603 | SourceLocation TemplateLoc, |
| 1604 | SourceLocation LAngleLoc, |
| 1605 | DeclTy **Params, unsigned NumParams, |
| 1606 | SourceLocation RAngleLoc); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 1607 | bool CheckTemplateParameterList(TemplateParameterList *NewParams, |
| 1608 | TemplateParameterList *OldParams); |
| 1609 | |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 1610 | virtual DeclTy * |
| 1611 | ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK, |
| 1612 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 1613 | IdentifierInfo *Name, SourceLocation NameLoc, |
| 1614 | AttributeList *Attr, |
| 1615 | MultiTemplateParamsArg TemplateParameterLists); |
| 1616 | |
Douglas Gregor | 40808ce | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 1617 | QualType CheckClassTemplateId(ClassTemplateDecl *ClassTemplate, |
| 1618 | SourceLocation TemplateLoc, |
| 1619 | SourceLocation LAngleLoc, |
| 1620 | const TemplateArgument *TemplateArgs, |
| 1621 | unsigned NumTemplateArgs, |
| 1622 | SourceLocation RAngleLoc); |
| 1623 | |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 1624 | virtual TypeResult |
| 1625 | ActOnClassTemplateId(DeclTy *Template, SourceLocation TemplateLoc, |
| 1626 | SourceLocation LAngleLoc, |
| 1627 | ASTTemplateArgsPtr TemplateArgs, |
| 1628 | SourceLocation *TemplateArgLocs, |
| 1629 | SourceLocation RAngleLoc, |
| 1630 | const CXXScopeSpec *SS); |
| 1631 | |
Douglas Gregor | 88b7094 | 2009-02-25 22:02:03 +0000 | [diff] [blame] | 1632 | bool CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate, |
| 1633 | ClassTemplateSpecializationDecl *PrevDecl, |
| 1634 | SourceLocation TemplateNameLoc, |
| 1635 | SourceRange ScopeSpecifierRange); |
| 1636 | |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 1637 | virtual DeclTy * |
| 1638 | ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK, |
| 1639 | SourceLocation KWLoc, |
| 1640 | const CXXScopeSpec &SS, |
| 1641 | DeclTy *Template, |
| 1642 | SourceLocation TemplateNameLoc, |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 1643 | SourceLocation LAngleLoc, |
Douglas Gregor | 5908e9f | 2009-02-09 19:34:22 +0000 | [diff] [blame] | 1644 | ASTTemplateArgsPtr TemplateArgs, |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 1645 | SourceLocation *TemplateArgLocs, |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 1646 | SourceLocation RAngleLoc, |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 1647 | AttributeList *Attr, |
| 1648 | MultiTemplateParamsArg TemplateParameterLists); |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 1649 | |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 1650 | bool CheckTemplateArgumentList(TemplateDecl *Template, |
| 1651 | SourceLocation TemplateLoc, |
| 1652 | SourceLocation LAngleLoc, |
Douglas Gregor | 40808ce | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 1653 | const TemplateArgument *TemplateArgs, |
| 1654 | unsigned NumTemplateArgs, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 1655 | SourceLocation RAngleLoc, |
| 1656 | llvm::SmallVectorImpl<TemplateArgument> &Converted); |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 1657 | |
| 1658 | bool CheckTemplateArgument(TemplateTypeParmDecl *Param, QualType Arg, |
| 1659 | SourceLocation ArgLoc); |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 1660 | bool CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg, |
| 1661 | NamedDecl *&Entity); |
| 1662 | bool CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member); |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1663 | bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param, |
| 1664 | QualType InstantiatedParamType, Expr *&Arg, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 1665 | llvm::SmallVectorImpl<TemplateArgument> *Converted = 0); |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 1666 | bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, DeclRefExpr *Arg); |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 1667 | bool TemplateParameterListsAreEqual(TemplateParameterList *New, |
| 1668 | TemplateParameterList *Old, |
| 1669 | bool Complain, |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 1670 | bool IsTemplateTemplateParm = false, |
| 1671 | SourceLocation TemplateArgLoc |
| 1672 | = SourceLocation()); |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 1673 | |
| 1674 | bool CheckTemplateDeclScope(Scope *S, |
| 1675 | MultiTemplateParamsArg &TemplateParameterLists); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 1676 | |
Douglas Gregor | 99ebf65 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 1677 | //===--------------------------------------------------------------------===// |
| 1678 | // C++ Template Instantiation |
| 1679 | // |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1680 | |
| 1681 | /// \brief A template instantiation that is currently in progress. |
| 1682 | struct ActiveTemplateInstantiation { |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1683 | /// \brief The kind of template instantiation we are performing |
| 1684 | enum { |
| 1685 | /// We are instantiating a template declaration. The entity is |
| 1686 | /// the declaration we're instantiation (e.g., a |
| 1687 | /// ClassTemplateSpecializationDecl). |
| 1688 | TemplateInstantiation, |
| 1689 | |
| 1690 | /// We are instantiating a default argument for a template |
| 1691 | /// parameter. The Entity is the template, and |
| 1692 | /// TemplateArgs/NumTemplateArguments provides the template |
| 1693 | /// arguments as specified. |
| 1694 | DefaultTemplateArgumentInstantiation |
| 1695 | } Kind; |
| 1696 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1697 | /// \brief The point of instantiation within the source code. |
| 1698 | SourceLocation PointOfInstantiation; |
| 1699 | |
| 1700 | /// \brief The entity that is being instantiated. |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1701 | uintptr_t Entity; |
| 1702 | |
| 1703 | // \brief If this the instantiation of a default template |
| 1704 | // argument, the list of tempalte arguments. |
| 1705 | const TemplateArgument *TemplateArgs; |
| 1706 | |
| 1707 | /// \brief The number of template arguments in TemplateArgs. |
| 1708 | unsigned NumTemplateArgs; |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1709 | |
| 1710 | /// \brief The source range that covers the construct that cause |
| 1711 | /// the instantiation, e.g., the template-id that causes a class |
| 1712 | /// template instantiation. |
| 1713 | SourceRange InstantiationRange; |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1714 | |
| 1715 | friend bool operator==(const ActiveTemplateInstantiation &X, |
| 1716 | const ActiveTemplateInstantiation &Y) { |
| 1717 | if (X.Kind != Y.Kind) |
| 1718 | return false; |
| 1719 | |
| 1720 | if (X.Entity != Y.Entity) |
| 1721 | return false; |
| 1722 | |
| 1723 | switch (X.Kind) { |
| 1724 | case TemplateInstantiation: |
| 1725 | return true; |
| 1726 | |
| 1727 | case DefaultTemplateArgumentInstantiation: |
| 1728 | return X.TemplateArgs == Y.TemplateArgs; |
| 1729 | } |
| 1730 | |
| 1731 | return true; |
| 1732 | } |
| 1733 | |
| 1734 | friend bool operator!=(const ActiveTemplateInstantiation &X, |
| 1735 | const ActiveTemplateInstantiation &Y) { |
| 1736 | return !(X == Y); |
| 1737 | } |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1738 | }; |
| 1739 | |
| 1740 | /// \brief List of active template instantiations. |
| 1741 | /// |
| 1742 | /// This vector is treated as a stack. As one template instantiation |
| 1743 | /// requires another template instantiation, additional |
| 1744 | /// instantiations are pushed onto the stack up to a |
| 1745 | /// user-configurable limit LangOptions::InstantiationDepth. |
| 1746 | llvm::SmallVector<ActiveTemplateInstantiation, 16> |
| 1747 | ActiveTemplateInstantiations; |
| 1748 | |
Douglas Gregor | 27b152f | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 1749 | /// \brief The last template from which a template instantiation |
| 1750 | /// error or warning was produced. |
| 1751 | /// |
| 1752 | /// This value is used to suppress printing of redundant template |
| 1753 | /// instantiation backtraces when there are multiple errors in the |
| 1754 | /// same instantiation. FIXME: Does this belong in Sema? It's tough |
| 1755 | /// to implement it anywhere else. |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1756 | ActiveTemplateInstantiation LastTemplateInstantiationErrorContext; |
Douglas Gregor | 27b152f | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 1757 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1758 | /// \brief A stack object to be created when performing template |
| 1759 | /// instantiation. |
| 1760 | /// |
| 1761 | /// Construction of an object of type \c InstantiatingTemplate |
| 1762 | /// pushes the current instantiation onto the stack of active |
| 1763 | /// instantiations. If the size of this stack exceeds the maximum |
| 1764 | /// number of recursive template instantiations, construction |
| 1765 | /// produces an error and evaluates true. |
| 1766 | /// |
| 1767 | /// Destruction of this object will pop the named instantiation off |
| 1768 | /// the stack. |
| 1769 | struct InstantiatingTemplate { |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1770 | /// \brief Note that we are instantiating a class template. |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1771 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 1772 | ClassTemplateSpecializationDecl *Entity, |
| 1773 | SourceRange InstantiationRange = SourceRange()); |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1774 | |
| 1775 | /// \brief Note that we are instantiating a default argument in a |
| 1776 | /// template-id. |
| 1777 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 1778 | TemplateDecl *Template, |
| 1779 | const TemplateArgument *TemplateArgs, |
| 1780 | unsigned NumTemplateArgs, |
| 1781 | SourceRange InstantiationRange = SourceRange()); |
| 1782 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1783 | ~InstantiatingTemplate(); |
| 1784 | |
| 1785 | /// \brief Determines whether we have exceeded the maximum |
| 1786 | /// recursive template instantiations. |
| 1787 | operator bool() const { return Invalid; } |
| 1788 | |
| 1789 | private: |
| 1790 | Sema &SemaRef; |
| 1791 | bool Invalid; |
| 1792 | |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 1793 | bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, |
| 1794 | SourceRange InstantiationRange); |
| 1795 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 1796 | InstantiatingTemplate(const InstantiatingTemplate&); // not implemented |
| 1797 | |
| 1798 | InstantiatingTemplate& |
| 1799 | operator=(const InstantiatingTemplate&); // not implemented |
| 1800 | }; |
| 1801 | |
Douglas Gregor | ee1828a | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 1802 | static void PrintInstantiationStackHook(unsigned DiagID, void *Cookie); |
| 1803 | void PrintInstantiationStack(); |
| 1804 | |
Douglas Gregor | 99ebf65 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 1805 | QualType InstantiateType(QualType T, const TemplateArgument *TemplateArgs, |
| 1806 | unsigned NumTemplateArgs, |
| 1807 | SourceLocation Loc, DeclarationName Entity); |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1808 | bool |
| 1809 | InstantiateBaseSpecifiers(ClassTemplateSpecializationDecl *ClassTemplateSpec, |
| 1810 | ClassTemplateDecl *ClassTemplate); |
| 1811 | bool |
| 1812 | InstantiateClassTemplateSpecialization( |
| 1813 | ClassTemplateSpecializationDecl *ClassTemplateSpec, |
| 1814 | bool ExplicitInstantiation); |
Douglas Gregor | 99ebf65 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 1815 | |
Steve Naroff | 3536b44 | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 1816 | // Objective-C declarations. |
Chris Lattner | 06036d3 | 2008-07-26 04:13:19 +0000 | [diff] [blame] | 1817 | virtual DeclTy *ActOnStartClassInterface(SourceLocation AtInterfaceLoc, |
| 1818 | IdentifierInfo *ClassName, |
| 1819 | SourceLocation ClassLoc, |
| 1820 | IdentifierInfo *SuperName, |
| 1821 | SourceLocation SuperLoc, |
| 1822 | DeclTy * const *ProtoRefs, |
| 1823 | unsigned NumProtoRefs, |
| 1824 | SourceLocation EndProtoLoc, |
| 1825 | AttributeList *AttrList); |
Fariborz Jahanian | 243b64b | 2007-10-11 23:42:27 +0000 | [diff] [blame] | 1826 | |
| 1827 | virtual DeclTy *ActOnCompatiblityAlias( |
| 1828 | SourceLocation AtCompatibilityAliasLoc, |
| 1829 | IdentifierInfo *AliasName, SourceLocation AliasLocation, |
| 1830 | IdentifierInfo *ClassName, SourceLocation ClassLocation); |
Steve Naroff | 61d6852 | 2009-03-05 15:22:01 +0000 | [diff] [blame] | 1831 | |
| 1832 | void CheckForwardProtocolDeclarationForCircularDependency( |
| 1833 | IdentifierInfo *PName, |
| 1834 | SourceLocation &PLoc, SourceLocation PrevLoc, |
| 1835 | const ObjCList<ObjCProtocolDecl> &PList); |
Steve Naroff | 3536b44 | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 1836 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 1837 | virtual DeclTy *ActOnStartProtocolInterface( |
Nate Begeman | 1abc7f6 | 2008-02-20 22:57:40 +0000 | [diff] [blame] | 1838 | SourceLocation AtProtoInterfaceLoc, |
Fariborz Jahanian | 25e077d | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 1839 | IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, |
Chris Lattner | e13b959 | 2008-07-26 04:03:38 +0000 | [diff] [blame] | 1840 | DeclTy * const *ProtoRefNames, unsigned NumProtoRefs, |
Daniel Dunbar | 246e70f | 2008-09-26 04:48:09 +0000 | [diff] [blame] | 1841 | SourceLocation EndProtoLoc, |
| 1842 | AttributeList *AttrList); |
Fariborz Jahanian | 25e077d | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 1843 | |
Chris Lattner | 6bd6d0b | 2008-07-26 04:07:02 +0000 | [diff] [blame] | 1844 | virtual DeclTy *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, |
| 1845 | IdentifierInfo *ClassName, |
| 1846 | SourceLocation ClassLoc, |
| 1847 | IdentifierInfo *CategoryName, |
| 1848 | SourceLocation CategoryLoc, |
| 1849 | DeclTy * const *ProtoRefs, |
| 1850 | unsigned NumProtoRefs, |
| 1851 | SourceLocation EndProtoLoc); |
Fariborz Jahanian | fd225cc | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 1852 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 1853 | virtual DeclTy *ActOnStartClassImplementation( |
Nate Begeman | 1abc7f6 | 2008-02-20 22:57:40 +0000 | [diff] [blame] | 1854 | SourceLocation AtClassImplLoc, |
Fariborz Jahanian | ccb4f31 | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 1855 | IdentifierInfo *ClassName, SourceLocation ClassLoc, |
| 1856 | IdentifierInfo *SuperClassname, |
| 1857 | SourceLocation SuperClassLoc); |
| 1858 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 1859 | virtual DeclTy *ActOnStartCategoryImplementation( |
Fariborz Jahanian | 8f3fde0 | 2007-10-02 16:38:50 +0000 | [diff] [blame] | 1860 | SourceLocation AtCatImplLoc, |
| 1861 | IdentifierInfo *ClassName, |
| 1862 | SourceLocation ClassLoc, |
| 1863 | IdentifierInfo *CatName, |
| 1864 | SourceLocation CatLoc); |
| 1865 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 1866 | virtual DeclTy *ActOnForwardClassDeclaration(SourceLocation Loc, |
Steve Naroff | 37e58d1 | 2007-10-02 22:39:18 +0000 | [diff] [blame] | 1867 | IdentifierInfo **IdentList, |
| 1868 | unsigned NumElts); |
Fariborz Jahanian | 894c57f | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 1869 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 1870 | virtual DeclTy *ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, |
Chris Lattner | 7caeabd | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 1871 | const IdentifierLocPair *IdentList, |
Fariborz Jahanian | bc1c877 | 2008-12-17 01:07:27 +0000 | [diff] [blame] | 1872 | unsigned NumElts, |
| 1873 | AttributeList *attrList); |
Fariborz Jahanian | 245f92a | 2007-10-05 21:01:53 +0000 | [diff] [blame] | 1874 | |
Chris Lattner | e13b959 | 2008-07-26 04:03:38 +0000 | [diff] [blame] | 1875 | virtual void FindProtocolDeclaration(bool WarnOnDeclarations, |
Chris Lattner | 7caeabd | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 1876 | const IdentifierLocPair *ProtocolId, |
Fariborz Jahanian | 4b6c905 | 2007-10-11 00:55:41 +0000 | [diff] [blame] | 1877 | unsigned NumProtocols, |
Chris Lattner | 7caeabd | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 1878 | llvm::SmallVectorImpl<DeclTy *> &Protocols); |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 1879 | |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 1880 | /// Ensure attributes are consistent with type. |
| 1881 | /// \param [in, out] Attributes The attributes to check; they will |
| 1882 | /// be modified to be consistent with \arg PropertyTy. |
| 1883 | void CheckObjCPropertyAttributes(QualType PropertyTy, |
| 1884 | SourceLocation Loc, |
| 1885 | unsigned &Attributes); |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 1886 | void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC); |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 1887 | void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, |
| 1888 | ObjCPropertyDecl *SuperProperty, |
Chris Lattner | 8ec03f5 | 2008-11-24 03:54:41 +0000 | [diff] [blame] | 1889 | const IdentifierInfo *Name); |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 1890 | void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl); |
Fariborz Jahanian | b5e0224 | 2008-04-24 19:58:34 +0000 | [diff] [blame] | 1891 | |
Fariborz Jahanian | 1ac2bc4 | 2008-12-06 23:03:39 +0000 | [diff] [blame] | 1892 | void MergeProtocolPropertiesIntoClass(Decl *CDecl, |
Fariborz Jahanian | aebf0cb | 2008-05-02 19:17:30 +0000 | [diff] [blame] | 1893 | DeclTy *MergeProtocols); |
| 1894 | |
Fariborz Jahanian | b7f95f5 | 2009-03-02 19:05:07 +0000 | [diff] [blame] | 1895 | void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, |
| 1896 | ObjCInterfaceDecl *ID); |
| 1897 | |
Fariborz Jahanian | 1ac2bc4 | 2008-12-06 23:03:39 +0000 | [diff] [blame] | 1898 | void MergeOneProtocolPropertiesIntoClass(Decl *CDecl, |
Fariborz Jahanian | aebf0cb | 2008-05-02 19:17:30 +0000 | [diff] [blame] | 1899 | ObjCProtocolDecl *PDecl); |
| 1900 | |
Steve Naroff | 0416fb9 | 2007-11-11 17:19:15 +0000 | [diff] [blame] | 1901 | virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclTy *classDecl, |
| 1902 | DeclTy **allMethods = 0, unsigned allNum = 0, |
| 1903 | DeclTy **allProperties = 0, unsigned pNum = 0); |
Fariborz Jahanian | d0b90bf | 2007-09-26 18:27:25 +0000 | [diff] [blame] | 1904 | |
Fariborz Jahanian | 1de1e74 | 2008-04-14 23:36:35 +0000 | [diff] [blame] | 1905 | virtual DeclTy *ActOnProperty(Scope *S, SourceLocation AtLoc, |
Fariborz Jahanian | 46b55e5 | 2008-05-05 18:51:55 +0000 | [diff] [blame] | 1906 | FieldDeclarator &FD, ObjCDeclSpec &ODS, |
Fariborz Jahanian | 5251e13 | 2008-05-06 18:09:04 +0000 | [diff] [blame] | 1907 | Selector GetterSel, Selector SetterSel, |
Fariborz Jahanian | 8cf0bb3 | 2008-11-26 20:01:34 +0000 | [diff] [blame] | 1908 | DeclTy *ClassCategory, bool *OverridingProperty, |
Fariborz Jahanian | 46b55e5 | 2008-05-05 18:51:55 +0000 | [diff] [blame] | 1909 | tok::ObjCKeywordKind MethodImplKind); |
| 1910 | |
Fariborz Jahanian | f624f81 | 2008-04-18 00:19:30 +0000 | [diff] [blame] | 1911 | virtual DeclTy *ActOnPropertyImplDecl(SourceLocation AtLoc, |
| 1912 | SourceLocation PropertyLoc, |
| 1913 | bool ImplKind, DeclTy *ClassImplDecl, |
| 1914 | IdentifierInfo *PropertyId, |
| 1915 | IdentifierInfo *PropertyIvar); |
| 1916 | |
Steve Naroff | bef1185 | 2007-10-26 20:53:56 +0000 | [diff] [blame] | 1917 | virtual DeclTy *ActOnMethodDeclaration( |
| 1918 | SourceLocation BeginLoc, // location of the + or -. |
| 1919 | SourceLocation EndLoc, // location of the ; or {. |
Fariborz Jahanian | 1f7b6f8 | 2007-11-09 19:52:12 +0000 | [diff] [blame] | 1920 | tok::TokenKind MethodType, |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1921 | DeclTy *ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType, |
Fariborz Jahanian | f1de0ca | 2007-10-31 23:53:01 +0000 | [diff] [blame] | 1922 | Selector Sel, |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 1923 | // optional arguments. The number of types/arguments is obtained |
| 1924 | // from the Sel.getNumArgs(). |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1925 | ObjCDeclSpec *ArgQT, TypeTy **ArgTypes, IdentifierInfo **ArgNames, |
Fariborz Jahanian | 439c658 | 2009-01-09 00:38:19 +0000 | [diff] [blame] | 1926 | llvm::SmallVectorImpl<Declarator> &Cdecls, |
Steve Naroff | 335eafa | 2007-11-15 12:35:21 +0000 | [diff] [blame] | 1927 | AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, |
| 1928 | bool isVariadic = false); |
Steve Naroff | 81bfde9 | 2007-10-16 23:12:48 +0000 | [diff] [blame] | 1929 | |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 1930 | // Helper method for ActOnClassMethod/ActOnInstanceMethod. |
| 1931 | // Will search "local" class/category implementations for a method decl. |
Fariborz Jahanian | 175ba1e | 2009-03-04 18:15:57 +0000 | [diff] [blame] | 1932 | // Will also search in class's root looking for instance method. |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 1933 | // Returns 0 if no method is found. |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 1934 | ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel, |
| 1935 | ObjCInterfaceDecl *CDecl); |
| 1936 | ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel, |
| 1937 | ObjCInterfaceDecl *ClassDecl); |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 1938 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 1939 | virtual OwningExprResult ActOnClassPropertyRefExpr( |
| 1940 | IdentifierInfo &receiverName, |
| 1941 | IdentifierInfo &propertyName, |
| 1942 | SourceLocation &receiverNameLoc, |
| 1943 | SourceLocation &propertyNameLoc); |
| 1944 | |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 1945 | // ActOnClassMessage - used for both unary and keyword messages. |
| 1946 | // ArgExprs is optional - if it is present, the number of expressions |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 1947 | // is obtained from NumArgs. |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 1948 | virtual ExprResult ActOnClassMessage( |
Fariborz Jahanian | 0523aaf | 2007-11-12 20:13:27 +0000 | [diff] [blame] | 1949 | Scope *S, |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 1950 | IdentifierInfo *receivingClassName, Selector Sel, SourceLocation lbrac, |
| 1951 | SourceLocation receiverLoc, SourceLocation selectorLoc,SourceLocation rbrac, |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 1952 | ExprTy **ArgExprs, unsigned NumArgs); |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 1953 | |
| 1954 | // ActOnInstanceMessage - used for both unary and keyword messages. |
| 1955 | // ArgExprs is optional - if it is present, the number of expressions |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 1956 | // is obtained from NumArgs. |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 1957 | virtual ExprResult ActOnInstanceMessage( |
Steve Naroff | bcfb06a | 2007-09-28 22:22:11 +0000 | [diff] [blame] | 1958 | ExprTy *receiver, Selector Sel, |
Anders Carlsson | ff975cf | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 1959 | SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac, |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 1960 | ExprTy **ArgExprs, unsigned NumArgs); |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 1961 | |
| 1962 | /// ActOnPragmaPack - Called on well formed #pragma pack(...). |
| 1963 | virtual void ActOnPragmaPack(PragmaPackKind Kind, |
| 1964 | IdentifierInfo *Name, |
| 1965 | ExprTy *Alignment, |
| 1966 | SourceLocation PragmaLoc, |
| 1967 | SourceLocation LParenLoc, |
| 1968 | SourceLocation RParenLoc); |
Chris Lattner | 574aa40 | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 1969 | |
| 1970 | /// getPragmaPackAlignment() - Return the current alignment as specified by |
| 1971 | /// the current #pragma pack directive, or 0 if none is currently active. |
| 1972 | unsigned getPragmaPackAlignment() const; |
| 1973 | |
| 1974 | /// FreePackedContext - Deallocate and null out PackContext. |
| 1975 | void FreePackedContext(); |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 1976 | |
Chris Lattner | 1e0a390 | 2008-01-16 19:17:22 +0000 | [diff] [blame] | 1977 | /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit |
| 1978 | /// cast. If there is already an implicit cast, merge into the existing one. |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 1979 | /// If isLvalue, the result of the cast is an lvalue. |
| 1980 | void ImpCastExprToType(Expr *&Expr, QualType Type, bool isLvalue = false); |
Chris Lattner | 1e0a390 | 2008-01-16 19:17:22 +0000 | [diff] [blame] | 1981 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1982 | // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 1983 | // functions and arrays to their respective pointers (C99 6.3.2.1). |
| 1984 | Expr *UsualUnaryConversions(Expr *&expr); |
Eli Friedman | 3c0eb16 | 2008-05-27 03:33:27 +0000 | [diff] [blame] | 1985 | |
Steve Naroff | c80b4ee | 2007-07-16 21:54:35 +0000 | [diff] [blame] | 1986 | // DefaultFunctionArrayConversion - converts functions and arrays |
| 1987 | // to their respective pointers (C99 6.3.2.1). |
| 1988 | void DefaultFunctionArrayConversion(Expr *&expr); |
Steve Naroff | 90045e8 | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 1989 | |
Steve Naroff | b291ab6 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 1990 | // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that |
| 1991 | // do not have a prototype. Integer promotions are performed on each |
| 1992 | // argument, and arguments that have type float are promoted to double. |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 1993 | void DefaultArgumentPromotion(Expr *&Expr); |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 1994 | |
| 1995 | // Used for emitting the right warning by DefaultVariadicArgumentPromotion |
| 1996 | enum VariadicCallType { |
| 1997 | VariadicFunction, |
| 1998 | VariadicBlock, |
| 1999 | VariadicMethod |
| 2000 | }; |
| 2001 | |
| 2002 | // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but |
| 2003 | // will warn if the resulting type is not a POD type. |
| 2004 | void DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT); |
Steve Naroff | b291ab6 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 2005 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2006 | // UsualArithmeticConversions - performs the UsualUnaryConversions on it's |
| 2007 | // operands and then handles various conversions that are common to binary |
| 2008 | // operators (C99 6.3.1.8). If both operands aren't arithmetic, this |
| 2009 | // routine returns the first non-arithmetic type found. The client is |
| 2010 | // responsible for emitting appropriate error diagnostics. |
Steve Naroff | 9f5fa9b | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 2011 | QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr, |
| 2012 | bool isCompAssign = false); |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2013 | |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 2014 | /// UsualArithmeticConversionsType - handles the various conversions |
| 2015 | /// that are common to binary operators (C99 6.3.1.8, C++ [expr]p9) |
| 2016 | /// and returns the result type of that conversion. |
| 2017 | QualType UsualArithmeticConversionsType(QualType lhs, QualType rhs); |
| 2018 | |
| 2019 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2020 | /// AssignConvertType - All of the 'assignment' semantic checks return this |
| 2021 | /// enum to indicate whether the assignment was allowed. These checks are |
| 2022 | /// done for simple assignments, as well as initialization, return from |
| 2023 | /// function, argument passing, etc. The query is phrased in terms of a |
| 2024 | /// source and destination type. |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 2025 | enum AssignConvertType { |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2026 | /// Compatible - the types are compatible according to the standard. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2027 | Compatible, |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2028 | |
| 2029 | /// PointerToInt - The assignment converts a pointer to an int, which we |
| 2030 | /// accept as an extension. |
| 2031 | PointerToInt, |
| 2032 | |
| 2033 | /// IntToPointer - The assignment converts an int to a pointer, which we |
| 2034 | /// accept as an extension. |
| 2035 | IntToPointer, |
| 2036 | |
| 2037 | /// FunctionVoidPointer - The assignment is between a function pointer and |
| 2038 | /// void*, which the standard doesn't allow, but we accept as an extension. |
Chris Lattner | bfe639e | 2008-01-03 22:56:36 +0000 | [diff] [blame] | 2039 | FunctionVoidPointer, |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2040 | |
| 2041 | /// IncompatiblePointer - The assignment is between two pointers types that |
| 2042 | /// are not compatible, but we accept them as an extension. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2043 | IncompatiblePointer, |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2044 | |
| 2045 | /// CompatiblePointerDiscardsQualifiers - The assignment discards |
| 2046 | /// c/v/r qualifiers, which we accept as an extension. |
| 2047 | CompatiblePointerDiscardsQualifiers, |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 2048 | |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 2049 | /// IncompatibleVectors - The assignment is between two vector types that |
| 2050 | /// have the same size, which we accept as an extension. |
| 2051 | IncompatibleVectors, |
| 2052 | |
Steve Naroff | bfdcae6 | 2008-09-04 15:31:07 +0000 | [diff] [blame] | 2053 | /// IntToBlockPointer - The assignment converts an int to a block |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 2054 | /// pointer. We disallow this. |
| 2055 | IntToBlockPointer, |
| 2056 | |
Steve Naroff | bfdcae6 | 2008-09-04 15:31:07 +0000 | [diff] [blame] | 2057 | /// IncompatibleBlockPointer - The assignment is between two block |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 2058 | /// pointers types that are not compatible. |
| 2059 | IncompatibleBlockPointer, |
| 2060 | |
Steve Naroff | 3957907 | 2008-10-14 22:18:38 +0000 | [diff] [blame] | 2061 | /// IncompatibleObjCQualifiedId - The assignment is between a qualified |
| 2062 | /// id type and something else (that is incompatible with it). For example, |
| 2063 | /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol. |
| 2064 | IncompatibleObjCQualifiedId, |
| 2065 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2066 | /// Incompatible - We reject this conversion outright, it is invalid to |
| 2067 | /// represent it in the AST. |
| 2068 | Incompatible |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2069 | }; |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 2070 | |
| 2071 | /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the |
| 2072 | /// assignment conversion type specified by ConvTy. This returns true if the |
| 2073 | /// conversion was invalid or false if the conversion was accepted. |
| 2074 | bool DiagnoseAssignmentResult(AssignConvertType ConvTy, |
| 2075 | SourceLocation Loc, |
| 2076 | QualType DstType, QualType SrcType, |
| 2077 | Expr *SrcExpr, const char *Flavor); |
| 2078 | |
| 2079 | /// CheckAssignmentConstraints - Perform type checking for assignment, |
| 2080 | /// argument passing, variable initialization, and function return values. |
| 2081 | /// This routine is only used by the following two methods. C99 6.5.16. |
| 2082 | AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs); |
Steve Naroff | 90045e8 | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 2083 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 2084 | // CheckSingleAssignmentConstraints - Currently used by ActOnCallExpr, |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 2085 | // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking, |
Steve Naroff | 90045e8 | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 2086 | // this routine performs the default function/array converions. |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 2087 | AssignConvertType CheckSingleAssignmentConstraints(QualType lhs, |
| 2088 | Expr *&rExpr); |
Steve Naroff | 90045e8 | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 2089 | // CheckCompoundAssignmentConstraints - Type check without performing any |
| 2090 | // conversions. For compound assignments, the "Check...Operands" methods |
| 2091 | // perform the necessary conversions. |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 2092 | AssignConvertType CheckCompoundAssignmentConstraints(QualType lhs, |
| 2093 | QualType rhs); |
Steve Naroff | 90045e8 | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 2094 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2095 | // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1) |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 2096 | AssignConvertType CheckPointerTypesForAssignment(QualType lhsType, |
| 2097 | QualType rhsType); |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 2098 | |
| 2099 | // Helper function for CheckAssignmentConstraints involving two |
| 2100 | // blcok pointer types. |
| 2101 | AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType, |
| 2102 | QualType rhsType); |
Douglas Gregor | 77a5223 | 2008-09-12 00:47:35 +0000 | [diff] [blame] | 2103 | |
| 2104 | bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType); |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 2105 | |
Douglas Gregor | 45920e8 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 2106 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 2107 | const char *Flavor, bool AllowExplicit = false); |
| 2108 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
| 2109 | const ImplicitConversionSequence& ICS, |
Douglas Gregor | 45920e8 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 2110 | const char *Flavor); |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 2111 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 45920e8 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 2112 | const StandardConversionSequence& SCS, |
| 2113 | const char *Flavor); |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 2114 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2115 | /// the following "Check" methods will return a valid/converted QualType |
| 2116 | /// or a null QualType (indicating an error diagnostic was issued). |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 2117 | |
| 2118 | /// type checking binary operators (subroutines of CreateBuiltinBinOp). |
Chris Lattner | ca5eede | 2007-12-12 05:47:28 +0000 | [diff] [blame] | 2119 | inline QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
Sebastian Redl | 7c8bd60 | 2009-02-07 20:10:22 +0000 | [diff] [blame] | 2120 | QualType CheckPointerToMemberOperands( // C++ 5.5 |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 2121 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2122 | inline QualType CheckMultiplyDivideOperands( // C99 6.5.5 |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 2123 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2124 | inline QualType CheckRemainderOperands( // C99 6.5.5 |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 2125 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2126 | inline QualType CheckAdditionOperands( // C99 6.5.6 |
Steve Naroff | 9f5fa9b | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 2127 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2128 | inline QualType CheckSubtractionOperands( // C99 6.5.6 |
Steve Naroff | 9f5fa9b | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 2129 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2130 | inline QualType CheckShiftOperands( // C99 6.5.7 |
Steve Naroff | 9f5fa9b | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 2131 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Chris Lattner | a5937dd | 2007-08-26 01:18:55 +0000 | [diff] [blame] | 2132 | inline QualType CheckCompareOperands( // C99 6.5.8/9 |
| 2133 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isRelational); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2134 | inline QualType CheckBitwiseOperands( // C99 6.5.[10...12] |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 2135 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2136 | inline QualType CheckLogicalOperands( // C99 6.5.[13,14] |
Steve Naroff | 49b4526 | 2007-07-13 16:58:59 +0000 | [diff] [blame] | 2137 | Expr *&lex, Expr *&rex, SourceLocation OpLoc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2138 | // CheckAssignmentOperands is used for both simple and compound assignment. |
| 2139 | // For simple assignment, pass both expressions and a null converted type. |
| 2140 | // For compound assignment, pass both expressions and the converted type. |
| 2141 | inline QualType CheckAssignmentOperands( // C99 6.5.16.[1,2] |
Steve Naroff | f1120de | 2007-08-24 22:33:52 +0000 | [diff] [blame] | 2142 | Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2143 | inline QualType CheckCommaOperands( // C99 6.5.17 |
Chris Lattner | 29a1cfb | 2008-11-18 01:30:42 +0000 | [diff] [blame] | 2144 | Expr *lex, Expr *&rex, SourceLocation OpLoc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2145 | inline QualType CheckConditionalOperands( // C99 6.5.15 |
Steve Naroff | 49b4526 | 2007-07-13 16:58:59 +0000 | [diff] [blame] | 2146 | Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc); |
Nate Begeman | be2341d | 2008-07-14 18:02:46 +0000 | [diff] [blame] | 2147 | |
| 2148 | /// type checking for vector binary operators. |
| 2149 | inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
| 2150 | inline QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx, |
| 2151 | SourceLocation l, bool isRel); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2152 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 2153 | /// type checking unary operators (subroutines of ActOnUnaryOp). |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2154 | /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4 |
Sebastian Redl | e6d5a4a | 2008-12-20 09:35:34 +0000 | [diff] [blame] | 2155 | QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc, |
| 2156 | bool isInc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2157 | QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc); |
| 2158 | QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc); |
Chris Lattner | ba27e2a | 2009-02-17 08:12:06 +0000 | [diff] [blame] | 2159 | QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal); |
Steve Naroff | e1b31fe | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 2160 | |
| 2161 | /// type checking primary expressions. |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 2162 | QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, |
Steve Naroff | e1b31fe | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 2163 | IdentifierInfo &Comp, SourceLocation CmpLoc); |
| 2164 | |
Steve Naroff | f009063 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 2165 | /// type checking declaration initializers (C99 6.7.8) |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 2166 | bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 2167 | SourceLocation InitLoc,DeclarationName InitEntity, |
| 2168 | bool DirectInit); |
Douglas Gregor | c34ee5e | 2009-01-29 00:45:39 +0000 | [diff] [blame] | 2169 | bool CheckInitList(InitListExpr *&InitList, QualType &DeclType); |
Steve Naroff | d0091aa | 2008-01-10 22:15:12 +0000 | [diff] [blame] | 2170 | bool CheckForConstantInitializer(Expr *e, QualType t); |
Steve Naroff | 2fdc374 | 2007-12-10 22:44:33 +0000 | [diff] [blame] | 2171 | |
Douglas Gregor | 87fd703 | 2009-02-02 17:43:21 +0000 | [diff] [blame] | 2172 | bool CheckValueInitialization(QualType Type, SourceLocation Loc); |
Argyrios Kyrtzidis | 6c2dc4d | 2008-08-16 20:27:34 +0000 | [diff] [blame] | 2173 | |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 2174 | // type checking C++ declaration initializers (C++ [dcl.init]). |
| 2175 | |
| 2176 | /// ReferenceCompareResult - Expresses the result of comparing two |
| 2177 | /// types (cv1 T1 and cv2 T2) to determine their compatibility for the |
| 2178 | /// purposes of initialization by reference (C++ [dcl.init.ref]p4). |
| 2179 | enum ReferenceCompareResult { |
| 2180 | /// Ref_Incompatible - The two types are incompatible, so direct |
| 2181 | /// reference binding is not possible. |
| 2182 | Ref_Incompatible = 0, |
| 2183 | /// Ref_Related - The two types are reference-related, which means |
| 2184 | /// that their unqualified forms (T1 and T2) are either the same |
| 2185 | /// or T1 is a base class of T2. |
| 2186 | Ref_Related, |
| 2187 | /// Ref_Compatible_With_Added_Qualification - The two types are |
| 2188 | /// reference-compatible with added qualification, meaning that |
| 2189 | /// they are reference-compatible and the qualifiers on T1 (cv1) |
| 2190 | /// are greater than the qualifiers on T2 (cv2). |
| 2191 | Ref_Compatible_With_Added_Qualification, |
| 2192 | /// Ref_Compatible - The two types are reference-compatible and |
| 2193 | /// have equivalent qualifiers (cv1 == cv2). |
| 2194 | Ref_Compatible |
| 2195 | }; |
| 2196 | |
Douglas Gregor | 15da57e | 2008-10-29 02:00:59 +0000 | [diff] [blame] | 2197 | ReferenceCompareResult CompareReferenceRelationship(QualType T1, QualType T2, |
| 2198 | bool& DerivedToBase); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 2199 | |
| 2200 | bool CheckReferenceInit(Expr *&simpleInit_or_initList, QualType &declType, |
Douglas Gregor | 225c41e | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 2201 | ImplicitConversionSequence *ICS = 0, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 2202 | bool SuppressUserConversions = false, |
| 2203 | bool AllowExplicit = false); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 2204 | |
Argyrios Kyrtzidis | 6c2dc4d | 2008-08-16 20:27:34 +0000 | [diff] [blame] | 2205 | /// CheckCastTypes - Check type constraints for casting between types. |
Daniel Dunbar | 58d5ebb | 2008-08-20 03:55:42 +0000 | [diff] [blame] | 2206 | bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr); |
Steve Naroff | a49e1fa | 2008-01-22 00:55:40 +0000 | [diff] [blame] | 2207 | |
Anders Carlsson | 584b247 | 2007-11-27 07:16:40 +0000 | [diff] [blame] | 2208 | // CheckVectorCast - check type constraints for vectors. |
| 2209 | // Since vectors are an extension, there are no C standard reference for this. |
| 2210 | // We allow casting between vectors and integer datatypes of the same size. |
Anders Carlsson | a64db8f | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 2211 | // returns true if the cast is invalid |
| 2212 | bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty); |
| 2213 | |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 2214 | /// CheckMessageArgumentTypes - Check types in an Obj-C message send. |
| 2215 | /// \param Method - May be null. |
| 2216 | /// \param [out] ReturnType - The return type of the send. |
| 2217 | /// \return true iff there were any incompatible types. |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 2218 | bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel, |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 2219 | ObjCMethodDecl *Method, bool isClassMessage, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 2220 | SourceLocation lbrac, SourceLocation rbrac, |
| 2221 | QualType &ReturnType); |
Argyrios Kyrtzidis | 5921093 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 2222 | |
| 2223 | /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid. |
| 2224 | bool CheckCXXBooleanCondition(Expr *&CondExpr); |
Steve Naroff | 81bfde9 | 2007-10-16 23:12:48 +0000 | [diff] [blame] | 2225 | |
Chris Lattner | f4021e7 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 2226 | /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have |
| 2227 | /// the specified width and sign. If an overflow occurs, detect it and emit |
| 2228 | /// the specified diagnostic. |
| 2229 | void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal, |
| 2230 | unsigned NewWidth, bool NewSign, |
| 2231 | SourceLocation Loc, unsigned DiagID); |
| 2232 | |
Chris Lattner | eca7be6 | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 2233 | bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, |
| 2234 | bool ForCompare); |
| 2235 | |
Anders Carlsson | 1528145 | 2008-11-04 16:57:32 +0000 | [diff] [blame] | 2236 | /// Checks that the Objective-C declaration is declared in the global scope. |
| 2237 | /// Emits an error and marks the declaration as invalid if it's not declared |
| 2238 | /// in the global scope. |
| 2239 | bool CheckObjCDeclScope(Decl *D); |
| 2240 | |
Anders Carlsson | 7c50aca | 2007-10-15 20:28:48 +0000 | [diff] [blame] | 2241 | void InitBuiltinVaListType(); |
Eli Friedman | 1b76ada | 2008-06-03 21:01:11 +0000 | [diff] [blame] | 2242 | |
Anders Carlsson | e21555e | 2008-11-30 19:50:32 +0000 | [diff] [blame] | 2243 | /// VerifyIntegerConstantExpression - verifies that an expression is an ICE, |
| 2244 | /// and reports the appropriate diagnostics. Returns false on success. |
| 2245 | /// Can optionally return the value of the expression. |
Anders Carlsson | 9f1e572 | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 2246 | bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0); |
Anders Carlsson | 4000ea6 | 2008-12-01 02:17:22 +0000 | [diff] [blame] | 2247 | |
Anders Carlsson | 9f1e572 | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 2248 | /// VerifyBitField - verifies that a bit field expression is an ICE and has |
| 2249 | /// the correct width, and that the field type is valid. |
| 2250 | /// Returns false on success. |
| 2251 | bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, |
| 2252 | QualType FieldTy, const Expr *BitWidth); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 2253 | |
Chris Lattner | 59907c4 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 2254 | //===--------------------------------------------------------------------===// |
| 2255 | // Extra semantic analysis beyond the C type system |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 2256 | private: |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 2257 | Action::OwningExprResult CheckFunctionCall(FunctionDecl *FDecl, |
| 2258 | CallExpr *TheCall); |
Chris Lattner | 6080008 | 2009-02-18 17:49:48 +0000 | [diff] [blame] | 2259 | SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, |
| 2260 | unsigned ByteNo) const; |
Chris Lattner | 6903981 | 2009-02-18 06:01:06 +0000 | [diff] [blame] | 2261 | bool CheckObjCString(Expr *Arg); |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 2262 | bool SemaBuiltinVAStart(CallExpr *TheCall); |
| 2263 | bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); |
Eli Friedman | 6cfda23 | 2008-05-20 08:23:37 +0000 | [diff] [blame] | 2264 | bool SemaBuiltinStackAddress(CallExpr *TheCall); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 2265 | Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall); |
Daniel Dunbar | 4493f79 | 2008-07-21 22:59:13 +0000 | [diff] [blame] | 2266 | bool SemaBuiltinPrefetch(CallExpr *TheCall); |
Daniel Dunbar | d5f8a4f | 2008-09-03 21:13:56 +0000 | [diff] [blame] | 2267 | bool SemaBuiltinObjectSize(CallExpr *TheCall); |
Ted Kremenek | d30ef87 | 2009-01-12 23:09:09 +0000 | [diff] [blame] | 2268 | bool SemaCheckStringLiteral(Expr *E, CallExpr *TheCall, bool HasVAListArg, |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 2269 | unsigned format_idx, unsigned firstDataArg); |
Ted Kremenek | d30ef87 | 2009-01-12 23:09:09 +0000 | [diff] [blame] | 2270 | void CheckPrintfString(StringLiteral *FExpr, Expr *OrigFormatExpr, |
| 2271 | CallExpr *TheCall, bool HasVAListArg, |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 2272 | unsigned format_idx, unsigned firstDataArg); |
| 2273 | void CheckPrintfArguments(CallExpr *TheCall, bool HasVAListArg, |
| 2274 | unsigned format_idx, unsigned firstDataArg); |
Ted Kremenek | 06de276 | 2007-08-17 16:46:58 +0000 | [diff] [blame] | 2275 | void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, |
| 2276 | SourceLocation ReturnLoc); |
Ted Kremenek | 588e5eb | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 2277 | void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2278 | }; |
| 2279 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 2280 | /// BlockSemaInfo - When a block is being parsed, this contains information |
| 2281 | /// about the block. It is pointed to from Sema::CurBlock. |
| 2282 | struct BlockSemaInfo { |
| 2283 | llvm::SmallVector<ParmVarDecl*, 8> Params; |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 2284 | bool hasPrototype; |
| 2285 | bool isVariadic; |
Mike Stump | b83d287 | 2009-02-19 22:01:56 +0000 | [diff] [blame] | 2286 | bool hasBlockDeclRefExprs; |
| 2287 | |
Steve Naroff | 1c90bfc | 2008-10-08 18:44:00 +0000 | [diff] [blame] | 2288 | BlockDecl *TheDecl; |
| 2289 | |
Chris Lattner | da425eb | 2009-02-18 07:09:44 +0000 | [diff] [blame] | 2290 | /// TheScope - This is the scope for the block itself, which contains |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 2291 | /// arguments etc. |
| 2292 | Scope *TheScope; |
| 2293 | |
| 2294 | /// ReturnType - This will get set to block result type, by looking at |
| 2295 | /// return types, if any, in the block body. |
| 2296 | Type *ReturnType; |
| 2297 | |
| 2298 | /// PrevBlockInfo - If this is nested inside another block, this points |
| 2299 | /// to the outer block. |
| 2300 | BlockSemaInfo *PrevBlockInfo; |
| 2301 | }; |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 2302 | |
| 2303 | //===--------------------------------------------------------------------===// |
| 2304 | // Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers). |
| 2305 | template <typename T> |
| 2306 | class ExprOwningPtr : public Action::ExprArg { |
| 2307 | public: |
| 2308 | ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}; |
| 2309 | |
| 2310 | void reset(T* p) { Action::ExprArg::operator=(p); } |
| 2311 | T* get() const { return static_cast<T*>(Action::ExprArg::get()); } |
| 2312 | T* take() { return static_cast<T*>(Action::ExprArg::take()); } |
| 2313 | T* release() { return take(); } |
| 2314 | |
| 2315 | T& operator*() const { return *get(); } |
| 2316 | T* operator->() const { return get(); } |
| 2317 | }; |
| 2318 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 2319 | } // end namespace clang |
| 2320 | |
| 2321 | #endif |