Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 1 | //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===// |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 5b12ab8 | 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. |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 10 | // This file defines the Sema class, which performs semantic analysis and |
| 11 | // builds ASTs. |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 15 | #ifndef LLVM_CLANG_AST_SEMA_H |
| 16 | #define LLVM_CLANG_AST_SEMA_H |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 17 | |
Chris Lattner | c5c95b5 | 2008-04-11 07:00:53 +0000 | [diff] [blame] | 18 | #include "IdentifierResolver.h" |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 19 | #include "CXXFieldCollector.h" |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 20 | #include "SemaOverload.h" |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 21 | #include "clang/AST/Attr.h" |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 22 | #include "clang/AST/DeclBase.h" |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 23 | #include "clang/AST/Decl.h" |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 24 | #include "clang/AST/DeclObjC.h" |
Anders Carlsson | 8aa89d4 | 2009-06-05 03:43:12 +0000 | [diff] [blame] | 25 | #include "clang/AST/DeclTemplate.h" |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 26 | #include "clang/Parse/Action.h" |
Chris Lattner | 60f3622 | 2009-01-29 05:15:15 +0000 | [diff] [blame] | 27 | #include "clang/Sema/SemaDiagnostic.h" |
Anders Carlsson | 51873c2 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 28 | #include "llvm/ADT/SmallVector.h" |
Fariborz Jahanian | 458f711 | 2007-10-05 18:00:57 +0000 | [diff] [blame] | 29 | #include "llvm/ADT/DenseSet.h" |
Chris Lattner | ee2d841 | 2007-10-07 01:13:46 +0000 | [diff] [blame] | 30 | #include "llvm/ADT/SmallPtrSet.h" |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 31 | #include "llvm/ADT/OwningPtr.h" |
Douglas Gregor | dda7ced | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 32 | #include <deque> |
Douglas Gregor | 0b6a624 | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 33 | #include <list> |
Douglas Gregor | 1c846b0 | 2009-01-16 00:38:09 +0000 | [diff] [blame] | 34 | #include <string> |
Douglas Gregor | 39c16d4 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 35 | #include <vector> |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 36 | |
Chris Lattner | fc1c44a | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 37 | namespace llvm { |
| 38 | class APSInt; |
| 39 | } |
| 40 | |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 41 | namespace clang { |
Chris Lattner | cb6a382 | 2006-11-10 06:20:45 +0000 | [diff] [blame] | 42 | class ASTContext; |
Chris Lattner | fe0e0af | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 43 | class ASTConsumer; |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 44 | class Preprocessor; |
| 45 | class Decl; |
Chris Lattner | 0a5ff0d | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 46 | class DeclContext; |
Daniel Dunbar | 34fb672 | 2008-08-11 03:27:53 +0000 | [diff] [blame] | 47 | class DeclSpec; |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 48 | class ExternalSemaSource; |
Steve Naroff | 257520b | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 49 | class NamedDecl; |
Sebastian Redl | c675bab | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 50 | class Stmt; |
Steve Naroff | 7840336 | 2007-04-02 22:55:05 +0000 | [diff] [blame] | 51 | class Expr; |
Steve Naroff | f33527a | 2007-09-02 15:34:30 +0000 | [diff] [blame] | 52 | class InitListExpr; |
Douglas Gregor | e4a0bb7 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 53 | class DesignatedInitExpr; |
Chris Lattner | 0846494 | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 54 | class CallExpr; |
Douglas Gregor | c7acfdf | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 55 | class DeclRefExpr; |
Chris Lattner | c5cdf4d | 2007-01-21 07:42:07 +0000 | [diff] [blame] | 56 | class VarDecl; |
Chris Lattner | 53621a5 | 2007-06-13 20:44:40 +0000 | [diff] [blame] | 57 | class ParmVarDecl; |
Chris Lattner | 01564d9 | 2007-01-27 19:27:06 +0000 | [diff] [blame] | 58 | class TypedefDecl; |
| 59 | class FunctionDecl; |
Steve Naroff | e5aa9be | 2007-04-05 22:36:20 +0000 | [diff] [blame] | 60 | class QualType; |
Sebastian Redl | 7dce772 | 2009-03-07 12:16:37 +0000 | [diff] [blame] | 61 | class LangOptions; |
Chris Lattner | 146762e | 2007-07-20 16:59:19 +0000 | [diff] [blame] | 62 | class Token; |
Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 63 | class IntegerLiteral; |
Steve Naroff | af2a022 | 2008-01-22 00:55:40 +0000 | [diff] [blame] | 64 | class StringLiteral; |
Steve Naroff | 8eeeb13 | 2007-05-08 21:09:37 +0000 | [diff] [blame] | 65 | class ArrayType; |
Chris Lattner | e247306 | 2007-05-28 06:28:18 +0000 | [diff] [blame] | 66 | class LabelStmt; |
Anders Carlsson | 51873c2 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 67 | class SwitchStmt; |
Sebastian Redl | 4c01866 | 2009-04-27 21:33:24 +0000 | [diff] [blame] | 68 | class CXXTryStmt; |
Nate Begeman | ce4d7fc | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 69 | class ExtVectorType; |
Steve Naroff | ddf5a1d | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 70 | class TypedefDecl; |
Douglas Gregor | ded2d7b | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 71 | class TemplateDecl; |
Douglas Gregor | 264ec4f | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 72 | class TemplateArgument; |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 73 | class TemplateArgumentList; |
Douglas Gregor | cd72ba9 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 74 | class TemplateParameterList; |
Douglas Gregor | d32e028 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 75 | class TemplateTemplateParmDecl; |
Douglas Gregor | 2373c59 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 76 | class ClassTemplatePartialSpecializationDecl; |
Douglas Gregor | f47b911 | 2009-02-25 22:02:03 +0000 | [diff] [blame] | 77 | class ClassTemplateDecl; |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 78 | class ObjCInterfaceDecl; |
Steve Naroff | 257520b | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 79 | class ObjCCompatibleAliasDecl; |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 80 | class ObjCProtocolDecl; |
Chris Lattner | 9ef10f4 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 81 | class ObjCImplDecl; |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 82 | class ObjCImplementationDecl; |
| 83 | class ObjCCategoryImplDecl; |
| 84 | class ObjCCategoryDecl; |
| 85 | class ObjCIvarDecl; |
| 86 | class ObjCMethodDecl; |
Fariborz Jahanian | 7cf1886 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 87 | class ObjCPropertyDecl; |
Steve Naroff | 35c62ae | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 88 | class ObjCContainerDecl; |
Sebastian Redl | 4f4d7b5 | 2009-07-04 11:39:00 +0000 | [diff] [blame] | 89 | class FunctionProtoType; |
Douglas Gregor | 39c16d4 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 90 | class BasePaths; |
Sebastian Redl | 7dce772 | 2009-03-07 12:16:37 +0000 | [diff] [blame] | 91 | struct MemberLookupCriteria; |
Anders Carlsson | a29ded9 | 2009-05-30 21:05:25 +0000 | [diff] [blame] | 92 | class CXXTemporary; |
Steve Naroff | ddf5a1d | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 93 | |
Chris Lattner | 3318e86 | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 94 | /// BlockSemaInfo - When a block is being parsed, this contains information |
| 95 | /// about the block. It is pointed to from Sema::CurBlock. |
| 96 | struct BlockSemaInfo { |
| 97 | llvm::SmallVector<ParmVarDecl*, 8> Params; |
| 98 | bool hasPrototype; |
| 99 | bool isVariadic; |
| 100 | bool hasBlockDeclRefExprs; |
| 101 | |
| 102 | BlockDecl *TheDecl; |
| 103 | |
| 104 | /// TheScope - This is the scope for the block itself, which contains |
| 105 | /// arguments etc. |
| 106 | Scope *TheScope; |
| 107 | |
| 108 | /// ReturnType - This will get set to block result type, by looking at |
| 109 | /// return types, if any, in the block body. |
Fariborz Jahanian | 3fd7310 | 2009-06-19 23:37:08 +0000 | [diff] [blame] | 110 | QualType ReturnType; |
Chris Lattner | 3318e86 | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 111 | |
| 112 | /// LabelMap - This is a mapping from label identifiers to the LabelStmt for |
| 113 | /// it (which acts like the label decl in some ways). Forward referenced |
| 114 | /// labels have a LabelStmt created for them with a null location & SubStmt. |
| 115 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap; |
| 116 | |
Chris Lattner | 96b3139 | 2009-04-18 20:10:59 +0000 | [diff] [blame] | 117 | /// SwitchStack - This is the current set of active switch statements in the |
| 118 | /// block. |
| 119 | llvm::SmallVector<SwitchStmt*, 8> SwitchStack; |
| 120 | |
Chris Lattner | 45542ea | 2009-04-19 05:28:12 +0000 | [diff] [blame] | 121 | /// SavedFunctionNeedsScopeChecking - This is the value of |
| 122 | /// CurFunctionNeedsScopeChecking at the point when the block started. |
| 123 | bool SavedFunctionNeedsScopeChecking; |
| 124 | |
Chris Lattner | 3318e86 | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 125 | /// PrevBlockInfo - If this is nested inside another block, this points |
| 126 | /// to the outer block. |
| 127 | BlockSemaInfo *PrevBlockInfo; |
| 128 | }; |
| 129 | |
Chris Lattner | cc67ec1 | 2006-11-09 06:54:47 +0000 | [diff] [blame] | 130 | /// Sema - This implements semantic analysis and AST building for C. |
| 131 | class Sema : public Action { |
Chris Lattner | 01c3d23 | 2009-02-17 00:58:30 +0000 | [diff] [blame] | 132 | Sema(const Sema&); // DO NOT IMPLEMENT |
| 133 | void operator=(const Sema&); // DO NOT IMPLEMENT |
Chris Lattner | a663a0a | 2008-06-29 00:28:59 +0000 | [diff] [blame] | 134 | public: |
Chris Lattner | 4da04a4e | 2009-01-22 19:21:44 +0000 | [diff] [blame] | 135 | const LangOptions &LangOpts; |
Steve Naroff | 38d31b4 | 2007-02-28 01:22:02 +0000 | [diff] [blame] | 136 | Preprocessor &PP; |
Chris Lattner | cb6a382 | 2006-11-10 06:20:45 +0000 | [diff] [blame] | 137 | ASTContext &Context; |
Chris Lattner | fe0e0af | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 138 | ASTConsumer &Consumer; |
Chris Lattner | bc495d7 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 139 | Diagnostic &Diags; |
| 140 | SourceManager &SourceMgr; |
Steve Naroff | e3d1ab2 | 2007-11-12 13:56:41 +0000 | [diff] [blame] | 141 | |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 142 | /// \brief Source of additional semantic information. |
| 143 | ExternalSemaSource *ExternalSource; |
| 144 | |
Argyrios Kyrtzidis | 853fbea | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 145 | /// CurContext - This is the current declaration context of parsing. |
Chris Lattner | 0a5ff0d | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 146 | DeclContext *CurContext; |
Chris Lattner | c5ffed4 | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 147 | |
Argyrios Kyrtzidis | 16ac9be | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 148 | /// PreDeclaratorDC - Keeps the declaration context before switching to the |
| 149 | /// context of a declarator's nested-name-specifier. |
| 150 | DeclContext *PreDeclaratorDC; |
| 151 | |
Steve Naroff | c540d66 | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 152 | /// CurBlock - If inside of a block definition, this contains a pointer to |
| 153 | /// the active block object that represents it. |
| 154 | BlockSemaInfo *CurBlock; |
| 155 | |
Daniel Dunbar | 5460374 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 156 | /// PackContext - Manages the stack for #pragma pack. An alignment |
| 157 | /// of 0 indicates default alignment. |
Chris Lattner | 31180bb | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 158 | void *PackContext; // Really a "PragmaPackStack*" |
Daniel Dunbar | 5460374 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 159 | |
Chris Lattner | 3318e86 | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 160 | /// FunctionLabelMap - This is a mapping from label identifiers to the |
| 161 | /// LabelStmt for it (which acts like the label decl in some ways). Forward |
| 162 | /// referenced labels have a LabelStmt created for them with a null location & |
| 163 | /// SubStmt. |
| 164 | /// |
| 165 | /// Note that this should always be accessed through getLabelMap() in order |
| 166 | /// to handle blocks properly. |
| 167 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> FunctionLabelMap; |
Steve Naroff | 846b1ec | 2009-03-13 15:38:40 +0000 | [diff] [blame] | 168 | |
Chris Lattner | 96b3139 | 2009-04-18 20:10:59 +0000 | [diff] [blame] | 169 | /// FunctionSwitchStack - This is the current set of active switch statements |
| 170 | /// in the top level function. Clients should always use getSwitchStack() to |
| 171 | /// handle the case when they are in a block. |
| 172 | llvm::SmallVector<SwitchStmt*, 8> FunctionSwitchStack; |
Anders Carlsson | 85a307d | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 173 | |
| 174 | /// ExprTemporaries - This is the stack of temporaries that are created by |
| 175 | /// the current full expression. |
Anders Carlsson | a29ded9 | 2009-05-30 21:05:25 +0000 | [diff] [blame] | 176 | llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries; |
Anders Carlsson | 85a307d | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 177 | |
Chris Lattner | 9fecd74 | 2009-04-19 05:21:20 +0000 | [diff] [blame] | 178 | /// CurFunctionNeedsScopeChecking - This is set to true when a function or |
| 179 | /// ObjC method body contains a VLA or an ObjC try block, which introduce |
| 180 | /// scopes that need to be checked for goto conditions. If a function does |
| 181 | /// not contain this, then it need not have the jump checker run on it. |
| 182 | bool CurFunctionNeedsScopeChecking; |
| 183 | |
Nate Begeman | ce4d7fc | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 184 | /// ExtVectorDecls - This is a list all the extended vector types. This allows |
| 185 | /// us to associate a raw vector type with one of the ext_vector type names. |
Steve Naroff | ddf5a1d | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 186 | /// This is only necessary for issuing pretty diagnostics. |
Nate Begeman | ce4d7fc | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 187 | llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls; |
Steve Naroff | 8edb573 | 2008-09-28 14:55:53 +0000 | [diff] [blame] | 188 | |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 189 | /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes. |
| 190 | llvm::OwningPtr<CXXFieldCollector> FieldCollector; |
| 191 | |
Anders Carlsson | 576cc6f | 2009-03-22 20:18:17 +0000 | [diff] [blame] | 192 | typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy; |
| 193 | |
| 194 | /// PureVirtualClassDiagSet - a set of class declarations which we have |
| 195 | /// emitted a list of pure virtual functions. Used to prevent emitting the |
| 196 | /// same list more than once. |
| 197 | llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet; |
| 198 | |
Douglas Gregor | 5a80bd1 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 199 | /// \brief A mapping from external names to the most recent |
| 200 | /// locally-scoped external declaration with that name. |
| 201 | /// |
| 202 | /// This map contains external declarations introduced in local |
| 203 | /// scoped, e.g., |
| 204 | /// |
| 205 | /// \code |
| 206 | /// void f() { |
| 207 | /// void foo(int, int); |
| 208 | /// } |
| 209 | /// \endcode |
| 210 | /// |
| 211 | /// Here, the name "foo" will be associated with the declaration on |
| 212 | /// "foo" within f. This name is not visible outside of |
| 213 | /// "f". However, we still find it in two cases: |
| 214 | /// |
| 215 | /// - If we are declaring another external with the name "foo", we |
| 216 | /// can find "foo" as a previous declaration, so that the types |
| 217 | /// of this external declaration can be checked for |
| 218 | /// compatibility. |
| 219 | /// |
| 220 | /// - If we would implicitly declare "foo" (e.g., due to a call to |
| 221 | /// "foo" in C when no prototype or definition is visible), then |
| 222 | /// we find this declaration of "foo" and complain that it is |
| 223 | /// not visible. |
| 224 | llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls; |
| 225 | |
Douglas Gregor | beecd58 | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 226 | /// \brief The set of tentative declarations seen so far in this |
| 227 | /// translation unit for which no definition has been seen. |
| 228 | /// |
| 229 | /// The tentative declarations are indexed by the name of the |
| 230 | /// declaration, and only the most recent tentative declaration for |
| 231 | /// a given variable will be recorded here. |
| 232 | llvm::DenseMap<DeclarationName, VarDecl *> TentativeDefinitions; |
| 233 | |
Chris Lattner | c5c95b5 | 2008-04-11 07:00:53 +0000 | [diff] [blame] | 234 | IdentifierResolver IdResolver; |
| 235 | |
Steve Naroff | 93eb5f1 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 236 | /// Translation Unit Scope - useful to Objective-C actions that need |
| 237 | /// to lookup file scope declarations in the "ordinary" C decl namespace. |
| 238 | /// For example, user-defined classes, built-in "id" type, etc. |
Steve Naroff | c62adb6 | 2007-10-09 22:01:59 +0000 | [diff] [blame] | 239 | Scope *TUScope; |
Sebastian Redl | c470476 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 240 | |
| 241 | /// The C++ "std" namespace, where the standard library resides. Cached here |
| 242 | /// by GetStdNamespace |
| 243 | NamespaceDecl *StdNamespace; |
Sebastian Redl | faf6808 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 244 | |
| 245 | /// A flag to remember whether the implicit forms of operator new and delete |
| 246 | /// have been declared. |
| 247 | bool GlobalNewDeleteDeclared; |
Douglas Gregor | 54feb84 | 2009-04-14 16:27:31 +0000 | [diff] [blame] | 248 | |
Douglas Gregor | 0b6a624 | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 249 | /// The current expression evaluation context. |
| 250 | ExpressionEvaluationContext ExprEvalContext; |
| 251 | |
| 252 | typedef std::vector<std::pair<SourceLocation, Decl *> > |
| 253 | PotentiallyReferencedDecls; |
| 254 | |
| 255 | /// A stack of declarations, each element of which is a set of declarations |
| 256 | /// that will be marked as referenced if the corresponding potentially |
| 257 | /// potentially evaluated expression is potentially evaluated. Each element |
| 258 | /// in the stack corresponds to a PotentiallyPotentiallyEvaluated expression |
| 259 | /// evaluation context. |
| 260 | std::list<PotentiallyReferencedDecls> PotentiallyReferencedDeclStack; |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 261 | |
Douglas Gregor | 54feb84 | 2009-04-14 16:27:31 +0000 | [diff] [blame] | 262 | /// \brief Whether the code handled by Sema should be considered a |
| 263 | /// complete translation unit or not. |
| 264 | /// |
| 265 | /// When true (which is generally the case), Sema will perform |
| 266 | /// end-of-translation-unit semantic tasks (such as creating |
| 267 | /// initializers for tentative definitions in C) once parsing has |
| 268 | /// completed. This flag will be false when building PCH files, |
| 269 | /// since a PCH file is by definition not a complete translation |
| 270 | /// unit. |
| 271 | bool CompleteTranslationUnit; |
| 272 | |
Douglas Gregor | e141633 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 273 | /// \brief The number of SFINAE diagnostics that have been trapped. |
| 274 | unsigned NumSFINAEErrors; |
| 275 | |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 276 | typedef llvm::DenseMap<Selector, ObjCMethodList> MethodPool; |
| 277 | |
Steve Naroff | 5811baf | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 278 | /// Instance/Factory Method Pools - allows efficient lookup when typechecking |
| 279 | /// messages to "id". We need to maintain a list, since selectors can have |
| 280 | /// differing signatures across classes. In Cocoa, this happens to be |
| 281 | /// extremely uncommon (only 1% of selectors are "overloaded"). |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 282 | MethodPool InstanceMethodPool; |
| 283 | MethodPool FactoryMethodPool; |
Steve Naroff | 3f49fee | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 284 | |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 285 | MethodPool::iterator ReadMethodPool(Selector Sel, bool isInstance); |
| 286 | |
Steve Naroff | 3f49fee | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 287 | /// Private Helper predicate to check for 'self'. |
| 288 | bool isSelfExpr(Expr *RExpr); |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 289 | public: |
Douglas Gregor | 54feb84 | 2009-04-14 16:27:31 +0000 | [diff] [blame] | 290 | Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, |
| 291 | bool CompleteTranslationUnit = true); |
Chris Lattner | 31180bb | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 292 | ~Sema() { |
| 293 | if (PackContext) FreePackedContext(); |
| 294 | } |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 295 | |
Chris Lattner | 4da04a4e | 2009-01-22 19:21:44 +0000 | [diff] [blame] | 296 | const LangOptions &getLangOptions() const { return LangOpts; } |
Chris Lattner | bc495d7 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 297 | Diagnostic &getDiagnostics() const { return Diags; } |
| 298 | SourceManager &getSourceManager() const { return SourceMgr; } |
| 299 | |
Douglas Gregor | da17bd3 | 2009-03-20 22:48:49 +0000 | [diff] [blame] | 300 | /// \brief Helper class that creates diagnostics with optional |
| 301 | /// template instantiation stacks. |
| 302 | /// |
| 303 | /// This class provides a wrapper around the basic DiagnosticBuilder |
| 304 | /// class that emits diagnostics. SemaDiagnosticBuilder is |
| 305 | /// responsible for emitting the diagnostic (as DiagnosticBuilder |
| 306 | /// does) and, if the diagnostic comes from inside a template |
| 307 | /// instantiation, printing the template instantiation stack as |
| 308 | /// well. |
| 309 | class SemaDiagnosticBuilder : public DiagnosticBuilder { |
| 310 | Sema &SemaRef; |
| 311 | unsigned DiagID; |
| 312 | |
| 313 | public: |
| 314 | SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID) |
| 315 | : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { } |
| 316 | |
Douglas Gregor | 3383451 | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 317 | explicit SemaDiagnosticBuilder(Sema &SemaRef) |
| 318 | : DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { } |
| 319 | |
Douglas Gregor | da17bd3 | 2009-03-20 22:48:49 +0000 | [diff] [blame] | 320 | ~SemaDiagnosticBuilder(); |
| 321 | }; |
| 322 | |
| 323 | /// \brief Emit a diagnostic. |
| 324 | SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) { |
Douglas Gregor | 3383451 | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 325 | if (isSFINAEContext() && Diagnostic::isBuiltinSFINAEDiag(DiagID)) { |
| 326 | // If we encountered an error during template argument |
| 327 | // deduction, and that error is one of the SFINAE errors, |
Douglas Gregor | e141633 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 328 | // suppress the diagnostic. |
Douglas Gregor | 15e08d8 | 2009-06-15 16:52:15 +0000 | [diff] [blame] | 329 | ++NumSFINAEErrors; |
| 330 | return SemaDiagnosticBuilder(*this); |
Douglas Gregor | 3383451 | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 331 | } |
| 332 | |
Douglas Gregor | 4ea568f | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 333 | DiagnosticBuilder DB = Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID); |
Douglas Gregor | da17bd3 | 2009-03-20 22:48:49 +0000 | [diff] [blame] | 334 | return SemaDiagnosticBuilder(DB, *this, DiagID); |
Chris Lattner | bc495d7 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 335 | } |
Steve Naroff | 71ce2e0 | 2007-05-18 22:53:50 +0000 | [diff] [blame] | 336 | |
Chris Lattner | 57c523f | 2007-08-31 04:53:24 +0000 | [diff] [blame] | 337 | virtual void DeleteExpr(ExprTy *E); |
| 338 | virtual void DeleteStmt(StmtTy *S); |
| 339 | |
Sebastian Redl | c675bab | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 340 | OwningExprResult Owned(Expr* E) { return OwningExprResult(*this, E); } |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 341 | OwningExprResult Owned(ExprResult R) { |
Douglas Gregor | f829825 | 2009-01-26 22:44:13 +0000 | [diff] [blame] | 342 | if (R.isInvalid()) |
Steve Naroff | d512956 | 2009-01-21 22:32:33 +0000 | [diff] [blame] | 343 | return ExprError(); |
Douglas Gregor | f829825 | 2009-01-26 22:44:13 +0000 | [diff] [blame] | 344 | return OwningExprResult(*this, R.get()); |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 345 | } |
Sebastian Redl | c675bab | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 346 | OwningStmtResult Owned(Stmt* S) { return OwningStmtResult(*this, S); } |
| 347 | |
Chris Lattner | f440440 | 2008-08-23 03:19:52 +0000 | [diff] [blame] | 348 | virtual void ActOnEndOfTranslationUnit(); |
Sebastian Redl | b5d4935 | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 349 | |
Chris Lattner | 3318e86 | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 350 | /// getLabelMap() - Return the current label map. If we're in a block, we |
| 351 | /// return it. |
| 352 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> &getLabelMap() { |
| 353 | return CurBlock ? CurBlock->LabelMap : FunctionLabelMap; |
| 354 | } |
| 355 | |
Chris Lattner | 96b3139 | 2009-04-18 20:10:59 +0000 | [diff] [blame] | 356 | /// getSwitchStack - This is returns the switch stack for the current block or |
| 357 | /// function. |
| 358 | llvm::SmallVector<SwitchStmt*,8> &getSwitchStack() { |
| 359 | return CurBlock ? CurBlock->SwitchStack : FunctionSwitchStack; |
| 360 | } |
| 361 | |
Douglas Gregor | c6d5edd | 2009-07-02 17:08:52 +0000 | [diff] [blame] | 362 | virtual void ActOnComment(SourceRange Comment); |
| 363 | |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 364 | //===--------------------------------------------------------------------===// |
Chris Lattner | f84a79c | 2006-11-11 22:59:23 +0000 | [diff] [blame] | 365 | // Type Analysis / Processing: SemaType.cpp. |
| 366 | // |
Douglas Gregor | f4f296d | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 367 | QualType adjustParameterType(QualType T); |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 368 | QualType ConvertDeclSpecToType(const DeclSpec &DS, SourceLocation DeclLoc, |
| 369 | bool &IsInvalid); |
Chris Lattner | a7e619c | 2008-06-29 00:50:08 +0000 | [diff] [blame] | 370 | void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL); |
Douglas Gregor | 17c0d7b | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 371 | QualType BuildPointerType(QualType T, unsigned Quals, |
| 372 | SourceLocation Loc, DeclarationName Entity); |
Sebastian Redl | 0f8b23f | 2009-03-16 23:22:08 +0000 | [diff] [blame] | 373 | QualType BuildReferenceType(QualType T, bool LValueRef, unsigned Quals, |
Douglas Gregor | 17c0d7b | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 374 | SourceLocation Loc, DeclarationName Entity); |
| 375 | QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, |
| 376 | Expr *ArraySize, unsigned Quals, |
Douglas Gregor | 0431825 | 2009-07-06 15:59:29 +0000 | [diff] [blame] | 377 | SourceRange Brackets, DeclarationName Entity); |
Douglas Gregor | 758a869 | 2009-06-17 21:51:59 +0000 | [diff] [blame] | 378 | QualType BuildExtVectorType(QualType T, ExprArg ArraySize, |
| 379 | SourceLocation AttrLoc); |
Douglas Gregor | 6eaaf30 | 2009-02-28 01:04:19 +0000 | [diff] [blame] | 380 | QualType BuildFunctionType(QualType T, |
| 381 | QualType *ParamTypes, unsigned NumParamTypes, |
| 382 | bool Variadic, unsigned Quals, |
| 383 | SourceLocation Loc, DeclarationName Entity); |
Douglas Gregor | 0bdc1f5 | 2009-06-09 22:17:39 +0000 | [diff] [blame] | 384 | QualType BuildMemberPointerType(QualType T, QualType Class, |
| 385 | unsigned Quals, SourceLocation Loc, |
| 386 | DeclarationName Entity); |
Anders Carlsson | 15f1dd1 | 2009-06-12 22:56:54 +0000 | [diff] [blame] | 387 | QualType BuildBlockPointerType(QualType T, unsigned Quals, |
| 388 | SourceLocation Loc, DeclarationName Entity); |
Douglas Gregor | d6ab874 | 2009-05-28 23:31:59 +0000 | [diff] [blame] | 389 | QualType GetTypeForDeclarator(Declarator &D, Scope *S, unsigned Skip = 0, |
| 390 | TagDecl **OwnedDecl = 0); |
Douglas Gregor | 92751d4 | 2008-11-17 22:58:34 +0000 | [diff] [blame] | 391 | DeclarationName GetNameForDeclarator(Declarator &D); |
Sebastian Redl | d643456 | 2009-05-29 18:02:33 +0000 | [diff] [blame] | 392 | bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range); |
Sebastian Redl | 10b9de4 | 2009-05-29 15:01:05 +0000 | [diff] [blame] | 393 | bool CheckDistantExceptionSpec(QualType T); |
Sebastian Redl | 4f4d7b5 | 2009-07-04 11:39:00 +0000 | [diff] [blame] | 394 | bool CheckEquivalentExceptionSpec( |
| 395 | const FunctionProtoType *Old, SourceLocation OldLoc, |
| 396 | const FunctionProtoType *New, SourceLocation NewLoc); |
Sebastian Redl | 86be854 | 2009-07-07 20:29:57 +0000 | [diff] [blame] | 397 | bool CheckExceptionSpecSubset(unsigned DiagID, unsigned NoteID, |
| 398 | const FunctionProtoType *Superset, SourceLocation SuperLoc, |
| 399 | const FunctionProtoType *Subset, SourceLocation SubLoc); |
Douglas Gregor | 92751d4 | 2008-11-17 22:58:34 +0000 | [diff] [blame] | 400 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 401 | QualType ObjCGetTypeForMethodDefinition(DeclPtrTy D); |
Fariborz Jahanian | 56ff146 | 2007-11-08 23:49:49 +0000 | [diff] [blame] | 402 | |
Douglas Gregor | e1eb9d8 | 2008-10-22 14:17:15 +0000 | [diff] [blame] | 403 | bool UnwrapSimilarPointerTypes(QualType& T1, QualType& T2); |
| 404 | |
Sebastian Redl | 351bb78 | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 405 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D); |
Sebastian Redl | 842ef52 | 2008-11-08 13:00:26 +0000 | [diff] [blame] | 406 | |
Douglas Gregor | ed0cfbd | 2009-03-09 16:13:40 +0000 | [diff] [blame] | 407 | bool RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, |
Douglas Gregor | dd430f7 | 2009-01-19 19:26:10 +0000 | [diff] [blame] | 408 | SourceRange Range1 = SourceRange(), |
| 409 | SourceRange Range2 = SourceRange(), |
| 410 | QualType PrintType = QualType()); |
| 411 | |
Douglas Gregor | e177b72 | 2009-03-19 00:39:20 +0000 | [diff] [blame] | 412 | QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T); |
| 413 | |
Anders Carlsson | 074a18a | 2009-06-29 22:58:55 +0000 | [diff] [blame] | 414 | QualType BuildTypeofExprType(Expr *E); |
| 415 | QualType BuildDecltypeType(Expr *E); |
| 416 | |
Chris Lattner | f84a79c | 2006-11-11 22:59:23 +0000 | [diff] [blame] | 417 | //===--------------------------------------------------------------------===// |
Chris Lattner | e168f76 | 2006-11-10 05:29:30 +0000 | [diff] [blame] | 418 | // Symbol table / Decl tracking callbacks: SemaDecl.cpp. |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 419 | // |
Chris Lattner | 03b5394 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 420 | |
| 421 | /// getDeclName - Return a pretty name for the specified decl if possible, or |
| 422 | /// an empty string if not. This is used for pretty crash reporting. |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 423 | virtual std::string getDeclName(DeclPtrTy D); |
Chris Lattner | 03b5394 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 424 | |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 425 | DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr); |
| 426 | |
Douglas Gregor | 9817f4a | 2009-02-09 15:09:02 +0000 | [diff] [blame] | 427 | virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc, |
Douglas Gregor | 8a6be5e | 2009-02-04 17:00:24 +0000 | [diff] [blame] | 428 | Scope *S, const CXXScopeSpec *SS); |
Chris Lattner | ffaa0e6 | 2009-04-12 21:49:30 +0000 | [diff] [blame] | 429 | virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S); |
| 430 | |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 431 | virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) { |
Douglas Gregor | b52fabb | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 432 | return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false); |
Douglas Gregor | ad59050 | 2008-12-15 23:53:10 +0000 | [diff] [blame] | 433 | } |
Douglas Gregor | b52fabb | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 434 | |
| 435 | DeclPtrTy HandleDeclarator(Scope *S, Declarator &D, |
| 436 | MultiTemplateParamsArg TemplateParameterLists, |
| 437 | bool IsFunctionDefinition); |
Douglas Gregor | 5a80bd1 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 438 | void RegisterLocallyScopedExternCDecl(NamedDecl *ND, NamedDecl *PrevDecl, |
| 439 | Scope *S); |
Eli Friedman | 574c745 | 2009-04-07 19:37:57 +0000 | [diff] [blame] | 440 | void DiagnoseFunctionSpecifiers(Declarator& D); |
Douglas Gregor | 6e6ad60 | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 441 | NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 442 | QualType R, Decl* PrevDecl, |
Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 443 | bool &Redeclaration); |
Douglas Gregor | 6e6ad60 | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 444 | NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 445 | QualType R, NamedDecl* PrevDecl, |
Douglas Gregor | b09f3d8 | 2009-07-22 17:18:37 +0000 | [diff] [blame] | 446 | MultiTemplateParamsArg TemplateParamLists, |
Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 447 | bool &Redeclaration); |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 448 | void CheckVariableDeclaration(VarDecl *NewVD, NamedDecl *PrevDecl, |
Douglas Gregor | ef1a09a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 449 | bool &Redeclaration); |
Douglas Gregor | 6e6ad60 | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 450 | NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 451 | QualType R, NamedDecl* PrevDecl, |
Douglas Gregor | b52fabb | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 452 | MultiTemplateParamsArg TemplateParamLists, |
Douglas Gregor | e62c0a4 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 453 | bool IsFunctionDefinition, |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 454 | bool &Redeclaration); |
| 455 | void CheckFunctionDeclaration(FunctionDecl *NewFD, NamedDecl *&PrevDecl, |
Douglas Gregor | f4f296d | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 456 | bool &Redeclaration, |
| 457 | bool &OverloadableAttrRequired); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 458 | virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D); |
| 459 | virtual void ActOnParamDefaultArgument(DeclPtrTy param, |
Chris Lattner | aa9c7ae | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 460 | SourceLocation EqualLoc, |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 461 | ExprArg defarg); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 462 | virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, |
Anders Carlsson | 84613c4 | 2009-06-12 16:51:40 +0000 | [diff] [blame] | 463 | SourceLocation EqualLoc, |
| 464 | SourceLocation ArgLoc); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 465 | virtual void ActOnParamDefaultArgumentError(DeclPtrTy param); |
Anders Carlsson | 84613c4 | 2009-06-12 16:51:40 +0000 | [diff] [blame] | 466 | |
| 467 | // Contains the locations of the beginning of unparsed default |
| 468 | // argument locations. |
| 469 | llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs; |
| 470 | |
Anders Carlsson | 5e9444f | 2009-05-30 21:37:25 +0000 | [diff] [blame] | 471 | virtual void AddInitializerToDecl(DeclPtrTy dcl, FullExprArg init); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 472 | void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit); |
Anders Carlsson | ae01993 | 2009-07-11 00:34:39 +0000 | [diff] [blame] | 473 | void ActOnUninitializedDecl(DeclPtrTy dcl, bool TypeContainsUndeducedAuto); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 474 | virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc); |
Eli Friedman | 55b9ecb | 2009-05-29 01:49:24 +0000 | [diff] [blame] | 475 | virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, |
| 476 | DeclPtrTy *Group, |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 477 | unsigned NumDecls); |
Douglas Gregor | 170512f | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 478 | virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, |
| 479 | SourceLocation LocAfterDecls); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 480 | virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, Declarator &D); |
| 481 | virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, DeclPtrTy D); |
| 482 | virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclPtrTy D); |
Sebastian Redl | b5d4935 | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 483 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 484 | virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body); |
Douglas Gregor | 67da0d9 | 2009-05-15 17:59:04 +0000 | [diff] [blame] | 485 | DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body, |
| 486 | bool IsInstantiation); |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 487 | |
| 488 | /// \brief Diagnose any unused parameters in the given sequence of |
| 489 | /// ParmVarDecl pointers. |
| 490 | template<typename InputIterator> |
| 491 | void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) { |
| 492 | for (; Param != ParamEnd; ++Param) { |
| 493 | if (!(*Param)->isUsed() && (*Param)->getDeclName() && |
Argyrios Kyrtzidis | b4b64ca | 2009-06-30 02:34:44 +0000 | [diff] [blame] | 494 | !(*Param)->template hasAttr<UnusedAttr>()) |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 495 | Diag((*Param)->getLocation(), diag::warn_unused_parameter) |
| 496 | << (*Param)->getDeclName(); |
| 497 | } |
| 498 | } |
| 499 | |
Chris Lattner | 1a1fdbd | 2009-04-19 04:46:21 +0000 | [diff] [blame] | 500 | void DiagnoseInvalidJumps(Stmt *Body); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 501 | virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr); |
Anders Carlsson | 5c6c059 | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 502 | |
Steve Naroff | c62adb6 | 2007-10-09 22:01:59 +0000 | [diff] [blame] | 503 | /// Scope actions. |
| 504 | virtual void ActOnPopScope(SourceLocation Loc, Scope *S); |
| 505 | virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S); |
Chris Lattner | 01564d9 | 2007-01-27 19:27:06 +0000 | [diff] [blame] | 506 | |
Chris Lattner | 200bdc3 | 2006-11-19 02:43:37 +0000 | [diff] [blame] | 507 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 508 | /// no declarator (e.g. "struct foo;") is parsed. |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 509 | virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS); |
Chris Lattner | 200bdc3 | 2006-11-19 02:43:37 +0000 | [diff] [blame] | 510 | |
Douglas Gregor | 9ac7a07 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 511 | bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, |
| 512 | RecordDecl *AnonRecord); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 513 | virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, |
| 514 | RecordDecl *Record); |
Douglas Gregor | 9ac7a07 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 515 | |
Douglas Gregor | d9034f0 | 2009-05-14 16:41:31 +0000 | [diff] [blame] | 516 | bool isAcceptableTagRedeclaration(const TagDecl *Previous, |
| 517 | TagDecl::TagKind NewTag, |
| 518 | SourceLocation NewTagLoc, |
| 519 | const IdentifierInfo &Name); |
Douglas Gregor | f9aa526 | 2009-05-03 17:18:57 +0000 | [diff] [blame] | 520 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 521 | virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagKind TK, |
| 522 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 523 | IdentifierInfo *Name, SourceLocation NameLoc, |
Douglas Gregor | d6ab874 | 2009-05-28 23:31:59 +0000 | [diff] [blame] | 524 | AttributeList *Attr, AccessSpecifier AS, |
Douglas Gregor | e93e46c | 2009-07-22 23:48:44 +0000 | [diff] [blame] | 525 | MultiTemplateParamsArg TemplateParameterLists, |
Douglas Gregor | d6ab874 | 2009-05-28 23:31:59 +0000 | [diff] [blame] | 526 | bool &OwnedDecl); |
Ted Kremenek | 2147570 | 2008-09-05 17:16:31 +0000 | [diff] [blame] | 527 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 528 | virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart, |
Chris Lattner | 2cc35ae | 2008-08-23 02:00:52 +0000 | [diff] [blame] | 529 | IdentifierInfo *ClassName, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 530 | llvm::SmallVectorImpl<DeclPtrTy> &Decls); |
| 531 | virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD, |
| 532 | SourceLocation DeclStart, |
| 533 | Declarator &D, ExprTy *BitfieldWidth); |
Chris Lattner | 73bf7b4 | 2009-03-05 22:45:59 +0000 | [diff] [blame] | 534 | |
| 535 | FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, |
Douglas Gregor | 4261e4c | 2009-03-11 20:50:30 +0000 | [diff] [blame] | 536 | Declarator &D, Expr *BitfieldWidth, |
| 537 | AccessSpecifier AS); |
Chris Lattner | 73bf7b4 | 2009-03-05 22:45:59 +0000 | [diff] [blame] | 538 | |
Douglas Gregor | 1efa437 | 2009-03-11 18:59:21 +0000 | [diff] [blame] | 539 | FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, |
| 540 | RecordDecl *Record, SourceLocation Loc, |
| 541 | bool Mutable, Expr *BitfieldWidth, |
Steve Naroff | 5ec6ff7 | 2009-07-14 14:58:18 +0000 | [diff] [blame] | 542 | SourceLocation TSSL, |
Douglas Gregor | 4261e4c | 2009-03-11 20:50:30 +0000 | [diff] [blame] | 543 | AccessSpecifier AS, NamedDecl *PrevDecl, |
Douglas Gregor | 1efa437 | 2009-03-11 18:59:21 +0000 | [diff] [blame] | 544 | Declarator *D = 0); |
Douglas Gregor | 8a27391 | 2009-07-22 18:25:24 +0000 | [diff] [blame] | 545 | |
| 546 | enum CXXSpecialMember { |
| 547 | CXXDefaultConstructor = 0, |
| 548 | CXXCopyConstructor = 1, |
| 549 | CXXCopyAssignment = 2, |
| 550 | CXXDestructor = 3 |
| 551 | }; |
| 552 | void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem); |
Fariborz Jahanian | de61583 | 2008-04-10 23:32:45 +0000 | [diff] [blame] | 553 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 554 | virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart, |
Fariborz Jahanian | 6845383 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 555 | DeclPtrTy IntfDecl, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 556 | Declarator &D, ExprTy *BitfieldWidth, |
| 557 | tok::ObjCKeywordKind visibility); |
Fariborz Jahanian | de61583 | 2008-04-10 23:32:45 +0000 | [diff] [blame] | 558 | |
Steve Naroff | 2e688fd | 2007-09-14 23:09:53 +0000 | [diff] [blame] | 559 | // This is used for both record definitions and ObjC interface declarations. |
Fariborz Jahanian | 343f709 | 2007-09-29 00:54:24 +0000 | [diff] [blame] | 560 | virtual void ActOnFields(Scope* S, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 561 | SourceLocation RecLoc, DeclPtrTy TagDecl, |
| 562 | DeclPtrTy *Fields, unsigned NumFields, |
Daniel Dunbar | 15619c7 | 2008-10-03 02:03:53 +0000 | [diff] [blame] | 563 | SourceLocation LBrac, SourceLocation RBrac, |
| 564 | AttributeList *AttrList); |
Douglas Gregor | 82ac25e | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 565 | |
| 566 | /// ActOnTagStartDefinition - Invoked when we have entered the |
| 567 | /// scope of a tag's definition (e.g., for an enumeration, class, |
| 568 | /// struct, or union). |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 569 | virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl); |
Douglas Gregor | 82ac25e | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 570 | |
| 571 | /// ActOnTagFinishDefinition - Invoked once we have finished parsing |
| 572 | /// the definition of a tag (enumeration, class, struct, or union). |
Argyrios Kyrtzidis | 23e1f1d | 2009-07-14 03:17:52 +0000 | [diff] [blame] | 573 | virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl, |
| 574 | SourceLocation RBraceLoc); |
Douglas Gregor | 82ac25e | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 575 | |
Douglas Gregor | 954f6b27 | 2009-03-17 19:05:46 +0000 | [diff] [blame] | 576 | EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum, |
| 577 | EnumConstantDecl *LastEnumConst, |
| 578 | SourceLocation IdLoc, |
| 579 | IdentifierInfo *Id, |
| 580 | ExprArg val); |
| 581 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 582 | virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl, |
| 583 | DeclPtrTy LastEnumConstant, |
| 584 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 585 | SourceLocation EqualLoc, ExprTy *Val); |
Mike Stump | 6814d1c | 2009-05-16 07:06:02 +0000 | [diff] [blame] | 586 | virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, |
| 587 | SourceLocation RBraceLoc, DeclPtrTy EnumDecl, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 588 | DeclPtrTy *Elements, unsigned NumElements); |
Sebastian Redl | 842ef52 | 2008-11-08 13:00:26 +0000 | [diff] [blame] | 589 | |
Argyrios Kyrtzidis | 16ac9be | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 590 | DeclContext *getContainingDC(DeclContext *DC); |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 591 | |
Chris Lattner | c5ffed4 | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 592 | /// Set the current declaration context until it gets popped. |
Douglas Gregor | 91f8421 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 593 | void PushDeclContext(Scope *S, DeclContext *DC); |
Chris Lattner | 0a5ff0d | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 594 | void PopDeclContext(); |
Argyrios Kyrtzidis | 853fbea | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 595 | |
Argyrios Kyrtzidis | 7bcce49 | 2009-06-17 23:15:40 +0000 | [diff] [blame] | 596 | /// EnterDeclaratorContext - Used when we must lookup names in the context |
| 597 | /// of a declarator's nested name specifier. |
| 598 | void EnterDeclaratorContext(Scope *S, DeclContext *DC); |
| 599 | void ExitDeclaratorContext(Scope *S); |
| 600 | |
| 601 | |
Chris Lattner | 7941395 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 602 | /// getCurFunctionDecl - If inside of a function body, this returns a pointer |
| 603 | /// to the function decl for the function being parsed. If we're currently |
| 604 | /// in a 'block', this returns the containing context. |
| 605 | FunctionDecl *getCurFunctionDecl(); |
| 606 | |
| 607 | /// getCurMethodDecl - If inside of a method body, this returns a pointer to |
| 608 | /// the method decl for the method being parsed. If we're currently |
| 609 | /// in a 'block', this returns the containing context. |
Daniel Dunbar | 6e8aa53 | 2008-08-11 05:35:13 +0000 | [diff] [blame] | 610 | ObjCMethodDecl *getCurMethodDecl(); |
Chris Lattner | c5ffed4 | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 611 | |
Chris Lattner | 7941395 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 612 | /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method |
| 613 | /// or C function we're in, otherwise return null. If we're currently |
| 614 | /// in a 'block', this returns the containing context. |
| 615 | NamedDecl *getCurFunctionOrMethodDecl(); |
| 616 | |
Argyrios Kyrtzidis | b8a4920 | 2008-04-12 00:47:19 +0000 | [diff] [blame] | 617 | /// Add this decl to the scope shadowed decl chains. |
| 618 | void PushOnScopeChains(NamedDecl *D, Scope *S); |
| 619 | |
Argyrios Kyrtzidis | 5b144d5 | 2008-09-09 21:18:04 +0000 | [diff] [blame] | 620 | /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true |
| 621 | /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns |
| 622 | /// true if 'D' belongs to the given declaration context. |
| 623 | bool isDeclInScope(Decl *D, DeclContext *Ctx, Scope *S = 0) { |
Douglas Gregor | 91f8421 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 624 | return IdResolver.isDeclInScope(D, Ctx, Context, S); |
Argyrios Kyrtzidis | 5b144d5 | 2008-09-09 21:18:04 +0000 | [diff] [blame] | 625 | } |
| 626 | |
Eli Friedman | f69d09b | 2009-02-28 05:41:13 +0000 | [diff] [blame] | 627 | |
Chris Lattner | efedd9e | 2008-02-21 01:07:18 +0000 | [diff] [blame] | 628 | /// Subroutines of ActOnDeclarator(). |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 629 | TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T); |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 630 | void MergeTypeDefDecl(TypedefDecl *New, Decl *Old); |
Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 631 | bool MergeFunctionDecl(FunctionDecl *New, Decl *Old); |
Douglas Gregor | e62c0a4 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 632 | bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old); |
Chris Lattner | f6d1c9c | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 633 | void MergeVarDecl(VarDecl *New, Decl *Old); |
Douglas Gregor | 75a45ba | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 634 | bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old); |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 635 | |
| 636 | /// C++ Overloading. |
| 637 | bool IsOverload(FunctionDecl *New, Decl* OldD, |
| 638 | OverloadedFunctionDecl::function_iterator &MatchedDecl); |
Douglas Gregor | 2fe9883 | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 639 | ImplicitConversionSequence |
| 640 | TryImplicitConversion(Expr* From, QualType ToType, |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 641 | bool SuppressUserConversions = false, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 642 | bool AllowExplicit = false, |
| 643 | bool ForceRValue = false); |
Douglas Gregor | 26bee0b | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 644 | bool IsStandardConversion(Expr *From, QualType ToType, |
| 645 | StandardConversionSequence& SCS); |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 646 | bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType); |
| 647 | bool IsFloatingPointPromotion(QualType FromType, QualType ToType); |
Douglas Gregor | 78ca74d | 2009-02-12 00:15:05 +0000 | [diff] [blame] | 648 | bool IsComplexPromotion(QualType FromType, QualType ToType); |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 649 | bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, |
Douglas Gregor | 47d3f27 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 650 | QualType& ConvertedType, bool &IncompatibleObjC); |
Douglas Gregor | a119f10 | 2008-12-19 19:13:09 +0000 | [diff] [blame] | 651 | bool isObjCPointerConversion(QualType FromType, QualType ToType, |
| 652 | QualType& ConvertedType, bool &IncompatibleObjC); |
Douglas Gregor | 39c16d4 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 653 | bool CheckPointerConversion(Expr *From, QualType ToType); |
Sebastian Redl | 72b597d | 2009-01-25 19:43:20 +0000 | [diff] [blame] | 654 | bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, |
| 655 | QualType &ConvertedType); |
| 656 | bool CheckMemberPointerConversion(Expr *From, QualType ToType); |
Douglas Gregor | 9a65793 | 2008-10-21 23:43:52 +0000 | [diff] [blame] | 657 | bool IsQualificationConversion(QualType FromType, QualType ToType); |
Douglas Gregor | 26bee0b | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 658 | bool IsUserDefinedConversion(Expr *From, QualType ToType, |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 659 | UserDefinedConversionSequence& User, |
Douglas Gregor | 576e98c | 2009-01-30 23:27:23 +0000 | [diff] [blame] | 660 | bool AllowConversionFunctions, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 661 | bool AllowExplicit, bool ForceRValue); |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 662 | |
| 663 | ImplicitConversionSequence::CompareKind |
| 664 | CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1, |
| 665 | const ImplicitConversionSequence& ICS2); |
| 666 | |
| 667 | ImplicitConversionSequence::CompareKind |
| 668 | CompareStandardConversionSequences(const StandardConversionSequence& SCS1, |
| 669 | const StandardConversionSequence& SCS2); |
| 670 | |
Douglas Gregor | e1eb9d8 | 2008-10-22 14:17:15 +0000 | [diff] [blame] | 671 | ImplicitConversionSequence::CompareKind |
| 672 | CompareQualificationConversions(const StandardConversionSequence& SCS1, |
| 673 | const StandardConversionSequence& SCS2); |
| 674 | |
Douglas Gregor | 5c407d9 | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 675 | ImplicitConversionSequence::CompareKind |
| 676 | CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1, |
| 677 | const StandardConversionSequence& SCS2); |
| 678 | |
Douglas Gregor | 2fe9883 | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 679 | ImplicitConversionSequence |
| 680 | TryCopyInitialization(Expr* From, QualType ToType, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 681 | bool SuppressUserConversions = false, |
| 682 | bool ForceRValue = false); |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 683 | bool PerformCopyInitialization(Expr *&From, QualType ToType, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 684 | const char *Flavor, bool Elidable = false); |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 685 | |
Douglas Gregor | 436424c | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 686 | ImplicitConversionSequence |
| 687 | TryObjectArgumentInitialization(Expr *From, CXXMethodDecl *Method); |
| 688 | bool PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method); |
| 689 | |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 690 | ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From); |
| 691 | bool PerformContextuallyConvertToBool(Expr *&From); |
| 692 | |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 693 | /// OverloadingResult - Capture the result of performing overload |
| 694 | /// resolution. |
| 695 | enum OverloadingResult { |
| 696 | OR_Success, ///< Overload resolution succeeded. |
| 697 | OR_No_Viable_Function, ///< No viable function found. |
Douglas Gregor | 171c45a | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 698 | OR_Ambiguous, ///< Ambiguous candidates found. |
| 699 | OR_Deleted ///< Overload resoltuion refers to a deleted function. |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 700 | }; |
| 701 | |
Douglas Gregor | 15448f8 | 2009-06-27 21:05:07 +0000 | [diff] [blame] | 702 | typedef llvm::SmallPtrSet<AnyFunctionDecl, 16> FunctionSet; |
Douglas Gregor | 1baf54e | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 703 | typedef llvm::SmallPtrSet<NamespaceDecl *, 16> AssociatedNamespaceSet; |
| 704 | typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet; |
| 705 | |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 706 | void AddOverloadCandidate(FunctionDecl *Function, |
| 707 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 2fe9883 | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 708 | OverloadCandidateSet& CandidateSet, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 709 | bool SuppressUserConversions = false, |
| 710 | bool ForceRValue = false); |
Douglas Gregor | 1baf54e | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 711 | void AddFunctionCandidates(const FunctionSet &Functions, |
| 712 | Expr **Args, unsigned NumArgs, |
| 713 | OverloadCandidateSet& CandidateSet, |
| 714 | bool SuppressUserConversions = false); |
Douglas Gregor | 436424c | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 715 | void AddMethodCandidate(CXXMethodDecl *Method, |
| 716 | Expr *Object, Expr **Args, unsigned NumArgs, |
| 717 | OverloadCandidateSet& CandidateSet, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 718 | bool SuppressUserConversions = false, |
| 719 | bool ForceRValue = false); |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 720 | void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, |
Douglas Gregor | 89026b5 | 2009-06-30 23:57:56 +0000 | [diff] [blame] | 721 | bool HasExplicitTemplateArgs, |
| 722 | const TemplateArgument *ExplicitTemplateArgs, |
| 723 | unsigned NumExplicitTemplateArgs, |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 724 | Expr **Args, unsigned NumArgs, |
| 725 | OverloadCandidateSet& CandidateSet, |
| 726 | bool SuppressUserConversions = false, |
| 727 | bool ForceRValue = false); |
Douglas Gregor | a1f013e | 2008-11-07 22:36:19 +0000 | [diff] [blame] | 728 | void AddConversionCandidate(CXXConversionDecl *Conversion, |
| 729 | Expr *From, QualType ToType, |
| 730 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | ab7897a | 2008-11-19 22:57:39 +0000 | [diff] [blame] | 731 | void AddSurrogateCandidate(CXXConversionDecl *Conversion, |
Douglas Gregor | deaad8c | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 732 | const FunctionProtoType *Proto, |
Douglas Gregor | ab7897a | 2008-11-19 22:57:39 +0000 | [diff] [blame] | 733 | Expr *Object, Expr **Args, unsigned NumArgs, |
| 734 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | 1baf54e | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 735 | void AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S, |
Douglas Gregor | 94eabf3 | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 736 | SourceLocation OpLoc, |
Douglas Gregor | 436424c | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 737 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 94eabf3 | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 738 | OverloadCandidateSet& CandidateSet, |
| 739 | SourceRange OpRange = SourceRange()); |
Douglas Gregor | 1baf54e | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 740 | void AddMemberOperatorCandidates(OverloadedOperatorKind Op, |
| 741 | SourceLocation OpLoc, |
| 742 | Expr **Args, unsigned NumArgs, |
| 743 | OverloadCandidateSet& CandidateSet, |
| 744 | SourceRange OpRange = SourceRange()); |
Douglas Gregor | a11693b | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 745 | void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, |
| 746 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | c5e6107 | 2009-01-13 00:52:54 +0000 | [diff] [blame] | 747 | OverloadCandidateSet& CandidateSet, |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 748 | bool IsAssignmentOperator = false, |
| 749 | unsigned NumContextualBoolArguments = 0); |
Douglas Gregor | d08452f | 2008-11-19 15:42:04 +0000 | [diff] [blame] | 750 | void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, |
| 751 | Expr **Args, unsigned NumArgs, |
| 752 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | e254f90 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 753 | void AddArgumentDependentLookupCandidates(DeclarationName Name, |
| 754 | Expr **Args, unsigned NumArgs, |
| 755 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 756 | bool isBetterOverloadCandidate(const OverloadCandidate& Cand1, |
| 757 | const OverloadCandidate& Cand2); |
| 758 | OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet, |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 759 | SourceLocation Loc, |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 760 | OverloadCandidateSet::iterator& Best); |
| 761 | void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet, |
| 762 | bool OnlyViable); |
| 763 | |
Douglas Gregor | cd695e5 | 2008-11-10 20:40:00 +0000 | [diff] [blame] | 764 | FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, |
| 765 | bool Complain); |
| 766 | void FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn); |
| 767 | |
Douglas Gregor | b8a9a41 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 768 | FunctionDecl *ResolveOverloadedCallFn(Expr *Fn, NamedDecl *Callee, |
| 769 | DeclarationName UnqualifiedName, |
Douglas Gregor | 89026b5 | 2009-06-30 23:57:56 +0000 | [diff] [blame] | 770 | bool HasExplicitTemplateArgs, |
| 771 | const TemplateArgument *ExplicitTemplateArgs, |
| 772 | unsigned NumExplicitTemplateArgs, |
Douglas Gregor | a60a691 | 2008-11-26 06:01:48 +0000 | [diff] [blame] | 773 | SourceLocation LParenLoc, |
| 774 | Expr **Args, unsigned NumArgs, |
| 775 | SourceLocation *CommaLocs, |
Douglas Gregor | e254f90 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 776 | SourceLocation RParenLoc, |
Douglas Gregor | b8a9a41 | 2009-02-04 15:01:18 +0000 | [diff] [blame] | 777 | bool &ArgumentDependentLookup); |
Douglas Gregor | 1baf54e | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 778 | |
Douglas Gregor | 084d855 | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 779 | OwningExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, |
| 780 | unsigned Opc, |
| 781 | FunctionSet &Functions, |
| 782 | ExprArg input); |
| 783 | |
Douglas Gregor | 1baf54e | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 784 | OwningExprResult CreateOverloadedBinOp(SourceLocation OpLoc, |
| 785 | unsigned Opc, |
| 786 | FunctionSet &Functions, |
| 787 | Expr *LHS, Expr *RHS); |
| 788 | |
Douglas Gregor | 97fd6e2 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 789 | ExprResult |
| 790 | BuildCallToMemberFunction(Scope *S, Expr *MemExpr, |
| 791 | SourceLocation LParenLoc, Expr **Args, |
| 792 | unsigned NumArgs, SourceLocation *CommaLocs, |
| 793 | SourceLocation RParenLoc); |
Douglas Gregor | 91cea0a | 2008-11-19 21:05:33 +0000 | [diff] [blame] | 794 | ExprResult |
Douglas Gregor | b0846b0 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 795 | BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, |
Douglas Gregor | 91cea0a | 2008-11-19 21:05:33 +0000 | [diff] [blame] | 796 | Expr **Args, unsigned NumArgs, |
| 797 | SourceLocation *CommaLocs, |
| 798 | SourceLocation RParenLoc); |
Douglas Gregor | 5251f1b | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 799 | |
Douglas Gregor | 55297ac | 2008-12-23 00:26:44 +0000 | [diff] [blame] | 800 | ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, |
Douglas Gregor | e0e79bd | 2008-11-20 16:27:02 +0000 | [diff] [blame] | 801 | SourceLocation MemberLoc, |
| 802 | IdentifierInfo &Member); |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 803 | |
Mike Stump | 33979f7 | 2009-07-22 23:56:57 +0000 | [diff] [blame^] | 804 | /// Helpers for dealing with functions. |
| 805 | void CheckFallThroughForFunctionDef(Decl *D, Stmt *Body); |
Chris Lattner | aa9c7ae | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 806 | bool CheckParmsForFunctionDef(FunctionDecl *FD); |
Chris Lattner | aa9c7ae | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 807 | void CheckCXXDefaultArguments(FunctionDecl *FD); |
Douglas Gregor | caa8ace | 2008-05-07 04:49:29 +0000 | [diff] [blame] | 808 | void CheckExtraCXXDefaultArguments(Declarator &D); |
Mike Stump | 33979f7 | 2009-07-22 23:56:57 +0000 | [diff] [blame^] | 809 | enum ControlFlowKind { NeverFallThrough = 0, MaybeFallThrough = 1, |
| 810 | AlwaysFallThrough = 2 }; |
| 811 | ControlFlowKind CheckFallThrough(Stmt *); |
Steve Naroff | 6fbf0dc | 2007-03-16 00:33:25 +0000 | [diff] [blame] | 812 | |
Douglas Gregor | 45a33ec | 2009-01-12 18:45:55 +0000 | [diff] [blame] | 813 | Scope *getNonFieldDeclScope(Scope *S); |
| 814 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 815 | /// \name Name lookup |
| 816 | /// |
| 817 | /// These routines provide name lookup that is used during semantic |
| 818 | /// analysis to resolve the various kinds of names (identifiers, |
| 819 | /// overloaded operator names, constructor names, etc.) into zero or |
| 820 | /// more declarations within a particular scope. The major entry |
| 821 | /// points are LookupName, which performs unqualified name lookup, |
| 822 | /// and LookupQualifiedName, which performs qualified name lookup. |
| 823 | /// |
| 824 | /// All name lookup is performed based on some specific criteria, |
| 825 | /// which specify what names will be visible to name lookup and how |
| 826 | /// far name lookup should work. These criteria are important both |
| 827 | /// for capturing language semantics (certain lookups will ignore |
| 828 | /// certain names, for example) and for performance, since name |
| 829 | /// lookup is often a bottleneck in the compilation of C++. Name |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 830 | /// lookup criteria is specified via the LookupCriteria enumeration. |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 831 | /// |
| 832 | /// The results of name lookup can vary based on the kind of name |
| 833 | /// lookup performed, the current language, and the translation |
| 834 | /// unit. In C, for example, name lookup will either return nothing |
| 835 | /// (no entity found) or a single declaration. In C++, name lookup |
| 836 | /// can additionally refer to a set of overloaded functions or |
| 837 | /// result in an ambiguity. All of the possible results of name |
| 838 | /// lookup are captured by the LookupResult class, which provides |
| 839 | /// the ability to distinguish among them. |
| 840 | //@{ |
Douglas Gregor | d7c4d98 | 2008-12-30 03:27:21 +0000 | [diff] [blame] | 841 | |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 842 | /// @brief Describes the kind of name lookup to perform. |
| 843 | enum LookupNameKind { |
| 844 | /// Ordinary name lookup, which finds ordinary names (functions, |
| 845 | /// variables, typedefs, etc.) in C and most kinds of names |
| 846 | /// (functions, variables, members, types, etc.) in C++. |
| 847 | LookupOrdinaryName = 0, |
| 848 | /// Tag name lookup, which finds the names of enums, classes, |
| 849 | /// structs, and unions. |
| 850 | LookupTagName, |
| 851 | /// Member name lookup, which finds the names of |
| 852 | /// class/struct/union members. |
| 853 | LookupMemberName, |
Douglas Gregor | 94eabf3 | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 854 | // Look up of an operator name (e.g., operator+) for use with |
| 855 | // operator overloading. This lookup is similar to ordinary name |
| 856 | // lookup, but will ignore any declarations that are class |
| 857 | // members. |
| 858 | LookupOperatorName, |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 859 | /// Look up of a name that precedes the '::' scope resolution |
| 860 | /// operator in C++. This lookup completely ignores operator, |
| 861 | /// function, and enumerator names (C++ [basic.lookup.qual]p1). |
| 862 | LookupNestedNameSpecifierName, |
| 863 | /// Look up a namespace name within a C++ using directive or |
| 864 | /// namespace alias definition, ignoring non-namespace names (C++ |
| 865 | /// [basic.lookup.udir]p1). |
Douglas Gregor | eddf433 | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 866 | LookupNamespaceName, |
Douglas Gregor | de9f17e | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 867 | /// Look up an ordinary name that is going to be redeclared as a |
| 868 | /// name with linkage. This lookup ignores any declarations that |
| 869 | /// are outside of the current scope unless they have linkage. See |
| 870 | /// C99 6.2.2p4-5 and C++ [basic.link]p6. |
| 871 | LookupRedeclarationWithLinkage, |
| 872 | /// Look up the name of an Objective-C protocol. |
Douglas Gregor | 79947a2 | 2009-04-24 00:11:27 +0000 | [diff] [blame] | 873 | LookupObjCProtocolName, |
| 874 | /// Look up the name of an Objective-C implementation |
| 875 | LookupObjCImplementationName, |
| 876 | /// Look up the name of an Objective-C category implementation |
| 877 | LookupObjCCategoryImplName |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 878 | }; |
| 879 | |
| 880 | /// @brief Represents the results of name lookup. |
| 881 | /// |
| 882 | /// An instance of the LookupResult class captures the results of a |
| 883 | /// single name lookup, which can return no result (nothing found), |
| 884 | /// a single declaration, a set of overloaded functions, or an |
| 885 | /// ambiguity. Use the getKind() method to determine which of these |
| 886 | /// results occurred for a given lookup. |
| 887 | /// |
| 888 | /// Any non-ambiguous lookup can be converted into a single |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 889 | /// (possibly NULL) @c NamedDecl* via a conversion function or the |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 890 | /// getAsDecl() method. This conversion permits the common-case |
| 891 | /// usage in C and Objective-C where name lookup will always return |
| 892 | /// a single declaration. |
Douglas Gregor | f23311d | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 893 | struct LookupResult { |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 894 | /// The kind of entity that is actually stored within the |
| 895 | /// LookupResult object. |
Douglas Gregor | f23311d | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 896 | enum { |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 897 | /// First is a single declaration (a NamedDecl*), which may be NULL. |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 898 | SingleDecl, |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 899 | |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 900 | /// First is a single declaration (an OverloadedFunctionDecl*). |
| 901 | OverloadedDeclSingleDecl, |
| 902 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 903 | /// [First, Last) is an iterator range represented as opaque |
| 904 | /// pointers used to reconstruct IdentifierResolver::iterators. |
| 905 | OverloadedDeclFromIdResolver, |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 906 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 907 | /// [First, Last) is an iterator range represented as opaque |
| 908 | /// pointers used to reconstruct DeclContext::lookup_iterators. |
| 909 | OverloadedDeclFromDeclContext, |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 910 | |
| 911 | /// First is a pointer to a BasePaths structure, which is owned |
| 912 | /// by the LookupResult. Last is non-zero to indicate that the |
| 913 | /// ambiguity is caused by two names found in base class |
| 914 | /// subobjects of different types. |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 915 | AmbiguousLookupStoresBasePaths, |
| 916 | |
| 917 | /// [First, Last) is an iterator range represented as opaque |
| 918 | /// pointers used to reconstruct new'ed Decl*[] array containing |
| 919 | /// found ambiguous decls. LookupResult is owner of this array. |
| 920 | AmbiguousLookupStoresDecls |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 921 | } StoredKind; |
| 922 | |
| 923 | /// The first lookup result, whose contents depend on the kind of |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 924 | /// lookup result. This may be a NamedDecl* (if StoredKind == |
| 925 | /// SingleDecl), OverloadedFunctionDecl* (if StoredKind == |
| 926 | /// OverloadedDeclSingleDecl), the opaque pointer from an |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 927 | /// IdentifierResolver::iterator (if StoredKind == |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 928 | /// OverloadedDeclFromIdResolver), a DeclContext::lookup_iterator |
| 929 | /// (if StoredKind == OverloadedDeclFromDeclContext), or a |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 930 | /// BasePaths pointer (if StoredKind == AmbiguousLookupStoresBasePaths). |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 931 | mutable uintptr_t First; |
| 932 | |
| 933 | /// The last lookup result, whose contents depend on the kind of |
| 934 | /// lookup result. This may be unused (if StoredKind == |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 935 | /// SingleDecl), it may have the same type as First (for |
| 936 | /// overloaded function declarations), or is may be used as a |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 937 | /// Boolean value (if StoredKind == AmbiguousLookupStoresBasePaths). |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 938 | mutable uintptr_t Last; |
| 939 | |
| 940 | /// Context - The context in which we will build any |
| 941 | /// OverloadedFunctionDecl nodes needed by the conversion to |
| 942 | /// Decl*. |
| 943 | ASTContext *Context; |
| 944 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 945 | /// @brief The kind of entity found by name lookup. |
| 946 | enum LookupKind { |
| 947 | /// @brief No entity found met the criteria. |
| 948 | NotFound = 0, |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 949 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 950 | /// @brief Name lookup found a single declaration that met the |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 951 | /// criteria. getAsDecl will return this declaration. |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 952 | Found, |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 953 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 954 | /// @brief Name lookup found a set of overloaded functions that |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 955 | /// met the criteria. getAsDecl will turn this set of overloaded |
| 956 | /// functions into an OverloadedFunctionDecl. |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 957 | FoundOverloaded, |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 958 | |
| 959 | /// Name lookup results in an ambiguity because multiple |
| 960 | /// entities that meet the lookup criteria were found in |
| 961 | /// subobjects of different types. For example: |
| 962 | /// @code |
| 963 | /// struct A { void f(int); } |
| 964 | /// struct B { void f(double); } |
| 965 | /// struct C : A, B { }; |
| 966 | /// void test(C c) { |
| 967 | /// c.f(0); // error: A::f and B::f come from subobjects of different |
| 968 | /// // types. overload resolution is not performed. |
| 969 | /// } |
| 970 | /// @endcode |
| 971 | AmbiguousBaseSubobjectTypes, |
| 972 | |
| 973 | /// Name lookup results in an ambiguity because multiple |
| 974 | /// nonstatic entities that meet the lookup criteria were found |
| 975 | /// in different subobjects of the same type. For example: |
| 976 | /// @code |
| 977 | /// struct A { int x; }; |
| 978 | /// struct B : A { }; |
| 979 | /// struct C : A { }; |
| 980 | /// struct D : B, C { }; |
| 981 | /// int test(D d) { |
| 982 | /// return d.x; // error: 'x' is found in two A subobjects (of B and C) |
| 983 | /// } |
| 984 | /// @endcode |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 985 | AmbiguousBaseSubobjects, |
| 986 | |
| 987 | /// Name lookup results in an ambiguity because multiple definitions |
| 988 | /// of entity that meet the lookup criteria were found in different |
| 989 | /// declaration contexts. |
| 990 | /// @code |
| 991 | /// namespace A { |
| 992 | /// int i; |
| 993 | /// namespace B { int i; } |
| 994 | /// int test() { |
| 995 | /// using namespace B; |
| 996 | /// return i; // error 'i' is found in namespace A and A::B |
| 997 | /// } |
| 998 | /// } |
| 999 | /// @endcode |
| 1000 | AmbiguousReference |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1001 | }; |
| 1002 | |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 1003 | static LookupResult CreateLookupResult(ASTContext &Context, NamedDecl *D); |
Douglas Gregor | 41c8ba8 | 2009-01-15 02:19:31 +0000 | [diff] [blame] | 1004 | |
Douglas Gregor | f23311d | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 1005 | static LookupResult CreateLookupResult(ASTContext &Context, |
| 1006 | IdentifierResolver::iterator F, |
| 1007 | IdentifierResolver::iterator L); |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1008 | |
Douglas Gregor | f23311d | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 1009 | static LookupResult CreateLookupResult(ASTContext &Context, |
| 1010 | DeclContext::lookup_iterator F, |
| 1011 | DeclContext::lookup_iterator L); |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1012 | |
Douglas Gregor | f23311d | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 1013 | static LookupResult CreateLookupResult(ASTContext &Context, BasePaths *Paths, |
| 1014 | bool DifferentSubobjectTypes) { |
| 1015 | LookupResult Result; |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1016 | Result.StoredKind = AmbiguousLookupStoresBasePaths; |
Douglas Gregor | f23311d | 2009-01-17 01:13:24 +0000 | [diff] [blame] | 1017 | Result.First = reinterpret_cast<uintptr_t>(Paths); |
| 1018 | Result.Last = DifferentSubobjectTypes? 1 : 0; |
| 1019 | Result.Context = &Context; |
| 1020 | return Result; |
| 1021 | } |
Douglas Gregor | 41c8ba8 | 2009-01-15 02:19:31 +0000 | [diff] [blame] | 1022 | |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1023 | template <typename Iterator> |
| 1024 | static LookupResult CreateLookupResult(ASTContext &Context, |
| 1025 | Iterator B, std::size_t Len) { |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 1026 | NamedDecl ** Array = new NamedDecl*[Len]; |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1027 | for (std::size_t Idx = 0; Idx < Len; ++Idx, ++B) |
| 1028 | Array[Idx] = *B; |
| 1029 | LookupResult Result; |
| 1030 | Result.StoredKind = AmbiguousLookupStoresDecls; |
| 1031 | Result.First = reinterpret_cast<uintptr_t>(Array); |
| 1032 | Result.Last = reinterpret_cast<uintptr_t>(Array + Len); |
| 1033 | Result.Context = &Context; |
| 1034 | return Result; |
| 1035 | } |
| 1036 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1037 | LookupKind getKind() const; |
| 1038 | |
| 1039 | /// @brief Determine whether name look found something. |
| 1040 | operator bool() const { return getKind() != NotFound; } |
| 1041 | |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1042 | /// @brief Determines whether the lookup resulted in an ambiguity. |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1043 | bool isAmbiguous() const { |
| 1044 | return StoredKind == AmbiguousLookupStoresBasePaths || |
| 1045 | StoredKind == AmbiguousLookupStoresDecls; |
| 1046 | } |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1047 | |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1048 | /// @brief Allows conversion of a lookup result into a |
| 1049 | /// declaration, with the same behavior as getAsDecl. |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 1050 | operator NamedDecl*() const { return getAsDecl(); } |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1051 | |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 1052 | NamedDecl* getAsDecl() const; |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1053 | |
| 1054 | BasePaths *getBasePaths() const; |
Douglas Gregor | 0e8fc3c | 2009-02-02 21:35:47 +0000 | [diff] [blame] | 1055 | |
| 1056 | /// \brief Iterate over the results of name lookup. |
| 1057 | /// |
| 1058 | /// The @c iterator class provides iteration over the results of a |
| 1059 | /// non-ambiguous name lookup. |
| 1060 | class iterator { |
| 1061 | /// The LookupResult structure we're iterating through. |
| 1062 | LookupResult *Result; |
| 1063 | |
| 1064 | /// The current position of this iterator within the sequence of |
| 1065 | /// results. This value will have the same representation as the |
| 1066 | /// @c First field in the LookupResult structure. |
| 1067 | mutable uintptr_t Current; |
| 1068 | |
| 1069 | public: |
Douglas Gregor | 2ada048 | 2009-02-04 17:27:36 +0000 | [diff] [blame] | 1070 | typedef NamedDecl * value_type; |
| 1071 | typedef NamedDecl * reference; |
| 1072 | typedef NamedDecl * pointer; |
Douglas Gregor | 0e8fc3c | 2009-02-02 21:35:47 +0000 | [diff] [blame] | 1073 | typedef std::ptrdiff_t difference_type; |
| 1074 | typedef std::forward_iterator_tag iterator_category; |
| 1075 | |
| 1076 | iterator() : Result(0), Current(0) { } |
| 1077 | |
| 1078 | iterator(LookupResult *Res, uintptr_t Cur) : Result(Res), Current(Cur) { } |
| 1079 | |
| 1080 | reference operator*() const; |
| 1081 | |
| 1082 | pointer operator->() const { return **this; } |
| 1083 | |
| 1084 | iterator &operator++(); |
| 1085 | |
| 1086 | iterator operator++(int) { |
| 1087 | iterator tmp(*this); |
| 1088 | ++(*this); |
| 1089 | return tmp; |
| 1090 | } |
| 1091 | |
| 1092 | friend inline bool operator==(iterator const& x, iterator const& y) { |
| 1093 | return x.Current == y.Current; |
| 1094 | } |
| 1095 | |
| 1096 | friend inline bool operator!=(iterator const& x, iterator const& y) { |
| 1097 | return x.Current != y.Current; |
| 1098 | } |
| 1099 | }; |
| 1100 | friend class iterator; |
| 1101 | |
| 1102 | iterator begin(); |
| 1103 | iterator end(); |
Douglas Gregor | fe3d7d0 | 2009-04-01 21:51:26 +0000 | [diff] [blame] | 1104 | |
| 1105 | /// \brief Free the memory associated with this lookup. |
| 1106 | void Destroy(); |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1107 | }; |
| 1108 | |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1109 | private: |
| 1110 | typedef llvm::SmallVector<LookupResult, 3> LookupResultsVecTy; |
| 1111 | |
| 1112 | std::pair<bool, LookupResult> CppLookupName(Scope *S, DeclarationName Name, |
| 1113 | LookupNameKind NameKind, |
| 1114 | bool RedeclarationOnly); |
Fariborz Jahanian | 69ba935 | 2009-04-07 18:28:06 +0000 | [diff] [blame] | 1115 | ObjCMethodDecl *FindMethodInNestedImplementations( |
| 1116 | const ObjCInterfaceDecl *IFace, |
| 1117 | const Selector &Sel); |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1118 | |
| 1119 | public: |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1120 | /// Determines whether D is a suitable lookup result according to the |
| 1121 | /// lookup criteria. |
Douglas Gregor | eddf433 | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 1122 | static bool isAcceptableLookupResult(NamedDecl *D, LookupNameKind NameKind, |
Douglas Gregor | 700792c | 2009-02-05 19:25:20 +0000 | [diff] [blame] | 1123 | unsigned IDNS) { |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1124 | switch (NameKind) { |
| 1125 | case Sema::LookupOrdinaryName: |
| 1126 | case Sema::LookupTagName: |
| 1127 | case Sema::LookupMemberName: |
Douglas Gregor | eddf433 | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 1128 | case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping |
Douglas Gregor | 79947a2 | 2009-04-24 00:11:27 +0000 | [diff] [blame] | 1129 | case Sema::LookupObjCProtocolName: |
| 1130 | case Sema::LookupObjCImplementationName: |
| 1131 | case Sema::LookupObjCCategoryImplName: |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1132 | return D->isInIdentifierNamespace(IDNS); |
| 1133 | |
Douglas Gregor | 94eabf3 | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 1134 | case Sema::LookupOperatorName: |
| 1135 | return D->isInIdentifierNamespace(IDNS) && |
| 1136 | !D->getDeclContext()->isRecord(); |
| 1137 | |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1138 | case Sema::LookupNestedNameSpecifierName: |
| 1139 | return isa<TypedefDecl>(D) || D->isInIdentifierNamespace(Decl::IDNS_Tag); |
| 1140 | |
| 1141 | case Sema::LookupNamespaceName: |
Anders Carlsson | bb1e472 | 2009-03-28 23:53:49 +0000 | [diff] [blame] | 1142 | return isa<NamespaceDecl>(D) || isa<NamespaceAliasDecl>(D); |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | assert(false && |
Douglas Gregor | 700792c | 2009-02-05 19:25:20 +0000 | [diff] [blame] | 1146 | "isAcceptableLookupResult always returns before this point"); |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1147 | return false; |
| 1148 | } |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1149 | |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1150 | LookupResult LookupName(Scope *S, DeclarationName Name, |
| 1151 | LookupNameKind NameKind, |
Douglas Gregor | b9063fc | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 1152 | bool RedeclarationOnly = false, |
Eli Friedman | 2696b1e | 2009-06-06 02:08:44 +0000 | [diff] [blame] | 1153 | bool AllowBuiltinCreation = false, |
Douglas Gregor | b9063fc | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 1154 | SourceLocation Loc = SourceLocation()); |
Douglas Gregor | ed8f288 | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1155 | LookupResult LookupQualifiedName(DeclContext *LookupCtx, DeclarationName Name, |
| 1156 | LookupNameKind NameKind, |
| 1157 | bool RedeclarationOnly = false); |
| 1158 | LookupResult LookupParsedName(Scope *S, const CXXScopeSpec *SS, |
| 1159 | DeclarationName Name, |
| 1160 | LookupNameKind NameKind, |
Douglas Gregor | b9063fc | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 1161 | bool RedeclarationOnly = false, |
Eli Friedman | 2696b1e | 2009-06-06 02:08:44 +0000 | [diff] [blame] | 1162 | bool AllowBuiltinCreation = false, |
Douglas Gregor | b9063fc | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 1163 | SourceLocation Loc = SourceLocation()); |
Douglas Gregor | d2b7ef6 | 2009-03-13 00:33:25 +0000 | [diff] [blame] | 1164 | |
Douglas Gregor | de9f17e | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 1165 | ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II); |
Douglas Gregor | 79947a2 | 2009-04-24 00:11:27 +0000 | [diff] [blame] | 1166 | ObjCCategoryImplDecl *LookupObjCCategoryImpl(IdentifierInfo *II); |
Douglas Gregor | de9f17e | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 1167 | |
Douglas Gregor | d2b7ef6 | 2009-03-13 00:33:25 +0000 | [diff] [blame] | 1168 | void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, |
| 1169 | QualType T1, QualType T2, |
| 1170 | FunctionSet &Functions); |
| 1171 | |
| 1172 | void ArgumentDependentLookup(DeclarationName Name, |
| 1173 | Expr **Args, unsigned NumArgs, |
| 1174 | FunctionSet &Functions); |
| 1175 | |
Douglas Gregor | e254f90 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 1176 | void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs, |
| 1177 | AssociatedNamespaceSet &AssociatedNamespaces, |
Douglas Gregor | 6127ca4 | 2009-06-23 20:14:09 +0000 | [diff] [blame] | 1178 | AssociatedClassSet &AssociatedClasses, |
| 1179 | bool &GlobalScope); |
Douglas Gregor | e254f90 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 1180 | |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1181 | bool DiagnoseAmbiguousLookup(LookupResult &Result, DeclarationName Name, |
| 1182 | SourceLocation NameLoc, |
| 1183 | SourceRange LookupRange = SourceRange()); |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1184 | //@} |
| 1185 | |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1186 | ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *Id); |
Douglas Gregor | 6e6ad60 | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 1187 | NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, |
Douglas Gregor | b9063fc | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 1188 | Scope *S, bool ForRedeclaration, |
| 1189 | SourceLocation Loc); |
Douglas Gregor | 6e6ad60 | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 1190 | NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, |
| 1191 | Scope *S); |
Douglas Gregor | e711f70 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 1192 | void AddKnownFunctionAttributes(FunctionDecl *FD); |
Douglas Gregor | 3407432 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1193 | |
| 1194 | // More parsing and symbol table subroutines. |
| 1195 | |
Steve Naroff | a8fd973 | 2007-06-11 00:35:03 +0000 | [diff] [blame] | 1196 | // Decl attributes - this routine is the top level dispatcher. |
Douglas Gregor | 758a869 | 2009-06-17 21:51:59 +0000 | [diff] [blame] | 1197 | void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD); |
| 1198 | void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AttrList); |
Christopher Lamb | 025b5fb | 2008-02-04 02:31:56 +0000 | [diff] [blame] | 1199 | |
Steve Naroff | 15833ed | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 1200 | void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, |
| 1201 | bool &IncompleteImpl); |
Fariborz Jahanian | 7988d7d | 2008-12-05 18:18:52 +0000 | [diff] [blame] | 1202 | void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod, |
| 1203 | ObjCMethodDecl *IntfMethod); |
Fariborz Jahanian | 0c20bdd | 2009-05-14 23:52:54 +0000 | [diff] [blame] | 1204 | bool QualifiedIdConformsQualifiedId(QualType LHS, QualType RHS); |
Sebastian Redl | c470476 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1205 | |
| 1206 | NamespaceDecl *GetStdNamespace(); |
Fariborz Jahanian | 8e1555c | 2009-01-12 19:55:42 +0000 | [diff] [blame] | 1207 | |
| 1208 | bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl, |
Steve Naroff | de68001 | 2009-02-26 19:11:32 +0000 | [diff] [blame] | 1209 | ObjCInterfaceDecl *IDecl); |
Steve Naroff | 15833ed | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 1210 | |
Chris Lattner | ce1da2c | 2009-01-06 07:27:21 +0000 | [diff] [blame] | 1211 | /// CheckProtocolMethodDefs - This routine checks unimplemented |
Daniel Dunbar | c7dfbfd | 2008-09-04 20:01:15 +0000 | [diff] [blame] | 1212 | /// methods declared in protocol, and those referenced by it. |
| 1213 | /// \param IDecl - Used for checking for methods which may have been |
| 1214 | /// inherited. |
Steve Naroff | a3699224 | 2008-02-08 22:06:17 +0000 | [diff] [blame] | 1215 | void CheckProtocolMethodDefs(SourceLocation ImpLoc, |
| 1216 | ObjCProtocolDecl *PDecl, |
Fariborz Jahanian | adf84f3 | 2007-10-02 20:06:01 +0000 | [diff] [blame] | 1217 | bool& IncompleteImpl, |
Steve Naroff | 71c3c1c | 2007-10-08 21:05:34 +0000 | [diff] [blame] | 1218 | const llvm::DenseSet<Selector> &InsMap, |
Daniel Dunbar | c7dfbfd | 2008-09-04 20:01:15 +0000 | [diff] [blame] | 1219 | const llvm::DenseSet<Selector> &ClsMap, |
| 1220 | ObjCInterfaceDecl *IDecl); |
Fariborz Jahanian | ec7b333 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 1221 | |
Steve Naroff | d174155 | 2007-10-02 21:43:37 +0000 | [diff] [blame] | 1222 | /// CheckImplementationIvars - This routine checks if the instance variables |
| 1223 | /// listed in the implelementation match those listed in the interface. |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1224 | void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, |
| 1225 | ObjCIvarDecl **Fields, unsigned nIvars, |
Steve Naroff | 15833ed | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 1226 | SourceLocation Loc); |
Steve Naroff | d174155 | 2007-10-02 21:43:37 +0000 | [diff] [blame] | 1227 | |
Fariborz Jahanian | ec7b333 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 1228 | /// ImplMethodsVsClassMethods - This is main routine to warn if any method |
Chris Lattner | 9ef10f4 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 1229 | /// remains unimplemented in the class or category @implementation. |
| 1230 | void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, |
| 1231 | ObjCContainerDecl* IDecl, |
| 1232 | bool IncompleteImpl = false); |
Fariborz Jahanian | ec7b333 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 1233 | |
Fariborz Jahanian | 458f711 | 2007-10-05 18:00:57 +0000 | [diff] [blame] | 1234 | /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns |
| 1235 | /// true, or false, accordingly. |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1236 | bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, |
Steve Naroff | a0ed165 | 2008-10-21 10:37:50 +0000 | [diff] [blame] | 1237 | const ObjCMethodDecl *PrevMethod, |
| 1238 | bool matchBasedOnSizeAndAlignment = false); |
Steve Naroff | 7f549f1 | 2007-10-10 21:53:07 +0000 | [diff] [blame] | 1239 | |
Fariborz Jahanian | 07b7165 | 2009-05-01 20:07:12 +0000 | [diff] [blame] | 1240 | /// MatchAllMethodDeclarations - Check methods declaraed in interface or |
| 1241 | /// or protocol against those declared in their implementations. |
| 1242 | void MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap, |
| 1243 | const llvm::DenseSet<Selector> &ClsMap, |
| 1244 | llvm::DenseSet<Selector> &InsMapSeen, |
| 1245 | llvm::DenseSet<Selector> &ClsMapSeen, |
| 1246 | ObjCImplDecl* IMPDecl, |
| 1247 | ObjCContainerDecl* IDecl, |
| 1248 | bool &IncompleteImpl, |
| 1249 | bool ImmediateClass); |
| 1250 | |
Steve Naroff | 5811baf | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1251 | /// AddInstanceMethodToGlobalPool - All instance methods in a translation |
| 1252 | /// unit are added to a global pool. This allows us to efficiently associate |
| 1253 | /// a selector with a method declaraation for purposes of typechecking |
| 1254 | /// messages sent to "id" (where the class of the object is unknown). |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1255 | void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method); |
Steve Naroff | 5811baf | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1256 | |
Steve Naroff | 4a82d81 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 1257 | /// LookupInstanceMethodInGlobalPool - Returns the method and warns if |
| 1258 | /// there are multiple signatures. |
| 1259 | ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R); |
Douglas Gregor | c78d346 | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 1260 | |
| 1261 | /// LookupFactoryMethodInGlobalPool - Returns the method and warns if |
| 1262 | /// there are multiple signatures. |
| 1263 | ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R); |
Steve Naroff | 4a82d81 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 1264 | |
Steve Naroff | 5811baf | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1265 | /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. |
Ted Kremenek | 1b0ea82 | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1266 | void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method); |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1267 | //===--------------------------------------------------------------------===// |
Chris Lattner | e168f76 | 2006-11-10 05:29:30 +0000 | [diff] [blame] | 1268 | // Statement Parsing Callbacks: SemaStmt.cpp. |
Steve Naroff | 3273c22 | 2007-03-14 21:52:03 +0000 | [diff] [blame] | 1269 | public: |
Anders Carlsson | 24824e5 | 2009-05-17 21:11:30 +0000 | [diff] [blame] | 1270 | virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr); |
Sebastian Redl | 52f03ba | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 1271 | |
| 1272 | virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc); |
| 1273 | virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, |
| 1274 | MultiStmtArg Elts, |
| 1275 | bool isStmtExpr); |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 1276 | virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1277 | SourceLocation StartLoc, |
Sebastian Redl | 52f03ba | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 1278 | SourceLocation EndLoc); |
Sebastian Redl | 1cbb5918 | 2008-12-28 16:13:43 +0000 | [diff] [blame] | 1279 | virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal, |
| 1280 | SourceLocation DotDotDotLoc, ExprArg RHSVal, |
Chris Lattner | 34a2209 | 2009-03-04 04:23:07 +0000 | [diff] [blame] | 1281 | SourceLocation ColonLoc); |
| 1282 | virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt); |
| 1283 | |
Sebastian Redl | 1cbb5918 | 2008-12-28 16:13:43 +0000 | [diff] [blame] | 1284 | virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
| 1285 | SourceLocation ColonLoc, |
| 1286 | StmtArg SubStmt, Scope *CurScope); |
Sebastian Redl | 6a8002e | 2009-01-11 00:38:46 +0000 | [diff] [blame] | 1287 | virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc, |
| 1288 | IdentifierInfo *II, |
| 1289 | SourceLocation ColonLoc, |
| 1290 | StmtArg SubStmt); |
Anders Carlsson | 5262746 | 2009-05-17 18:26:53 +0000 | [diff] [blame] | 1291 | virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, |
| 1292 | FullExprArg CondVal, StmtArg ThenVal, |
| 1293 | SourceLocation ElseLoc, StmtArg ElseVal); |
Sebastian Redl | 6a8002e | 2009-01-11 00:38:46 +0000 | [diff] [blame] | 1294 | virtual OwningStmtResult ActOnStartOfSwitchStmt(ExprArg Cond); |
| 1295 | virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, |
| 1296 | StmtArg Switch, StmtArg Body); |
Anders Carlsson | ee13926 | 2009-05-17 21:22:26 +0000 | [diff] [blame] | 1297 | virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, |
| 1298 | FullExprArg Cond, StmtArg Body); |
Sebastian Redl | fbfaafc | 2009-01-16 23:28:06 +0000 | [diff] [blame] | 1299 | virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, |
Chris Lattner | 815b70e | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 1300 | SourceLocation WhileLoc, |
| 1301 | SourceLocation CondLParen, ExprArg Cond, |
| 1302 | SourceLocation CondRParen); |
Sebastian Redl | fbfaafc | 2009-01-16 23:28:06 +0000 | [diff] [blame] | 1303 | |
| 1304 | virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc, |
| 1305 | SourceLocation LParenLoc, |
| 1306 | StmtArg First, ExprArg Second, |
| 1307 | ExprArg Third, SourceLocation RParenLoc, |
| 1308 | StmtArg Body); |
| 1309 | virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, |
| 1310 | SourceLocation LParenLoc, |
| 1311 | StmtArg First, ExprArg Second, |
| 1312 | SourceLocation RParenLoc, StmtArg Body); |
Sebastian Redl | 573feed | 2009-01-18 13:19:59 +0000 | [diff] [blame] | 1313 | |
| 1314 | virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
| 1315 | SourceLocation LabelLoc, |
| 1316 | IdentifierInfo *LabelII); |
| 1317 | virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
| 1318 | SourceLocation StarLoc, |
| 1319 | ExprArg DestExp); |
| 1320 | virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
| 1321 | Scope *CurScope); |
| 1322 | virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc, |
| 1323 | Scope *CurScope); |
| 1324 | |
| 1325 | virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
Anders Carlsson | 5de832e | 2009-05-30 21:42:34 +0000 | [diff] [blame] | 1326 | FullExprArg RetValExp); |
Sebastian Redl | 573feed | 2009-01-18 13:19:59 +0000 | [diff] [blame] | 1327 | OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc, |
| 1328 | Expr *RetValExp); |
| 1329 | |
Sebastian Redl | 24b8e15 | 2009-01-18 16:53:17 +0000 | [diff] [blame] | 1330 | virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc, |
| 1331 | bool IsSimple, |
| 1332 | bool IsVolatile, |
| 1333 | unsigned NumOutputs, |
| 1334 | unsigned NumInputs, |
| 1335 | std::string *Names, |
| 1336 | MultiExprArg Constraints, |
| 1337 | MultiExprArg Exprs, |
| 1338 | ExprArg AsmString, |
| 1339 | MultiExprArg Clobbers, |
| 1340 | SourceLocation RParenLoc); |
Sebastian Redl | 481bf3f | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1341 | |
| 1342 | virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, |
| 1343 | SourceLocation RParen, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1344 | DeclPtrTy Parm, StmtArg Body, |
Sebastian Redl | 481bf3f | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1345 | StmtArg CatchList); |
| 1346 | |
| 1347 | virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, |
| 1348 | StmtArg Body); |
| 1349 | |
| 1350 | virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, |
| 1351 | StmtArg Try, |
| 1352 | StmtArg Catch, StmtArg Finally); |
| 1353 | |
| 1354 | virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, |
Steve Naroff | 5ee2c02 | 2009-02-11 20:05:44 +0000 | [diff] [blame] | 1355 | ExprArg Throw, |
| 1356 | Scope *CurScope); |
Sebastian Redl | 481bf3f | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1357 | virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| 1358 | ExprArg SynchExpr, |
| 1359 | StmtArg SynchBody); |
Sebastian Redl | b219c90 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 1360 | |
Douglas Gregor | 5e16fbe | 2009-05-18 20:51:54 +0000 | [diff] [blame] | 1361 | VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType, |
| 1362 | IdentifierInfo *Name, |
| 1363 | SourceLocation Loc, |
| 1364 | SourceRange Range); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1365 | virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D); |
Douglas Gregor | 5e16fbe | 2009-05-18 20:51:54 +0000 | [diff] [blame] | 1366 | |
Sebastian Redl | 54c04d4 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1367 | virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1368 | DeclPtrTy ExDecl, |
Sebastian Redl | 54c04d4 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1369 | StmtArg HandlerBlock); |
Sebastian Redl | 9b244a8 | 2008-12-22 21:35:02 +0000 | [diff] [blame] | 1370 | virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc, |
| 1371 | StmtArg TryBlock, |
| 1372 | MultiStmtArg Handlers); |
Sebastian Redl | 4c01866 | 2009-04-27 21:33:24 +0000 | [diff] [blame] | 1373 | void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock); |
Sebastian Redl | b219c90 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 1374 | |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1375 | //===--------------------------------------------------------------------===// |
Chris Lattner | e168f76 | 2006-11-10 05:29:30 +0000 | [diff] [blame] | 1376 | // Expression Parsing Callbacks: SemaExpr.cpp. |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1377 | |
Douglas Gregor | 171c45a | 2009-02-18 21:56:37 +0000 | [diff] [blame] | 1378 | bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc); |
Fariborz Jahanian | fe9e394 | 2009-05-08 20:20:55 +0000 | [diff] [blame] | 1379 | bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, |
| 1380 | ObjCMethodDecl *Getter, |
| 1381 | SourceLocation Loc); |
Fariborz Jahanian | 027b886 | 2009-05-13 18:09:35 +0000 | [diff] [blame] | 1382 | void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, |
| 1383 | Expr **Args, unsigned NumArgs); |
Chris Lattner | 4bf74fd | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 1384 | |
Douglas Gregor | 0b6a624 | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 1385 | virtual ExpressionEvaluationContext |
| 1386 | PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext); |
| 1387 | |
| 1388 | virtual void |
| 1389 | PopExpressionEvaluationContext(ExpressionEvaluationContext OldContext, |
| 1390 | ExpressionEvaluationContext NewContext); |
| 1391 | |
Douglas Gregor | c9c02ed | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 1392 | void MarkDeclarationReferenced(SourceLocation Loc, Decl *D); |
| 1393 | |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1394 | // Primary Expressions. |
Douglas Gregor | 87f95b0 | 2009-02-26 21:00:50 +0000 | [diff] [blame] | 1395 | virtual SourceRange getExprRange(ExprTy *E) const; |
| 1396 | |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1397 | virtual OwningExprResult ActOnIdentifierExpr(Scope *S, SourceLocation Loc, |
| 1398 | IdentifierInfo &II, |
| 1399 | bool HasTrailingLParen, |
Sebastian Redl | 3d3f75a | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1400 | const CXXScopeSpec *SS = 0, |
| 1401 | bool isAddressOfOperand = false); |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1402 | virtual OwningExprResult ActOnCXXOperatorFunctionIdExpr(Scope *S, |
Douglas Gregor | 7911b37 | 2008-11-19 19:09:45 +0000 | [diff] [blame] | 1403 | SourceLocation OperatorLoc, |
| 1404 | OverloadedOperatorKind Op, |
| 1405 | bool HasTrailingLParen, |
Sebastian Redl | 3d3f75a | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1406 | const CXXScopeSpec &SS, |
| 1407 | bool isAddressOfOperand); |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1408 | virtual OwningExprResult ActOnCXXConversionFunctionExpr(Scope *S, |
Douglas Gregor | 7911b37 | 2008-11-19 19:09:45 +0000 | [diff] [blame] | 1409 | SourceLocation OperatorLoc, |
| 1410 | TypeTy *Ty, |
| 1411 | bool HasTrailingLParen, |
Sebastian Redl | 3d3f75a | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1412 | const CXXScopeSpec &SS, |
| 1413 | bool isAddressOfOperand); |
Anders Carlsson | 946b86d | 2009-06-24 00:10:43 +0000 | [diff] [blame] | 1414 | OwningExprResult BuildDeclRefExpr(NamedDecl *D, QualType Ty, |
| 1415 | SourceLocation Loc, bool TypeDependent, |
| 1416 | bool ValueDependent, |
| 1417 | const CXXScopeSpec *SS = 0); |
Douglas Gregor | d5846a1 | 2009-04-15 06:41:24 +0000 | [diff] [blame] | 1418 | VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field, |
| 1419 | llvm::SmallVectorImpl<FieldDecl *> &Path); |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1420 | OwningExprResult |
Douglas Gregor | 9ac7a07 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 1421 | BuildAnonymousStructUnionMemberReference(SourceLocation Loc, |
| 1422 | FieldDecl *Field, |
| 1423 | Expr *BaseObjectExpr = 0, |
| 1424 | SourceLocation OpLoc = SourceLocation()); |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1425 | OwningExprResult ActOnDeclarationNameExpr(Scope *S, SourceLocation Loc, |
| 1426 | DeclarationName Name, |
| 1427 | bool HasTrailingLParen, |
| 1428 | const CXXScopeSpec *SS, |
Sebastian Redl | 3d3f75a | 2009-02-03 20:19:35 +0000 | [diff] [blame] | 1429 | bool isAddressOfOperand = false); |
Douglas Gregor | 3256d04 | 2009-06-30 15:47:41 +0000 | [diff] [blame] | 1430 | OwningExprResult BuildDeclarationNameExpr(SourceLocation Loc, NamedDecl *D, |
| 1431 | bool HasTrailingLParen, |
| 1432 | const CXXScopeSpec *SS, |
| 1433 | bool isAddressOfOperand); |
| 1434 | |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1435 | virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc, |
| 1436 | tok::TokenKind Kind); |
| 1437 | virtual OwningExprResult ActOnNumericConstant(const Token &); |
| 1438 | virtual OwningExprResult ActOnCharacterConstant(const Token &); |
| 1439 | virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
| 1440 | ExprArg Val); |
Chris Lattner | 697e5d6 | 2006-11-09 06:32:27 +0000 | [diff] [blame] | 1441 | |
Steve Naroff | 83895f7 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1442 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
Chris Lattner | 697e5d6 | 2006-11-09 06:32:27 +0000 | [diff] [blame] | 1443 | /// fragments (e.g. "foo" "bar" L"baz"). |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1444 | virtual OwningExprResult ActOnStringLiteral(const Token *Toks, |
| 1445 | unsigned NumToks); |
Sebastian Redl | ffbcf96 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1446 | |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1447 | // Binary/Unary Operators. 'Tok' is the token for the operator. |
Douglas Gregor | 084d855 | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 1448 | OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, |
| 1449 | unsigned OpcIn, |
| 1450 | ExprArg InputArg); |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1451 | virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1452 | tok::TokenKind Op, ExprArg Input); |
Sebastian Redl | 6f28289 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 1453 | |
Douglas Gregor | 0950e41 | 2009-03-13 21:01:28 +0000 | [diff] [blame] | 1454 | OwningExprResult CreateSizeOfAlignOfExpr(QualType T, SourceLocation OpLoc, |
| 1455 | bool isSizeOf, SourceRange R); |
| 1456 | OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc, |
| 1457 | bool isSizeOf, SourceRange R); |
Douglas Gregor | 084d855 | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 1458 | virtual OwningExprResult |
| 1459 | ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, |
| 1460 | void *TyOrEx, const SourceRange &ArgRange); |
Douglas Gregor | 0950e41 | 2009-03-13 21:01:28 +0000 | [diff] [blame] | 1461 | |
Chris Lattner | 8dff017 | 2009-01-24 20:17:12 +0000 | [diff] [blame] | 1462 | bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R); |
Sebastian Redl | 6f28289 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 1463 | bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc, |
| 1464 | const SourceRange &R, bool isSizeof); |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1465 | |
| 1466 | virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1467 | tok::TokenKind Kind, |
| 1468 | ExprArg Input); |
| 1469 | |
| 1470 | virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base, |
| 1471 | SourceLocation LLoc, |
| 1472 | ExprArg Idx, |
| 1473 | SourceLocation RLoc); |
| 1474 | virtual OwningExprResult ActOnMemberReferenceExpr(Scope *S, ExprArg Base, |
| 1475 | SourceLocation OpLoc, |
| 1476 | tok::TokenKind OpKind, |
| 1477 | SourceLocation MemberLoc, |
Fariborz Jahanian | b8d091c | 2009-03-04 22:30:12 +0000 | [diff] [blame] | 1478 | IdentifierInfo &Member, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1479 | DeclPtrTy ImplDecl); |
Fariborz Jahanian | aee31ac | 2009-07-21 22:36:06 +0000 | [diff] [blame] | 1480 | virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl); |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1481 | bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, |
Douglas Gregor | 97fd6e2 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1482 | FunctionDecl *FDecl, |
Douglas Gregor | deaad8c | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 1483 | const FunctionProtoType *Proto, |
Douglas Gregor | 97fd6e2 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1484 | Expr **Args, unsigned NumArgs, |
| 1485 | SourceLocation RParenLoc); |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1486 | |
Steve Naroff | 83895f7 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1487 | /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1488 | /// This provides the location of the left/right parens and a list of comma |
| 1489 | /// locations. |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1490 | virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn, |
| 1491 | SourceLocation LParenLoc, |
| 1492 | MultiExprArg Args, |
| 1493 | SourceLocation *CommaLocs, |
| 1494 | SourceLocation RParenLoc); |
| 1495 | |
Sebastian Redl | b5d4935 | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1496 | virtual OwningExprResult ActOnCastExpr(SourceLocation LParenLoc, TypeTy *Ty, |
| 1497 | SourceLocation RParenLoc, ExprArg Op); |
| 1498 | |
| 1499 | virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, |
| 1500 | TypeTy *Ty, |
| 1501 | SourceLocation RParenLoc, |
| 1502 | ExprArg Op); |
| 1503 | |
| 1504 | virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc, |
| 1505 | MultiExprArg InitList, |
Sebastian Redl | b5d4935 | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1506 | SourceLocation RParenLoc); |
| 1507 | |
Douglas Gregor | e4a0bb7 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 1508 | virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig, |
| 1509 | SourceLocation Loc, |
Douglas Gregor | 5c7c9cb | 2009-03-28 00:41:23 +0000 | [diff] [blame] | 1510 | bool GNUSyntax, |
Douglas Gregor | e4a0bb7 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 1511 | OwningExprResult Init); |
| 1512 | |
Sebastian Redl | b5d4935 | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1513 | virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, |
| 1514 | tok::TokenKind Kind, |
| 1515 | ExprArg LHS, ExprArg RHS); |
| 1516 | OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc, |
| 1517 | unsigned Opc, Expr *lhs, Expr *rhs); |
Douglas Gregor | 7d5fc7e | 2008-11-06 23:29:22 +0000 | [diff] [blame] | 1518 | |
Steve Naroff | 83895f7 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1519 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 1520 | /// in the case of a the GNU conditional expr extension. |
Sebastian Redl | b5d4935 | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1521 | virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
| 1522 | SourceLocation ColonLoc, |
| 1523 | ExprArg Cond, ExprArg LHS, |
| 1524 | ExprArg RHS); |
Chris Lattner | 2937565 | 2006-12-04 18:06:35 +0000 | [diff] [blame] | 1525 | |
Steve Naroff | 66356bd | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1526 | /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1527 | virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc, |
| 1528 | SourceLocation LabLoc, |
| 1529 | IdentifierInfo *LabelII); |
| 1530 | |
| 1531 | virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt, |
| 1532 | SourceLocation RPLoc); // "({..})" |
Chris Lattner | f17bd42 | 2007-08-30 17:45:32 +0000 | [diff] [blame] | 1533 | |
| 1534 | /// __builtin_offsetof(type, a.b[123][456].c) |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1535 | virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S, |
| 1536 | SourceLocation BuiltinLoc, |
| 1537 | SourceLocation TypeLoc, |
| 1538 | TypeTy *Arg1, |
| 1539 | OffsetOfComponent *CompPtr, |
| 1540 | unsigned NumComponents, |
| 1541 | SourceLocation RParenLoc); |
| 1542 | |
Steve Naroff | 7886467 | 2007-08-01 22:05:33 +0000 | [diff] [blame] | 1543 | // __builtin_types_compatible_p(type1, type2) |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1544 | virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
| 1545 | TypeTy *arg1, TypeTy *arg2, |
| 1546 | SourceLocation RPLoc); |
| 1547 | |
Steve Naroff | 9efdabc | 2007-08-03 21:21:27 +0000 | [diff] [blame] | 1548 | // __builtin_choose_expr(constExpr, expr1, expr2) |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1549 | virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
| 1550 | ExprArg cond, ExprArg expr1, |
| 1551 | ExprArg expr2, SourceLocation RPLoc); |
| 1552 | |
Anders Carlsson | 7e13ab8 | 2007-10-15 20:28:48 +0000 | [diff] [blame] | 1553 | // __builtin_va_arg(expr, type) |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1554 | virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc, |
| 1555 | ExprArg expr, TypeTy *type, |
| 1556 | SourceLocation RPLoc); |
Steve Naroff | c540d66 | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1557 | |
Douglas Gregor | 3be4b12 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 1558 | // __null |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1559 | virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc); |
Douglas Gregor | 3be4b12 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 1560 | |
Steve Naroff | c540d66 | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1561 | //===------------------------- "Block" Extension ------------------------===// |
| 1562 | |
| 1563 | /// ActOnBlockStart - This callback is invoked when a block literal is |
| 1564 | /// started. |
Steve Naroff | 1d95e5a | 2008-10-10 01:28:17 +0000 | [diff] [blame] | 1565 | virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope); |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1566 | |
Steve Naroff | 1d95e5a | 2008-10-10 01:28:17 +0000 | [diff] [blame] | 1567 | /// ActOnBlockArguments - This callback allows processing of block arguments. |
| 1568 | /// If there are no arguments, this is still invoked. |
Mike Stump | 82f071f | 2009-02-04 22:31:32 +0000 | [diff] [blame] | 1569 | virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope); |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1570 | |
Steve Naroff | c540d66 | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1571 | /// ActOnBlockError - If there is an error parsing a block, this callback |
| 1572 | /// is invoked to pop the information about the block from the action impl. |
| 1573 | virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope); |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1574 | |
Steve Naroff | c540d66 | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1575 | /// ActOnBlockStmtExpr - This is called when the body of a block statement |
| 1576 | /// literal was successfully completed. ^(int x){...} |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1577 | virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, |
| 1578 | StmtArg Body, Scope *CurScope); |
Steve Naroff | c540d66 | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1579 | |
Chris Lattner | 4bf74fd | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 1580 | //===---------------------------- C++ Features --------------------------===// |
| 1581 | |
Argyrios Kyrtzidis | 0811489 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 1582 | // Act on C++ namespaces |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1583 | virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc, |
| 1584 | IdentifierInfo *Ident, |
| 1585 | SourceLocation LBrace); |
| 1586 | virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace); |
Argyrios Kyrtzidis | 0811489 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 1587 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1588 | virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope, |
| 1589 | SourceLocation UsingLoc, |
| 1590 | SourceLocation NamespcLoc, |
| 1591 | const CXXScopeSpec &SS, |
| 1592 | SourceLocation IdentLoc, |
| 1593 | IdentifierInfo *NamespcName, |
| 1594 | AttributeList *AttrList); |
Anders Carlsson | 9205d55 | 2009-03-28 05:27:17 +0000 | [diff] [blame] | 1595 | |
Douglas Gregor | 889ceb7 | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1596 | void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir); |
| 1597 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1598 | virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope, |
Anders Carlsson | 47952ae | 2009-03-28 22:53:22 +0000 | [diff] [blame] | 1599 | SourceLocation NamespaceLoc, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1600 | SourceLocation AliasLoc, |
| 1601 | IdentifierInfo *Alias, |
| 1602 | const CXXScopeSpec &SS, |
Anders Carlsson | 47952ae | 2009-03-28 22:53:22 +0000 | [diff] [blame] | 1603 | SourceLocation IdentLoc, |
| 1604 | IdentifierInfo *Ident); |
Douglas Gregor | fec5263 | 2009-06-20 00:51:54 +0000 | [diff] [blame] | 1605 | |
| 1606 | virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope, |
| 1607 | SourceLocation UsingLoc, |
| 1608 | const CXXScopeSpec &SS, |
| 1609 | SourceLocation IdentLoc, |
| 1610 | IdentifierInfo *TargetName, |
Anders Carlsson | 74d7f0d | 2009-06-27 00:27:47 +0000 | [diff] [blame] | 1611 | OverloadedOperatorKind Op, |
Douglas Gregor | fec5263 | 2009-06-20 00:51:54 +0000 | [diff] [blame] | 1612 | AttributeList *AttrList, |
| 1613 | bool IsTypeName); |
Anders Carlsson | 9205d55 | 2009-03-28 05:27:17 +0000 | [diff] [blame] | 1614 | |
Argyrios Kyrtzidis | 9a1191c | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1615 | /// AddCXXDirectInitializerToDecl - This action is called immediately after |
| 1616 | /// ActOnDeclarator, when a C++ direct initializer is present. |
| 1617 | /// e.g: "int x(1);" |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1618 | virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, |
Argyrios Kyrtzidis | 9a1191c | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1619 | SourceLocation LParenLoc, |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1620 | MultiExprArg Exprs, |
Argyrios Kyrtzidis | 9a1191c | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1621 | SourceLocation *CommaLocs, |
| 1622 | SourceLocation RParenLoc); |
| 1623 | |
Anders Carlsson | e500faf | 2009-04-24 05:16:06 +0000 | [diff] [blame] | 1624 | /// InitializeVarWithConstructor - Creates an CXXConstructExpr |
| 1625 | /// and sets it as the initializer for the the passed in VarDecl. |
Anders Carlsson | e6840d8 | 2009-04-16 23:50:50 +0000 | [diff] [blame] | 1626 | void InitializeVarWithConstructor(VarDecl *VD, |
| 1627 | CXXConstructorDecl *Constructor, |
| 1628 | QualType DeclInitType, |
| 1629 | Expr **Exprs, unsigned NumExprs); |
Fariborz Jahanian | 24a175b | 2009-06-26 23:49:16 +0000 | [diff] [blame] | 1630 | |
Fariborz Jahanian | 3fe6b61 | 2009-06-27 15:05:11 +0000 | [diff] [blame] | 1631 | /// MarkDestructorReferenced - Prepare for calling destructor on the |
Fariborz Jahanian | 24a175b | 2009-06-26 23:49:16 +0000 | [diff] [blame] | 1632 | /// constructed decl. |
Fariborz Jahanian | 3fe6b61 | 2009-06-27 15:05:11 +0000 | [diff] [blame] | 1633 | void MarkDestructorReferenced(SourceLocation Loc, QualType DeclInitType); |
Fariborz Jahanian | 423a81f | 2009-06-19 19:55:27 +0000 | [diff] [blame] | 1634 | |
Fariborz Jahanian | 477d242 | 2009-06-22 23:34:40 +0000 | [diff] [blame] | 1635 | /// DefineImplicitDefaultConstructor - Checks for feasibility of |
Fariborz Jahanian | 423a81f | 2009-06-19 19:55:27 +0000 | [diff] [blame] | 1636 | /// defining this constructor as the default constructor. |
| 1637 | void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, |
| 1638 | CXXConstructorDecl *Constructor); |
Fariborz Jahanian | 477d242 | 2009-06-22 23:34:40 +0000 | [diff] [blame] | 1639 | |
Fariborz Jahanian | 24a175b | 2009-06-26 23:49:16 +0000 | [diff] [blame] | 1640 | /// DefineImplicitDestructor - Checks for feasibility of |
| 1641 | /// defining this destructor as the default destructor. |
| 1642 | void DefineImplicitDestructor(SourceLocation CurrentLocation, |
| 1643 | CXXDestructorDecl *Destructor); |
| 1644 | |
Fariborz Jahanian | 477d242 | 2009-06-22 23:34:40 +0000 | [diff] [blame] | 1645 | /// DefineImplicitCopyConstructor - Checks for feasibility of |
| 1646 | /// defining this constructor as the copy constructor. |
| 1647 | void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, |
| 1648 | CXXConstructorDecl *Constructor, |
| 1649 | unsigned TypeQuals); |
Fariborz Jahanian | 41f7927 | 2009-06-25 21:45:19 +0000 | [diff] [blame] | 1650 | |
| 1651 | /// DefineImplicitOverloadedAssign - Checks for feasibility of |
| 1652 | /// defining implicit this overloaded assignment operator. |
| 1653 | void DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, |
| 1654 | CXXMethodDecl *MethodDecl); |
| 1655 | |
| 1656 | /// getAssignOperatorMethod - Returns the default copy assignmment operator |
| 1657 | /// for the class. |
| 1658 | CXXMethodDecl *getAssignOperatorMethod(ParmVarDecl *Decl, |
| 1659 | CXXRecordDecl *ClassDecl); |
Anders Carlsson | 2d4cada | 2009-05-30 20:36:53 +0000 | [diff] [blame] | 1660 | |
| 1661 | /// MaybeBindToTemporary - If the passed in expression has a record type with |
| 1662 | /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise |
| 1663 | /// it simply returns the passed in expression. |
| 1664 | OwningExprResult MaybeBindToTemporary(Expr *E); |
Anders Carlsson | 777711b | 2009-05-30 22:47:03 +0000 | [diff] [blame] | 1665 | |
Douglas Gregor | 6f54315 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1666 | /// InitializationKind - Represents which kind of C++ initialization |
| 1667 | /// [dcl.init] a routine is to perform. |
| 1668 | enum InitializationKind { |
| 1669 | IK_Direct, ///< Direct initialization |
| 1670 | IK_Copy, ///< Copy initialization |
| 1671 | IK_Default ///< Default initialization |
| 1672 | }; |
| 1673 | |
Douglas Gregor | c28b57d | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 1674 | CXXConstructorDecl * |
Douglas Gregor | 6f54315 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1675 | PerformInitializationByConstructor(QualType ClassType, |
| 1676 | Expr **Args, unsigned NumArgs, |
| 1677 | SourceLocation Loc, SourceRange Range, |
Chris Lattner | f3d3fae | 2008-11-24 05:29:24 +0000 | [diff] [blame] | 1678 | DeclarationName InitEntity, |
Douglas Gregor | 6f54315 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1679 | InitializationKind Kind); |
Douglas Gregor | c28b57d | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 1680 | |
Douglas Gregor | e200adc | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1681 | /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's. |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1682 | virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc, |
| 1683 | tok::TokenKind Kind, |
| 1684 | SourceLocation LAngleBracketLoc, |
| 1685 | TypeTy *Ty, |
| 1686 | SourceLocation RAngleBracketLoc, |
| 1687 | SourceLocation LParenLoc, |
| 1688 | ExprArg E, |
| 1689 | SourceLocation RParenLoc); |
Bill Wendling | 4073ed5 | 2007-02-13 01:51:42 +0000 | [diff] [blame] | 1690 | |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1691 | /// ActOnCXXTypeid - Parse typeid( something ). |
| 1692 | virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc, |
| 1693 | SourceLocation LParenLoc, bool isType, |
| 1694 | void *TyOrExpr, |
| 1695 | SourceLocation RParenLoc); |
Sebastian Redl | c470476 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1696 | |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1697 | //// ActOnCXXThis - Parse 'this' pointer. |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1698 | virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc); |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1699 | |
Steve Naroff | 66356bd | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1700 | /// ActOnCXXBoolLiteral - Parse {true,false} literals. |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1701 | virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, |
| 1702 | tok::TokenKind Kind); |
| 1703 | |
Sebastian Redl | 576fd42 | 2009-05-10 18:38:11 +0000 | [diff] [blame] | 1704 | /// ActOnCXXNullPtrLiteral - Parse 'nullptr'. |
| 1705 | virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc); |
| 1706 | |
Chris Lattner | b7e656b | 2008-02-26 00:51:44 +0000 | [diff] [blame] | 1707 | //// ActOnCXXThrow - Parse throw expressions. |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1708 | virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc, |
| 1709 | ExprArg expr); |
Sebastian Redl | 4de47b4 | 2009-04-27 20:27:31 +0000 | [diff] [blame] | 1710 | bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E); |
Chris Lattner | b7e656b | 2008-02-26 00:51:44 +0000 | [diff] [blame] | 1711 | |
Argyrios Kyrtzidis | 857fcc2 | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1712 | /// ActOnCXXTypeConstructExpr - Parse construction of a specified type. |
| 1713 | /// Can be interpreted either as function-style casting ("int(x)") |
| 1714 | /// or class type construction ("ClassType(x,y,z)") |
| 1715 | /// or creation of a value-initialized type ("int()"). |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1716 | virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange, |
| 1717 | TypeTy *TypeRep, |
| 1718 | SourceLocation LParenLoc, |
| 1719 | MultiExprArg Exprs, |
| 1720 | SourceLocation *CommaLocs, |
| 1721 | SourceLocation RParenLoc); |
Argyrios Kyrtzidis | 857fcc2 | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1722 | |
Sebastian Redl | bd150f4 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1723 | /// ActOnCXXNew - Parsed a C++ 'new' expression. |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1724 | virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, |
| 1725 | SourceLocation PlacementLParen, |
| 1726 | MultiExprArg PlacementArgs, |
| 1727 | SourceLocation PlacementRParen, |
| 1728 | bool ParenTypeId, Declarator &D, |
| 1729 | SourceLocation ConstructorLParen, |
| 1730 | MultiExprArg ConstructorArgs, |
| 1731 | SourceLocation ConstructorRParen); |
Douglas Gregor | d0fefba | 2009-05-21 00:00:09 +0000 | [diff] [blame] | 1732 | OwningExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, |
| 1733 | SourceLocation PlacementLParen, |
| 1734 | MultiExprArg PlacementArgs, |
| 1735 | SourceLocation PlacementRParen, |
| 1736 | bool ParenTypeId, |
| 1737 | QualType AllocType, |
| 1738 | SourceLocation TypeLoc, |
| 1739 | SourceRange TypeRange, |
| 1740 | ExprArg ArraySize, |
| 1741 | SourceLocation ConstructorLParen, |
| 1742 | MultiExprArg ConstructorArgs, |
| 1743 | SourceLocation ConstructorRParen); |
| 1744 | |
| 1745 | bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, |
| 1746 | SourceRange R); |
Sebastian Redl | 1df2bbe | 2009-02-09 18:24:27 +0000 | [diff] [blame] | 1747 | bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, |
| 1748 | bool UseGlobal, QualType AllocType, bool IsArray, |
Sebastian Redl | faf6808 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 1749 | Expr **PlaceArgs, unsigned NumPlaceArgs, |
| 1750 | FunctionDecl *&OperatorNew, |
| 1751 | FunctionDecl *&OperatorDelete); |
Sebastian Redl | 1df2bbe | 2009-02-09 18:24:27 +0000 | [diff] [blame] | 1752 | bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, |
| 1753 | DeclarationName Name, Expr** Args, |
| 1754 | unsigned NumArgs, DeclContext *Ctx, |
Sebastian Redl | 33a3101 | 2008-12-04 22:20:51 +0000 | [diff] [blame] | 1755 | bool AllowMissing, FunctionDecl *&Operator); |
Sebastian Redl | faf6808 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 1756 | void DeclareGlobalNewDelete(); |
| 1757 | void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, |
| 1758 | QualType Argument); |
Sebastian Redl | bd150f4 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1759 | |
| 1760 | /// ActOnCXXDelete - Parsed a C++ 'delete' expression |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1761 | virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc, |
| 1762 | bool UseGlobal, bool ArrayForm, |
| 1763 | ExprArg Operand); |
Sebastian Redl | bd150f4 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1764 | |
Argyrios Kyrtzidis | 7620ee4 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 1765 | /// ActOnCXXConditionDeclarationExpr - Parsed a condition declaration of a |
| 1766 | /// C++ if/switch/while/for statement. |
| 1767 | /// e.g: "if (int x = f()) {...}" |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1768 | virtual OwningExprResult ActOnCXXConditionDeclarationExpr(Scope *S, |
Argyrios Kyrtzidis | 7620ee4 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 1769 | SourceLocation StartLoc, |
| 1770 | Declarator &D, |
| 1771 | SourceLocation EqualLoc, |
Sebastian Redl | 6d4256c | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1772 | ExprArg AssignExprVal); |
Argyrios Kyrtzidis | 7620ee4 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 1773 | |
Sebastian Redl | baad4e7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 1774 | /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support |
| 1775 | /// pseudo-functions. |
| 1776 | virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, |
| 1777 | SourceLocation KWLoc, |
| 1778 | SourceLocation LParen, |
| 1779 | TypeTy *Ty, |
| 1780 | SourceLocation RParen); |
| 1781 | |
Anders Carlsson | b3d05d6 | 2009-06-05 15:38:08 +0000 | [diff] [blame] | 1782 | /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is |
| 1783 | /// non-empty, will create a new CXXExprWithTemporaries expression. |
| 1784 | /// Otherwise, just returs the passed in expression. |
Anders Carlsson | a42ab8f | 2009-06-16 03:37:31 +0000 | [diff] [blame] | 1785 | Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr, |
| 1786 | bool ShouldDestroyTemporaries); |
Anders Carlsson | b3d05d6 | 2009-06-05 15:38:08 +0000 | [diff] [blame] | 1787 | |
Anders Carlsson | 85a307d | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 1788 | virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr); |
| 1789 | |
Douglas Gregor | 2689746 | 2009-03-11 16:48:53 +0000 | [diff] [blame] | 1790 | bool RequireCompleteDeclContext(const CXXScopeSpec &SS); |
Douglas Gregor | 5253768 | 2009-03-19 00:18:19 +0000 | [diff] [blame] | 1791 | |
Douglas Gregor | d8d297c | 2009-07-21 23:53:31 +0000 | [diff] [blame] | 1792 | DeclContext *computeDeclContext(const CXXScopeSpec &SS, |
| 1793 | bool EnteringContext = false); |
Douglas Gregor | 90a1a65 | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 1794 | bool isDependentScopeSpecifier(const CXXScopeSpec &SS); |
Douglas Gregor | c9f9b86 | 2009-05-11 19:58:34 +0000 | [diff] [blame] | 1795 | CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS); |
| 1796 | bool isUnknownSpecialization(const CXXScopeSpec &SS); |
Douglas Gregor | 6bfde49 | 2009-03-18 00:36:05 +0000 | [diff] [blame] | 1797 | |
Argyrios Kyrtzidis | 16ac9be | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1798 | /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the |
| 1799 | /// global scope ('::'). |
| 1800 | virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S, |
| 1801 | SourceLocation CCLoc); |
| 1802 | |
| 1803 | /// ActOnCXXNestedNameSpecifier - Called during parsing of a |
| 1804 | /// nested-name-specifier. e.g. for "foo::bar::" we parsed "foo::" and now |
| 1805 | /// we want to resolve "bar::". 'SS' is empty or the previously parsed |
| 1806 | /// nested-name part ("foo::"), 'IdLoc' is the source location of 'bar', |
| 1807 | /// 'CCLoc' is the location of '::' and 'II' is the identifier for 'bar'. |
| 1808 | /// Returns a CXXScopeTy* object representing the C++ scope. |
| 1809 | virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, |
| 1810 | const CXXScopeSpec &SS, |
| 1811 | SourceLocation IdLoc, |
| 1812 | SourceLocation CCLoc, |
Douglas Gregor | ae2fbad | 2008-11-17 20:34:05 +0000 | [diff] [blame] | 1813 | IdentifierInfo &II); |
Argyrios Kyrtzidis | 16ac9be | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1814 | |
Douglas Gregor | 7f74112 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 1815 | /// ActOnCXXNestedNameSpecifier - Called during parsing of a |
| 1816 | /// nested-name-specifier that involves a template-id, e.g., |
| 1817 | /// "foo::bar<int, float>::", and now we need to build a scope |
| 1818 | /// specifier. \p SS is empty or the previously parsed nested-name |
| 1819 | /// part ("foo::"), \p Type is the already-parsed class template |
| 1820 | /// specialization (or other template-id that names a type), \p |
| 1821 | /// TypeRange is the source range where the type is located, and \p |
| 1822 | /// CCLoc is the location of the trailing '::'. |
| 1823 | virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, |
| 1824 | const CXXScopeSpec &SS, |
| 1825 | TypeTy *Type, |
| 1826 | SourceRange TypeRange, |
| 1827 | SourceLocation CCLoc); |
| 1828 | |
Argyrios Kyrtzidis | 16ac9be | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1829 | /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global |
| 1830 | /// scope or nested-name-specifier) is parsed, part of a declarator-id. |
| 1831 | /// After this method is called, according to [C++ 3.4.3p3], names should be |
| 1832 | /// looked up in the declarator-id's scope, until the declarator is parsed and |
| 1833 | /// ActOnCXXExitDeclaratorScope is called. |
| 1834 | /// The 'SS' should be a non-empty valid CXXScopeSpec. |
| 1835 | virtual void ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
| 1836 | |
| 1837 | /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously |
| 1838 | /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same |
| 1839 | /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. |
| 1840 | /// Used to indicate that names should revert to being looked up in the |
| 1841 | /// defining scope. |
Douglas Gregor | 29e174c | 2008-12-16 00:38:16 +0000 | [diff] [blame] | 1842 | virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
Argyrios Kyrtzidis | 16ac9be | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 1843 | |
Argyrios Kyrtzidis | 3df1978 | 2009-06-17 22:50:06 +0000 | [diff] [blame] | 1844 | /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an |
| 1845 | /// initializer for the declaration 'Dcl'. |
| 1846 | /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a |
| 1847 | /// static data member of class X, names should be looked up in the scope of |
| 1848 | /// class X. |
| 1849 | virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl); |
| 1850 | |
| 1851 | /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an |
| 1852 | /// initializer for the declaration 'Dcl'. |
| 1853 | virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl); |
| 1854 | |
Anders Carlsson | 76f4a90 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 1855 | // ParseObjCStringLiteral - Parse Objective-C string literals. |
Chris Lattner | e002fbe | 2007-12-12 01:04:12 +0000 | [diff] [blame] | 1856 | virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, |
| 1857 | ExprTy **Strings, |
| 1858 | unsigned NumStrings); |
Anders Carlsson | 315d229 | 2009-06-07 18:45:35 +0000 | [diff] [blame] | 1859 | |
| 1860 | Expr *BuildObjCEncodeExpression(SourceLocation AtLoc, |
| 1861 | QualType EncodedType, |
| 1862 | SourceLocation RParenLoc); |
Anders Carlsson | c5a81eb | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 1863 | virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, |
Chris Lattner | 37390be | 2007-10-16 22:51:17 +0000 | [diff] [blame] | 1864 | SourceLocation EncodeLoc, |
Anders Carlsson | c5a81eb | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 1865 | SourceLocation LParenLoc, |
| 1866 | TypeTy *Ty, |
| 1867 | SourceLocation RParenLoc); |
| 1868 | |
Fariborz Jahanian | 4bef462 | 2007-10-16 20:40:23 +0000 | [diff] [blame] | 1869 | // ParseObjCSelectorExpression - Build selector expression for @selector |
| 1870 | virtual ExprResult ParseObjCSelectorExpression(Selector Sel, |
| 1871 | SourceLocation AtLoc, |
Fariborz Jahanian | 6bd1d61 | 2007-10-16 23:21:02 +0000 | [diff] [blame] | 1872 | SourceLocation SelLoc, |
Fariborz Jahanian | 4bef462 | 2007-10-16 20:40:23 +0000 | [diff] [blame] | 1873 | SourceLocation LParenLoc, |
| 1874 | SourceLocation RParenLoc); |
| 1875 | |
Fariborz Jahanian | a32aaef | 2007-10-17 16:58:11 +0000 | [diff] [blame] | 1876 | // ParseObjCProtocolExpression - Build protocol expression for @protocol |
| 1877 | virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, |
| 1878 | SourceLocation AtLoc, |
| 1879 | SourceLocation ProtoLoc, |
| 1880 | SourceLocation LParenLoc, |
| 1881 | SourceLocation RParenLoc); |
Douglas Gregor | 556877c | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 1882 | |
| 1883 | //===--------------------------------------------------------------------===// |
Douglas Gregor | 07665a6 | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 1884 | // C++ Declarations |
| 1885 | // |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1886 | virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S, |
| 1887 | SourceLocation ExternLoc, |
| 1888 | SourceLocation LangLoc, |
| 1889 | const char *Lang, |
| 1890 | unsigned StrSize, |
| 1891 | SourceLocation LBraceLoc); |
| 1892 | virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S, |
| 1893 | DeclPtrTy LinkageSpec, |
| 1894 | SourceLocation RBraceLoc); |
Douglas Gregor | 07665a6 | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 1895 | |
| 1896 | |
| 1897 | //===--------------------------------------------------------------------===// |
Douglas Gregor | 556877c | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 1898 | // C++ Classes |
| 1899 | // |
Argyrios Kyrtzidis | 32a0379 | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 1900 | virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S, |
| 1901 | const CXXScopeSpec *SS); |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 1902 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1903 | virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, |
| 1904 | Declarator &D, |
| 1905 | ExprTy *BitfieldWidth, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 1906 | ExprTy *Init, |
| 1907 | bool Deleted = false); |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1908 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1909 | virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD, |
Douglas Gregor | e8381c0 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 1910 | Scope *S, |
Fariborz Jahanian | 302bb66 | 2009-06-30 23:26:25 +0000 | [diff] [blame] | 1911 | const CXXScopeSpec &SS, |
Douglas Gregor | e8381c0 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 1912 | IdentifierInfo *MemberOrBase, |
Fariborz Jahanian | c1fc3ec | 2009-07-01 19:21:19 +0000 | [diff] [blame] | 1913 | TypeTy *TemplateTypeTy, |
Douglas Gregor | e8381c0 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 1914 | SourceLocation IdLoc, |
| 1915 | SourceLocation LParenLoc, |
| 1916 | ExprTy **Args, unsigned NumArgs, |
| 1917 | SourceLocation *CommaLocs, |
| 1918 | SourceLocation RParenLoc); |
| 1919 | |
Douglas Gregor | 0537942 | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 1920 | void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl); |
| 1921 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1922 | virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl, |
Anders Carlsson | 75fdaa4 | 2009-03-25 02:58:17 +0000 | [diff] [blame] | 1923 | SourceLocation ColonLoc, |
| 1924 | MemInitTy **MemInits, unsigned NumMemInits); |
| 1925 | |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1926 | virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1927 | DeclPtrTy TagDecl, |
Argyrios Kyrtzidis | ed98342 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1928 | SourceLocation LBrac, |
| 1929 | SourceLocation RBrac); |
| 1930 | |
Douglas Gregor | e44a2ad | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 1931 | virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1932 | virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, |
| 1933 | DeclPtrTy Method); |
| 1934 | virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param); |
| 1935 | virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, |
| 1936 | DeclPtrTy Method); |
Douglas Gregor | 4d87df5 | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 1937 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1938 | virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc, |
| 1939 | ExprArg AssertExpr, |
| 1940 | ExprArg AssertMessageExpr); |
Anders Carlsson | 5bbe1d7 | 2009-03-14 00:25:26 +0000 | [diff] [blame] | 1941 | |
Anders Carlsson | 3881170 | 2009-05-11 22:55:49 +0000 | [diff] [blame] | 1942 | virtual bool ActOnFriendDecl(Scope *S, SourceLocation FriendLoc, |
| 1943 | DeclPtrTy Dcl); |
| 1944 | |
Chris Lattner | 38378bf | 2009-04-25 08:28:21 +0000 | [diff] [blame] | 1945 | QualType CheckConstructorDeclarator(Declarator &D, QualType R, |
| 1946 | FunctionDecl::StorageClass& SC); |
Chris Lattner | b41df4f | 2009-04-25 08:35:12 +0000 | [diff] [blame] | 1947 | void CheckConstructor(CXXConstructorDecl *Constructor); |
Chris Lattner | 38378bf | 2009-04-25 08:28:21 +0000 | [diff] [blame] | 1948 | QualType CheckDestructorDeclarator(Declarator &D, |
| 1949 | FunctionDecl::StorageClass& SC); |
Chris Lattner | b41df4f | 2009-04-25 08:35:12 +0000 | [diff] [blame] | 1950 | void CheckConversionDeclarator(Declarator &D, QualType &R, |
Douglas Gregor | dbc5daf | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 1951 | FunctionDecl::StorageClass& SC); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1952 | DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion); |
Douglas Gregor | 61956c4 | 2008-10-31 09:07:45 +0000 | [diff] [blame] | 1953 | |
Douglas Gregor | 5c407d9 | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1954 | //===--------------------------------------------------------------------===// |
| 1955 | // C++ Derived Classes |
| 1956 | // |
| 1957 | |
| 1958 | /// ActOnBaseSpecifier - Parsed a base specifier |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1959 | CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class, |
| 1960 | SourceRange SpecifierRange, |
| 1961 | bool Virtual, AccessSpecifier Access, |
| 1962 | QualType BaseType, |
| 1963 | SourceLocation BaseLoc); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1964 | virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl, |
Douglas Gregor | 5c407d9 | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1965 | SourceRange SpecifierRange, |
| 1966 | bool Virtual, AccessSpecifier Access, |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1967 | TypeTy *basetype, SourceLocation |
| 1968 | BaseLoc); |
Douglas Gregor | 5c407d9 | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1969 | |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 1970 | bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, |
| 1971 | unsigned NumBases); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1972 | virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases, |
Douglas Gregor | 5c407d9 | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 1973 | unsigned NumBases); |
| 1974 | |
| 1975 | bool IsDerivedFrom(QualType Derived, QualType Base); |
Douglas Gregor | 39c16d4 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 1976 | bool IsDerivedFrom(QualType Derived, QualType Base, BasePaths &Paths); |
Douglas Gregor | 960b5bc | 2009-01-15 00:26:24 +0000 | [diff] [blame] | 1977 | bool LookupInBases(CXXRecordDecl *Class, const MemberLookupCriteria& Criteria, |
| 1978 | BasePaths &Paths); |
Douglas Gregor | cea4e743 | 2008-10-24 16:17:19 +0000 | [diff] [blame] | 1979 | bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, |
| 1980 | SourceLocation Loc, SourceRange Range); |
Anders Carlsson | 49d216d | 2009-05-13 21:11:42 +0000 | [diff] [blame] | 1981 | bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, |
| 1982 | unsigned InaccessibleBaseID, |
| 1983 | unsigned AmbigiousBaseConvID, |
| 1984 | SourceLocation Loc, SourceRange Range, |
| 1985 | DeclarationName Name); |
| 1986 | |
Douglas Gregor | 1c846b0 | 2009-01-16 00:38:09 +0000 | [diff] [blame] | 1987 | std::string getAmbiguousPathsDisplayString(BasePaths &Paths); |
Anders Carlsson | f2a2e33 | 2009-05-14 01:09:04 +0000 | [diff] [blame] | 1988 | |
Sebastian Redl | 86be854 | 2009-07-07 20:29:57 +0000 | [diff] [blame] | 1989 | /// CheckOverridingFunctionReturnType - Checks whether the return types are |
| 1990 | /// covariant, according to C++ [class.virtual]p5. |
| 1991 | bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, |
Anders Carlsson | f2a2e33 | 2009-05-14 01:09:04 +0000 | [diff] [blame] | 1992 | const CXXMethodDecl *Old); |
Sebastian Redl | 86be854 | 2009-07-07 20:29:57 +0000 | [diff] [blame] | 1993 | |
| 1994 | /// CheckOverridingFunctionExceptionSpec - Checks whether the exception |
| 1995 | /// spec is a subset of base spec. |
| 1996 | bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, |
| 1997 | const CXXMethodDecl *Old); |
Douglas Gregor | 556877c | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 1998 | |
Anders Carlsson | 4742a9c | 2009-03-27 05:05:05 +0000 | [diff] [blame] | 1999 | //===--------------------------------------------------------------------===// |
| 2000 | // C++ Access Control |
| 2001 | // |
Sebastian Redl | e644e19 | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2002 | |
Anders Carlsson | 4742a9c | 2009-03-27 05:05:05 +0000 | [diff] [blame] | 2003 | bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, |
| 2004 | NamedDecl *PrevMemberDecl, |
| 2005 | AccessSpecifier LexicalAS); |
Sebastian Redl | e644e19 | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2006 | |
| 2007 | const CXXBaseSpecifier *FindInaccessibleBase(QualType Derived, QualType Base, |
| 2008 | BasePaths &Paths, |
| 2009 | bool NoPrivileges = false); |
| 2010 | |
| 2011 | bool CheckBaseClassAccess(QualType Derived, QualType Base, |
Anders Carlsson | 49d216d | 2009-05-13 21:11:42 +0000 | [diff] [blame] | 2012 | unsigned InaccessibleBaseID, |
| 2013 | BasePaths& Paths, SourceLocation AccessLoc, |
| 2014 | DeclarationName Name); |
Sebastian Redl | e644e19 | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2015 | |
| 2016 | |
Anders Carlsson | b5a27b4 | 2009-03-24 01:19:16 +0000 | [diff] [blame] | 2017 | enum AbstractDiagSelID { |
| 2018 | AbstractNone = -1, |
| 2019 | AbstractReturnType, |
| 2020 | AbstractParamType, |
| 2021 | AbstractVariableType, |
| 2022 | AbstractFieldType |
| 2023 | }; |
| 2024 | |
| 2025 | bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, |
Anders Carlsson | b57738b | 2009-03-24 17:23:42 +0000 | [diff] [blame] | 2026 | AbstractDiagSelID SelID = AbstractNone, |
| 2027 | const CXXRecordDecl *CurrentRD = 0); |
Anders Carlsson | 576cc6f | 2009-03-22 20:18:17 +0000 | [diff] [blame] | 2028 | |
Douglas Gregor | 11d0c4c | 2008-11-06 22:13:31 +0000 | [diff] [blame] | 2029 | //===--------------------------------------------------------------------===// |
| 2030 | // C++ Overloaded Operators [C++ 13.5] |
| 2031 | // |
| 2032 | |
| 2033 | bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl); |
| 2034 | |
Douglas Gregor | 5101c24 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 2035 | //===--------------------------------------------------------------------===// |
| 2036 | // C++ Templates [C++ 14] |
| 2037 | // |
Douglas Gregor | b67535d | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 2038 | virtual TemplateNameKind isTemplateName(const IdentifierInfo &II, Scope *S, |
Douglas Gregor | dc572a3 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2039 | TemplateTy &Template, |
Douglas Gregor | 8bf4205 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2040 | const CXXScopeSpec *SS = 0); |
Douglas Gregor | 5101c24 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 2041 | bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2042 | TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl); |
Douglas Gregor | ded2d7b | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 2043 | |
Anders Carlsson | 01e9e93 | 2009-06-12 19:58:00 +0000 | [diff] [blame] | 2044 | virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, |
| 2045 | SourceLocation EllipsisLoc, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2046 | SourceLocation KeyLoc, |
| 2047 | IdentifierInfo *ParamName, |
| 2048 | SourceLocation ParamNameLoc, |
| 2049 | unsigned Depth, unsigned Position); |
| 2050 | virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam, |
Douglas Gregor | dba3263 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2051 | SourceLocation EqualLoc, |
| 2052 | SourceLocation DefaultLoc, |
| 2053 | TypeTy *Default); |
| 2054 | |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2055 | QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2056 | virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, |
| 2057 | unsigned Depth, |
| 2058 | unsigned Position); |
| 2059 | virtual void ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParam, |
Douglas Gregor | dba3263 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2060 | SourceLocation EqualLoc, |
| 2061 | ExprArg Default); |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2062 | virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S, |
| 2063 | SourceLocation TmpLoc, |
| 2064 | TemplateParamsTy *Params, |
| 2065 | IdentifierInfo *ParamName, |
| 2066 | SourceLocation ParamNameLoc, |
| 2067 | unsigned Depth, |
| 2068 | unsigned Position); |
| 2069 | virtual void ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParam, |
Douglas Gregor | dba3263 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2070 | SourceLocation EqualLoc, |
| 2071 | ExprArg Default); |
| 2072 | |
Douglas Gregor | b9bd8a9 | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 2073 | virtual TemplateParamsTy * |
| 2074 | ActOnTemplateParameterList(unsigned Depth, |
| 2075 | SourceLocation ExportLoc, |
| 2076 | SourceLocation TemplateLoc, |
| 2077 | SourceLocation LAngleLoc, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2078 | DeclPtrTy *Params, unsigned NumParams, |
Douglas Gregor | b9bd8a9 | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 2079 | SourceLocation RAngleLoc); |
Douglas Gregor | dba3263 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2080 | bool CheckTemplateParameterList(TemplateParameterList *NewParams, |
| 2081 | TemplateParameterList *OldParams); |
Douglas Gregor | d8d297c | 2009-07-21 23:53:31 +0000 | [diff] [blame] | 2082 | TemplateParameterList * |
| 2083 | MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, |
| 2084 | const CXXScopeSpec &SS, |
| 2085 | TemplateParameterList **ParamLists, |
| 2086 | unsigned NumParamLists); |
| 2087 | |
Douglas Gregor | c08f489 | 2009-03-25 00:13:59 +0000 | [diff] [blame] | 2088 | virtual DeclResult |
Douglas Gregor | cd72ba9 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2089 | ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK, |
| 2090 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 2091 | IdentifierInfo *Name, SourceLocation NameLoc, |
| 2092 | AttributeList *Attr, |
Anders Carlsson | dfbbdf6 | 2009-03-26 00:52:18 +0000 | [diff] [blame] | 2093 | MultiTemplateParamsArg TemplateParameterLists, |
| 2094 | AccessSpecifier AS); |
Douglas Gregor | cd72ba9 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2095 | |
Douglas Gregor | dc572a3 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2096 | QualType CheckTemplateIdType(TemplateName Template, |
| 2097 | SourceLocation TemplateLoc, |
| 2098 | SourceLocation LAngleLoc, |
| 2099 | const TemplateArgument *TemplateArgs, |
| 2100 | unsigned NumTemplateArgs, |
| 2101 | SourceLocation RAngleLoc); |
Douglas Gregor | c40290e | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 2102 | |
Douglas Gregor | 67a6564 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2103 | virtual TypeResult |
Douglas Gregor | dc572a3 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2104 | ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc, |
| 2105 | SourceLocation LAngleLoc, |
| 2106 | ASTTemplateArgsPtr TemplateArgs, |
| 2107 | SourceLocation *TemplateArgLocs, |
| 2108 | SourceLocation RAngleLoc); |
Douglas Gregor | 67a6564 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2109 | |
Douglas Gregor | a727cb9 | 2009-06-30 22:34:41 +0000 | [diff] [blame] | 2110 | OwningExprResult BuildTemplateIdExpr(TemplateName Template, |
| 2111 | SourceLocation TemplateNameLoc, |
| 2112 | SourceLocation LAngleLoc, |
| 2113 | const TemplateArgument *TemplateArgs, |
| 2114 | unsigned NumTemplateArgs, |
| 2115 | SourceLocation RAngleLoc); |
| 2116 | |
| 2117 | virtual OwningExprResult ActOnTemplateIdExpr(TemplateTy Template, |
| 2118 | SourceLocation TemplateNameLoc, |
| 2119 | SourceLocation LAngleLoc, |
| 2120 | ASTTemplateArgsPtr TemplateArgs, |
| 2121 | SourceLocation *TemplateArgLocs, |
| 2122 | SourceLocation RAngleLoc); |
| 2123 | |
Douglas Gregor | b67535d | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 2124 | virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc, |
| 2125 | const IdentifierInfo &Name, |
| 2126 | SourceLocation NameLoc, |
| 2127 | const CXXScopeSpec &SS); |
| 2128 | |
Douglas Gregor | f47b911 | 2009-02-25 22:02:03 +0000 | [diff] [blame] | 2129 | bool CheckClassTemplateSpecializationScope(ClassTemplateDecl *ClassTemplate, |
| 2130 | ClassTemplateSpecializationDecl *PrevDecl, |
| 2131 | SourceLocation TemplateNameLoc, |
Douglas Gregor | f61eca9 | 2009-05-13 18:28:20 +0000 | [diff] [blame] | 2132 | SourceRange ScopeSpecifierRange, |
Douglas Gregor | 30b0197 | 2009-06-12 22:21:45 +0000 | [diff] [blame] | 2133 | bool PartialSpecialization, |
Douglas Gregor | f61eca9 | 2009-05-13 18:28:20 +0000 | [diff] [blame] | 2134 | bool ExplicitInstantiation); |
Douglas Gregor | f47b911 | 2009-02-25 22:02:03 +0000 | [diff] [blame] | 2135 | |
Douglas Gregor | 8cfd2ba | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 2136 | bool CheckClassTemplatePartialSpecializationArgs( |
| 2137 | TemplateParameterList *TemplateParams, |
Anders Carlsson | 40c1d49 | 2009-06-13 18:20:51 +0000 | [diff] [blame] | 2138 | const TemplateArgumentListBuilder &TemplateArgs, |
Douglas Gregor | 09a3023 | 2009-06-12 22:08:06 +0000 | [diff] [blame] | 2139 | bool &MirrorsPrimaryTemplate); |
Douglas Gregor | 8cfd2ba | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 2140 | |
Douglas Gregor | c08f489 | 2009-03-25 00:13:59 +0000 | [diff] [blame] | 2141 | virtual DeclResult |
Douglas Gregor | 67a6564 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2142 | ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagKind TK, |
| 2143 | SourceLocation KWLoc, |
| 2144 | const CXXScopeSpec &SS, |
Douglas Gregor | dc572a3 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2145 | TemplateTy Template, |
Douglas Gregor | 67a6564 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2146 | SourceLocation TemplateNameLoc, |
Douglas Gregor | 8bf4205 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2147 | SourceLocation LAngleLoc, |
Douglas Gregor | 67b556a | 2009-02-09 19:34:22 +0000 | [diff] [blame] | 2148 | ASTTemplateArgsPtr TemplateArgs, |
Douglas Gregor | d32e028 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2149 | SourceLocation *TemplateArgLocs, |
Douglas Gregor | 8bf4205 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2150 | SourceLocation RAngleLoc, |
Douglas Gregor | 67a6564 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2151 | AttributeList *Attr, |
| 2152 | MultiTemplateParamsArg TemplateParameterLists); |
Douglas Gregor | 8bf4205 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2153 | |
Douglas Gregor | b52fabb | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 2154 | virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S, |
| 2155 | MultiTemplateParamsArg TemplateParameterLists, |
| 2156 | Declarator &D); |
| 2157 | |
Douglas Gregor | 17a7c12 | 2009-06-24 00:54:41 +0000 | [diff] [blame] | 2158 | virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope, |
| 2159 | MultiTemplateParamsArg TemplateParameterLists, |
| 2160 | Declarator &D); |
| 2161 | |
Douglas Gregor | a1f4997 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 2162 | virtual DeclResult |
| 2163 | ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc, |
| 2164 | unsigned TagSpec, |
| 2165 | SourceLocation KWLoc, |
| 2166 | const CXXScopeSpec &SS, |
| 2167 | TemplateTy Template, |
| 2168 | SourceLocation TemplateNameLoc, |
| 2169 | SourceLocation LAngleLoc, |
| 2170 | ASTTemplateArgsPtr TemplateArgs, |
| 2171 | SourceLocation *TemplateArgLocs, |
| 2172 | SourceLocation RAngleLoc, |
| 2173 | AttributeList *Attr); |
| 2174 | |
Douglas Gregor | 2ec748c | 2009-05-14 00:28:11 +0000 | [diff] [blame] | 2175 | virtual DeclResult |
| 2176 | ActOnExplicitInstantiation(Scope *S, SourceLocation TemplateLoc, |
| 2177 | unsigned TagSpec, |
| 2178 | SourceLocation KWLoc, |
| 2179 | const CXXScopeSpec &SS, |
| 2180 | IdentifierInfo *Name, |
| 2181 | SourceLocation NameLoc, |
| 2182 | AttributeList *Attr); |
| 2183 | |
Douglas Gregor | d32e028 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2184 | bool CheckTemplateArgumentList(TemplateDecl *Template, |
| 2185 | SourceLocation TemplateLoc, |
| 2186 | SourceLocation LAngleLoc, |
Douglas Gregor | c40290e | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 2187 | const TemplateArgument *TemplateArgs, |
| 2188 | unsigned NumTemplateArgs, |
Douglas Gregor | 264ec4f | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 2189 | SourceLocation RAngleLoc, |
Douglas Gregor | e3f1f35 | 2009-07-01 00:28:38 +0000 | [diff] [blame] | 2190 | bool PartialTemplateArgs, |
Anders Carlsson | 8aa89d4 | 2009-06-05 03:43:12 +0000 | [diff] [blame] | 2191 | TemplateArgumentListBuilder &Converted); |
Douglas Gregor | d32e028 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2192 | |
Anders Carlsson | c8cbb2d | 2009-06-13 00:33:33 +0000 | [diff] [blame] | 2193 | bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, |
| 2194 | const TemplateArgument &Arg, |
| 2195 | TemplateArgumentListBuilder &Converted); |
| 2196 | |
Douglas Gregor | d32e028 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2197 | bool CheckTemplateArgument(TemplateTypeParmDecl *Param, QualType Arg, |
| 2198 | SourceLocation ArgLoc); |
Douglas Gregor | 264ec4f | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 2199 | bool CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg, |
| 2200 | NamedDecl *&Entity); |
| 2201 | bool CheckTemplateArgumentPointerToMember(Expr *Arg, NamedDecl *&Member); |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2202 | bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param, |
| 2203 | QualType InstantiatedParamType, Expr *&Arg, |
Douglas Gregor | 74eba0b | 2009-06-11 18:10:32 +0000 | [diff] [blame] | 2204 | TemplateArgument &Converted); |
Douglas Gregor | d32e028 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2205 | bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, DeclRefExpr *Arg); |
Douglas Gregor | cd72ba9 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2206 | bool TemplateParameterListsAreEqual(TemplateParameterList *New, |
| 2207 | TemplateParameterList *Old, |
| 2208 | bool Complain, |
Douglas Gregor | 85e0f66 | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 2209 | bool IsTemplateTemplateParm = false, |
| 2210 | SourceLocation TemplateArgLoc |
| 2211 | = SourceLocation()); |
Douglas Gregor | cd72ba9 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2212 | |
| 2213 | bool CheckTemplateDeclScope(Scope *S, |
| 2214 | MultiTemplateParamsArg &TemplateParameterLists); |
Douglas Gregor | ded2d7b | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 2215 | |
Douglas Gregor | 333489b | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 2216 | /// \brief Called when the parser has parsed a C++ typename |
| 2217 | /// specifier, e.g., "typename T::type". |
| 2218 | /// |
| 2219 | /// \param TypenameLoc the location of the 'typename' keyword |
| 2220 | /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). |
| 2221 | /// \param II the identifier we're retrieving (e.g., 'type' in the example). |
| 2222 | /// \param IdLoc the location of the identifier. |
| 2223 | virtual TypeResult |
| 2224 | ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS, |
| 2225 | const IdentifierInfo &II, SourceLocation IdLoc); |
Douglas Gregor | dce2b62 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 2226 | |
| 2227 | /// \brief Called when the parser has parsed a C++ typename |
| 2228 | /// specifier that ends in a template-id, e.g., |
| 2229 | /// "typename MetaFun::template apply<T1, T2>". |
| 2230 | /// |
| 2231 | /// \param TypenameLoc the location of the 'typename' keyword |
| 2232 | /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). |
| 2233 | /// \param TemplateLoc the location of the 'template' keyword, if any. |
| 2234 | /// \param Ty the type that the typename specifier refers to. |
| 2235 | virtual TypeResult |
| 2236 | ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS, |
| 2237 | SourceLocation TemplateLoc, TypeTy *Ty); |
| 2238 | |
Douglas Gregor | 333489b | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 2239 | QualType CheckTypenameType(NestedNameSpecifier *NNS, |
| 2240 | const IdentifierInfo &II, |
| 2241 | SourceRange Range); |
Douglas Gregor | 2373c59 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 2242 | |
Douglas Gregor | 181aa4a | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2243 | /// \brief Describes the result of template argument deduction. |
| 2244 | /// |
| 2245 | /// The TemplateDeductionResult enumeration describes the result of |
| 2246 | /// template argument deduction, as returned from |
| 2247 | /// DeduceTemplateArguments(). The separate TemplateDeductionInfo |
| 2248 | /// structure provides additional information about the results of |
| 2249 | /// template argument deduction, e.g., the deduced template argument |
| 2250 | /// list (if successful) or the specific template parameters or |
| 2251 | /// deduced arguments that were involved in the failure. |
| 2252 | enum TemplateDeductionResult { |
| 2253 | /// \brief Template argument deduction was successful. |
| 2254 | TDK_Success = 0, |
| 2255 | /// \brief Template argument deduction exceeded the maximum template |
| 2256 | /// instantiation depth (which has already been diagnosed). |
| 2257 | TDK_InstantiationDepth, |
| 2258 | /// \brief Template argument deduction did not deduce a value |
| 2259 | /// for every template parameter. |
| 2260 | TDK_Incomplete, |
| 2261 | /// \brief Template argument deduction produced inconsistent |
| 2262 | /// deduced values for the given template parameter. |
| 2263 | TDK_Inconsistent, |
| 2264 | /// \brief Template argument deduction failed due to inconsistent |
| 2265 | /// cv-qualifiers on a template parameter type that would |
| 2266 | /// otherwise be deduced, e.g., we tried to deduce T in "const T" |
| 2267 | /// but were given a non-const "X". |
| 2268 | TDK_InconsistentQuals, |
| 2269 | /// \brief Substitution of the deduced template argument values |
| 2270 | /// resulted in an error. |
| 2271 | TDK_SubstitutionFailure, |
| 2272 | /// \brief Substitution of the deduced template argument values |
| 2273 | /// into a non-deduced context produced a type or value that |
| 2274 | /// produces a type that does not match the original template |
| 2275 | /// arguments provided. |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2276 | TDK_NonDeducedMismatch, |
| 2277 | /// \brief When performing template argument deduction for a function |
| 2278 | /// template, there were too many call arguments. |
| 2279 | TDK_TooManyArguments, |
Douglas Gregor | e81f3e7 | 2009-07-07 23:09:34 +0000 | [diff] [blame] | 2280 | /// \brief When performing template argument deduction for a function |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2281 | /// template, there were too few call arguments. |
Douglas Gregor | 89026b5 | 2009-06-30 23:57:56 +0000 | [diff] [blame] | 2282 | TDK_TooFewArguments, |
| 2283 | /// \brief The explicitly-specified template arguments were not valid |
| 2284 | /// template arguments for the given template. |
| 2285 | TDK_InvalidExplicitArguments |
Douglas Gregor | 181aa4a | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2286 | }; |
| 2287 | |
| 2288 | /// \brief Provides information about an attempted template argument |
| 2289 | /// deduction, whose success or failure was described by a |
| 2290 | /// TemplateDeductionResult value. |
| 2291 | class TemplateDeductionInfo { |
| 2292 | /// \brief The context in which the template arguments are stored. |
| 2293 | ASTContext &Context; |
| 2294 | |
| 2295 | /// \brief The deduced template argument list. |
| 2296 | /// |
| 2297 | TemplateArgumentList *Deduced; |
| 2298 | |
| 2299 | // do not implement these |
| 2300 | TemplateDeductionInfo(const TemplateDeductionInfo&); |
| 2301 | TemplateDeductionInfo &operator=(const TemplateDeductionInfo&); |
| 2302 | |
| 2303 | public: |
| 2304 | TemplateDeductionInfo(ASTContext &Context) : Context(Context), Deduced(0) { } |
| 2305 | |
| 2306 | ~TemplateDeductionInfo() { |
| 2307 | // FIXME: if (Deduced) Deduced->Destroy(Context); |
| 2308 | } |
| 2309 | |
| 2310 | /// \brief Take ownership of the deduced template argument list. |
| 2311 | TemplateArgumentList *take() { |
| 2312 | TemplateArgumentList *Result = Deduced; |
| 2313 | Deduced = 0; |
| 2314 | return Result; |
| 2315 | } |
| 2316 | |
| 2317 | /// \brief Provide a new template argument list that contains the |
| 2318 | /// results of template argument deduction. |
| 2319 | void reset(TemplateArgumentList *NewDeduced) { |
| 2320 | // FIXME: if (Deduced) Deduced->Destroy(Context); |
| 2321 | Deduced = NewDeduced; |
| 2322 | } |
| 2323 | |
| 2324 | /// \brief The template parameter to which a template argument |
| 2325 | /// deduction failure refers. |
| 2326 | /// |
| 2327 | /// Depending on the result of template argument deduction, this |
| 2328 | /// template parameter may have different meanings: |
| 2329 | /// |
| 2330 | /// TDK_Incomplete: this is the first template parameter whose |
| 2331 | /// corresponding template argument was not deduced. |
| 2332 | /// |
| 2333 | /// TDK_Inconsistent: this is the template parameter for which |
| 2334 | /// two different template argument values were deduced. |
| 2335 | TemplateParameter Param; |
| 2336 | |
| 2337 | /// \brief The first template argument to which the template |
| 2338 | /// argument deduction failure refers. |
| 2339 | /// |
| 2340 | /// Depending on the result of the template argument deduction, |
| 2341 | /// this template argument may have different meanings: |
| 2342 | /// |
| 2343 | /// TDK_Inconsistent: this argument is the first value deduced |
| 2344 | /// for the corresponding template parameter. |
| 2345 | /// |
| 2346 | /// TDK_SubstitutionFailure: this argument is the template |
| 2347 | /// argument we were instantiating when we encountered an error. |
| 2348 | /// |
| 2349 | /// TDK_NonDeducedMismatch: this is the template argument |
| 2350 | /// provided in the source code. |
| 2351 | TemplateArgument FirstArg; |
| 2352 | |
| 2353 | /// \brief The second template argument to which the template |
| 2354 | /// argument deduction failure refers. |
| 2355 | /// |
| 2356 | /// FIXME: Finish documenting this. |
| 2357 | TemplateArgument SecondArg; |
| 2358 | }; |
| 2359 | |
| 2360 | TemplateDeductionResult |
Douglas Gregor | b7ae10f | 2009-06-05 00:53:49 +0000 | [diff] [blame] | 2361 | DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, |
Douglas Gregor | 181aa4a | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2362 | const TemplateArgumentList &TemplateArgs, |
| 2363 | TemplateDeductionInfo &Info); |
Douglas Gregor | 9b14658 | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2364 | |
| 2365 | TemplateDeductionResult |
| 2366 | SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
| 2367 | const TemplateArgument *ExplicitTemplateArgs, |
| 2368 | unsigned NumExplicitTemplateArgs, |
| 2369 | llvm::SmallVectorImpl<TemplateArgument> &Deduced, |
| 2370 | llvm::SmallVectorImpl<QualType> &ParamTypes, |
| 2371 | QualType *FunctionType, |
| 2372 | TemplateDeductionInfo &Info); |
| 2373 | |
| 2374 | TemplateDeductionResult |
| 2375 | FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, |
| 2376 | llvm::SmallVectorImpl<TemplateArgument> &Deduced, |
| 2377 | FunctionDecl *&Specialization, |
| 2378 | TemplateDeductionInfo &Info); |
| 2379 | |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2380 | TemplateDeductionResult |
| 2381 | DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
Douglas Gregor | 89026b5 | 2009-06-30 23:57:56 +0000 | [diff] [blame] | 2382 | bool HasExplicitTemplateArgs, |
| 2383 | const TemplateArgument *ExplicitTemplateArgs, |
| 2384 | unsigned NumExplicitTemplateArgs, |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2385 | Expr **Args, unsigned NumArgs, |
| 2386 | FunctionDecl *&Specialization, |
| 2387 | TemplateDeductionInfo &Info); |
Douglas Gregor | 9b14658 | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2388 | |
| 2389 | TemplateDeductionResult |
| 2390 | DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
| 2391 | bool HasExplicitTemplateArgs, |
| 2392 | const TemplateArgument *ExplicitTemplateArgs, |
| 2393 | unsigned NumExplicitTemplateArgs, |
| 2394 | QualType ArgFunctionType, |
| 2395 | FunctionDecl *&Specialization, |
| 2396 | TemplateDeductionInfo &Info); |
Douglas Gregor | ad3f2fc | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2397 | |
Douglas Gregor | 91772d1 | 2009-06-13 00:26:55 +0000 | [diff] [blame] | 2398 | void MarkDeducedTemplateParameters(const TemplateArgumentList &TemplateArgs, |
| 2399 | llvm::SmallVectorImpl<bool> &Deduced); |
| 2400 | |
Douglas Gregor | fe1e110 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 2401 | //===--------------------------------------------------------------------===// |
| 2402 | // C++ Template Instantiation |
| 2403 | // |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2404 | |
Douglas Gregor | b485046 | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 2405 | const TemplateArgumentList &getTemplateInstantiationArgs(NamedDecl *D); |
| 2406 | |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2407 | /// \brief A template instantiation that is currently in progress. |
| 2408 | struct ActiveTemplateInstantiation { |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2409 | /// \brief The kind of template instantiation we are performing |
Douglas Gregor | ff6cbdf | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2410 | enum InstantiationKind { |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2411 | /// We are instantiating a template declaration. The entity is |
Douglas Gregor | 923feac | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 2412 | /// the declaration we're instantiating (e.g., a CXXRecordDecl). |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2413 | TemplateInstantiation, |
| 2414 | |
| 2415 | /// We are instantiating a default argument for a template |
| 2416 | /// parameter. The Entity is the template, and |
| 2417 | /// TemplateArgs/NumTemplateArguments provides the template |
| 2418 | /// arguments as specified. |
Douglas Gregor | 637d998 | 2009-06-10 23:47:09 +0000 | [diff] [blame] | 2419 | /// FIXME: Use a TemplateArgumentList |
| 2420 | DefaultTemplateArgumentInstantiation, |
| 2421 | |
Douglas Gregor | ff6cbdf | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2422 | /// We are substituting explicit template arguments provided for |
| 2423 | /// a function template. The entity is a FunctionTemplateDecl. |
| 2424 | ExplicitTemplateArgumentSubstitution, |
| 2425 | |
| 2426 | /// We are substituting template argument determined as part of |
| 2427 | /// template argument deduction for either a class template |
| 2428 | /// partial specialization or a function template. The |
| 2429 | /// Entity is either a ClassTemplatePartialSpecializationDecl or |
| 2430 | /// a FunctionTemplateDecl. |
| 2431 | DeducedTemplateArgumentSubstitution |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2432 | } Kind; |
| 2433 | |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2434 | /// \brief The point of instantiation within the source code. |
| 2435 | SourceLocation PointOfInstantiation; |
| 2436 | |
| 2437 | /// \brief The entity that is being instantiated. |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2438 | uintptr_t Entity; |
| 2439 | |
| 2440 | // \brief If this the instantiation of a default template |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2441 | // argument, the list of template arguments. |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2442 | const TemplateArgument *TemplateArgs; |
| 2443 | |
| 2444 | /// \brief The number of template arguments in TemplateArgs. |
| 2445 | unsigned NumTemplateArgs; |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2446 | |
| 2447 | /// \brief The source range that covers the construct that cause |
| 2448 | /// the instantiation, e.g., the template-id that causes a class |
| 2449 | /// template instantiation. |
| 2450 | SourceRange InstantiationRange; |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2451 | |
| 2452 | friend bool operator==(const ActiveTemplateInstantiation &X, |
| 2453 | const ActiveTemplateInstantiation &Y) { |
| 2454 | if (X.Kind != Y.Kind) |
| 2455 | return false; |
| 2456 | |
| 2457 | if (X.Entity != Y.Entity) |
| 2458 | return false; |
| 2459 | |
| 2460 | switch (X.Kind) { |
| 2461 | case TemplateInstantiation: |
| 2462 | return true; |
| 2463 | |
| 2464 | case DefaultTemplateArgumentInstantiation: |
Douglas Gregor | ff6cbdf | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2465 | case ExplicitTemplateArgumentSubstitution: |
| 2466 | case DeducedTemplateArgumentSubstitution: |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2467 | return X.TemplateArgs == Y.TemplateArgs; |
| 2468 | } |
| 2469 | |
| 2470 | return true; |
| 2471 | } |
| 2472 | |
| 2473 | friend bool operator!=(const ActiveTemplateInstantiation &X, |
| 2474 | const ActiveTemplateInstantiation &Y) { |
| 2475 | return !(X == Y); |
| 2476 | } |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2477 | }; |
| 2478 | |
| 2479 | /// \brief List of active template instantiations. |
| 2480 | /// |
| 2481 | /// This vector is treated as a stack. As one template instantiation |
| 2482 | /// requires another template instantiation, additional |
| 2483 | /// instantiations are pushed onto the stack up to a |
| 2484 | /// user-configurable limit LangOptions::InstantiationDepth. |
| 2485 | llvm::SmallVector<ActiveTemplateInstantiation, 16> |
| 2486 | ActiveTemplateInstantiations; |
| 2487 | |
Douglas Gregor | 2a72edd | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 2488 | /// \brief The last template from which a template instantiation |
| 2489 | /// error or warning was produced. |
| 2490 | /// |
| 2491 | /// This value is used to suppress printing of redundant template |
| 2492 | /// instantiation backtraces when there are multiple errors in the |
| 2493 | /// same instantiation. FIXME: Does this belong in Sema? It's tough |
| 2494 | /// to implement it anywhere else. |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2495 | ActiveTemplateInstantiation LastTemplateInstantiationErrorContext; |
Douglas Gregor | 2a72edd | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 2496 | |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2497 | /// \brief A stack object to be created when performing template |
| 2498 | /// instantiation. |
| 2499 | /// |
| 2500 | /// Construction of an object of type \c InstantiatingTemplate |
| 2501 | /// pushes the current instantiation onto the stack of active |
| 2502 | /// instantiations. If the size of this stack exceeds the maximum |
| 2503 | /// number of recursive template instantiations, construction |
| 2504 | /// produces an error and evaluates true. |
| 2505 | /// |
| 2506 | /// Destruction of this object will pop the named instantiation off |
| 2507 | /// the stack. |
| 2508 | struct InstantiatingTemplate { |
Douglas Gregor | 8567358 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 2509 | /// \brief Note that we are instantiating a class template, |
| 2510 | /// function template, or a member thereof. |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2511 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
Douglas Gregor | 8567358 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 2512 | Decl *Entity, |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2513 | SourceRange InstantiationRange = SourceRange()); |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2514 | |
| 2515 | /// \brief Note that we are instantiating a default argument in a |
| 2516 | /// template-id. |
| 2517 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 2518 | TemplateDecl *Template, |
| 2519 | const TemplateArgument *TemplateArgs, |
| 2520 | unsigned NumTemplateArgs, |
| 2521 | SourceRange InstantiationRange = SourceRange()); |
| 2522 | |
Douglas Gregor | ff6cbdf | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2523 | /// \brief Note that we are instantiating a default argument in a |
| 2524 | /// template-id. |
| 2525 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 2526 | FunctionTemplateDecl *FunctionTemplate, |
| 2527 | const TemplateArgument *TemplateArgs, |
| 2528 | unsigned NumTemplateArgs, |
| 2529 | ActiveTemplateInstantiation::InstantiationKind Kind, |
| 2530 | SourceRange InstantiationRange = SourceRange()); |
| 2531 | |
Douglas Gregor | 637d998 | 2009-06-10 23:47:09 +0000 | [diff] [blame] | 2532 | /// \brief Note that we are instantiating as part of template |
| 2533 | /// argument deduction for a class template partial |
| 2534 | /// specialization. |
| 2535 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 2536 | ClassTemplatePartialSpecializationDecl *PartialSpec, |
| 2537 | const TemplateArgument *TemplateArgs, |
| 2538 | unsigned NumTemplateArgs, |
| 2539 | SourceRange InstantiationRange = SourceRange()); |
| 2540 | |
Douglas Gregor | 8567358 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 2541 | /// \brief Note that we have finished instantiating this template. |
| 2542 | void Clear(); |
| 2543 | |
| 2544 | ~InstantiatingTemplate() { Clear(); } |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2545 | |
| 2546 | /// \brief Determines whether we have exceeded the maximum |
| 2547 | /// recursive template instantiations. |
| 2548 | operator bool() const { return Invalid; } |
| 2549 | |
| 2550 | private: |
| 2551 | Sema &SemaRef; |
| 2552 | bool Invalid; |
| 2553 | |
Douglas Gregor | 79cf603 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2554 | bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, |
| 2555 | SourceRange InstantiationRange); |
| 2556 | |
Douglas Gregor | fcd5db3 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2557 | InstantiatingTemplate(const InstantiatingTemplate&); // not implemented |
| 2558 | |
| 2559 | InstantiatingTemplate& |
| 2560 | operator=(const InstantiatingTemplate&); // not implemented |
| 2561 | }; |
| 2562 | |
Douglas Gregor | 4ea568f | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 2563 | void PrintInstantiationStack(); |
| 2564 | |
Douglas Gregor | 3383451 | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 2565 | /// \brief Determines whether we are currently in a context where |
| 2566 | /// template argument substitution failures are not considered |
| 2567 | /// errors. |
| 2568 | /// |
| 2569 | /// When this routine returns true, the emission of most diagnostics |
| 2570 | /// will be suppressed and there will be no local error recovery. |
| 2571 | bool isSFINAEContext() const; |
| 2572 | |
Douglas Gregor | e141633 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 2573 | /// \brief RAII class used to determine whether SFINAE has |
| 2574 | /// trapped any errors that occur during template argument |
| 2575 | /// deduction. |
| 2576 | class SFINAETrap { |
| 2577 | Sema &SemaRef; |
| 2578 | unsigned PrevSFINAEErrors; |
| 2579 | public: |
| 2580 | explicit SFINAETrap(Sema &SemaRef) |
| 2581 | : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors) { } |
| 2582 | |
| 2583 | ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; } |
| 2584 | |
| 2585 | /// \brief Determine whether any SFINAE errors have been trapped. |
| 2586 | bool hasErrorOccurred() const { |
| 2587 | return SemaRef.NumSFINAEErrors > PrevSFINAEErrors; |
| 2588 | } |
| 2589 | }; |
| 2590 | |
Douglas Gregor | 3725652 | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 2591 | /// \brief A stack-allocated class that identifies which local |
| 2592 | /// variable declaration instantiations are present in this scope. |
| 2593 | /// |
| 2594 | /// A new instance of this class type will be created whenever we |
| 2595 | /// instantiate a new function declaration, which will have its own |
| 2596 | /// set of parameter declarations. |
| 2597 | class LocalInstantiationScope { |
| 2598 | /// \brief Reference to the semantic analysis that is performing |
| 2599 | /// this template instantiation. |
| 2600 | Sema &SemaRef; |
| 2601 | |
Douglas Gregor | 5178331 | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 2602 | /// \brief A mapping from local declarations that occur |
Douglas Gregor | 3725652 | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 2603 | /// within a template to their instantiations. |
| 2604 | /// |
| 2605 | /// This mapping is used during instantiation to keep track of, |
| 2606 | /// e.g., function parameter and variable declarations. For example, |
| 2607 | /// given: |
| 2608 | /// |
| 2609 | /// \code |
| 2610 | /// template<typename T> T add(T x, T y) { return x + y; } |
| 2611 | /// \endcode |
| 2612 | /// |
| 2613 | /// when we instantiate add<int>, we will introduce a mapping from |
| 2614 | /// the ParmVarDecl for 'x' that occurs in the template to the |
| 2615 | /// instantiated ParmVarDecl for 'x'. |
Douglas Gregor | 5178331 | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 2616 | llvm::DenseMap<const Decl *, Decl *> LocalDecls; |
Douglas Gregor | 3725652 | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 2617 | |
| 2618 | /// \brief The outer scope, in which contains local variable |
| 2619 | /// definitions from some other instantiation (that is not |
| 2620 | /// relevant to this particular scope). |
| 2621 | LocalInstantiationScope *Outer; |
| 2622 | |
| 2623 | // This class is non-copyable |
| 2624 | LocalInstantiationScope(const LocalInstantiationScope &); |
| 2625 | LocalInstantiationScope &operator=(const LocalInstantiationScope &); |
| 2626 | |
| 2627 | public: |
| 2628 | LocalInstantiationScope(Sema &SemaRef) |
| 2629 | : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) { |
| 2630 | SemaRef.CurrentInstantiationScope = this; |
| 2631 | } |
| 2632 | |
| 2633 | ~LocalInstantiationScope() { |
| 2634 | SemaRef.CurrentInstantiationScope = Outer; |
| 2635 | } |
| 2636 | |
Douglas Gregor | 5178331 | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 2637 | Decl *getInstantiationOf(const Decl *D) { |
| 2638 | Decl *Result = LocalDecls[D]; |
| 2639 | assert(Result && "declaration was not instantiated in this scope!"); |
Douglas Gregor | 3725652 | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 2640 | return Result; |
| 2641 | } |
| 2642 | |
Douglas Gregor | 5178331 | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 2643 | VarDecl *getInstantiationOf(const VarDecl *Var) { |
| 2644 | return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var))); |
Douglas Gregor | 3725652 | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 2645 | } |
| 2646 | |
Douglas Gregor | 5178331 | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 2647 | ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) { |
| 2648 | return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var))); |
| 2649 | } |
| 2650 | |
| 2651 | void InstantiatedLocal(const Decl *D, Decl *Inst) { |
| 2652 | Decl *&Stored = LocalDecls[D]; |
| 2653 | assert(!Stored && "Already instantiated this local"); |
| 2654 | Stored = Inst; |
Douglas Gregor | 3725652 | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 2655 | } |
| 2656 | }; |
| 2657 | |
| 2658 | /// \brief The current instantiation scope used to store local |
| 2659 | /// variables. |
| 2660 | LocalInstantiationScope *CurrentInstantiationScope; |
| 2661 | |
Douglas Gregor | 77b50e1 | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 2662 | /// \brief An entity for which implicit template instantiation is required. |
| 2663 | /// |
| 2664 | /// The source location associated with the declaration is the first place in |
| 2665 | /// the source code where the declaration was "used". It is not necessarily |
| 2666 | /// the point of instantiation (which will be either before or after the |
| 2667 | /// namespace-scope declaration that triggered this implicit instantiation), |
| 2668 | /// However, it is the location that diagnostics should generally refer to, |
| 2669 | /// because users will need to know what code triggered the instantiation. |
| 2670 | typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation; |
| 2671 | |
| 2672 | /// \brief The queue of implicit template instantiations that are required |
| 2673 | /// but have not yet been performed. |
Douglas Gregor | dda7ced | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 2674 | std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations; |
Douglas Gregor | 77b50e1 | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 2675 | |
| 2676 | void PerformPendingImplicitInstantiations(); |
| 2677 | |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2678 | QualType InstantiateType(QualType T, const TemplateArgumentList &TemplateArgs, |
Douglas Gregor | fe1e110 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 2679 | SourceLocation Loc, DeclarationName Entity); |
Douglas Gregor | b7ae10f | 2009-06-05 00:53:49 +0000 | [diff] [blame] | 2680 | |
Douglas Gregor | 573c746 | 2009-03-12 16:53:44 +0000 | [diff] [blame] | 2681 | OwningExprResult InstantiateExpr(Expr *E, |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2682 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | 573c746 | 2009-03-12 16:53:44 +0000 | [diff] [blame] | 2683 | |
Douglas Gregor | b485046 | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 2684 | OwningStmtResult InstantiateStmt(Stmt *S, |
| 2685 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | 920e3af | 2009-05-20 22:57:03 +0000 | [diff] [blame] | 2686 | OwningStmtResult InstantiateCompoundStmt(CompoundStmt *S, |
| 2687 | const TemplateArgumentList &TemplateArgs, |
| 2688 | bool isStmtExpr); |
Douglas Gregor | b485046 | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 2689 | |
Douglas Gregor | d7e7a51 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 2690 | Decl *InstantiateDecl(Decl *D, DeclContext *Owner, |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2691 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | d7e7a51 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 2692 | |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2693 | bool |
Douglas Gregor | 8ea8fd4 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 2694 | InstantiateBaseSpecifiers(CXXRecordDecl *Instantiation, |
| 2695 | CXXRecordDecl *Pattern, |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2696 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | 8ea8fd4 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 2697 | |
| 2698 | bool |
| 2699 | InstantiateClass(SourceLocation PointOfInstantiation, |
| 2700 | CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, |
Douglas Gregor | a1f4997 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 2701 | const TemplateArgumentList &TemplateArgs, |
| 2702 | bool ExplicitInstantiation); |
Douglas Gregor | 8ea8fd4 | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 2703 | |
Douglas Gregor | 463421d | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2704 | bool |
| 2705 | InstantiateClassTemplateSpecialization( |
| 2706 | ClassTemplateSpecializationDecl *ClassTemplateSpec, |
| 2707 | bool ExplicitInstantiation); |
Douglas Gregor | fe1e110 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 2708 | |
Douglas Gregor | bbbb02d | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 2709 | void InstantiateClassMembers(SourceLocation PointOfInstantiation, |
| 2710 | CXXRecordDecl *Instantiation, |
| 2711 | const TemplateArgumentList &TemplateArgs); |
| 2712 | |
| 2713 | void InstantiateClassTemplateSpecializationMembers( |
| 2714 | SourceLocation PointOfInstantiation, |
| 2715 | ClassTemplateSpecializationDecl *ClassTemplateSpec); |
| 2716 | |
Douglas Gregor | f21eb49 | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 2717 | NestedNameSpecifier * |
| 2718 | InstantiateNestedNameSpecifier(NestedNameSpecifier *NNS, |
| 2719 | SourceRange Range, |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2720 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | 90a1a65 | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 2721 | |
Douglas Gregor | aa59489 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 2722 | TemplateName |
| 2723 | InstantiateTemplateName(TemplateName Name, SourceLocation Loc, |
Douglas Gregor | d002c7b | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 2724 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | c43620d | 2009-06-11 00:06:24 +0000 | [diff] [blame] | 2725 | TemplateArgument Instantiate(TemplateArgument Arg, |
| 2726 | const TemplateArgumentList &TemplateArgs); |
Douglas Gregor | aa59489 | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 2727 | |
Douglas Gregor | 8567358 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 2728 | void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, |
Douglas Gregor | dda7ced | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 2729 | FunctionDecl *Function, |
| 2730 | bool Recursive = false); |
Douglas Gregor | bbbb02d | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 2731 | void InstantiateVariableDefinition(VarDecl *Var); |
| 2732 | |
Douglas Gregor | cd3a097 | 2009-05-27 17:54:46 +0000 | [diff] [blame] | 2733 | NamedDecl *InstantiateCurrentDeclRef(NamedDecl *D); |
Douglas Gregor | 77b50e1 | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 2734 | |
Anders Carlsson | a390581 | 2009-03-15 18:34:13 +0000 | [diff] [blame] | 2735 | // Simple function for cloning expressions. |
| 2736 | template<typename T> |
| 2737 | OwningExprResult Clone(T *E) { |
| 2738 | assert(!E->isValueDependent() && !E->isTypeDependent() && |
| 2739 | "expression is value or type dependent!"); |
| 2740 | return Owned(E->Clone(Context)); |
| 2741 | } |
| 2742 | |
Steve Naroff | 09bf815 | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 2743 | // Objective-C declarations. |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2744 | virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc, |
| 2745 | IdentifierInfo *ClassName, |
| 2746 | SourceLocation ClassLoc, |
| 2747 | IdentifierInfo *SuperName, |
| 2748 | SourceLocation SuperLoc, |
| 2749 | const DeclPtrTy *ProtoRefs, |
| 2750 | unsigned NumProtoRefs, |
| 2751 | SourceLocation EndProtoLoc, |
| 2752 | AttributeList *AttrList); |
Fariborz Jahanian | 49c6425 | 2007-10-11 23:42:27 +0000 | [diff] [blame] | 2753 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2754 | virtual DeclPtrTy ActOnCompatiblityAlias( |
Fariborz Jahanian | 49c6425 | 2007-10-11 23:42:27 +0000 | [diff] [blame] | 2755 | SourceLocation AtCompatibilityAliasLoc, |
| 2756 | IdentifierInfo *AliasName, SourceLocation AliasLocation, |
| 2757 | IdentifierInfo *ClassName, SourceLocation ClassLocation); |
Steve Naroff | 41d09ad | 2009-03-05 15:22:01 +0000 | [diff] [blame] | 2758 | |
| 2759 | void CheckForwardProtocolDeclarationForCircularDependency( |
| 2760 | IdentifierInfo *PName, |
| 2761 | SourceLocation &PLoc, SourceLocation PrevLoc, |
| 2762 | const ObjCList<ObjCProtocolDecl> &PList); |
Steve Naroff | 09bf815 | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 2763 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2764 | virtual DeclPtrTy ActOnStartProtocolInterface( |
Nate Begeman | 7dd8e72 | 2008-02-20 22:57:40 +0000 | [diff] [blame] | 2765 | SourceLocation AtProtoInterfaceLoc, |
Fariborz Jahanian | 39d641f | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 2766 | IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2767 | const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs, |
Daniel Dunbar | 26e2ab4 | 2008-09-26 04:48:09 +0000 | [diff] [blame] | 2768 | SourceLocation EndProtoLoc, |
| 2769 | AttributeList *AttrList); |
Fariborz Jahanian | 39d641f | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 2770 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2771 | virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, |
| 2772 | IdentifierInfo *ClassName, |
| 2773 | SourceLocation ClassLoc, |
| 2774 | IdentifierInfo *CategoryName, |
| 2775 | SourceLocation CategoryLoc, |
| 2776 | const DeclPtrTy *ProtoRefs, |
| 2777 | unsigned NumProtoRefs, |
| 2778 | SourceLocation EndProtoLoc); |
Fariborz Jahanian | 867a7eb | 2007-09-18 20:26:58 +0000 | [diff] [blame] | 2779 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2780 | virtual DeclPtrTy ActOnStartClassImplementation( |
Nate Begeman | 7dd8e72 | 2008-02-20 22:57:40 +0000 | [diff] [blame] | 2781 | SourceLocation AtClassImplLoc, |
Fariborz Jahanian | bfe13c5 | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 2782 | IdentifierInfo *ClassName, SourceLocation ClassLoc, |
| 2783 | IdentifierInfo *SuperClassname, |
| 2784 | SourceLocation SuperClassLoc); |
| 2785 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2786 | virtual DeclPtrTy ActOnStartCategoryImplementation( |
Fariborz Jahanian | 89b8ef9 | 2007-10-02 16:38:50 +0000 | [diff] [blame] | 2787 | SourceLocation AtCatImplLoc, |
| 2788 | IdentifierInfo *ClassName, |
| 2789 | SourceLocation ClassLoc, |
| 2790 | IdentifierInfo *CatName, |
| 2791 | SourceLocation CatLoc); |
| 2792 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2793 | virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, |
Steve Naroff | 0c37b0c | 2007-10-02 22:39:18 +0000 | [diff] [blame] | 2794 | IdentifierInfo **IdentList, |
| 2795 | unsigned NumElts); |
Fariborz Jahanian | 876e27d | 2007-09-21 15:40:54 +0000 | [diff] [blame] | 2796 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2797 | virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, |
Chris Lattner | d7352d6 | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 2798 | const IdentifierLocPair *IdentList, |
Fariborz Jahanian | 1470e93 | 2008-12-17 01:07:27 +0000 | [diff] [blame] | 2799 | unsigned NumElts, |
| 2800 | AttributeList *attrList); |
Fariborz Jahanian | ea7a98d | 2007-10-05 21:01:53 +0000 | [diff] [blame] | 2801 | |
Chris Lattner | 3bbae00 | 2008-07-26 04:03:38 +0000 | [diff] [blame] | 2802 | virtual void FindProtocolDeclaration(bool WarnOnDeclarations, |
Chris Lattner | d7352d6 | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 2803 | const IdentifierLocPair *ProtocolId, |
Fariborz Jahanian | 70e8f10 | 2007-10-11 00:55:41 +0000 | [diff] [blame] | 2804 | unsigned NumProtocols, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2805 | llvm::SmallVectorImpl<DeclPtrTy> &Protocols); |
Fariborz Jahanian | 7cf1886 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 2806 | |
Daniel Dunbar | e8a06e6 | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 2807 | /// Ensure attributes are consistent with type. |
| 2808 | /// \param [in, out] Attributes The attributes to check; they will |
| 2809 | /// be modified to be consistent with \arg PropertyTy. |
| 2810 | void CheckObjCPropertyAttributes(QualType PropertyTy, |
| 2811 | SourceLocation Loc, |
| 2812 | unsigned &Attributes); |
Steve Naroff | 35c62ae | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 2813 | void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC); |
Fariborz Jahanian | 7cf1886 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 2814 | void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, |
| 2815 | ObjCPropertyDecl *SuperProperty, |
Chris Lattner | 86d7d91 | 2008-11-24 03:54:41 +0000 | [diff] [blame] | 2816 | const IdentifierInfo *Name); |
Fariborz Jahanian | 7cf1886 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 2817 | void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl); |
Fariborz Jahanian | 0a070ff | 2008-04-24 19:58:34 +0000 | [diff] [blame] | 2818 | |
Fariborz Jahanian | d2c2ad5 | 2008-12-06 23:03:39 +0000 | [diff] [blame] | 2819 | void MergeProtocolPropertiesIntoClass(Decl *CDecl, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2820 | DeclPtrTy MergeProtocols); |
Fariborz Jahanian | 98a6c4f | 2008-05-02 19:17:30 +0000 | [diff] [blame] | 2821 | |
Fariborz Jahanian | 33afd77 | 2009-03-02 19:05:07 +0000 | [diff] [blame] | 2822 | void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, |
| 2823 | ObjCInterfaceDecl *ID); |
| 2824 | |
Fariborz Jahanian | d2c2ad5 | 2008-12-06 23:03:39 +0000 | [diff] [blame] | 2825 | void MergeOneProtocolPropertiesIntoClass(Decl *CDecl, |
Fariborz Jahanian | 98a6c4f | 2008-05-02 19:17:30 +0000 | [diff] [blame] | 2826 | ObjCProtocolDecl *PDecl); |
| 2827 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2828 | virtual void ActOnAtEnd(SourceLocation AtEndLoc, DeclPtrTy classDecl, |
| 2829 | DeclPtrTy *allMethods = 0, unsigned allNum = 0, |
| 2830 | DeclPtrTy *allProperties = 0, unsigned pNum = 0, |
Chris Lattner | 5bbb3c8 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 2831 | DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0); |
Fariborz Jahanian | 2a4dd31 | 2007-09-26 18:27:25 +0000 | [diff] [blame] | 2832 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2833 | virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc, |
| 2834 | FieldDeclarator &FD, ObjCDeclSpec &ODS, |
| 2835 | Selector GetterSel, Selector SetterSel, |
| 2836 | DeclPtrTy ClassCategory, |
| 2837 | bool *OverridingProperty, |
| 2838 | tok::ObjCKeywordKind MethodImplKind); |
Fariborz Jahanian | 8d91686 | 2008-05-05 18:51:55 +0000 | [diff] [blame] | 2839 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2840 | virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc, |
| 2841 | SourceLocation PropertyLoc, |
| 2842 | bool ImplKind,DeclPtrTy ClassImplDecl, |
| 2843 | IdentifierInfo *PropertyId, |
| 2844 | IdentifierInfo *PropertyIvar); |
Fariborz Jahanian | ffe97a3 | 2008-04-18 00:19:30 +0000 | [diff] [blame] | 2845 | |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2846 | virtual DeclPtrTy ActOnMethodDeclaration( |
Steve Naroff | 161a92b | 2007-10-26 20:53:56 +0000 | [diff] [blame] | 2847 | SourceLocation BeginLoc, // location of the + or -. |
| 2848 | SourceLocation EndLoc, // location of the ; or {. |
Fariborz Jahanian | b560517 | 2007-11-09 19:52:12 +0000 | [diff] [blame] | 2849 | tok::TokenKind MethodType, |
Chris Lattner | 83f095c | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2850 | DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType, |
Fariborz Jahanian | 7a9c474 | 2007-10-31 23:53:01 +0000 | [diff] [blame] | 2851 | Selector Sel, |
Steve Naroff | f73590d | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 2852 | // optional arguments. The number of types/arguments is obtained |
| 2853 | // from the Sel.getNumArgs(). |
Chris Lattner | d8626fd | 2009-04-11 18:57:04 +0000 | [diff] [blame] | 2854 | ObjCArgInfo *ArgInfo, |
Fariborz Jahanian | e84858c | 2009-01-09 00:38:19 +0000 | [diff] [blame] | 2855 | llvm::SmallVectorImpl<Declarator> &Cdecls, |
Steve Naroff | d8ea1ac | 2007-11-15 12:35:21 +0000 | [diff] [blame] | 2856 | AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, |
| 2857 | bool isVariadic = false); |
Steve Naroff | 077c83b | 2007-10-16 23:12:48 +0000 | [diff] [blame] | 2858 | |
Steve Naroff | b162f17 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 2859 | // Helper method for ActOnClassMethod/ActOnInstanceMethod. |
| 2860 | // Will search "local" class/category implementations for a method decl. |
Fariborz Jahanian | 4f4de6c | 2009-03-04 18:15:57 +0000 | [diff] [blame] | 2861 | // Will also search in class's root looking for instance method. |
Steve Naroff | b162f17 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 2862 | // Returns 0 if no method is found. |
Steve Naroff | ed03170 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 2863 | ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel, |
| 2864 | ObjCInterfaceDecl *CDecl); |
| 2865 | ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel, |
| 2866 | ObjCInterfaceDecl *ClassDecl); |
Steve Naroff | b162f17 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 2867 | |
Steve Naroff | 9527bbf | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 2868 | virtual OwningExprResult ActOnClassPropertyRefExpr( |
| 2869 | IdentifierInfo &receiverName, |
| 2870 | IdentifierInfo &propertyName, |
| 2871 | SourceLocation &receiverNameLoc, |
| 2872 | SourceLocation &propertyNameLoc); |
| 2873 | |
Steve Naroff | f73590d | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 2874 | // ActOnClassMessage - used for both unary and keyword messages. |
| 2875 | // ArgExprs is optional - if it is present, the number of expressions |
Steve Naroff | e3ffc2f | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 2876 | // is obtained from NumArgs. |
Steve Naroff | f73590d | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 2877 | virtual ExprResult ActOnClassMessage( |
Fariborz Jahanian | d98a734 | 2007-11-12 20:13:27 +0000 | [diff] [blame] | 2878 | Scope *S, |
Anders Carlsson | 978f08d | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 2879 | IdentifierInfo *receivingClassName, Selector Sel, SourceLocation lbrac, |
| 2880 | SourceLocation receiverLoc, SourceLocation selectorLoc,SourceLocation rbrac, |
Steve Naroff | e3ffc2f | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 2881 | ExprTy **ArgExprs, unsigned NumArgs); |
Steve Naroff | f73590d | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 2882 | |
| 2883 | // ActOnInstanceMessage - used for both unary and keyword messages. |
| 2884 | // ArgExprs is optional - if it is present, the number of expressions |
Steve Naroff | e3ffc2f | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 2885 | // is obtained from NumArgs. |
Steve Naroff | f73590d | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 2886 | virtual ExprResult ActOnInstanceMessage( |
Steve Naroff | 8017506 | 2007-09-28 22:22:11 +0000 | [diff] [blame] | 2887 | ExprTy *receiver, Selector Sel, |
Anders Carlsson | 978f08d | 2009-02-14 18:21:46 +0000 | [diff] [blame] | 2888 | SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac, |
Steve Naroff | e3ffc2f | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 2889 | ExprTy **ArgExprs, unsigned NumArgs); |
Daniel Dunbar | 5460374 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 2890 | |
| 2891 | /// ActOnPragmaPack - Called on well formed #pragma pack(...). |
| 2892 | virtual void ActOnPragmaPack(PragmaPackKind Kind, |
| 2893 | IdentifierInfo *Name, |
| 2894 | ExprTy *Alignment, |
| 2895 | SourceLocation PragmaLoc, |
| 2896 | SourceLocation LParenLoc, |
| 2897 | SourceLocation RParenLoc); |
Chris Lattner | 31180bb | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 2898 | |
Ted Kremenek | fd14fad | 2009-03-23 22:28:25 +0000 | [diff] [blame] | 2899 | /// ActOnPragmaUnused - Called on well-formed '#pragma unused'. |
| 2900 | virtual void ActOnPragmaUnused(ExprTy **Exprs, unsigned NumExprs, |
| 2901 | SourceLocation PragmaLoc, |
| 2902 | SourceLocation LParenLoc, |
| 2903 | SourceLocation RParenLoc); |
Eli Friedman | 5ed5198 | 2009-06-05 02:44:36 +0000 | [diff] [blame] | 2904 | |
Eli Friedman | 302c4e1 | 2009-06-05 06:28:29 +0000 | [diff] [blame] | 2905 | /// ActOnPragmaWeakID - Called on well formed #pragma weak ident. |
Eli Friedman | 5ed5198 | 2009-06-05 02:44:36 +0000 | [diff] [blame] | 2906 | virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName, |
| 2907 | SourceLocation PragmaLoc, |
| 2908 | SourceLocation WeakNameLoc); |
| 2909 | |
Eli Friedman | 302c4e1 | 2009-06-05 06:28:29 +0000 | [diff] [blame] | 2910 | /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident. |
Eli Friedman | 5ed5198 | 2009-06-05 02:44:36 +0000 | [diff] [blame] | 2911 | virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName, |
| 2912 | IdentifierInfo* AliasName, |
| 2913 | SourceLocation PragmaLoc, |
| 2914 | SourceLocation WeakNameLoc, |
| 2915 | SourceLocation AliasNameLoc); |
| 2916 | |
Chris Lattner | 31180bb | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 2917 | /// getPragmaPackAlignment() - Return the current alignment as specified by |
| 2918 | /// the current #pragma pack directive, or 0 if none is currently active. |
| 2919 | unsigned getPragmaPackAlignment() const; |
| 2920 | |
| 2921 | /// FreePackedContext - Deallocate and null out PackContext. |
| 2922 | void FreePackedContext(); |
Daniel Dunbar | 5460374 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 2923 | |
Chris Lattner | a65e1f3 | 2008-01-16 19:17:22 +0000 | [diff] [blame] | 2924 | /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit |
| 2925 | /// cast. If there is already an implicit cast, merge into the existing one. |
Douglas Gregor | a11693b | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 2926 | /// If isLvalue, the result of the cast is an lvalue. |
| 2927 | void ImpCastExprToType(Expr *&Expr, QualType Type, bool isLvalue = false); |
Chris Lattner | a65e1f3 | 2008-01-16 19:17:22 +0000 | [diff] [blame] | 2928 | |
Steve Naroff | 71b59a9 | 2007-06-04 22:22:31 +0000 | [diff] [blame] | 2929 | // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts |
Chris Lattner | 0846494 | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 2930 | // functions and arrays to their respective pointers (C99 6.3.2.1). |
| 2931 | Expr *UsualUnaryConversions(Expr *&expr); |
Eli Friedman | 3e11340 | 2008-05-27 03:33:27 +0000 | [diff] [blame] | 2932 | |
Steve Naroff | 3109001 | 2007-07-16 21:54:35 +0000 | [diff] [blame] | 2933 | // DefaultFunctionArrayConversion - converts functions and arrays |
| 2934 | // to their respective pointers (C99 6.3.2.1). |
| 2935 | void DefaultFunctionArrayConversion(Expr *&expr); |
Steve Naroff | b8ea4fb | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 2936 | |
Steve Naroff | 0b66158 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 2937 | // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that |
| 2938 | // do not have a prototype. Integer promotions are performed on each |
| 2939 | // argument, and arguments that have type float are promoted to double. |
Chris Lattner | 0846494 | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 2940 | void DefaultArgumentPromotion(Expr *&Expr); |
Anders Carlsson | a7d069d | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 2941 | |
| 2942 | // Used for emitting the right warning by DefaultVariadicArgumentPromotion |
| 2943 | enum VariadicCallType { |
| 2944 | VariadicFunction, |
| 2945 | VariadicBlock, |
| 2946 | VariadicMethod |
| 2947 | }; |
| 2948 | |
| 2949 | // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but |
| 2950 | // will warn if the resulting type is not a POD type. |
Chris Lattner | a8a7d0f | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 2951 | bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT); |
Steve Naroff | 0b66158 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 2952 | |
Steve Naroff | 71b59a9 | 2007-06-04 22:22:31 +0000 | [diff] [blame] | 2953 | // UsualArithmeticConversions - performs the UsualUnaryConversions on it's |
| 2954 | // operands and then handles various conversions that are common to binary |
| 2955 | // operators (C99 6.3.1.8). If both operands aren't arithmetic, this |
| 2956 | // routine returns the first non-arithmetic type found. The client is |
| 2957 | // responsible for emitting appropriate error diagnostics. |
Steve Naroff | be4c4d1 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 2958 | QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr, |
| 2959 | bool isCompAssign = false); |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2960 | |
Douglas Gregor | a11693b | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 2961 | /// UsualArithmeticConversionsType - handles the various conversions |
| 2962 | /// that are common to binary operators (C99 6.3.1.8, C++ [expr]p9) |
| 2963 | /// and returns the result type of that conversion. |
| 2964 | QualType UsualArithmeticConversionsType(QualType lhs, QualType rhs); |
| 2965 | |
| 2966 | |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2967 | /// AssignConvertType - All of the 'assignment' semantic checks return this |
| 2968 | /// enum to indicate whether the assignment was allowed. These checks are |
| 2969 | /// done for simple assignments, as well as initialization, return from |
| 2970 | /// function, argument passing, etc. The query is phrased in terms of a |
| 2971 | /// source and destination type. |
Chris Lattner | 9bad62c | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 2972 | enum AssignConvertType { |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2973 | /// Compatible - the types are compatible according to the standard. |
Steve Naroff | 17f76e0 | 2007-05-03 21:03:48 +0000 | [diff] [blame] | 2974 | Compatible, |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2975 | |
| 2976 | /// PointerToInt - The assignment converts a pointer to an int, which we |
| 2977 | /// accept as an extension. |
| 2978 | PointerToInt, |
| 2979 | |
| 2980 | /// IntToPointer - The assignment converts an int to a pointer, which we |
| 2981 | /// accept as an extension. |
| 2982 | IntToPointer, |
| 2983 | |
| 2984 | /// FunctionVoidPointer - The assignment is between a function pointer and |
| 2985 | /// void*, which the standard doesn't allow, but we accept as an extension. |
Chris Lattner | 0a78843 | 2008-01-03 22:56:36 +0000 | [diff] [blame] | 2986 | FunctionVoidPointer, |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2987 | |
| 2988 | /// IncompatiblePointer - The assignment is between two pointers types that |
| 2989 | /// are not compatible, but we accept them as an extension. |
Steve Naroff | 1f4d727 | 2007-05-11 04:00:31 +0000 | [diff] [blame] | 2990 | IncompatiblePointer, |
Eli Friedman | 80160bd | 2009-03-22 23:59:44 +0000 | [diff] [blame] | 2991 | |
| 2992 | /// IncompatiblePointer - The assignment is between two pointers types which |
| 2993 | /// point to integers which have a different sign, but are otherwise identical. |
| 2994 | /// This is a subset of the above, but broken out because it's by far the most |
| 2995 | /// common case of incompatible pointers. |
| 2996 | IncompatiblePointerSign, |
| 2997 | |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 2998 | /// CompatiblePointerDiscardsQualifiers - The assignment discards |
| 2999 | /// c/v/r qualifiers, which we accept as an extension. |
| 3000 | CompatiblePointerDiscardsQualifiers, |
Steve Naroff | 081c742 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3001 | |
Anders Carlsson | db5a9b6 | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 3002 | /// IncompatibleVectors - The assignment is between two vector types that |
| 3003 | /// have the same size, which we accept as an extension. |
| 3004 | IncompatibleVectors, |
| 3005 | |
Steve Naroff | 991e99d | 2008-09-04 15:31:07 +0000 | [diff] [blame] | 3006 | /// IntToBlockPointer - The assignment converts an int to a block |
Steve Naroff | 081c742 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3007 | /// pointer. We disallow this. |
| 3008 | IntToBlockPointer, |
| 3009 | |
Steve Naroff | 991e99d | 2008-09-04 15:31:07 +0000 | [diff] [blame] | 3010 | /// IncompatibleBlockPointer - The assignment is between two block |
Steve Naroff | 081c742 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3011 | /// pointers types that are not compatible. |
| 3012 | IncompatibleBlockPointer, |
| 3013 | |
Steve Naroff | 8afa989 | 2008-10-14 22:18:38 +0000 | [diff] [blame] | 3014 | /// IncompatibleObjCQualifiedId - The assignment is between a qualified |
| 3015 | /// id type and something else (that is incompatible with it). For example, |
| 3016 | /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol. |
| 3017 | IncompatibleObjCQualifiedId, |
| 3018 | |
Chris Lattner | 940cfeb | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3019 | /// Incompatible - We reject this conversion outright, it is invalid to |
| 3020 | /// represent it in the AST. |
| 3021 | Incompatible |
Steve Naroff | 17f76e0 | 2007-05-03 21:03:48 +0000 | [diff] [blame] | 3022 | }; |
Chris Lattner | 9bad62c | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3023 | |
| 3024 | /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the |
| 3025 | /// assignment conversion type specified by ConvTy. This returns true if the |
| 3026 | /// conversion was invalid or false if the conversion was accepted. |
| 3027 | bool DiagnoseAssignmentResult(AssignConvertType ConvTy, |
| 3028 | SourceLocation Loc, |
| 3029 | QualType DstType, QualType SrcType, |
| 3030 | Expr *SrcExpr, const char *Flavor); |
| 3031 | |
| 3032 | /// CheckAssignmentConstraints - Perform type checking for assignment, |
| 3033 | /// argument passing, variable initialization, and function return values. |
| 3034 | /// This routine is only used by the following two methods. C99 6.5.16. |
| 3035 | AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs); |
Steve Naroff | b8ea4fb | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 3036 | |
Douglas Gregor | 0cfbdab | 2009-04-29 22:16:16 +0000 | [diff] [blame] | 3037 | // CheckSingleAssignmentConstraints - Currently used by |
Steve Naroff | 66356bd | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 3038 | // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking, |
Steve Naroff | b8ea4fb | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 3039 | // this routine performs the default function/array converions. |
Chris Lattner | 9bad62c | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3040 | AssignConvertType CheckSingleAssignmentConstraints(QualType lhs, |
| 3041 | Expr *&rExpr); |
Douglas Gregor | 0cfbdab | 2009-04-29 22:16:16 +0000 | [diff] [blame] | 3042 | |
| 3043 | // \brief If the lhs type is a transparent union, check whether we |
| 3044 | // can initialize the transparent union with the given expression. |
| 3045 | AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs, |
| 3046 | Expr *&rExpr); |
Steve Naroff | b8ea4fb | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 3047 | |
Steve Naroff | 98cf3e9 | 2007-06-06 18:38:38 +0000 | [diff] [blame] | 3048 | // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1) |
Chris Lattner | 9bad62c | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3049 | AssignConvertType CheckPointerTypesForAssignment(QualType lhsType, |
| 3050 | QualType rhsType); |
Steve Naroff | 081c742 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3051 | |
| 3052 | // Helper function for CheckAssignmentConstraints involving two |
Sebastian Redl | 3b7ef5e | 2009-04-19 19:26:31 +0000 | [diff] [blame] | 3053 | // block pointer types. |
Steve Naroff | 081c742 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3054 | AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType, |
| 3055 | QualType rhsType); |
Douglas Gregor | aa1e21d | 2008-09-12 00:47:35 +0000 | [diff] [blame] | 3056 | |
| 3057 | bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType); |
Douglas Gregor | 39c16d4 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 3058 | |
Douglas Gregor | 47d3f27 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 3059 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 3060 | const char *Flavor, |
| 3061 | bool AllowExplicit = false, |
| 3062 | bool Elidable = false); |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 3063 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
| 3064 | const ImplicitConversionSequence& ICS, |
Douglas Gregor | 47d3f27 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 3065 | const char *Flavor); |
Douglas Gregor | 39c16d4 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 3066 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 47d3f27 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 3067 | const StandardConversionSequence& SCS, |
| 3068 | const char *Flavor); |
Sebastian Redl | 112a9766 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3069 | |
Steve Naroff | 8eeeb13 | 2007-05-08 21:09:37 +0000 | [diff] [blame] | 3070 | /// the following "Check" methods will return a valid/converted QualType |
| 3071 | /// or a null QualType (indicating an error diagnostic was issued). |
Sebastian Redl | 112a9766 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3072 | |
| 3073 | /// type checking binary operators (subroutines of CreateBuiltinBinOp). |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3074 | QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
Sebastian Redl | 5822f08 | 2009-02-07 20:10:22 +0000 | [diff] [blame] | 3075 | QualType CheckPointerToMemberOperands( // C++ 5.5 |
Sebastian Redl | 112a9766 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3076 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3077 | QualType CheckMultiplyDivideOperands( // C99 6.5.5 |
Sebastian Redl | 112a9766 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3078 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3079 | QualType CheckRemainderOperands( // C99 6.5.5 |
Sebastian Redl | 112a9766 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3080 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3081 | QualType CheckAdditionOperands( // C99 6.5.6 |
Eli Friedman | 8b7b1b1 | 2009-03-28 01:22:36 +0000 | [diff] [blame] | 3082 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3083 | QualType CheckSubtractionOperands( // C99 6.5.6 |
Eli Friedman | 8b7b1b1 | 2009-03-28 01:22:36 +0000 | [diff] [blame] | 3084 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3085 | QualType CheckShiftOperands( // C99 6.5.7 |
Steve Naroff | be4c4d1 | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 3086 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3087 | QualType CheckCompareOperands( // C99 6.5.8/9 |
Douglas Gregor | 7a5bc76 | 2009-04-06 18:45:53 +0000 | [diff] [blame] | 3088 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc, bool isRelational); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3089 | QualType CheckBitwiseOperands( // C99 6.5.[10...12] |
Sebastian Redl | 112a9766 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3090 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3091 | QualType CheckLogicalOperands( // C99 6.5.[13,14] |
Steve Naroff | 7a5af78 | 2007-07-13 16:58:59 +0000 | [diff] [blame] | 3092 | Expr *&lex, Expr *&rex, SourceLocation OpLoc); |
Steve Naroff | 35d8515 | 2007-05-07 00:24:15 +0000 | [diff] [blame] | 3093 | // CheckAssignmentOperands is used for both simple and compound assignment. |
| 3094 | // For simple assignment, pass both expressions and a null converted type. |
| 3095 | // For compound assignment, pass both expressions and the converted type. |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3096 | QualType CheckAssignmentOperands( // C99 6.5.16.[1,2] |
Steve Naroff | 0c1c7ed | 2007-08-24 22:33:52 +0000 | [diff] [blame] | 3097 | Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3098 | QualType CheckCommaOperands( // C99 6.5.17 |
Chris Lattner | 326f757 | 2008-11-18 01:30:42 +0000 | [diff] [blame] | 3099 | Expr *lex, Expr *&rex, SourceLocation OpLoc); |
Douglas Gregor | 6873f9c | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3100 | QualType CheckConditionalOperands( // C99 6.5.15 |
Steve Naroff | 7a5af78 | 2007-07-13 16:58:59 +0000 | [diff] [blame] | 3101 | Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc); |
Sebastian Redl | 1a99f44 | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 3102 | QualType CXXCheckConditionalOperands( // C++ 5.16 |
| 3103 | Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc); |
Sebastian Redl | 3b7ef5e | 2009-04-19 19:26:31 +0000 | [diff] [blame] | 3104 | QualType FindCompositePointerType(Expr *&E1, Expr *&E2); // C++ 5.9 |
Nate Begeman | 191a6b1 | 2008-07-14 18:02:46 +0000 | [diff] [blame] | 3105 | |
| 3106 | /// type checking for vector binary operators. |
| 3107 | inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
| 3108 | inline QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx, |
| 3109 | SourceLocation l, bool isRel); |
Steve Naroff | 95af013 | 2007-03-30 23:47:58 +0000 | [diff] [blame] | 3110 | |
Steve Naroff | 83895f7 | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 3111 | /// type checking unary operators (subroutines of ActOnUnaryOp). |
Steve Naroff | 9358c71 | 2007-05-27 23:58:33 +0000 | [diff] [blame] | 3112 | /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4 |
Sebastian Redl | e10c2c3 | 2008-12-20 09:35:34 +0000 | [diff] [blame] | 3113 | QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc, |
| 3114 | bool isInc); |
Steve Naroff | 71ce2e0 | 2007-05-18 22:53:50 +0000 | [diff] [blame] | 3115 | QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc); |
| 3116 | QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc); |
Chris Lattner | 709322b | 2009-02-17 08:12:06 +0000 | [diff] [blame] | 3117 | QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal); |
Steve Naroff | f8fd09e | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 3118 | |
| 3119 | /// type checking primary expressions. |
Nate Begeman | ce4d7fc | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 3120 | QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, |
Steve Naroff | f8fd09e | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 3121 | IdentifierInfo &Comp, SourceLocation CmpLoc); |
| 3122 | |
Steve Naroff | 2fea139 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 3123 | /// type checking declaration initializers (C99 6.7.8) |
Anders Carlsson | 98cee2f | 2009-05-27 16:10:08 +0000 | [diff] [blame] | 3124 | |
Douglas Gregor | 6f54315 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 3125 | bool CheckInitializerTypes(Expr *&simpleInit_or_initList, QualType &declType, |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 3126 | SourceLocation InitLoc,DeclarationName InitEntity, |
Anders Carlsson | 28486d4 | 2009-05-30 20:41:30 +0000 | [diff] [blame] | 3127 | bool DirectInit); |
Douglas Gregor | 85df8d8 | 2009-01-29 00:45:39 +0000 | [diff] [blame] | 3128 | bool CheckInitList(InitListExpr *&InitList, QualType &DeclType); |
Steve Naroff | 98f7203 | 2008-01-10 22:15:12 +0000 | [diff] [blame] | 3129 | bool CheckForConstantInitializer(Expr *e, QualType t); |
Steve Naroff | 91f7808 | 2007-12-10 22:44:33 +0000 | [diff] [blame] | 3130 | |
Douglas Gregor | a5c9e1a | 2009-02-02 17:43:21 +0000 | [diff] [blame] | 3131 | bool CheckValueInitialization(QualType Type, SourceLocation Loc); |
Argyrios Kyrtzidis | 2ade390 | 2008-08-16 20:27:34 +0000 | [diff] [blame] | 3132 | |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 3133 | // type checking C++ declaration initializers (C++ [dcl.init]). |
| 3134 | |
| 3135 | /// ReferenceCompareResult - Expresses the result of comparing two |
| 3136 | /// types (cv1 T1 and cv2 T2) to determine their compatibility for the |
| 3137 | /// purposes of initialization by reference (C++ [dcl.init.ref]p4). |
| 3138 | enum ReferenceCompareResult { |
| 3139 | /// Ref_Incompatible - The two types are incompatible, so direct |
| 3140 | /// reference binding is not possible. |
| 3141 | Ref_Incompatible = 0, |
| 3142 | /// Ref_Related - The two types are reference-related, which means |
| 3143 | /// that their unqualified forms (T1 and T2) are either the same |
| 3144 | /// or T1 is a base class of T2. |
| 3145 | Ref_Related, |
| 3146 | /// Ref_Compatible_With_Added_Qualification - The two types are |
| 3147 | /// reference-compatible with added qualification, meaning that |
| 3148 | /// they are reference-compatible and the qualifiers on T1 (cv1) |
| 3149 | /// are greater than the qualifiers on T2 (cv2). |
| 3150 | Ref_Compatible_With_Added_Qualification, |
| 3151 | /// Ref_Compatible - The two types are reference-compatible and |
| 3152 | /// have equivalent qualifiers (cv1 == cv2). |
| 3153 | Ref_Compatible |
| 3154 | }; |
| 3155 | |
Douglas Gregor | 786ab21 | 2008-10-29 02:00:59 +0000 | [diff] [blame] | 3156 | ReferenceCompareResult CompareReferenceRelationship(QualType T1, QualType T2, |
| 3157 | bool& DerivedToBase); |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 3158 | |
Sebastian Redl | 1a99f44 | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 3159 | bool CheckReferenceInit(Expr *&simpleInit_or_initList, QualType declType, |
Douglas Gregor | 2fe9883 | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 3160 | ImplicitConversionSequence *ICS = 0, |
Douglas Gregor | 5fb5397 | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 3161 | bool SuppressUserConversions = false, |
Sebastian Redl | 42e92c4 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 3162 | bool AllowExplicit = false, |
| 3163 | bool ForceRValue = false); |
Douglas Gregor | 8e1cf60 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 3164 | |
Argyrios Kyrtzidis | 2ade390 | 2008-08-16 20:27:34 +0000 | [diff] [blame] | 3165 | /// CheckCastTypes - Check type constraints for casting between types. |
Daniel Dunbar | 94834d8 | 2008-08-20 03:55:42 +0000 | [diff] [blame] | 3166 | bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr); |
Steve Naroff | af2a022 | 2008-01-22 00:55:40 +0000 | [diff] [blame] | 3167 | |
Anders Carlsson | 24c5995 | 2007-11-27 07:16:40 +0000 | [diff] [blame] | 3168 | // CheckVectorCast - check type constraints for vectors. |
| 3169 | // Since vectors are an extension, there are no C standard reference for this. |
| 3170 | // We allow casting between vectors and integer datatypes of the same size. |
Anders Carlsson | de71adf | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 3171 | // returns true if the cast is invalid |
| 3172 | bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty); |
| 3173 | |
Nate Begeman | c69b740 | 2009-06-26 00:50:28 +0000 | [diff] [blame] | 3174 | // CheckExtVectorCast - check type constraints for extended vectors. |
| 3175 | // Since vectors are an extension, there are no C standard reference for this. |
| 3176 | // We allow casting between vectors and integer datatypes of the same size, |
| 3177 | // or vectors and the element type of that vector. |
| 3178 | // returns true if the cast is invalid |
| 3179 | bool CheckExtVectorCast(SourceRange R, QualType VectorTy, QualType Ty); |
| 3180 | |
Daniel Dunbar | aa9326c | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 3181 | /// CheckMessageArgumentTypes - Check types in an Obj-C message send. |
| 3182 | /// \param Method - May be null. |
| 3183 | /// \param [out] ReturnType - The return type of the send. |
| 3184 | /// \return true iff there were any incompatible types. |
Daniel Dunbar | ce05c8e | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 3185 | bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel, |
Chris Lattner | e4b9569 | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 3186 | ObjCMethodDecl *Method, bool isClassMessage, |
Daniel Dunbar | aa9326c | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 3187 | SourceLocation lbrac, SourceLocation rbrac, |
| 3188 | QualType &ReturnType); |
Argyrios Kyrtzidis | 7620ee4 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 3189 | |
| 3190 | /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid. |
| 3191 | bool CheckCXXBooleanCondition(Expr *&CondExpr); |
Steve Naroff | 077c83b | 2007-10-16 23:12:48 +0000 | [diff] [blame] | 3192 | |
Chris Lattner | fc1c44a | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 3193 | /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have |
| 3194 | /// the specified width and sign. If an overflow occurs, detect it and emit |
| 3195 | /// the specified diagnostic. |
| 3196 | void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal, |
| 3197 | unsigned NewWidth, bool NewSign, |
| 3198 | SourceLocation Loc, unsigned DiagID); |
| 3199 | |
Chris Lattner | 2a3569b | 2008-04-07 05:30:13 +0000 | [diff] [blame] | 3200 | bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, |
| 3201 | bool ForCompare); |
| 3202 | |
Anders Carlsson | a6b508a | 2008-11-04 16:57:32 +0000 | [diff] [blame] | 3203 | /// Checks that the Objective-C declaration is declared in the global scope. |
| 3204 | /// Emits an error and marks the declaration as invalid if it's not declared |
| 3205 | /// in the global scope. |
| 3206 | bool CheckObjCDeclScope(Decl *D); |
| 3207 | |
Anders Carlsson | 7e13ab8 | 2007-10-15 20:28:48 +0000 | [diff] [blame] | 3208 | void InitBuiltinVaListType(); |
Eli Friedman | 149614b | 2008-06-03 21:01:11 +0000 | [diff] [blame] | 3209 | |
Anders Carlsson | e54e8a1 | 2008-11-30 19:50:32 +0000 | [diff] [blame] | 3210 | /// VerifyIntegerConstantExpression - verifies that an expression is an ICE, |
| 3211 | /// and reports the appropriate diagnostics. Returns false on success. |
| 3212 | /// Can optionally return the value of the expression. |
Anders Carlsson | 5df391e | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 3213 | bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0); |
Anders Carlsson | 1dbffc6 | 2008-12-01 02:17:22 +0000 | [diff] [blame] | 3214 | |
Anders Carlsson | 5df391e | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 3215 | /// VerifyBitField - verifies that a bit field expression is an ICE and has |
| 3216 | /// the correct width, and that the field type is valid. |
| 3217 | /// Returns false on success. |
| 3218 | bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, |
| 3219 | QualType FieldTy, const Expr *BitWidth); |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 3220 | |
Chris Lattner | b87b1b3 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 3221 | //===--------------------------------------------------------------------===// |
| 3222 | // Extra semantic analysis beyond the C type system |
Chris Lattner | 0846494 | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 3223 | private: |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 3224 | Action::OwningExprResult CheckFunctionCall(FunctionDecl *FDecl, |
| 3225 | CallExpr *TheCall); |
Fariborz Jahanian | c1585be | 2009-05-18 21:05:18 +0000 | [diff] [blame] | 3226 | |
| 3227 | Action::OwningExprResult CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall); |
Chris Lattner | a26fb34 | 2009-02-18 17:49:48 +0000 | [diff] [blame] | 3228 | SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, |
| 3229 | unsigned ByteNo) const; |
Chris Lattner | 6436fb6 | 2009-02-18 06:01:06 +0000 | [diff] [blame] | 3230 | bool CheckObjCString(Expr *Arg); |
Chris Lattner | 0846494 | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 3231 | bool SemaBuiltinVAStart(CallExpr *TheCall); |
| 3232 | bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); |
Eli Friedman | f835303 | 2008-05-20 08:23:37 +0000 | [diff] [blame] | 3233 | bool SemaBuiltinStackAddress(CallExpr *TheCall); |
Douglas Gregor | c25f766 | 2009-05-19 22:10:17 +0000 | [diff] [blame] | 3234 | |
| 3235 | public: |
| 3236 | // Used by C++ template instantiation. |
Sebastian Redl | c215cfc | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 3237 | Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall); |
Douglas Gregor | c25f766 | 2009-05-19 22:10:17 +0000 | [diff] [blame] | 3238 | |
| 3239 | private: |
Daniel Dunbar | b725726 | 2008-07-21 22:59:13 +0000 | [diff] [blame] | 3240 | bool SemaBuiltinPrefetch(CallExpr *TheCall); |
Eli Friedman | eed8ad2 | 2009-05-03 04:46:36 +0000 | [diff] [blame] | 3241 | bool SemaBuiltinObjectSize(CallExpr *TheCall); |
| 3242 | bool SemaBuiltinLongjmp(CallExpr *TheCall); |
Chris Lattner | dc04654 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 3243 | bool SemaBuiltinAtomicOverloaded(CallExpr *TheCall); |
Ted Kremenek | dfd72c2 | 2009-03-20 21:35:28 +0000 | [diff] [blame] | 3244 | bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, |
| 3245 | bool HasVAListArg, unsigned format_idx, |
| 3246 | unsigned firstDataArg); |
| 3247 | void CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr, |
| 3248 | const CallExpr *TheCall, bool HasVAListArg, |
Douglas Gregor | e711f70 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 3249 | unsigned format_idx, unsigned firstDataArg); |
Fariborz Jahanian | cd1a88d | 2009-05-21 18:48:51 +0000 | [diff] [blame] | 3250 | void CheckNonNullArguments(const NonNullAttr *NonNull, |
| 3251 | const CallExpr *TheCall); |
Ted Kremenek | dfd72c2 | 2009-03-20 21:35:28 +0000 | [diff] [blame] | 3252 | void CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg, |
Douglas Gregor | e711f70 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 3253 | unsigned format_idx, unsigned firstDataArg); |
Ted Kremenek | cff94fa | 2007-08-17 16:46:58 +0000 | [diff] [blame] | 3254 | void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, |
| 3255 | SourceLocation ReturnLoc); |
Ted Kremenek | 43fb8b0 | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 3256 | void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex); |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 3257 | }; |
| 3258 | |
Mike Stump | a670332 | 2009-02-19 22:01:56 +0000 | [diff] [blame] | 3259 | |
Ted Kremenek | 5a20195 | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 3260 | //===--------------------------------------------------------------------===// |
| 3261 | // Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers). |
| 3262 | template <typename T> |
| 3263 | class ExprOwningPtr : public Action::ExprArg { |
| 3264 | public: |
Douglas Gregor | 573c746 | 2009-03-12 16:53:44 +0000 | [diff] [blame] | 3265 | ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {} |
Ted Kremenek | 5a20195 | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 3266 | |
| 3267 | void reset(T* p) { Action::ExprArg::operator=(p); } |
| 3268 | T* get() const { return static_cast<T*>(Action::ExprArg::get()); } |
| 3269 | T* take() { return static_cast<T*>(Action::ExprArg::take()); } |
| 3270 | T* release() { return take(); } |
| 3271 | |
| 3272 | T& operator*() const { return *get(); } |
| 3273 | T* operator->() const { return get(); } |
| 3274 | }; |
Douglas Gregor | 1301fdd | 2009-05-20 22:33:37 +0000 | [diff] [blame] | 3275 | |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 3276 | } // end namespace clang |
Chris Lattner | 7cee11f | 2006-11-03 06:42:29 +0000 | [diff] [blame] | 3277 | |
| 3278 | #endif |