Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1 | //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 0bc735f | 2007-12-29 19:59:25 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the Sema class, which performs semantic analysis and |
| 11 | // builds ASTs. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CLANG_AST_SEMA_H |
| 16 | #define LLVM_CLANG_AST_SEMA_H |
| 17 | |
Chris Lattner | 7f925cc | 2008-04-11 07:00:53 +0000 | [diff] [blame] | 18 | #include "IdentifierResolver.h" |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 19 | #include "CXXFieldCollector.h" |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 20 | #include "SemaOverload.h" |
Douglas Gregor | d110243 | 2009-08-28 17:37:35 +0000 | [diff] [blame] | 21 | #include "SemaTemplate.h" |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 22 | #include "clang/AST/Attr.h" |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 23 | #include "clang/AST/DeclBase.h" |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 24 | #include "clang/AST/Decl.h" |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 25 | #include "clang/AST/DeclObjC.h" |
Anders Carlsson | 1c5976e | 2009-06-05 03:43:12 +0000 | [diff] [blame] | 26 | #include "clang/AST/DeclTemplate.h" |
Anders Carlsson | 5ee56e9 | 2009-12-16 02:09:40 +0000 | [diff] [blame] | 27 | #include "clang/AST/FullExpr.h" |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 28 | #include "clang/Parse/Action.h" |
Chris Lattner | 500d329 | 2009-01-29 05:15:15 +0000 | [diff] [blame] | 29 | #include "clang/Sema/SemaDiagnostic.h" |
Anders Carlsson | c1fcb77 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 30 | #include "llvm/ADT/SmallVector.h" |
Fariborz Jahanian | 85ff264 | 2007-10-05 18:00:57 +0000 | [diff] [blame] | 31 | #include "llvm/ADT/DenseSet.h" |
Chris Lattner | f387668 | 2007-10-07 01:13:46 +0000 | [diff] [blame] | 32 | #include "llvm/ADT/SmallPtrSet.h" |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 33 | #include "llvm/ADT/OwningPtr.h" |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 34 | #include <deque> |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 35 | #include <list> |
Anders Carlsson | d6a637f | 2009-12-07 08:24:59 +0000 | [diff] [blame] | 36 | #include <map> |
Douglas Gregor | 4dc6b1c | 2009-01-16 00:38:09 +0000 | [diff] [blame] | 37 | #include <string> |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 38 | #include <vector> |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 39 | |
Chris Lattner | f4021e7 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 40 | namespace llvm { |
| 41 | class APSInt; |
| 42 | } |
| 43 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 44 | namespace clang { |
| 45 | class ASTContext; |
Chris Lattner | 2ae34ed | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 46 | class ASTConsumer; |
Douglas Gregor | 81b747b | 2009-09-17 21:32:03 +0000 | [diff] [blame] | 47 | class CodeCompleteConsumer; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 48 | class Preprocessor; |
| 49 | class Decl; |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 50 | class DeclContext; |
Daniel Dunbar | 12bc692 | 2008-08-11 03:27:53 +0000 | [diff] [blame] | 51 | class DeclSpec; |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 52 | class ExternalSemaSource; |
Steve Naroff | e8043c3 | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 53 | class NamedDecl; |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 54 | class Stmt; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 55 | class Expr; |
Steve Naroff | 6f9f307 | 2007-09-02 15:34:30 +0000 | [diff] [blame] | 56 | class InitListExpr; |
Nate Begeman | 2ef13e5 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 57 | class ParenListExpr; |
Douglas Gregor | 05c13a3 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 58 | class DesignatedInitExpr; |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 59 | class CallExpr; |
Douglas Gregor | 1a49af9 | 2009-01-06 05:10:23 +0000 | [diff] [blame] | 60 | class DeclRefExpr; |
John McCall | 3b4294e | 2009-12-16 12:17:52 +0000 | [diff] [blame] | 61 | class UnresolvedLookupExpr; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 62 | class VarDecl; |
| 63 | class ParmVarDecl; |
| 64 | class TypedefDecl; |
| 65 | class FunctionDecl; |
| 66 | class QualType; |
Sebastian Redl | 43af76e | 2009-03-07 12:16:37 +0000 | [diff] [blame] | 67 | class LangOptions; |
Chris Lattner | d217773 | 2007-07-20 16:59:19 +0000 | [diff] [blame] | 68 | class Token; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 69 | class IntegerLiteral; |
Steve Naroff | a49e1fa | 2008-01-22 00:55:40 +0000 | [diff] [blame] | 70 | class StringLiteral; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 71 | class ArrayType; |
| 72 | class LabelStmt; |
Anders Carlsson | c1fcb77 | 2007-07-22 07:07:56 +0000 | [diff] [blame] | 73 | class SwitchStmt; |
Sebastian Redl | 13e8854 | 2009-04-27 21:33:24 +0000 | [diff] [blame] | 74 | class CXXTryStmt; |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 75 | class ExtVectorType; |
Steve Naroff | bea0b34 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 76 | class TypedefDecl; |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 77 | class TemplateDecl; |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 78 | class TemplateArgument; |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 79 | class TemplateArgumentLoc; |
Douglas Gregor | 7e06390 | 2009-05-11 23:53:27 +0000 | [diff] [blame] | 80 | class TemplateArgumentList; |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 81 | class TemplateParameterList; |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 82 | class TemplateTemplateParmDecl; |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 83 | class ClassTemplatePartialSpecializationDecl; |
Douglas Gregor | 88b7094 | 2009-02-25 22:02:03 +0000 | [diff] [blame] | 84 | class ClassTemplateDecl; |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 85 | class ObjCInterfaceDecl; |
Steve Naroff | e8043c3 | 2008-04-01 23:04:06 +0000 | [diff] [blame] | 86 | class ObjCCompatibleAliasDecl; |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 87 | class ObjCProtocolDecl; |
Chris Lattner | cddc888 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 88 | class ObjCImplDecl; |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 89 | class ObjCImplementationDecl; |
| 90 | class ObjCCategoryImplDecl; |
| 91 | class ObjCCategoryDecl; |
| 92 | class ObjCIvarDecl; |
| 93 | class ObjCMethodDecl; |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 94 | class ObjCPropertyDecl; |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 95 | class ObjCContainerDecl; |
Sebastian Redl | 4994d2d | 2009-07-04 11:39:00 +0000 | [diff] [blame] | 96 | class FunctionProtoType; |
Douglas Gregor | a8f32e0 | 2009-10-06 17:59:45 +0000 | [diff] [blame] | 97 | class CXXBasePaths; |
Anders Carlsson | ff6b3d6 | 2009-05-30 21:05:25 +0000 | [diff] [blame] | 98 | class CXXTemporary; |
John McCall | 7d384dd | 2009-11-18 07:57:50 +0000 | [diff] [blame] | 99 | class LookupResult; |
Douglas Gregor | 20093b4 | 2009-12-09 23:02:17 +0000 | [diff] [blame] | 100 | class InitializedEntity; |
| 101 | class InitializationKind; |
| 102 | class InitializationSequence; |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 103 | class VisibleDeclConsumer; |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 104 | class TargetAttributesSema; |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 105 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 106 | /// BlockSemaInfo - When a block is being parsed, this contains information |
| 107 | /// about the block. It is pointed to from Sema::CurBlock. |
| 108 | struct BlockSemaInfo { |
| 109 | llvm::SmallVector<ParmVarDecl*, 8> Params; |
| 110 | bool hasPrototype; |
| 111 | bool isVariadic; |
| 112 | bool hasBlockDeclRefExprs; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 113 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 114 | BlockDecl *TheDecl; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 115 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 116 | /// TheScope - This is the scope for the block itself, which contains |
| 117 | /// arguments etc. |
| 118 | Scope *TheScope; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 119 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 120 | /// ReturnType - This will get set to block result type, by looking at |
| 121 | /// return types, if any, in the block body. |
Fariborz Jahanian | 7d5c74e | 2009-06-19 23:37:08 +0000 | [diff] [blame] | 122 | QualType ReturnType; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 123 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 124 | /// LabelMap - This is a mapping from label identifiers to the LabelStmt for |
| 125 | /// it (which acts like the label decl in some ways). Forward referenced |
| 126 | /// labels have a LabelStmt created for them with a null location & SubStmt. |
| 127 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 128 | |
Chris Lattner | bcfce66 | 2009-04-18 20:10:59 +0000 | [diff] [blame] | 129 | /// SwitchStack - This is the current set of active switch statements in the |
| 130 | /// block. |
| 131 | llvm::SmallVector<SwitchStmt*, 8> SwitchStack; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 132 | |
Chris Lattner | 17a7830 | 2009-04-19 05:28:12 +0000 | [diff] [blame] | 133 | /// SavedFunctionNeedsScopeChecking - This is the value of |
| 134 | /// CurFunctionNeedsScopeChecking at the point when the block started. |
| 135 | bool SavedFunctionNeedsScopeChecking; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 136 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 137 | /// PrevBlockInfo - If this is nested inside another block, this points |
| 138 | /// to the outer block. |
| 139 | BlockSemaInfo *PrevBlockInfo; |
| 140 | }; |
| 141 | |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 142 | /// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator |
Argyrios Kyrtzidis | 1bb8a45 | 2009-08-19 01:28:17 +0000 | [diff] [blame] | 143 | /// parsing. |
| 144 | /// |
| 145 | /// LocInfoType is a "transient" type, only needed for passing to/from Parser |
| 146 | /// and Sema, when we want to preserve type source info for a parsed type. |
| 147 | /// It will not participate in the type system semantics in any way. |
| 148 | class LocInfoType : public Type { |
| 149 | enum { |
| 150 | // The last number that can fit in Type's TC. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 151 | // Avoids conflict with an existing Type class. |
Argyrios Kyrtzidis | 1bb8a45 | 2009-08-19 01:28:17 +0000 | [diff] [blame] | 152 | LocInfo = (1 << TypeClassBitSize) - 1 |
| 153 | }; |
| 154 | |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 155 | TypeSourceInfo *DeclInfo; |
Argyrios Kyrtzidis | 1bb8a45 | 2009-08-19 01:28:17 +0000 | [diff] [blame] | 156 | |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 157 | LocInfoType(QualType ty, TypeSourceInfo *TInfo) |
| 158 | : Type((TypeClass)LocInfo, ty, ty->isDependentType()), DeclInfo(TInfo) { |
Argyrios Kyrtzidis | 1bb8a45 | 2009-08-19 01:28:17 +0000 | [diff] [blame] | 159 | assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?"); |
| 160 | } |
| 161 | friend class Sema; |
| 162 | |
| 163 | public: |
| 164 | QualType getType() const { return getCanonicalTypeInternal(); } |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 165 | TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; } |
Argyrios Kyrtzidis | 1bb8a45 | 2009-08-19 01:28:17 +0000 | [diff] [blame] | 166 | |
| 167 | virtual void getAsStringInternal(std::string &Str, |
| 168 | const PrintingPolicy &Policy) const; |
| 169 | |
| 170 | static bool classof(const Type *T) { |
| 171 | return T->getTypeClass() == (TypeClass)LocInfo; |
| 172 | } |
| 173 | static bool classof(const LocInfoType *) { return true; } |
| 174 | }; |
| 175 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 176 | /// Sema - This implements semantic analysis and AST building for C. |
| 177 | class Sema : public Action { |
Chris Lattner | f50adff | 2009-02-17 00:58:30 +0000 | [diff] [blame] | 178 | Sema(const Sema&); // DO NOT IMPLEMENT |
| 179 | void operator=(const Sema&); // DO NOT IMPLEMENT |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 180 | mutable const TargetAttributesSema* TheTargetAttributesSema; |
Chris Lattner | 0b2f4da | 2008-06-29 00:28:59 +0000 | [diff] [blame] | 181 | public: |
Chris Lattner | 53ebff3 | 2009-01-22 19:21:44 +0000 | [diff] [blame] | 182 | const LangOptions &LangOpts; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 183 | Preprocessor &PP; |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 184 | ASTContext &Context; |
Chris Lattner | 2ae34ed | 2008-02-06 00:46:58 +0000 | [diff] [blame] | 185 | ASTConsumer &Consumer; |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 186 | Diagnostic &Diags; |
| 187 | SourceManager &SourceMgr; |
Steve Naroff | 0330071 | 2007-11-12 13:56:41 +0000 | [diff] [blame] | 188 | |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 189 | /// \brief Source of additional semantic information. |
| 190 | ExternalSemaSource *ExternalSource; |
| 191 | |
Douglas Gregor | 81b747b | 2009-09-17 21:32:03 +0000 | [diff] [blame] | 192 | /// \brief Code-completion consumer. |
| 193 | CodeCompleteConsumer *CodeCompleter; |
| 194 | |
Argyrios Kyrtzidis | 53d0ea5 | 2008-06-28 06:07:14 +0000 | [diff] [blame] | 195 | /// CurContext - This is the current declaration context of parsing. |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 196 | DeclContext *CurContext; |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 197 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 198 | /// CurBlock - If inside of a block definition, this contains a pointer to |
| 199 | /// the active block object that represents it. |
| 200 | BlockSemaInfo *CurBlock; |
| 201 | |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 202 | /// PackContext - Manages the stack for #pragma pack. An alignment |
| 203 | /// of 0 indicates default alignment. |
Chris Lattner | 574aa40 | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 204 | void *PackContext; // Really a "PragmaPackStack*" |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 205 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 206 | /// FunctionLabelMap - This is a mapping from label identifiers to the |
| 207 | /// LabelStmt for it (which acts like the label decl in some ways). Forward |
| 208 | /// referenced labels have a LabelStmt created for them with a null location & |
| 209 | /// SubStmt. |
| 210 | /// |
| 211 | /// Note that this should always be accessed through getLabelMap() in order |
| 212 | /// to handle blocks properly. |
| 213 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> FunctionLabelMap; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 214 | |
Chris Lattner | bcfce66 | 2009-04-18 20:10:59 +0000 | [diff] [blame] | 215 | /// FunctionSwitchStack - This is the current set of active switch statements |
| 216 | /// in the top level function. Clients should always use getSwitchStack() to |
| 217 | /// handle the case when they are in a block. |
| 218 | llvm::SmallVector<SwitchStmt*, 8> FunctionSwitchStack; |
Anders Carlsson | 165a0a0 | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 219 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 220 | /// ExprTemporaries - This is the stack of temporaries that are created by |
Anders Carlsson | 165a0a0 | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 221 | /// the current full expression. |
Anders Carlsson | ff6b3d6 | 2009-05-30 21:05:25 +0000 | [diff] [blame] | 222 | llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries; |
Anders Carlsson | 165a0a0 | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 223 | |
Chris Lattner | 38c5ebd | 2009-04-19 05:21:20 +0000 | [diff] [blame] | 224 | /// CurFunctionNeedsScopeChecking - This is set to true when a function or |
| 225 | /// ObjC method body contains a VLA or an ObjC try block, which introduce |
| 226 | /// scopes that need to be checked for goto conditions. If a function does |
| 227 | /// not contain this, then it need not have the jump checker run on it. |
| 228 | bool CurFunctionNeedsScopeChecking; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 229 | |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 230 | /// ExtVectorDecls - This is a list all the extended vector types. This allows |
| 231 | /// us to associate a raw vector type with one of the ext_vector type names. |
Steve Naroff | bea0b34 | 2007-07-29 16:33:31 +0000 | [diff] [blame] | 232 | /// This is only necessary for issuing pretty diagnostics. |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 233 | llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 234 | |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 235 | /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes. |
| 236 | llvm::OwningPtr<CXXFieldCollector> FieldCollector; |
| 237 | |
Anders Carlsson | 4681ebd | 2009-03-22 20:18:17 +0000 | [diff] [blame] | 238 | typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 239 | |
| 240 | /// PureVirtualClassDiagSet - a set of class declarations which we have |
Anders Carlsson | 4681ebd | 2009-03-22 20:18:17 +0000 | [diff] [blame] | 241 | /// emitted a list of pure virtual functions. Used to prevent emitting the |
| 242 | /// same list more than once. |
| 243 | llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 244 | |
Douglas Gregor | 6393519 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 245 | /// \brief A mapping from external names to the most recent |
| 246 | /// locally-scoped external declaration with that name. |
| 247 | /// |
| 248 | /// This map contains external declarations introduced in local |
| 249 | /// scoped, e.g., |
| 250 | /// |
| 251 | /// \code |
| 252 | /// void f() { |
| 253 | /// void foo(int, int); |
| 254 | /// } |
| 255 | /// \endcode |
| 256 | /// |
| 257 | /// Here, the name "foo" will be associated with the declaration on |
| 258 | /// "foo" within f. This name is not visible outside of |
| 259 | /// "f". However, we still find it in two cases: |
| 260 | /// |
| 261 | /// - If we are declaring another external with the name "foo", we |
| 262 | /// can find "foo" as a previous declaration, so that the types |
| 263 | /// of this external declaration can be checked for |
| 264 | /// compatibility. |
| 265 | /// |
| 266 | /// - If we would implicitly declare "foo" (e.g., due to a call to |
| 267 | /// "foo" in C when no prototype or definition is visible), then |
| 268 | /// we find this declaration of "foo" and complain that it is |
| 269 | /// not visible. |
| 270 | llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls; |
| 271 | |
Douglas Gregor | b6c8c8b | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 272 | /// \brief The set of tentative declarations seen so far in this |
| 273 | /// translation unit for which no definition has been seen. |
| 274 | /// |
| 275 | /// The tentative declarations are indexed by the name of the |
| 276 | /// declaration, and only the most recent tentative declaration for |
| 277 | /// a given variable will be recorded here. |
| 278 | llvm::DenseMap<DeclarationName, VarDecl *> TentativeDefinitions; |
Chris Lattner | 63d65f8 | 2009-09-08 18:19:27 +0000 | [diff] [blame] | 279 | std::vector<DeclarationName> TentativeDefinitionList; |
Douglas Gregor | b6c8c8b | 2009-04-21 17:11:58 +0000 | [diff] [blame] | 280 | |
John McCall | 54abf7d | 2009-11-04 02:18:39 +0000 | [diff] [blame] | 281 | /// \brief The collection of delayed deprecation warnings. |
| 282 | llvm::SmallVector<std::pair<SourceLocation,NamedDecl*>, 8> |
| 283 | DelayedDeprecationWarnings; |
| 284 | |
| 285 | /// \brief The depth of the current ParsingDeclaration stack. |
| 286 | /// If nonzero, we are currently parsing a declaration (and |
| 287 | /// hence should delay deprecation warnings). |
| 288 | unsigned ParsingDeclDepth; |
| 289 | |
Ryan Flynn | e25ff83 | 2009-07-30 03:15:39 +0000 | [diff] [blame] | 290 | /// WeakUndeclaredIdentifiers - Identifiers contained in |
| 291 | /// #pragma weak before declared. rare. may alias another |
| 292 | /// identifier, declared or undeclared |
| 293 | class WeakInfo { |
| 294 | IdentifierInfo *alias; // alias (optional) |
| 295 | SourceLocation loc; // for diagnostics |
| 296 | bool used; // identifier later declared? |
| 297 | public: |
| 298 | WeakInfo() |
| 299 | : alias(0), loc(SourceLocation()), used(false) {} |
| 300 | WeakInfo(IdentifierInfo *Alias, SourceLocation Loc) |
| 301 | : alias(Alias), loc(Loc), used(false) {} |
| 302 | inline IdentifierInfo * getAlias() const { return alias; } |
| 303 | inline SourceLocation getLocation() const { return loc; } |
| 304 | void setUsed(bool Used=true) { used = Used; } |
| 305 | inline bool getUsed() { return used; } |
| 306 | bool operator==(WeakInfo RHS) const { |
| 307 | return alias == RHS.getAlias() && loc == RHS.getLocation(); |
| 308 | } |
| 309 | bool operator!=(WeakInfo RHS) const { return !(*this == RHS); } |
| 310 | }; |
| 311 | llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers; |
| 312 | |
Ryan Flynn | 7b1fdbd | 2009-07-31 02:52:19 +0000 | [diff] [blame] | 313 | /// WeakTopLevelDecl - Translation-unit scoped declarations generated by |
| 314 | /// #pragma weak during processing of other Decls. |
| 315 | /// I couldn't figure out a clean way to generate these in-line, so |
| 316 | /// we store them here and handle separately -- which is a hack. |
| 317 | /// It would be best to refactor this. |
| 318 | llvm::SmallVector<Decl*,2> WeakTopLevelDecl; |
| 319 | |
Chris Lattner | 7f925cc | 2008-04-11 07:00:53 +0000 | [diff] [blame] | 320 | IdentifierResolver IdResolver; |
| 321 | |
Steve Naroff | e440eb8 | 2007-10-10 17:32:04 +0000 | [diff] [blame] | 322 | /// Translation Unit Scope - useful to Objective-C actions that need |
| 323 | /// to lookup file scope declarations in the "ordinary" C decl namespace. |
| 324 | /// For example, user-defined classes, built-in "id" type, etc. |
Steve Naroff | b216c88 | 2007-10-09 22:01:59 +0000 | [diff] [blame] | 325 | Scope *TUScope; |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 326 | |
Douglas Gregor | 7adb10f | 2009-09-15 22:30:29 +0000 | [diff] [blame] | 327 | /// \brief The C++ "std" namespace, where the standard library resides. |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 328 | NamespaceDecl *StdNamespace; |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 329 | |
Douglas Gregor | 7adb10f | 2009-09-15 22:30:29 +0000 | [diff] [blame] | 330 | /// \brief The C++ "std::bad_alloc" class, which is defined by the C++ |
| 331 | /// standard library. |
| 332 | CXXRecordDecl *StdBadAlloc; |
| 333 | |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 334 | /// A flag to remember whether the implicit forms of operator new and delete |
| 335 | /// have been declared. |
| 336 | bool GlobalNewDeleteDeclared; |
Douglas Gregor | f807fe0 | 2009-04-14 16:27:31 +0000 | [diff] [blame] | 337 | |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 338 | /// \brief The set of declarations that have been referenced within |
| 339 | /// a potentially evaluated expression. |
| 340 | typedef std::vector<std::pair<SourceLocation, Decl *> > |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 341 | PotentiallyReferencedDecls; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 342 | |
Douglas Gregor | 06d3369 | 2009-12-12 07:57:52 +0000 | [diff] [blame] | 343 | /// \brief A set of diagnostics that may be emitted. |
| 344 | typedef std::vector<std::pair<SourceLocation, PartialDiagnostic> > |
| 345 | PotentiallyEmittedDiagnostics; |
| 346 | |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 347 | /// \brief Data structure used to record current or nested |
| 348 | /// expression evaluation contexts. |
| 349 | struct ExpressionEvaluationContextRecord { |
| 350 | /// \brief The expression evaluation context. |
| 351 | ExpressionEvaluationContext Context; |
| 352 | |
| 353 | /// \brief The number of temporaries that were active when we |
| 354 | /// entered this expression evaluation context. |
| 355 | unsigned NumTemporaries; |
| 356 | |
| 357 | /// \brief The set of declarations referenced within a |
| 358 | /// potentially potentially-evaluated context. |
| 359 | /// |
| 360 | /// When leaving a potentially potentially-evaluated context, each |
| 361 | /// of these elements will be as referenced if the corresponding |
| 362 | /// potentially potentially evaluated expression is potentially |
| 363 | /// evaluated. |
| 364 | PotentiallyReferencedDecls *PotentiallyReferenced; |
| 365 | |
Douglas Gregor | 06d3369 | 2009-12-12 07:57:52 +0000 | [diff] [blame] | 366 | /// \brief The set of diagnostics to emit should this potentially |
| 367 | /// potentially-evaluated context become evaluated. |
| 368 | PotentiallyEmittedDiagnostics *PotentiallyDiagnosed; |
| 369 | |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 370 | ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, |
| 371 | unsigned NumTemporaries) |
| 372 | : Context(Context), NumTemporaries(NumTemporaries), |
Douglas Gregor | 06d3369 | 2009-12-12 07:57:52 +0000 | [diff] [blame] | 373 | PotentiallyReferenced(0), PotentiallyDiagnosed(0) { } |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 374 | |
| 375 | void addReferencedDecl(SourceLocation Loc, Decl *Decl) { |
| 376 | if (!PotentiallyReferenced) |
| 377 | PotentiallyReferenced = new PotentiallyReferencedDecls; |
| 378 | PotentiallyReferenced->push_back(std::make_pair(Loc, Decl)); |
| 379 | } |
| 380 | |
Douglas Gregor | 06d3369 | 2009-12-12 07:57:52 +0000 | [diff] [blame] | 381 | void addDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) { |
| 382 | if (!PotentiallyDiagnosed) |
| 383 | PotentiallyDiagnosed = new PotentiallyEmittedDiagnostics; |
| 384 | PotentiallyDiagnosed->push_back(std::make_pair(Loc, PD)); |
| 385 | } |
| 386 | |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 387 | void Destroy() { |
| 388 | delete PotentiallyReferenced; |
Douglas Gregor | 06d3369 | 2009-12-12 07:57:52 +0000 | [diff] [blame] | 389 | delete PotentiallyDiagnosed; |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 390 | PotentiallyReferenced = 0; |
Douglas Gregor | 06d3369 | 2009-12-12 07:57:52 +0000 | [diff] [blame] | 391 | PotentiallyDiagnosed = 0; |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 392 | } |
| 393 | }; |
| 394 | |
| 395 | /// A stack of expression evaluation contexts. |
| 396 | llvm::SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 397 | |
Douglas Gregor | f807fe0 | 2009-04-14 16:27:31 +0000 | [diff] [blame] | 398 | /// \brief Whether the code handled by Sema should be considered a |
| 399 | /// complete translation unit or not. |
| 400 | /// |
| 401 | /// When true (which is generally the case), Sema will perform |
| 402 | /// end-of-translation-unit semantic tasks (such as creating |
| 403 | /// initializers for tentative definitions in C) once parsing has |
| 404 | /// completed. This flag will be false when building PCH files, |
| 405 | /// since a PCH file is by definition not a complete translation |
| 406 | /// unit. |
| 407 | bool CompleteTranslationUnit; |
| 408 | |
Argyrios Kyrtzidis | 1bb8a45 | 2009-08-19 01:28:17 +0000 | [diff] [blame] | 409 | llvm::BumpPtrAllocator BumpAlloc; |
| 410 | |
Douglas Gregor | bb26041 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 411 | /// \brief The number of SFINAE diagnostics that have been trapped. |
| 412 | unsigned NumSFINAEErrors; |
| 413 | |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 414 | typedef llvm::DenseMap<Selector, ObjCMethodList> MethodPool; |
| 415 | |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 416 | /// Instance/Factory Method Pools - allows efficient lookup when typechecking |
| 417 | /// messages to "id". We need to maintain a list, since selectors can have |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 418 | /// differing signatures across classes. In Cocoa, this happens to be |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 419 | /// extremely uncommon (only 1% of selectors are "overloaded"). |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 420 | MethodPool InstanceMethodPool; |
| 421 | MethodPool FactoryMethodPool; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 422 | |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 423 | MethodPool::iterator ReadMethodPool(Selector Sel, bool isInstance); |
| 424 | |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 425 | /// Private Helper predicate to check for 'self'. |
| 426 | bool isSelfExpr(Expr *RExpr); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 427 | public: |
Douglas Gregor | f807fe0 | 2009-04-14 16:27:31 +0000 | [diff] [blame] | 428 | Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, |
Daniel Dunbar | 3a2838d | 2009-11-13 08:58:20 +0000 | [diff] [blame] | 429 | bool CompleteTranslationUnit = true, |
| 430 | CodeCompleteConsumer *CompletionConsumer = 0); |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 431 | ~Sema(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 432 | |
Chris Lattner | 53ebff3 | 2009-01-22 19:21:44 +0000 | [diff] [blame] | 433 | const LangOptions &getLangOptions() const { return LangOpts; } |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 434 | Diagnostic &getDiagnostics() const { return Diags; } |
| 435 | SourceManager &getSourceManager() const { return SourceMgr; } |
Anton Korobeynikov | 82d0a41 | 2010-01-10 12:58:08 +0000 | [diff] [blame] | 436 | const TargetAttributesSema &getTargetAttributesSema() const; |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 437 | |
Douglas Gregor | 25a88bb | 2009-03-20 22:48:49 +0000 | [diff] [blame] | 438 | /// \brief Helper class that creates diagnostics with optional |
| 439 | /// template instantiation stacks. |
| 440 | /// |
| 441 | /// This class provides a wrapper around the basic DiagnosticBuilder |
| 442 | /// class that emits diagnostics. SemaDiagnosticBuilder is |
| 443 | /// responsible for emitting the diagnostic (as DiagnosticBuilder |
| 444 | /// does) and, if the diagnostic comes from inside a template |
| 445 | /// instantiation, printing the template instantiation stack as |
| 446 | /// well. |
| 447 | class SemaDiagnosticBuilder : public DiagnosticBuilder { |
| 448 | Sema &SemaRef; |
| 449 | unsigned DiagID; |
| 450 | |
| 451 | public: |
| 452 | SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID) |
| 453 | : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { } |
| 454 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 455 | explicit SemaDiagnosticBuilder(Sema &SemaRef) |
Douglas Gregor | 5e9f35c | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 456 | : DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { } |
| 457 | |
Douglas Gregor | 25a88bb | 2009-03-20 22:48:49 +0000 | [diff] [blame] | 458 | ~SemaDiagnosticBuilder(); |
| 459 | }; |
| 460 | |
| 461 | /// \brief Emit a diagnostic. |
| 462 | SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) { |
Douglas Gregor | 5e9f35c | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 463 | if (isSFINAEContext() && Diagnostic::isBuiltinSFINAEDiag(DiagID)) { |
| 464 | // If we encountered an error during template argument |
| 465 | // deduction, and that error is one of the SFINAE errors, |
Douglas Gregor | bb26041 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 466 | // suppress the diagnostic. |
Douglas Gregor | 8439fac | 2009-06-15 16:52:15 +0000 | [diff] [blame] | 467 | ++NumSFINAEErrors; |
Douglas Gregor | 0b60d9e | 2009-09-25 23:53:26 +0000 | [diff] [blame] | 468 | Diags.setLastDiagnosticIgnored(); |
Douglas Gregor | 8439fac | 2009-06-15 16:52:15 +0000 | [diff] [blame] | 469 | return SemaDiagnosticBuilder(*this); |
Douglas Gregor | 5e9f35c | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 470 | } |
| 471 | |
Douglas Gregor | ee1828a | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 472 | DiagnosticBuilder DB = Diags.Report(FullSourceLoc(Loc, SourceMgr), DiagID); |
Douglas Gregor | 25a88bb | 2009-03-20 22:48:49 +0000 | [diff] [blame] | 473 | return SemaDiagnosticBuilder(DB, *this, DiagID); |
Chris Lattner | 3cfa928 | 2008-11-22 08:28:49 +0000 | [diff] [blame] | 474 | } |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 475 | |
Anders Carlsson | 91a0cc9 | 2009-08-26 22:33:56 +0000 | [diff] [blame] | 476 | /// \brief Emit a partial diagnostic. |
| 477 | SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD); |
| 478 | |
Chris Lattner | 394a3fd | 2007-08-31 04:53:24 +0000 | [diff] [blame] | 479 | virtual void DeleteExpr(ExprTy *E); |
| 480 | virtual void DeleteStmt(StmtTy *S); |
| 481 | |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 482 | OwningExprResult Owned(Expr* E) { |
| 483 | assert(!E || E->isRetained()); |
| 484 | return OwningExprResult(*this, E); |
| 485 | } |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 486 | OwningExprResult Owned(ExprResult R) { |
Douglas Gregor | 5ac8aff | 2009-01-26 22:44:13 +0000 | [diff] [blame] | 487 | if (R.isInvalid()) |
Steve Naroff | 872b9ac | 2009-01-21 22:32:33 +0000 | [diff] [blame] | 488 | return ExprError(); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 489 | assert(!R.get() || ((Expr*) R.get())->isRetained()); |
Douglas Gregor | 5ac8aff | 2009-01-26 22:44:13 +0000 | [diff] [blame] | 490 | return OwningExprResult(*this, R.get()); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 491 | } |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 492 | OwningStmtResult Owned(Stmt* S) { |
| 493 | assert(!S || S->isRetained()); |
| 494 | return OwningStmtResult(*this, S); |
| 495 | } |
Sebastian Redl | 798d119 | 2008-12-13 16:23:55 +0000 | [diff] [blame] | 496 | |
Chris Lattner | 9299f3f | 2008-08-23 03:19:52 +0000 | [diff] [blame] | 497 | virtual void ActOnEndOfTranslationUnit(); |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 498 | |
Chris Lattner | ea29a3a | 2009-04-18 20:01:55 +0000 | [diff] [blame] | 499 | /// getLabelMap() - Return the current label map. If we're in a block, we |
| 500 | /// return it. |
| 501 | llvm::DenseMap<IdentifierInfo*, LabelStmt*> &getLabelMap() { |
| 502 | return CurBlock ? CurBlock->LabelMap : FunctionLabelMap; |
| 503 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 504 | |
Chris Lattner | bcfce66 | 2009-04-18 20:10:59 +0000 | [diff] [blame] | 505 | /// getSwitchStack - This is returns the switch stack for the current block or |
| 506 | /// function. |
| 507 | llvm::SmallVector<SwitchStmt*,8> &getSwitchStack() { |
| 508 | return CurBlock ? CurBlock->SwitchStack : FunctionSwitchStack; |
| 509 | } |
Ryan Flynn | 7b1fdbd | 2009-07-31 02:52:19 +0000 | [diff] [blame] | 510 | |
| 511 | /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls |
| 512 | llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 513 | |
Douglas Gregor | 2e22253 | 2009-07-02 17:08:52 +0000 | [diff] [blame] | 514 | virtual void ActOnComment(SourceRange Comment); |
| 515 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 516 | //===--------------------------------------------------------------------===// |
| 517 | // Type Analysis / Processing: SemaType.cpp. |
| 518 | // |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 519 | QualType adjustParameterType(QualType T); |
Chris Lattner | c9b346d | 2008-06-29 00:50:08 +0000 | [diff] [blame] | 520 | void ProcessTypeAttributeList(QualType &Result, const AttributeList *AL); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 521 | QualType BuildPointerType(QualType T, unsigned Quals, |
Douglas Gregor | cd281c3 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 522 | SourceLocation Loc, DeclarationName Entity); |
Sebastian Redl | 7c80bd6 | 2009-03-16 23:22:08 +0000 | [diff] [blame] | 523 | QualType BuildReferenceType(QualType T, bool LValueRef, unsigned Quals, |
Douglas Gregor | cd281c3 | 2009-02-28 00:25:32 +0000 | [diff] [blame] | 524 | SourceLocation Loc, DeclarationName Entity); |
| 525 | QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, |
| 526 | Expr *ArraySize, unsigned Quals, |
Douglas Gregor | 7e7eb3d | 2009-07-06 15:59:29 +0000 | [diff] [blame] | 527 | SourceRange Brackets, DeclarationName Entity); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 528 | QualType BuildExtVectorType(QualType T, ExprArg ArraySize, |
Douglas Gregor | 9cdda0c | 2009-06-17 21:51:59 +0000 | [diff] [blame] | 529 | SourceLocation AttrLoc); |
Douglas Gregor | 724651c | 2009-02-28 01:04:19 +0000 | [diff] [blame] | 530 | QualType BuildFunctionType(QualType T, |
| 531 | QualType *ParamTypes, unsigned NumParamTypes, |
| 532 | bool Variadic, unsigned Quals, |
| 533 | SourceLocation Loc, DeclarationName Entity); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 534 | QualType BuildMemberPointerType(QualType T, QualType Class, |
| 535 | unsigned Quals, SourceLocation Loc, |
Douglas Gregor | 949bf69 | 2009-06-09 22:17:39 +0000 | [diff] [blame] | 536 | DeclarationName Entity); |
Anders Carlsson | 9a917e4 | 2009-06-12 22:56:54 +0000 | [diff] [blame] | 537 | QualType BuildBlockPointerType(QualType T, unsigned Quals, |
| 538 | SourceLocation Loc, DeclarationName Entity); |
Argyrios Kyrtzidis | a1d5662 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 539 | QualType GetTypeForDeclarator(Declarator &D, Scope *S, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 540 | TypeSourceInfo **TInfo = 0, |
Sebastian Redl | 8ce35b0 | 2009-10-25 21:45:37 +0000 | [diff] [blame] | 541 | TagDecl **OwnedDecl = 0); |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 542 | TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T); |
| 543 | /// \brief Create a LocInfoType to hold the given QualType and TypeSourceInfo. |
| 544 | QualType CreateLocInfoType(QualType T, TypeSourceInfo *TInfo); |
Douglas Gregor | 10bd368 | 2008-11-17 22:58:34 +0000 | [diff] [blame] | 545 | DeclarationName GetNameForDeclarator(Declarator &D); |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 546 | DeclarationName GetNameFromUnqualifiedId(const UnqualifiedId &Name); |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 547 | static QualType GetTypeFromParser(TypeTy *Ty, TypeSourceInfo **TInfo = 0); |
Sebastian Redl | ef65f06 | 2009-05-29 18:02:33 +0000 | [diff] [blame] | 548 | bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range); |
Sebastian Redl | 6a7330c | 2009-05-29 15:01:05 +0000 | [diff] [blame] | 549 | bool CheckDistantExceptionSpec(QualType T); |
Sebastian Redl | 4994d2d | 2009-07-04 11:39:00 +0000 | [diff] [blame] | 550 | bool CheckEquivalentExceptionSpec( |
| 551 | const FunctionProtoType *Old, SourceLocation OldLoc, |
| 552 | const FunctionProtoType *New, SourceLocation NewLoc); |
Sebastian Redl | 37c38ec | 2009-10-14 16:09:29 +0000 | [diff] [blame] | 553 | bool CheckEquivalentExceptionSpec( |
| 554 | const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, |
Sebastian Redl | dced226 | 2009-10-11 09:03:14 +0000 | [diff] [blame] | 555 | const FunctionProtoType *Old, SourceLocation OldLoc, |
| 556 | const FunctionProtoType *New, SourceLocation NewLoc); |
Sebastian Redl | 37c38ec | 2009-10-14 16:09:29 +0000 | [diff] [blame] | 557 | bool CheckExceptionSpecSubset( |
| 558 | const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, |
Sebastian Redl | 23c7d06 | 2009-07-07 20:29:57 +0000 | [diff] [blame] | 559 | const FunctionProtoType *Superset, SourceLocation SuperLoc, |
| 560 | const FunctionProtoType *Subset, SourceLocation SubLoc); |
Sebastian Redl | 37c38ec | 2009-10-14 16:09:29 +0000 | [diff] [blame] | 561 | bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID, |
Sebastian Redl | dced226 | 2009-10-11 09:03:14 +0000 | [diff] [blame] | 562 | const FunctionProtoType *Target, SourceLocation TargetLoc, |
| 563 | const FunctionProtoType *Source, SourceLocation SourceLoc); |
Douglas Gregor | 10bd368 | 2008-11-17 22:58:34 +0000 | [diff] [blame] | 564 | |
Douglas Gregor | 5737326 | 2008-10-22 14:17:15 +0000 | [diff] [blame] | 565 | bool UnwrapSimilarPointerTypes(QualType& T1, QualType& T2); |
| 566 | |
Sebastian Redl | cee63fb | 2008-12-02 14:43:59 +0000 | [diff] [blame] | 567 | virtual TypeResult ActOnTypeName(Scope *S, Declarator &D); |
Sebastian Redl | 37d6de3 | 2008-11-08 13:00:26 +0000 | [diff] [blame] | 568 | |
Anders Carlsson | 91a0cc9 | 2009-08-26 22:33:56 +0000 | [diff] [blame] | 569 | bool RequireCompleteType(SourceLocation Loc, QualType T, |
Anders Carlsson | 8c8d919 | 2009-10-09 23:51:55 +0000 | [diff] [blame] | 570 | const PartialDiagnostic &PD, |
| 571 | std::pair<SourceLocation, |
| 572 | PartialDiagnostic> Note = |
| 573 | std::make_pair(SourceLocation(), PDiag())); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 574 | |
Douglas Gregor | e625893 | 2009-03-19 00:39:20 +0000 | [diff] [blame] | 575 | QualType getQualifiedNameType(const CXXScopeSpec &SS, QualType T); |
| 576 | |
Anders Carlsson | af017e6 | 2009-06-29 22:58:55 +0000 | [diff] [blame] | 577 | QualType BuildTypeofExprType(Expr *E); |
| 578 | QualType BuildDecltypeType(Expr *E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 579 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 580 | //===--------------------------------------------------------------------===// |
| 581 | // Symbol table / Decl tracking callbacks: SemaDecl.cpp. |
| 582 | // |
Chris Lattner | 21ff9c9 | 2009-03-05 01:25:28 +0000 | [diff] [blame] | 583 | |
| 584 | /// getDeclName - Return a pretty name for the specified decl if possible, or |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 585 | /// an empty string if not. This is used for pretty crash reporting. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 586 | virtual std::string getDeclName(DeclPtrTy D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 587 | |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 588 | DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr); |
| 589 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 590 | virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc, |
Douglas Gregor | 42c39f3 | 2009-08-26 18:27:52 +0000 | [diff] [blame] | 591 | Scope *S, const CXXScopeSpec *SS, |
Douglas Gregor | f6e6fc8 | 2009-11-20 22:03:38 +0000 | [diff] [blame] | 592 | bool isClassName = false, |
| 593 | TypeTy *ObjectType = 0); |
Chris Lattner | 4c97d76 | 2009-04-12 21:49:30 +0000 | [diff] [blame] | 594 | virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S); |
Douglas Gregor | a786fdb | 2009-10-13 23:27:22 +0000 | [diff] [blame] | 595 | virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II, |
| 596 | SourceLocation IILoc, |
| 597 | Scope *S, |
| 598 | const CXXScopeSpec *SS, |
| 599 | TypeTy *&SuggestedType); |
| 600 | |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 601 | virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) { |
Douglas Gregor | e542c86 | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 602 | return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false); |
Douglas Gregor | 584049d | 2008-12-15 23:53:10 +0000 | [diff] [blame] | 603 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 604 | |
| 605 | DeclPtrTy HandleDeclarator(Scope *S, Declarator &D, |
Douglas Gregor | e542c86 | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 606 | MultiTemplateParamsArg TemplateParameterLists, |
| 607 | bool IsFunctionDefinition); |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 608 | void RegisterLocallyScopedExternCDecl(NamedDecl *ND, |
| 609 | const LookupResult &Previous, |
Douglas Gregor | 6393519 | 2009-03-02 00:19:53 +0000 | [diff] [blame] | 610 | Scope *S); |
Eli Friedman | 85a5319 | 2009-04-07 19:37:57 +0000 | [diff] [blame] | 611 | void DiagnoseFunctionSpecifiers(Declarator& D); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 612 | NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 613 | QualType R, TypeSourceInfo *TInfo, |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 614 | LookupResult &Previous, bool &Redeclaration); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 615 | NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 616 | QualType R, TypeSourceInfo *TInfo, |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 617 | LookupResult &Previous, |
Douglas Gregor | dfe3f2d | 2009-07-22 17:18:37 +0000 | [diff] [blame] | 618 | MultiTemplateParamsArg TemplateParamLists, |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 619 | bool &Redeclaration); |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 620 | void CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous, |
Douglas Gregor | 3d7a12a | 2009-03-25 23:32:15 +0000 | [diff] [blame] | 621 | bool &Redeclaration); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 622 | NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 623 | QualType R, TypeSourceInfo *TInfo, |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 624 | LookupResult &Previous, |
Douglas Gregor | e542c86 | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 625 | MultiTemplateParamsArg TemplateParamLists, |
Douglas Gregor | 04495c8 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 626 | bool IsFunctionDefinition, |
Chris Lattner | eaaebc7 | 2009-04-25 08:06:05 +0000 | [diff] [blame] | 627 | bool &Redeclaration); |
Sebastian Redl | a165da0 | 2009-11-18 21:51:29 +0000 | [diff] [blame] | 628 | void AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD); |
John McCall | 9f54ad4 | 2009-12-10 09:41:52 +0000 | [diff] [blame] | 629 | void CheckFunctionDeclaration(Scope *S, |
| 630 | FunctionDecl *NewFD, LookupResult &Previous, |
Douglas Gregor | fd056bc | 2009-10-13 16:30:37 +0000 | [diff] [blame] | 631 | bool IsExplicitSpecialization, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 632 | bool &Redeclaration, |
Douglas Gregor | 2dc0e64 | 2009-03-23 23:06:20 +0000 | [diff] [blame] | 633 | bool &OverloadableAttrRequired); |
John McCall | 8c4859a | 2009-07-24 03:03:21 +0000 | [diff] [blame] | 634 | void CheckMain(FunctionDecl *FD); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 635 | virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D); |
| 636 | virtual void ActOnParamDefaultArgument(DeclPtrTy param, |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 637 | SourceLocation EqualLoc, |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 638 | ExprArg defarg); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 639 | virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param, |
Anders Carlsson | 5e300d1 | 2009-06-12 16:51:40 +0000 | [diff] [blame] | 640 | SourceLocation EqualLoc, |
| 641 | SourceLocation ArgLoc); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 642 | virtual void ActOnParamDefaultArgumentError(DeclPtrTy param); |
Anders Carlsson | ed961f9 | 2009-08-25 02:29:20 +0000 | [diff] [blame] | 643 | bool SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg, |
| 644 | SourceLocation EqualLoc); |
| 645 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 646 | |
Anders Carlsson | 5e300d1 | 2009-06-12 16:51:40 +0000 | [diff] [blame] | 647 | // Contains the locations of the beginning of unparsed default |
| 648 | // argument locations. |
| 649 | llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs; |
| 650 | |
Anders Carlsson | 9abf2ae | 2009-08-16 05:13:48 +0000 | [diff] [blame] | 651 | virtual void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 652 | void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit); |
Anders Carlsson | 6a75cd9 | 2009-07-11 00:34:39 +0000 | [diff] [blame] | 653 | void ActOnUninitializedDecl(DeclPtrTy dcl, bool TypeContainsUndeducedAuto); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 654 | virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc); |
Eli Friedman | c1dc653 | 2009-05-29 01:49:24 +0000 | [diff] [blame] | 655 | virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, |
| 656 | DeclPtrTy *Group, |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 657 | unsigned NumDecls); |
Douglas Gregor | a3a8351 | 2009-04-01 23:51:29 +0000 | [diff] [blame] | 658 | virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, |
| 659 | SourceLocation LocAfterDecls); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 660 | virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, Declarator &D); |
| 661 | virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, DeclPtrTy D); |
| 662 | virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclPtrTy D); |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 663 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 664 | virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body); |
Douglas Gregor | e2c31ff | 2009-05-15 17:59:04 +0000 | [diff] [blame] | 665 | DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body, |
| 666 | bool IsInstantiation); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 667 | |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 668 | /// \brief Diagnose any unused parameters in the given sequence of |
| 669 | /// ParmVarDecl pointers. |
| 670 | template<typename InputIterator> |
| 671 | void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) { |
| 672 | for (; Param != ParamEnd; ++Param) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 673 | if (!(*Param)->isUsed() && (*Param)->getDeclName() && |
Argyrios Kyrtzidis | 40b598e | 2009-06-30 02:34:44 +0000 | [diff] [blame] | 674 | !(*Param)->template hasAttr<UnusedAttr>()) |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 675 | Diag((*Param)->getLocation(), diag::warn_unused_parameter) |
| 676 | << (*Param)->getDeclName(); |
| 677 | } |
| 678 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 679 | |
Chris Lattner | 5af280c | 2009-04-19 04:46:21 +0000 | [diff] [blame] | 680 | void DiagnoseInvalidJumps(Stmt *Body); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 681 | virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr); |
Anders Carlsson | dfab6cb | 2008-02-08 00:33:21 +0000 | [diff] [blame] | 682 | |
Steve Naroff | b216c88 | 2007-10-09 22:01:59 +0000 | [diff] [blame] | 683 | /// Scope actions. |
| 684 | virtual void ActOnPopScope(SourceLocation Loc, Scope *S); |
| 685 | virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 686 | |
| 687 | /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with |
| 688 | /// no declarator (e.g. "struct foo;") is parsed. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 689 | virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, DeclSpec &DS); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 690 | |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 691 | bool InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, |
| 692 | RecordDecl *AnonRecord); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 693 | virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 694 | RecordDecl *Record); |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 695 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 696 | bool isAcceptableTagRedeclaration(const TagDecl *Previous, |
Douglas Gregor | 501c5ce | 2009-05-14 16:41:31 +0000 | [diff] [blame] | 697 | TagDecl::TagKind NewTag, |
| 698 | SourceLocation NewTagLoc, |
| 699 | const IdentifierInfo &Name); |
Douglas Gregor | ed4ec8f | 2009-05-03 17:18:57 +0000 | [diff] [blame] | 700 | |
John McCall | 0f434ec | 2009-07-31 02:45:11 +0000 | [diff] [blame] | 701 | virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 702 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 703 | IdentifierInfo *Name, SourceLocation NameLoc, |
Douglas Gregor | 402abb5 | 2009-05-28 23:31:59 +0000 | [diff] [blame] | 704 | AttributeList *Attr, AccessSpecifier AS, |
Douglas Gregor | 7cdbc58 | 2009-07-22 23:48:44 +0000 | [diff] [blame] | 705 | MultiTemplateParamsArg TemplateParameterLists, |
John McCall | c4e7019 | 2009-09-11 04:59:25 +0000 | [diff] [blame] | 706 | bool &OwnedDecl, bool &IsDependent); |
| 707 | |
| 708 | virtual TypeResult ActOnDependentTag(Scope *S, |
| 709 | unsigned TagSpec, |
| 710 | TagUseKind TUK, |
| 711 | const CXXScopeSpec &SS, |
| 712 | IdentifierInfo *Name, |
| 713 | SourceLocation TagLoc, |
| 714 | SourceLocation NameLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 715 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 716 | virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart, |
Chris Lattner | 06f5485 | 2008-08-23 02:00:52 +0000 | [diff] [blame] | 717 | IdentifierInfo *ClassName, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 718 | llvm::SmallVectorImpl<DeclPtrTy> &Decls); |
| 719 | virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD, |
| 720 | SourceLocation DeclStart, |
| 721 | Declarator &D, ExprTy *BitfieldWidth); |
Chris Lattner | 2479366 | 2009-03-05 22:45:59 +0000 | [diff] [blame] | 722 | |
| 723 | FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, |
Douglas Gregor | 4dd55f5 | 2009-03-11 20:50:30 +0000 | [diff] [blame] | 724 | Declarator &D, Expr *BitfieldWidth, |
| 725 | AccessSpecifier AS); |
Chris Lattner | 2479366 | 2009-03-05 22:45:59 +0000 | [diff] [blame] | 726 | |
Argyrios Kyrtzidis | a1d5662 | 2009-08-19 01:27:57 +0000 | [diff] [blame] | 727 | FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 728 | TypeSourceInfo *TInfo, |
Douglas Gregor | 3cf538d | 2009-03-11 18:59:21 +0000 | [diff] [blame] | 729 | RecordDecl *Record, SourceLocation Loc, |
| 730 | bool Mutable, Expr *BitfieldWidth, |
Steve Naroff | ea218b8 | 2009-07-14 14:58:18 +0000 | [diff] [blame] | 731 | SourceLocation TSSL, |
Douglas Gregor | 4dd55f5 | 2009-03-11 20:50:30 +0000 | [diff] [blame] | 732 | AccessSpecifier AS, NamedDecl *PrevDecl, |
Douglas Gregor | 3cf538d | 2009-03-11 18:59:21 +0000 | [diff] [blame] | 733 | Declarator *D = 0); |
Douglas Gregor | 1f2023a | 2009-07-22 18:25:24 +0000 | [diff] [blame] | 734 | |
| 735 | enum CXXSpecialMember { |
| 736 | CXXDefaultConstructor = 0, |
| 737 | CXXCopyConstructor = 1, |
| 738 | CXXCopyAssignment = 2, |
| 739 | CXXDestructor = 3 |
| 740 | }; |
| 741 | void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 742 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 743 | virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart, |
Fariborz Jahanian | 496b5a8 | 2009-06-05 18:16:35 +0000 | [diff] [blame] | 744 | DeclPtrTy IntfDecl, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 745 | Declarator &D, ExprTy *BitfieldWidth, |
| 746 | tok::ObjCKeywordKind visibility); |
Fariborz Jahanian | 1d78cc4 | 2008-04-10 23:32:45 +0000 | [diff] [blame] | 747 | |
Steve Naroff | f13271f | 2007-09-14 23:09:53 +0000 | [diff] [blame] | 748 | // This is used for both record definitions and ObjC interface declarations. |
Fariborz Jahanian | 9d048ff | 2007-09-29 00:54:24 +0000 | [diff] [blame] | 749 | virtual void ActOnFields(Scope* S, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 750 | SourceLocation RecLoc, DeclPtrTy TagDecl, |
| 751 | DeclPtrTy *Fields, unsigned NumFields, |
Daniel Dunbar | 1bfe1c2 | 2008-10-03 02:03:53 +0000 | [diff] [blame] | 752 | SourceLocation LBrac, SourceLocation RBrac, |
| 753 | AttributeList *AttrList); |
Douglas Gregor | 72de667 | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 754 | |
| 755 | /// ActOnTagStartDefinition - Invoked when we have entered the |
| 756 | /// scope of a tag's definition (e.g., for an enumeration, class, |
| 757 | /// struct, or union). |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 758 | virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl); |
Douglas Gregor | 72de667 | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 759 | |
John McCall | f936815 | 2009-12-20 07:58:13 +0000 | [diff] [blame] | 760 | /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a |
| 761 | /// C++ record definition's base-specifiers clause and are starting its |
| 762 | /// member declarations. |
| 763 | virtual void ActOnStartCXXMemberDeclarations(Scope *S, DeclPtrTy TagDecl, |
| 764 | SourceLocation LBraceLoc); |
| 765 | |
Douglas Gregor | 72de667 | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 766 | /// ActOnTagFinishDefinition - Invoked once we have finished parsing |
| 767 | /// the definition of a tag (enumeration, class, struct, or union). |
Argyrios Kyrtzidis | 07a5b28 | 2009-07-14 03:17:52 +0000 | [diff] [blame] | 768 | virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl, |
| 769 | SourceLocation RBraceLoc); |
Douglas Gregor | 72de667 | 2009-01-08 20:45:30 +0000 | [diff] [blame] | 770 | |
Douglas Gregor | 879fd49 | 2009-03-17 19:05:46 +0000 | [diff] [blame] | 771 | EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum, |
| 772 | EnumConstantDecl *LastEnumConst, |
| 773 | SourceLocation IdLoc, |
| 774 | IdentifierInfo *Id, |
| 775 | ExprArg val); |
| 776 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 777 | virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl, |
| 778 | DeclPtrTy LastEnumConstant, |
| 779 | SourceLocation IdLoc, IdentifierInfo *Id, |
| 780 | SourceLocation EqualLoc, ExprTy *Val); |
Mike Stump | c6e35aa | 2009-05-16 07:06:02 +0000 | [diff] [blame] | 781 | virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, |
| 782 | SourceLocation RBraceLoc, DeclPtrTy EnumDecl, |
Edward O'Callaghan | fee1381 | 2009-08-08 14:36:57 +0000 | [diff] [blame] | 783 | DeclPtrTy *Elements, unsigned NumElements, |
| 784 | Scope *S, AttributeList *Attr); |
Sebastian Redl | 37d6de3 | 2008-11-08 13:00:26 +0000 | [diff] [blame] | 785 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 786 | DeclContext *getContainingDC(DeclContext *DC); |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 787 | |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 788 | /// Set the current declaration context until it gets popped. |
Douglas Gregor | 44b4321 | 2008-12-11 16:49:14 +0000 | [diff] [blame] | 789 | void PushDeclContext(Scope *S, DeclContext *DC); |
Chris Lattner | b048c98 | 2008-04-06 04:47:34 +0000 | [diff] [blame] | 790 | void PopDeclContext(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 791 | |
Argyrios Kyrtzidis | 1d17553 | 2009-06-17 23:15:40 +0000 | [diff] [blame] | 792 | /// EnterDeclaratorContext - Used when we must lookup names in the context |
| 793 | /// of a declarator's nested name specifier. |
| 794 | void EnterDeclaratorContext(Scope *S, DeclContext *DC); |
| 795 | void ExitDeclaratorContext(Scope *S); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 796 | |
Anders Carlsson | 8517d9b | 2009-08-08 17:45:02 +0000 | [diff] [blame] | 797 | DeclContext *getFunctionLevelDeclContext(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 798 | |
Chris Lattner | 371f258 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 799 | /// getCurFunctionDecl - If inside of a function body, this returns a pointer |
| 800 | /// to the function decl for the function being parsed. If we're currently |
| 801 | /// in a 'block', this returns the containing context. |
| 802 | FunctionDecl *getCurFunctionDecl(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 803 | |
Chris Lattner | 371f258 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 804 | /// getCurMethodDecl - If inside of a method body, this returns a pointer to |
| 805 | /// the method decl for the method being parsed. If we're currently |
| 806 | /// in a 'block', this returns the containing context. |
Daniel Dunbar | c4a1dea | 2008-08-11 05:35:13 +0000 | [diff] [blame] | 807 | ObjCMethodDecl *getCurMethodDecl(); |
Chris Lattner | 0ed844b | 2008-04-04 06:12:32 +0000 | [diff] [blame] | 808 | |
Chris Lattner | 371f258 | 2008-12-04 23:50:19 +0000 | [diff] [blame] | 809 | /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method |
| 810 | /// or C function we're in, otherwise return null. If we're currently |
| 811 | /// in a 'block', this returns the containing context. |
| 812 | NamedDecl *getCurFunctionOrMethodDecl(); |
| 813 | |
Argyrios Kyrtzidis | 87f3ff0 | 2008-04-12 00:47:19 +0000 | [diff] [blame] | 814 | /// Add this decl to the scope shadowed decl chains. |
John McCall | ab88d97 | 2009-08-31 22:39:49 +0000 | [diff] [blame] | 815 | void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true); |
Argyrios Kyrtzidis | 87f3ff0 | 2008-04-12 00:47:19 +0000 | [diff] [blame] | 816 | |
Argyrios Kyrtzidis | 15a12d0 | 2008-09-09 21:18:04 +0000 | [diff] [blame] | 817 | /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true |
| 818 | /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns |
| 819 | /// true if 'D' belongs to the given declaration context. |
Douglas Gregor | 2531c2d | 2009-09-28 00:47:05 +0000 | [diff] [blame] | 820 | bool isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S = 0); |
Argyrios Kyrtzidis | 15a12d0 | 2008-09-09 21:18:04 +0000 | [diff] [blame] | 821 | |
John McCall | ab88d97 | 2009-08-31 22:39:49 +0000 | [diff] [blame] | 822 | /// Finds the scope corresponding to the given decl context, if it |
| 823 | /// happens to be an enclosing scope. Otherwise return NULL. |
| 824 | Scope *getScopeForDeclContext(Scope *S, DeclContext *DC) { |
John McCall | 1a26c27 | 2009-09-02 01:07:03 +0000 | [diff] [blame] | 825 | DeclContext *TargetDC = DC->getPrimaryContext(); |
John McCall | ab88d97 | 2009-08-31 22:39:49 +0000 | [diff] [blame] | 826 | do { |
John McCall | 1a26c27 | 2009-09-02 01:07:03 +0000 | [diff] [blame] | 827 | if (DeclContext *ScopeDC = (DeclContext*) S->getEntity()) |
| 828 | if (ScopeDC->getPrimaryContext() == TargetDC) |
| 829 | return S; |
John McCall | ab88d97 | 2009-08-31 22:39:49 +0000 | [diff] [blame] | 830 | } while ((S = S->getParent())); |
| 831 | |
| 832 | return NULL; |
| 833 | } |
| 834 | |
Chris Lattner | f1d705c | 2008-02-21 01:07:18 +0000 | [diff] [blame] | 835 | /// Subroutines of ActOnDeclarator(). |
John McCall | ba6a9bd | 2009-10-24 08:00:42 +0000 | [diff] [blame] | 836 | TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 837 | TypeSourceInfo *TInfo); |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 838 | void MergeTypeDefDecl(TypedefDecl *New, LookupResult &OldDecls); |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 839 | bool MergeFunctionDecl(FunctionDecl *New, Decl *Old); |
Douglas Gregor | 04495c8 | 2009-02-24 01:23:02 +0000 | [diff] [blame] | 840 | bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old); |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 841 | void MergeVarDecl(VarDecl *New, LookupResult &OldDecls); |
Douglas Gregor | cda9c67 | 2009-02-16 17:45:42 +0000 | [diff] [blame] | 842 | bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 843 | |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 844 | // AssignmentAction - This is used by all the assignment diagnostic functions |
| 845 | // to represent what is actually causing the operation |
| 846 | enum AssignmentAction { |
| 847 | AA_Assigning, |
| 848 | AA_Passing, |
| 849 | AA_Returning, |
| 850 | AA_Converting, |
| 851 | AA_Initializing, |
| 852 | AA_Sending, |
| 853 | AA_Casting |
| 854 | }; |
| 855 | |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 856 | /// C++ Overloading. |
John McCall | 871b2e7 | 2009-12-09 03:35:25 +0000 | [diff] [blame] | 857 | enum OverloadKind { |
| 858 | /// This is a legitimate overload: the existing declarations are |
| 859 | /// functions or function templates with different signatures. |
| 860 | Ovl_Overload, |
| 861 | |
| 862 | /// This is not an overload because the signature exactly matches |
| 863 | /// an existing declaration. |
| 864 | Ovl_Match, |
| 865 | |
| 866 | /// This is not an overload because the lookup results contain a |
| 867 | /// non-function. |
| 868 | Ovl_NonFunction |
| 869 | }; |
| 870 | OverloadKind CheckOverload(FunctionDecl *New, |
John McCall | 9f54ad4 | 2009-12-10 09:41:52 +0000 | [diff] [blame] | 871 | const LookupResult &OldDecls, |
John McCall | 871b2e7 | 2009-12-09 03:35:25 +0000 | [diff] [blame] | 872 | NamedDecl *&OldDecl); |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 873 | bool IsOverload(FunctionDecl *New, FunctionDecl *Old); |
| 874 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 875 | ImplicitConversionSequence |
Anders Carlsson | 2974b5c | 2009-08-27 17:14:02 +0000 | [diff] [blame] | 876 | TryImplicitConversion(Expr* From, QualType ToType, |
Anders Carlsson | da7a18b | 2009-08-27 17:24:15 +0000 | [diff] [blame] | 877 | bool SuppressUserConversions, |
| 878 | bool AllowExplicit, |
Anders Carlsson | 0897292 | 2009-08-28 15:33:32 +0000 | [diff] [blame] | 879 | bool ForceRValue, |
Fariborz Jahanian | 249cead | 2009-10-01 20:39:51 +0000 | [diff] [blame] | 880 | bool InOverloadResolution, |
| 881 | bool UserCast = false); |
Anders Carlsson | 0897292 | 2009-08-28 15:33:32 +0000 | [diff] [blame] | 882 | bool IsStandardConversion(Expr *From, QualType ToType, |
| 883 | bool InOverloadResolution, |
Douglas Gregor | 60d62c2 | 2008-10-31 16:23:19 +0000 | [diff] [blame] | 884 | StandardConversionSequence& SCS); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 885 | bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType); |
| 886 | bool IsFloatingPointPromotion(QualType FromType, QualType ToType); |
Douglas Gregor | 5cdf821 | 2009-02-12 00:15:05 +0000 | [diff] [blame] | 887 | bool IsComplexPromotion(QualType FromType, QualType ToType); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 888 | bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, |
Anders Carlsson | 0897292 | 2009-08-28 15:33:32 +0000 | [diff] [blame] | 889 | bool InOverloadResolution, |
Douglas Gregor | 45920e8 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 890 | QualType& ConvertedType, bool &IncompatibleObjC); |
Douglas Gregor | c788751 | 2008-12-19 19:13:09 +0000 | [diff] [blame] | 891 | bool isObjCPointerConversion(QualType FromType, QualType ToType, |
| 892 | QualType& ConvertedType, bool &IncompatibleObjC); |
Sebastian Redl | a82e4ae | 2009-11-14 21:15:49 +0000 | [diff] [blame] | 893 | bool CheckPointerConversion(Expr *From, QualType ToType, |
| 894 | CastExpr::CastKind &Kind, |
| 895 | bool IgnoreBaseAccess); |
Sebastian Redl | 4433aaf | 2009-01-25 19:43:20 +0000 | [diff] [blame] | 896 | bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, |
Douglas Gregor | ce94049 | 2009-09-25 04:25:58 +0000 | [diff] [blame] | 897 | bool InOverloadResolution, |
Sebastian Redl | 4433aaf | 2009-01-25 19:43:20 +0000 | [diff] [blame] | 898 | QualType &ConvertedType); |
Anders Carlsson | 27a5b9b | 2009-08-22 23:33:40 +0000 | [diff] [blame] | 899 | bool CheckMemberPointerConversion(Expr *From, QualType ToType, |
Sebastian Redl | a82e4ae | 2009-11-14 21:15:49 +0000 | [diff] [blame] | 900 | CastExpr::CastKind &Kind, |
| 901 | bool IgnoreBaseAccess); |
Douglas Gregor | 98cd599 | 2008-10-21 23:43:52 +0000 | [diff] [blame] | 902 | bool IsQualificationConversion(QualType FromType, QualType ToType); |
Fariborz Jahanian | 34acd3e | 2009-09-15 19:12:21 +0000 | [diff] [blame] | 903 | OverloadingResult IsUserDefinedConversion(Expr *From, QualType ToType, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 904 | UserDefinedConversionSequence& User, |
Fariborz Jahanian | 78cf9a2 | 2009-09-15 00:10:11 +0000 | [diff] [blame] | 905 | OverloadCandidateSet& Conversions, |
Douglas Gregor | 734d986 | 2009-01-30 23:27:23 +0000 | [diff] [blame] | 906 | bool AllowConversionFunctions, |
Fariborz Jahanian | 249cead | 2009-10-01 20:39:51 +0000 | [diff] [blame] | 907 | bool AllowExplicit, bool ForceRValue, |
| 908 | bool UserCast = false); |
Fariborz Jahanian | cc5306a | 2009-11-18 18:26:29 +0000 | [diff] [blame] | 909 | bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType); |
Fariborz Jahanian | 17c7a5d | 2009-09-22 20:24:30 +0000 | [diff] [blame] | 910 | |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 911 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 912 | ImplicitConversionSequence::CompareKind |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 913 | CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1, |
| 914 | const ImplicitConversionSequence& ICS2); |
| 915 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 916 | ImplicitConversionSequence::CompareKind |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 917 | CompareStandardConversionSequences(const StandardConversionSequence& SCS1, |
| 918 | const StandardConversionSequence& SCS2); |
| 919 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 920 | ImplicitConversionSequence::CompareKind |
Douglas Gregor | 5737326 | 2008-10-22 14:17:15 +0000 | [diff] [blame] | 921 | CompareQualificationConversions(const StandardConversionSequence& SCS1, |
| 922 | const StandardConversionSequence& SCS2); |
| 923 | |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 924 | ImplicitConversionSequence::CompareKind |
| 925 | CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1, |
| 926 | const StandardConversionSequence& SCS2); |
| 927 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 928 | ImplicitConversionSequence |
Douglas Gregor | 225c41e | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 929 | TryCopyInitialization(Expr* From, QualType ToType, |
Anders Carlsson | 7b361b5 | 2009-08-27 17:37:39 +0000 | [diff] [blame] | 930 | bool SuppressUserConversions, bool ForceRValue, |
| 931 | bool InOverloadResolution); |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 932 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 933 | bool PerformCopyInitialization(Expr *&From, QualType ToType, |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 934 | AssignmentAction Action, bool Elidable = false); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 935 | |
Douglas Gregor | 18ef5e2 | 2009-12-18 05:02:21 +0000 | [diff] [blame] | 936 | OwningExprResult PerformCopyInitialization(const InitializedEntity &Entity, |
| 937 | SourceLocation EqualLoc, |
| 938 | OwningExprResult Init); |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 939 | ImplicitConversionSequence |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 940 | TryObjectArgumentInitialization(QualType FromType, CXXMethodDecl *Method, |
| 941 | CXXRecordDecl *ActingContext); |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 942 | bool PerformObjectArgumentInitialization(Expr *&From, CXXMethodDecl *Method); |
| 943 | |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 944 | ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From); |
| 945 | bool PerformContextuallyConvertToBool(Expr *&From); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 946 | |
Fariborz Jahanian | f3e53d3 | 2009-07-29 19:40:11 +0000 | [diff] [blame] | 947 | bool PerformObjectMemberConversion(Expr *&From, NamedDecl *Member); |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 948 | |
John McCall | 6ff0785 | 2009-08-07 22:18:02 +0000 | [diff] [blame] | 949 | // Members have to be NamespaceDecl* or TranslationUnitDecl*. |
| 950 | // TODO: make this is a typesafe union. |
| 951 | typedef llvm::SmallPtrSet<DeclContext *, 16> AssociatedNamespaceSet; |
| 952 | |
Douglas Gregor | 364e021 | 2009-06-27 21:05:07 +0000 | [diff] [blame] | 953 | typedef llvm::SmallPtrSet<AnyFunctionDecl, 16> FunctionSet; |
Douglas Gregor | 063daf6 | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 954 | typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet; |
| 955 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 956 | void AddOverloadCandidate(FunctionDecl *Function, |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 957 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 225c41e | 2008-11-03 19:09:14 +0000 | [diff] [blame] | 958 | OverloadCandidateSet& CandidateSet, |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 959 | bool SuppressUserConversions = false, |
Douglas Gregor | 9c6a0e9 | 2009-09-22 15:41:20 +0000 | [diff] [blame] | 960 | bool ForceRValue = false, |
| 961 | bool PartialOverloading = false); |
Douglas Gregor | 063daf6 | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 962 | void AddFunctionCandidates(const FunctionSet &Functions, |
| 963 | Expr **Args, unsigned NumArgs, |
| 964 | OverloadCandidateSet& CandidateSet, |
| 965 | bool SuppressUserConversions = false); |
John McCall | 314be4e | 2009-11-17 07:50:12 +0000 | [diff] [blame] | 966 | void AddMethodCandidate(NamedDecl *Decl, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 967 | QualType ObjectType, Expr **Args, unsigned NumArgs, |
John McCall | 314be4e | 2009-11-17 07:50:12 +0000 | [diff] [blame] | 968 | OverloadCandidateSet& CandidateSet, |
| 969 | bool SuppressUserConversion = false, |
| 970 | bool ForceRValue = false); |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 971 | void AddMethodCandidate(CXXMethodDecl *Method, CXXRecordDecl *ActingContext, |
| 972 | QualType ObjectType, Expr **Args, unsigned NumArgs, |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 973 | OverloadCandidateSet& CandidateSet, |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 974 | bool SuppressUserConversions = false, |
| 975 | bool ForceRValue = false); |
Douglas Gregor | 6b90686 | 2009-08-21 00:16:32 +0000 | [diff] [blame] | 976 | void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 977 | CXXRecordDecl *ActingContext, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 978 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 979 | QualType ObjectType, |
| 980 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 6b90686 | 2009-08-21 00:16:32 +0000 | [diff] [blame] | 981 | OverloadCandidateSet& CandidateSet, |
| 982 | bool SuppressUserConversions = false, |
| 983 | bool ForceRValue = false); |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 984 | void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 985 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 986 | Expr **Args, unsigned NumArgs, |
| 987 | OverloadCandidateSet& CandidateSet, |
| 988 | bool SuppressUserConversions = false, |
| 989 | bool ForceRValue = false); |
Douglas Gregor | f1991ea | 2008-11-07 22:36:19 +0000 | [diff] [blame] | 990 | void AddConversionCandidate(CXXConversionDecl *Conversion, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 991 | CXXRecordDecl *ActingContext, |
Douglas Gregor | f1991ea | 2008-11-07 22:36:19 +0000 | [diff] [blame] | 992 | Expr *From, QualType ToType, |
| 993 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | 65ec1fd | 2009-08-21 23:19:43 +0000 | [diff] [blame] | 994 | void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 995 | CXXRecordDecl *ActingContext, |
Douglas Gregor | 65ec1fd | 2009-08-21 23:19:43 +0000 | [diff] [blame] | 996 | Expr *From, QualType ToType, |
| 997 | OverloadCandidateSet &CandidateSet); |
Douglas Gregor | 106c6eb | 2008-11-19 22:57:39 +0000 | [diff] [blame] | 998 | void AddSurrogateCandidate(CXXConversionDecl *Conversion, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 999 | CXXRecordDecl *ActingContext, |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 1000 | const FunctionProtoType *Proto, |
John McCall | 701c89e | 2009-12-03 04:06:58 +0000 | [diff] [blame] | 1001 | QualType ObjectTy, Expr **Args, unsigned NumArgs, |
Douglas Gregor | 106c6eb | 2008-11-19 22:57:39 +0000 | [diff] [blame] | 1002 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | 063daf6 | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 1003 | void AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S, |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 1004 | SourceLocation OpLoc, |
Douglas Gregor | 96176b3 | 2008-11-18 23:14:02 +0000 | [diff] [blame] | 1005 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 1006 | OverloadCandidateSet& CandidateSet, |
| 1007 | SourceRange OpRange = SourceRange()); |
Douglas Gregor | 063daf6 | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 1008 | void AddMemberOperatorCandidates(OverloadedOperatorKind Op, |
| 1009 | SourceLocation OpLoc, |
| 1010 | Expr **Args, unsigned NumArgs, |
| 1011 | OverloadCandidateSet& CandidateSet, |
| 1012 | SourceRange OpRange = SourceRange()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1013 | void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 1014 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 88b4bf2 | 2009-01-13 00:52:54 +0000 | [diff] [blame] | 1015 | OverloadCandidateSet& CandidateSet, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 1016 | bool IsAssignmentOperator = false, |
| 1017 | unsigned NumContextualBoolArguments = 0); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1018 | void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, |
Douglas Gregor | 573d9c3 | 2009-10-21 23:19:44 +0000 | [diff] [blame] | 1019 | SourceLocation OpLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1020 | Expr **Args, unsigned NumArgs, |
Douglas Gregor | 7425373 | 2008-11-19 15:42:04 +0000 | [diff] [blame] | 1021 | OverloadCandidateSet& CandidateSet); |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 1022 | void AddArgumentDependentLookupCandidates(DeclarationName Name, |
| 1023 | Expr **Args, unsigned NumArgs, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 1024 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
Douglas Gregor | 9c6a0e9 | 2009-09-22 15:41:20 +0000 | [diff] [blame] | 1025 | OverloadCandidateSet& CandidateSet, |
| 1026 | bool PartialOverloading = false); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 1027 | bool isBetterOverloadCandidate(const OverloadCandidate& Cand1, |
| 1028 | const OverloadCandidate& Cand2); |
| 1029 | OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet, |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 1030 | SourceLocation Loc, |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 1031 | OverloadCandidateSet::iterator& Best); |
John McCall | 8120162 | 2010-01-08 04:41:39 +0000 | [diff] [blame] | 1032 | |
| 1033 | enum OverloadCandidateDisplayKind { |
| 1034 | /// Requests that all candidates be shown. Viable candidates will |
| 1035 | /// be printed first. |
| 1036 | OCD_AllCandidates, |
| 1037 | |
| 1038 | /// Requests that only viable candidates be shown. |
| 1039 | OCD_ViableCandidates |
| 1040 | }; |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 1041 | void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet, |
John McCall | 8120162 | 2010-01-08 04:41:39 +0000 | [diff] [blame] | 1042 | OverloadCandidateDisplayKind OCD, |
John McCall | cbce606 | 2010-01-12 07:18:19 +0000 | [diff] [blame] | 1043 | Expr **Args, unsigned NumArgs, |
John McCall | 8120162 | 2010-01-08 04:41:39 +0000 | [diff] [blame] | 1044 | const char *Opc = 0, |
| 1045 | SourceLocation Loc = SourceLocation()); |
| 1046 | |
John McCall | b1622a1 | 2010-01-06 09:43:14 +0000 | [diff] [blame] | 1047 | void NoteOverloadCandidate(FunctionDecl *Fn); |
John McCall | 1d31833 | 2010-01-12 00:44:57 +0000 | [diff] [blame] | 1048 | void DiagnoseAmbiguousConversion(const ImplicitConversionSequence &ICS, |
| 1049 | SourceLocation CaretLoc, |
| 1050 | const PartialDiagnostic &PDiag); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1051 | |
Douglas Gregor | 904eed3 | 2008-11-10 20:40:00 +0000 | [diff] [blame] | 1052 | FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, |
| 1053 | bool Complain); |
Douglas Gregor | 4b52e25 | 2009-12-21 23:17:24 +0000 | [diff] [blame] | 1054 | FunctionDecl *ResolveSingleFunctionTemplateSpecialization(Expr *From); |
| 1055 | |
Anders Carlsson | 96ad533 | 2009-10-21 17:16:23 +0000 | [diff] [blame] | 1056 | Expr *FixOverloadedFunctionReference(Expr *E, FunctionDecl *Fn); |
Douglas Gregor | 20093b4 | 2009-12-09 23:02:17 +0000 | [diff] [blame] | 1057 | OwningExprResult FixOverloadedFunctionReference(OwningExprResult, |
| 1058 | FunctionDecl *Fn); |
Douglas Gregor | 904eed3 | 2008-11-10 20:40:00 +0000 | [diff] [blame] | 1059 | |
John McCall | 3b4294e | 2009-12-16 12:17:52 +0000 | [diff] [blame] | 1060 | void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, |
Douglas Gregor | 9c6a0e9 | 2009-09-22 15:41:20 +0000 | [diff] [blame] | 1061 | Expr **Args, unsigned NumArgs, |
| 1062 | OverloadCandidateSet &CandidateSet, |
| 1063 | bool PartialOverloading = false); |
| 1064 | |
John McCall | 3b4294e | 2009-12-16 12:17:52 +0000 | [diff] [blame] | 1065 | OwningExprResult BuildOverloadedCallExpr(Expr *Fn, |
Nuno Lopes | 9a84ac2 | 2009-12-16 14:20:08 +0000 | [diff] [blame] | 1066 | UnresolvedLookupExpr *ULE, |
John McCall | 3b4294e | 2009-12-16 12:17:52 +0000 | [diff] [blame] | 1067 | SourceLocation LParenLoc, |
| 1068 | Expr **Args, unsigned NumArgs, |
| 1069 | SourceLocation *CommaLocs, |
| 1070 | SourceLocation RParenLoc); |
Douglas Gregor | 063daf6 | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 1071 | |
Douglas Gregor | bc736fc | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 1072 | OwningExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, |
| 1073 | unsigned Opc, |
| 1074 | FunctionSet &Functions, |
| 1075 | ExprArg input); |
| 1076 | |
Douglas Gregor | 063daf6 | 2009-03-13 18:40:31 +0000 | [diff] [blame] | 1077 | OwningExprResult CreateOverloadedBinOp(SourceLocation OpLoc, |
| 1078 | unsigned Opc, |
| 1079 | FunctionSet &Functions, |
| 1080 | Expr *LHS, Expr *RHS); |
| 1081 | |
Sebastian Redl | f322ed6 | 2009-10-29 20:17:01 +0000 | [diff] [blame] | 1082 | OwningExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, |
| 1083 | SourceLocation RLoc, |
| 1084 | ExprArg Base,ExprArg Idx); |
| 1085 | |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1086 | OwningExprResult |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1087 | BuildCallToMemberFunction(Scope *S, Expr *MemExpr, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1088 | SourceLocation LParenLoc, Expr **Args, |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1089 | unsigned NumArgs, SourceLocation *CommaLocs, |
| 1090 | SourceLocation RParenLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1091 | ExprResult |
Douglas Gregor | 5c37de7 | 2008-12-06 00:22:45 +0000 | [diff] [blame] | 1092 | BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, |
Douglas Gregor | f9eb905 | 2008-11-19 21:05:33 +0000 | [diff] [blame] | 1093 | Expr **Args, unsigned NumArgs, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1094 | SourceLocation *CommaLocs, |
Douglas Gregor | f9eb905 | 2008-11-19 21:05:33 +0000 | [diff] [blame] | 1095 | SourceLocation RParenLoc); |
Douglas Gregor | 8e9bebd | 2008-10-21 16:13:35 +0000 | [diff] [blame] | 1096 | |
Douglas Gregor | fe85ced | 2009-08-06 03:17:00 +0000 | [diff] [blame] | 1097 | OwningExprResult BuildOverloadedArrowExpr(Scope *S, ExprArg Base, |
| 1098 | SourceLocation OpLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1099 | |
Anders Carlsson | 8c8d919 | 2009-10-09 23:51:55 +0000 | [diff] [blame] | 1100 | /// CheckCallReturnType - Checks that a call expression's return type is |
| 1101 | /// complete. Returns true on failure. The location passed in is the location |
| 1102 | /// that best represents the call. |
| 1103 | bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, |
| 1104 | CallExpr *CE, FunctionDecl *FD); |
| 1105 | |
Mike Stump | 5692586 | 2009-07-28 22:04:01 +0000 | [diff] [blame] | 1106 | /// Helpers for dealing with blocks and functions. |
Mike Stump | b1682c5 | 2009-07-22 23:56:57 +0000 | [diff] [blame] | 1107 | void CheckFallThroughForFunctionDef(Decl *D, Stmt *Body); |
Mike Stump | 5692586 | 2009-07-28 22:04:01 +0000 | [diff] [blame] | 1108 | void CheckFallThroughForBlock(QualType BlockTy, Stmt *Body); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1109 | bool CheckParmsForFunctionDef(FunctionDecl *FD); |
Chris Lattner | 0442108 | 2008-04-08 04:40:51 +0000 | [diff] [blame] | 1110 | void CheckCXXDefaultArguments(FunctionDecl *FD); |
Douglas Gregor | 6d6eb57 | 2008-05-07 04:49:29 +0000 | [diff] [blame] | 1111 | void CheckExtraCXXDefaultArguments(Declarator &D); |
Mike Stump | b1682c5 | 2009-07-22 23:56:57 +0000 | [diff] [blame] | 1112 | enum ControlFlowKind { NeverFallThrough = 0, MaybeFallThrough = 1, |
Mike Stump | 1d7e767 | 2009-10-27 01:59:05 +0000 | [diff] [blame] | 1113 | AlwaysFallThrough = 2, NeverFallThroughOrReturn = 3 }; |
Mike Stump | b1682c5 | 2009-07-22 23:56:57 +0000 | [diff] [blame] | 1114 | ControlFlowKind CheckFallThrough(Stmt *); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1115 | |
Douglas Gregor | 1a0d31a | 2009-01-12 18:45:55 +0000 | [diff] [blame] | 1116 | Scope *getNonFieldDeclScope(Scope *S); |
| 1117 | |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1118 | /// \name Name lookup |
| 1119 | /// |
| 1120 | /// These routines provide name lookup that is used during semantic |
| 1121 | /// analysis to resolve the various kinds of names (identifiers, |
| 1122 | /// overloaded operator names, constructor names, etc.) into zero or |
| 1123 | /// more declarations within a particular scope. The major entry |
| 1124 | /// points are LookupName, which performs unqualified name lookup, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1125 | /// and LookupQualifiedName, which performs qualified name lookup. |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1126 | /// |
| 1127 | /// All name lookup is performed based on some specific criteria, |
| 1128 | /// which specify what names will be visible to name lookup and how |
| 1129 | /// far name lookup should work. These criteria are important both |
| 1130 | /// for capturing language semantics (certain lookups will ignore |
| 1131 | /// certain names, for example) and for performance, since name |
| 1132 | /// lookup is often a bottleneck in the compilation of C++. Name |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1133 | /// lookup criteria is specified via the LookupCriteria enumeration. |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1134 | /// |
| 1135 | /// The results of name lookup can vary based on the kind of name |
| 1136 | /// lookup performed, the current language, and the translation |
| 1137 | /// unit. In C, for example, name lookup will either return nothing |
| 1138 | /// (no entity found) or a single declaration. In C++, name lookup |
| 1139 | /// can additionally refer to a set of overloaded functions or |
| 1140 | /// result in an ambiguity. All of the possible results of name |
| 1141 | /// lookup are captured by the LookupResult class, which provides |
| 1142 | /// the ability to distinguish among them. |
| 1143 | //@{ |
Douglas Gregor | f780abc | 2008-12-30 03:27:21 +0000 | [diff] [blame] | 1144 | |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1145 | /// @brief Describes the kind of name lookup to perform. |
| 1146 | enum LookupNameKind { |
| 1147 | /// Ordinary name lookup, which finds ordinary names (functions, |
| 1148 | /// variables, typedefs, etc.) in C and most kinds of names |
| 1149 | /// (functions, variables, members, types, etc.) in C++. |
| 1150 | LookupOrdinaryName = 0, |
| 1151 | /// Tag name lookup, which finds the names of enums, classes, |
| 1152 | /// structs, and unions. |
| 1153 | LookupTagName, |
| 1154 | /// Member name lookup, which finds the names of |
| 1155 | /// class/struct/union members. |
| 1156 | LookupMemberName, |
Douglas Gregor | f680a0f | 2009-02-04 16:44:47 +0000 | [diff] [blame] | 1157 | // Look up of an operator name (e.g., operator+) for use with |
| 1158 | // operator overloading. This lookup is similar to ordinary name |
| 1159 | // lookup, but will ignore any declarations that are class |
| 1160 | // members. |
| 1161 | LookupOperatorName, |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1162 | /// Look up of a name that precedes the '::' scope resolution |
Eli Friedman | b1df333 | 2009-12-21 01:26:45 +0000 | [diff] [blame] | 1163 | /// operator in C++. This lookup completely ignores operator, object, |
Douglas Gregor | 4c921ae | 2009-01-30 01:04:22 +0000 | [diff] [blame] | 1164 | /// function, and enumerator names (C++ [basic.lookup.qual]p1). |
| 1165 | LookupNestedNameSpecifierName, |
| 1166 | /// Look up a namespace name within a C++ using directive or |
| 1167 | /// namespace alias definition, ignoring non-namespace names (C++ |
| 1168 | /// [basic.lookup.udir]p1). |
Douglas Gregor | d6f7e9d | 2009-02-24 20:03:32 +0000 | [diff] [blame] | 1169 | LookupNamespaceName, |
John McCall | 9f54ad4 | 2009-12-10 09:41:52 +0000 | [diff] [blame] | 1170 | /// Look up all declarations in a scope with the given name, |
| 1171 | /// including resolved using declarations. This is appropriate |
| 1172 | /// for checking redeclarations for a using declaration. |
| 1173 | LookupUsingDeclName, |
Douglas Gregor | 6e378de | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 1174 | /// Look up an ordinary name that is going to be redeclared as a |
| 1175 | /// name with linkage. This lookup ignores any declarations that |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1176 | /// are outside of the current scope unless they have linkage. See |
Douglas Gregor | 6e378de | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 1177 | /// C99 6.2.2p4-5 and C++ [basic.link]p6. |
| 1178 | LookupRedeclarationWithLinkage, |
| 1179 | /// Look up the name of an Objective-C protocol. |
Douglas Gregor | 8fc463a | 2009-04-24 00:11:27 +0000 | [diff] [blame] | 1180 | LookupObjCProtocolName, |
| 1181 | /// Look up the name of an Objective-C implementation |
Fariborz Jahanian | 737061f | 2009-12-11 00:26:36 +0000 | [diff] [blame] | 1182 | LookupObjCImplementationName |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1183 | }; |
| 1184 | |
Douglas Gregor | 48026d2 | 2010-01-11 18:40:55 +0000 | [diff] [blame] | 1185 | /// \brief Specifies whether (or how) name lookup is being performed for a |
| 1186 | /// redeclaration (vs. a reference). |
John McCall | 7d384dd | 2009-11-18 07:57:50 +0000 | [diff] [blame] | 1187 | enum RedeclarationKind { |
Douglas Gregor | 48026d2 | 2010-01-11 18:40:55 +0000 | [diff] [blame] | 1188 | /// \brief The lookup is a reference to this name that is not for the |
| 1189 | /// purpose of redeclaring the name. |
| 1190 | NotForRedeclaration = 0, |
| 1191 | /// \brief The lookup results will be used for redeclaration of a name, |
| 1192 | /// if an entity by that name already exists. |
John McCall | 7d384dd | 2009-11-18 07:57:50 +0000 | [diff] [blame] | 1193 | ForRedeclaration |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1194 | }; |
| 1195 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1196 | private: |
John McCall | a24dc2e | 2009-11-17 02:14:36 +0000 | [diff] [blame] | 1197 | bool CppLookupName(LookupResult &R, Scope *S); |
| 1198 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1199 | public: |
John McCall | f36e02d | 2009-10-09 21:13:30 +0000 | [diff] [blame] | 1200 | /// \brief Look up a name, looking for a single declaration. Return |
John McCall | 1bcee0a | 2009-12-02 08:25:40 +0000 | [diff] [blame] | 1201 | /// null if the results were absent, ambiguous, or overloaded. |
John McCall | f36e02d | 2009-10-09 21:13:30 +0000 | [diff] [blame] | 1202 | /// |
| 1203 | /// It is preferable to use the elaborated form and explicitly handle |
| 1204 | /// ambiguity and overloaded. |
| 1205 | NamedDecl *LookupSingleName(Scope *S, DeclarationName Name, |
| 1206 | LookupNameKind NameKind, |
John McCall | 7d384dd | 2009-11-18 07:57:50 +0000 | [diff] [blame] | 1207 | RedeclarationKind Redecl |
| 1208 | = NotForRedeclaration); |
John McCall | f36e02d | 2009-10-09 21:13:30 +0000 | [diff] [blame] | 1209 | bool LookupName(LookupResult &R, Scope *S, |
John McCall | a24dc2e | 2009-11-17 02:14:36 +0000 | [diff] [blame] | 1210 | bool AllowBuiltinCreation = false); |
| 1211 | bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx); |
John McCall | f36e02d | 2009-10-09 21:13:30 +0000 | [diff] [blame] | 1212 | bool LookupParsedName(LookupResult &R, Scope *S, const CXXScopeSpec *SS, |
John McCall | f36e02d | 2009-10-09 21:13:30 +0000 | [diff] [blame] | 1213 | bool AllowBuiltinCreation = false, |
John McCall | f36e02d | 2009-10-09 21:13:30 +0000 | [diff] [blame] | 1214 | bool EnteringContext = false); |
Douglas Gregor | 3fd95ce | 2009-03-13 00:33:25 +0000 | [diff] [blame] | 1215 | |
Douglas Gregor | 6e378de | 2009-04-23 23:18:26 +0000 | [diff] [blame] | 1216 | ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II); |
| 1217 | |
Douglas Gregor | 3fd95ce | 2009-03-13 00:33:25 +0000 | [diff] [blame] | 1218 | void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1219 | QualType T1, QualType T2, |
Douglas Gregor | 3fd95ce | 2009-03-13 00:33:25 +0000 | [diff] [blame] | 1220 | FunctionSet &Functions); |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 1221 | |
Sebastian Redl | 644be85 | 2009-10-23 19:23:15 +0000 | [diff] [blame] | 1222 | void ArgumentDependentLookup(DeclarationName Name, bool Operator, |
Douglas Gregor | 3fd95ce | 2009-03-13 00:33:25 +0000 | [diff] [blame] | 1223 | Expr **Args, unsigned NumArgs, |
| 1224 | FunctionSet &Functions); |
| 1225 | |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 1226 | void LookupVisibleDecls(Scope *S, LookupNameKind Kind, |
| 1227 | VisibleDeclConsumer &Consumer); |
| 1228 | void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind, |
| 1229 | VisibleDeclConsumer &Consumer); |
| 1230 | |
| 1231 | bool CorrectTypo(LookupResult &R, Scope *S, const CXXScopeSpec *SS, |
Douglas Gregor | 2dcc011 | 2009-12-31 07:42:17 +0000 | [diff] [blame] | 1232 | DeclContext *MemberContext = 0, |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 1233 | bool EnteringContext = false, |
| 1234 | const ObjCObjectPointerType *OPT = 0); |
Douglas Gregor | 546be3c | 2009-12-30 17:04:44 +0000 | [diff] [blame] | 1235 | |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 1236 | void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs, |
| 1237 | AssociatedNamespaceSet &AssociatedNamespaces, |
John McCall | 6ff0785 | 2009-08-07 22:18:02 +0000 | [diff] [blame] | 1238 | AssociatedClassSet &AssociatedClasses); |
Douglas Gregor | fa04764 | 2009-02-04 00:32:51 +0000 | [diff] [blame] | 1239 | |
John McCall | a24dc2e | 2009-11-17 02:14:36 +0000 | [diff] [blame] | 1240 | bool DiagnoseAmbiguousLookup(LookupResult &Result); |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1241 | //@} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1242 | |
Douglas Gregor | f06cdae | 2010-01-03 18:01:57 +0000 | [diff] [blame] | 1243 | ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id, |
| 1244 | SourceLocation RecoverLoc = SourceLocation()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1245 | NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, |
Douglas Gregor | 3e41d60 | 2009-02-13 23:20:09 +0000 | [diff] [blame] | 1246 | Scope *S, bool ForRedeclaration, |
| 1247 | SourceLocation Loc); |
Douglas Gregor | 4afa39d | 2009-01-20 01:17:11 +0000 | [diff] [blame] | 1248 | NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, |
| 1249 | Scope *S); |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 1250 | void AddKnownFunctionAttributes(FunctionDecl *FD); |
Douglas Gregor | eb11cd0 | 2009-01-14 22:20:51 +0000 | [diff] [blame] | 1251 | |
| 1252 | // More parsing and symbol table subroutines. |
| 1253 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1254 | // Decl attributes - this routine is the top level dispatcher. |
Douglas Gregor | 9cdda0c | 2009-06-17 21:51:59 +0000 | [diff] [blame] | 1255 | void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD); |
| 1256 | void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AttrList); |
Christopher Lamb | ebb97e9 | 2008-02-04 02:31:56 +0000 | [diff] [blame] | 1257 | |
Steve Naroff | 3c2eb66 | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 1258 | void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, |
| 1259 | bool &IncompleteImpl); |
Fariborz Jahanian | 8daab97 | 2008-12-05 18:18:52 +0000 | [diff] [blame] | 1260 | void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod, |
| 1261 | ObjCMethodDecl *IntfMethod); |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1262 | |
Fariborz Jahanian | d1fa644 | 2009-01-12 19:55:42 +0000 | [diff] [blame] | 1263 | bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl, |
Steve Naroff | 22dc0b0 | 2009-02-26 19:11:32 +0000 | [diff] [blame] | 1264 | ObjCInterfaceDecl *IDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1265 | |
Chris Lattner | 823c44e | 2009-01-06 07:27:21 +0000 | [diff] [blame] | 1266 | /// CheckProtocolMethodDefs - This routine checks unimplemented |
Daniel Dunbar | 7ad1b1f | 2008-09-04 20:01:15 +0000 | [diff] [blame] | 1267 | /// methods declared in protocol, and those referenced by it. |
| 1268 | /// \param IDecl - Used for checking for methods which may have been |
| 1269 | /// inherited. |
Steve Naroff | efe7f36 | 2008-02-08 22:06:17 +0000 | [diff] [blame] | 1270 | void CheckProtocolMethodDefs(SourceLocation ImpLoc, |
| 1271 | ObjCProtocolDecl *PDecl, |
Fariborz Jahanian | ca3adf7 | 2007-10-02 20:06:01 +0000 | [diff] [blame] | 1272 | bool& IncompleteImpl, |
Steve Naroff | eefc418 | 2007-10-08 21:05:34 +0000 | [diff] [blame] | 1273 | const llvm::DenseSet<Selector> &InsMap, |
Daniel Dunbar | 7ad1b1f | 2008-09-04 20:01:15 +0000 | [diff] [blame] | 1274 | const llvm::DenseSet<Selector> &ClsMap, |
| 1275 | ObjCInterfaceDecl *IDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1276 | |
Steve Naroff | a5997c4 | 2007-10-02 21:43:37 +0000 | [diff] [blame] | 1277 | /// CheckImplementationIvars - This routine checks if the instance variables |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1278 | /// listed in the implelementation match those listed in the interface. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1279 | void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, |
| 1280 | ObjCIvarDecl **Fields, unsigned nIvars, |
Steve Naroff | 3c2eb66 | 2008-02-10 21:38:56 +0000 | [diff] [blame] | 1281 | SourceLocation Loc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1282 | |
Fariborz Jahanian | 8c74fa4 | 2007-09-29 17:14:55 +0000 | [diff] [blame] | 1283 | /// ImplMethodsVsClassMethods - This is main routine to warn if any method |
Chris Lattner | cddc888 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 1284 | /// remains unimplemented in the class or category @implementation. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1285 | void ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, |
| 1286 | ObjCContainerDecl* IDecl, |
Chris Lattner | cddc888 | 2009-03-01 00:56:52 +0000 | [diff] [blame] | 1287 | bool IncompleteImpl = false); |
Fariborz Jahanian | 7ca8b06 | 2009-11-11 22:40:11 +0000 | [diff] [blame] | 1288 | |
| 1289 | /// AtomicPropertySetterGetterRules - This routine enforces the rule (via |
| 1290 | /// warning) when atomic property has one but not the other user-declared |
| 1291 | /// setter or getter. |
| 1292 | void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl, |
| 1293 | ObjCContainerDecl* IDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1294 | |
Fariborz Jahanian | 85ff264 | 2007-10-05 18:00:57 +0000 | [diff] [blame] | 1295 | /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns |
| 1296 | /// true, or false, accordingly. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1297 | bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, |
Steve Naroff | fe6b0dc | 2008-10-21 10:37:50 +0000 | [diff] [blame] | 1298 | const ObjCMethodDecl *PrevMethod, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1299 | bool matchBasedOnSizeAndAlignment = false); |
Steve Naroff | 3b95017 | 2007-10-10 21:53:07 +0000 | [diff] [blame] | 1300 | |
Fariborz Jahanian | b33f3ad | 2009-05-01 20:07:12 +0000 | [diff] [blame] | 1301 | /// MatchAllMethodDeclarations - Check methods declaraed in interface or |
| 1302 | /// or protocol against those declared in their implementations. |
| 1303 | void MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap, |
| 1304 | const llvm::DenseSet<Selector> &ClsMap, |
| 1305 | llvm::DenseSet<Selector> &InsMapSeen, |
| 1306 | llvm::DenseSet<Selector> &ClsMapSeen, |
| 1307 | ObjCImplDecl* IMPDecl, |
| 1308 | ObjCContainerDecl* IDecl, |
| 1309 | bool &IncompleteImpl, |
| 1310 | bool ImmediateClass); |
| 1311 | |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1312 | /// AddInstanceMethodToGlobalPool - All instance methods in a translation |
| 1313 | /// unit are added to a global pool. This allows us to efficiently associate |
| 1314 | /// a selector with a method declaraation for purposes of typechecking |
| 1315 | /// messages sent to "id" (where the class of the object is unknown). |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1316 | void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1317 | |
Steve Naroff | 037cda5 | 2008-09-30 14:38:43 +0000 | [diff] [blame] | 1318 | /// LookupInstanceMethodInGlobalPool - Returns the method and warns if |
| 1319 | /// there are multiple signatures. |
Fariborz Jahanian | 835ed7f | 2009-08-22 21:13:55 +0000 | [diff] [blame] | 1320 | ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, |
| 1321 | bool warn=true); |
Douglas Gregor | f0aaf7a | 2009-04-24 21:10:55 +0000 | [diff] [blame] | 1322 | |
| 1323 | /// LookupFactoryMethodInGlobalPool - Returns the method and warns if |
| 1324 | /// there are multiple signatures. |
| 1325 | ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1326 | |
Steve Naroff | 58ff9e8 | 2007-10-14 00:58:41 +0000 | [diff] [blame] | 1327 | /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. |
Ted Kremenek | a526c5c | 2008-01-07 19:49:32 +0000 | [diff] [blame] | 1328 | void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1329 | //===--------------------------------------------------------------------===// |
| 1330 | // Statement Parsing Callbacks: SemaStmt.cpp. |
| 1331 | public: |
Anders Carlsson | 6b1d283 | 2009-05-17 21:11:30 +0000 | [diff] [blame] | 1332 | virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr); |
Sebastian Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 1333 | |
| 1334 | virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc); |
| 1335 | virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, |
| 1336 | MultiStmtArg Elts, |
| 1337 | bool isStmtExpr); |
Chris Lattner | 682bf92 | 2009-03-29 16:50:03 +0000 | [diff] [blame] | 1338 | virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1339 | SourceLocation StartLoc, |
Sebastian Redl | a60528c | 2008-12-21 12:04:03 +0000 | [diff] [blame] | 1340 | SourceLocation EndLoc); |
Fariborz Jahanian | a7cf23a | 2009-11-19 22:12:37 +0000 | [diff] [blame] | 1341 | virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl); |
Sebastian Redl | 117054a | 2008-12-28 16:13:43 +0000 | [diff] [blame] | 1342 | virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal, |
| 1343 | SourceLocation DotDotDotLoc, ExprArg RHSVal, |
Chris Lattner | 24e1e70 | 2009-03-04 04:23:07 +0000 | [diff] [blame] | 1344 | SourceLocation ColonLoc); |
| 1345 | virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1346 | |
Sebastian Redl | 117054a | 2008-12-28 16:13:43 +0000 | [diff] [blame] | 1347 | virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, |
| 1348 | SourceLocation ColonLoc, |
| 1349 | StmtArg SubStmt, Scope *CurScope); |
Sebastian Redl | de30747 | 2009-01-11 00:38:46 +0000 | [diff] [blame] | 1350 | virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc, |
| 1351 | IdentifierInfo *II, |
| 1352 | SourceLocation ColonLoc, |
| 1353 | StmtArg SubStmt); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1354 | virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc, |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 1355 | FullExprArg CondVal, DeclPtrTy CondVar, |
| 1356 | StmtArg ThenVal, |
Anders Carlsson | a99fad8 | 2009-05-17 18:26:53 +0000 | [diff] [blame] | 1357 | SourceLocation ElseLoc, StmtArg ElseVal); |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 1358 | virtual OwningStmtResult ActOnStartOfSwitchStmt(FullExprArg Cond, |
| 1359 | DeclPtrTy CondVar); |
Sebastian Redl | de30747 | 2009-01-11 00:38:46 +0000 | [diff] [blame] | 1360 | virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, |
| 1361 | StmtArg Switch, StmtArg Body); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1362 | virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc, |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 1363 | FullExprArg Cond, |
| 1364 | DeclPtrTy CondVar, StmtArg Body); |
Sebastian Redl | f05b152 | 2009-01-16 23:28:06 +0000 | [diff] [blame] | 1365 | virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body, |
Chris Lattner | 9891359 | 2009-06-12 23:04:47 +0000 | [diff] [blame] | 1366 | SourceLocation WhileLoc, |
| 1367 | SourceLocation CondLParen, ExprArg Cond, |
| 1368 | SourceLocation CondRParen); |
Sebastian Redl | f05b152 | 2009-01-16 23:28:06 +0000 | [diff] [blame] | 1369 | |
| 1370 | virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc, |
| 1371 | SourceLocation LParenLoc, |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 1372 | StmtArg First, FullExprArg Second, |
| 1373 | DeclPtrTy SecondVar, |
| 1374 | FullExprArg Third, |
| 1375 | SourceLocation RParenLoc, |
Sebastian Redl | f05b152 | 2009-01-16 23:28:06 +0000 | [diff] [blame] | 1376 | StmtArg Body); |
| 1377 | virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, |
| 1378 | SourceLocation LParenLoc, |
| 1379 | StmtArg First, ExprArg Second, |
| 1380 | SourceLocation RParenLoc, StmtArg Body); |
Sebastian Redl | 4cffe2f | 2009-01-18 13:19:59 +0000 | [diff] [blame] | 1381 | |
| 1382 | virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc, |
| 1383 | SourceLocation LabelLoc, |
| 1384 | IdentifierInfo *LabelII); |
| 1385 | virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, |
| 1386 | SourceLocation StarLoc, |
| 1387 | ExprArg DestExp); |
| 1388 | virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc, |
| 1389 | Scope *CurScope); |
| 1390 | virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc, |
| 1391 | Scope *CurScope); |
| 1392 | |
| 1393 | virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc, |
Anders Carlsson | f53b443 | 2009-08-18 16:11:00 +0000 | [diff] [blame] | 1394 | ExprArg RetValExp); |
Sebastian Redl | 4cffe2f | 2009-01-18 13:19:59 +0000 | [diff] [blame] | 1395 | OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc, |
| 1396 | Expr *RetValExp); |
| 1397 | |
Sebastian Redl | 3037ed0 | 2009-01-18 16:53:17 +0000 | [diff] [blame] | 1398 | virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc, |
| 1399 | bool IsSimple, |
| 1400 | bool IsVolatile, |
| 1401 | unsigned NumOutputs, |
| 1402 | unsigned NumInputs, |
| 1403 | std::string *Names, |
| 1404 | MultiExprArg Constraints, |
| 1405 | MultiExprArg Exprs, |
| 1406 | ExprArg AsmString, |
| 1407 | MultiExprArg Clobbers, |
Mike Stump | 3b11fd3 | 2010-01-04 22:37:17 +0000 | [diff] [blame] | 1408 | SourceLocation RParenLoc, |
| 1409 | bool MSAsm = false); |
Sebastian Redl | 431e90e | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1410 | |
| 1411 | virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, |
| 1412 | SourceLocation RParen, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1413 | DeclPtrTy Parm, StmtArg Body, |
Sebastian Redl | 431e90e | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1414 | StmtArg CatchList); |
| 1415 | |
| 1416 | virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, |
| 1417 | StmtArg Body); |
| 1418 | |
| 1419 | virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, |
| 1420 | StmtArg Try, |
| 1421 | StmtArg Catch, StmtArg Finally); |
| 1422 | |
| 1423 | virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1424 | ExprArg Throw, |
Steve Naroff | e21dd6f | 2009-02-11 20:05:44 +0000 | [diff] [blame] | 1425 | Scope *CurScope); |
Sebastian Redl | 431e90e | 2009-01-18 17:43:11 +0000 | [diff] [blame] | 1426 | virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, |
| 1427 | ExprArg SynchExpr, |
| 1428 | StmtArg SynchBody); |
Sebastian Redl | a0fd865 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 1429 | |
Douglas Gregor | d308e62 | 2009-05-18 20:51:54 +0000 | [diff] [blame] | 1430 | VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 1431 | TypeSourceInfo *TInfo, |
Douglas Gregor | d308e62 | 2009-05-18 20:51:54 +0000 | [diff] [blame] | 1432 | IdentifierInfo *Name, |
| 1433 | SourceLocation Loc, |
| 1434 | SourceRange Range); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1435 | virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D); |
Douglas Gregor | d308e62 | 2009-05-18 20:51:54 +0000 | [diff] [blame] | 1436 | |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1437 | virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1438 | DeclPtrTy ExDecl, |
Sebastian Redl | 4b07b29 | 2008-12-22 19:15:10 +0000 | [diff] [blame] | 1439 | StmtArg HandlerBlock); |
Sebastian Redl | 8351da0 | 2008-12-22 21:35:02 +0000 | [diff] [blame] | 1440 | virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc, |
| 1441 | StmtArg TryBlock, |
| 1442 | MultiStmtArg Handlers); |
Sebastian Redl | 13e8854 | 2009-04-27 21:33:24 +0000 | [diff] [blame] | 1443 | void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock); |
Sebastian Redl | a0fd865 | 2008-12-21 16:41:36 +0000 | [diff] [blame] | 1444 | |
Anders Carlsson | 636463e | 2009-07-30 22:17:18 +0000 | [diff] [blame] | 1445 | /// DiagnoseUnusedExprResult - If the statement passed in is an expression |
| 1446 | /// whose result is unused, warn. |
| 1447 | void DiagnoseUnusedExprResult(const Stmt *S); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1448 | |
John McCall | 54abf7d | 2009-11-04 02:18:39 +0000 | [diff] [blame] | 1449 | ParsingDeclStackState PushParsingDeclaration(); |
| 1450 | void PopParsingDeclaration(ParsingDeclStackState S, DeclPtrTy D); |
| 1451 | void EmitDeprecationWarning(NamedDecl *D, SourceLocation Loc); |
| 1452 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1453 | //===--------------------------------------------------------------------===// |
| 1454 | // Expression Parsing Callbacks: SemaExpr.cpp. |
| 1455 | |
John McCall | 54abf7d | 2009-11-04 02:18:39 +0000 | [diff] [blame] | 1456 | bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1457 | bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, |
Fariborz Jahanian | c001e89 | 2009-05-08 20:20:55 +0000 | [diff] [blame] | 1458 | ObjCMethodDecl *Getter, |
| 1459 | SourceLocation Loc); |
Fariborz Jahanian | 5b53005 | 2009-05-13 18:09:35 +0000 | [diff] [blame] | 1460 | void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, |
| 1461 | Expr **Args, unsigned NumArgs); |
Chris Lattner | 76a642f | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 1462 | |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 1463 | virtual void |
Douglas Gregor | ac7610d | 2009-06-22 20:57:11 +0000 | [diff] [blame] | 1464 | PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1465 | |
Douglas Gregor | 2afce72 | 2009-11-26 00:44:06 +0000 | [diff] [blame] | 1466 | virtual void PopExpressionEvaluationContext(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1467 | |
Douglas Gregor | e0762c9 | 2009-06-19 23:52:42 +0000 | [diff] [blame] | 1468 | void MarkDeclarationReferenced(SourceLocation Loc, Decl *D); |
Douglas Gregor | 1c7c3fb | 2009-12-22 01:01:55 +0000 | [diff] [blame] | 1469 | bool DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD); |
| 1470 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1471 | // Primary Expressions. |
Douglas Gregor | 4b2d3f7 | 2009-02-26 21:00:50 +0000 | [diff] [blame] | 1472 | virtual SourceRange getExprRange(ExprTy *E) const; |
| 1473 | |
Douglas Gregor | 02a24ee | 2009-11-03 16:56:39 +0000 | [diff] [blame] | 1474 | virtual OwningExprResult ActOnIdExpression(Scope *S, |
| 1475 | const CXXScopeSpec &SS, |
| 1476 | UnqualifiedId &Name, |
| 1477 | bool HasTrailingLParen, |
| 1478 | bool IsAddressOfOperand); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1479 | |
Douglas Gregor | bb092ba | 2009-12-31 05:20:13 +0000 | [diff] [blame] | 1480 | bool DiagnoseEmptyLookup(Scope *S, const CXXScopeSpec &SS, LookupResult &R); |
John McCall | 578b69b | 2009-12-16 08:11:27 +0000 | [diff] [blame] | 1481 | |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1482 | OwningExprResult LookupInObjCMethod(LookupResult &R, |
| 1483 | Scope *S, |
Fariborz Jahanian | 48c2d56 | 2010-01-12 23:58:59 +0000 | [diff] [blame^] | 1484 | IdentifierInfo *II, |
| 1485 | bool AllowBuiltinCreation=false); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1486 | |
| 1487 | OwningExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, |
| 1488 | DeclarationName Name, |
| 1489 | SourceLocation NameLoc, |
John McCall | 2f841ba | 2009-12-02 03:53:29 +0000 | [diff] [blame] | 1490 | bool isAddressOfOperand, |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1491 | const TemplateArgumentListInfo *TemplateArgs); |
Douglas Gregor | 02a24ee | 2009-11-03 16:56:39 +0000 | [diff] [blame] | 1492 | |
John McCall | dbd872f | 2009-12-08 09:08:17 +0000 | [diff] [blame] | 1493 | OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, |
Douglas Gregor | 0da76df | 2009-11-23 11:41:28 +0000 | [diff] [blame] | 1494 | SourceLocation Loc, |
Anders Carlsson | e41590d | 2009-06-24 00:10:43 +0000 | [diff] [blame] | 1495 | const CXXScopeSpec *SS = 0); |
Douglas Gregor | ffb4b6e | 2009-04-15 06:41:24 +0000 | [diff] [blame] | 1496 | VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field, |
| 1497 | llvm::SmallVectorImpl<FieldDecl *> &Path); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1498 | OwningExprResult |
Douglas Gregor | bcbffc4 | 2009-01-07 00:43:41 +0000 | [diff] [blame] | 1499 | BuildAnonymousStructUnionMemberReference(SourceLocation Loc, |
| 1500 | FieldDecl *Field, |
| 1501 | Expr *BaseObjectExpr = 0, |
| 1502 | SourceLocation OpLoc = SourceLocation()); |
John McCall | 3b4294e | 2009-12-16 12:17:52 +0000 | [diff] [blame] | 1503 | OwningExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, |
| 1504 | LookupResult &R, |
| 1505 | const TemplateArgumentListInfo *TemplateArgs); |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1506 | OwningExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, |
| 1507 | LookupResult &R, |
| 1508 | const TemplateArgumentListInfo *TemplateArgs, |
| 1509 | bool IsDefiniteInstance); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1510 | bool UseArgumentDependentLookup(const CXXScopeSpec &SS, |
John McCall | 5b3f913 | 2009-11-22 01:44:31 +0000 | [diff] [blame] | 1511 | const LookupResult &R, |
| 1512 | bool HasTrailingLParen); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 1513 | |
| 1514 | OwningExprResult BuildQualifiedDeclarationNameExpr(const CXXScopeSpec &SS, |
| 1515 | DeclarationName Name, |
| 1516 | SourceLocation NameLoc); |
| 1517 | OwningExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, |
| 1518 | DeclarationName Name, |
| 1519 | SourceLocation NameLoc, |
| 1520 | const TemplateArgumentListInfo *TemplateArgs); |
| 1521 | |
| 1522 | OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, |
| 1523 | LookupResult &R, |
| 1524 | bool ADL); |
| 1525 | OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, |
John McCall | ba13543 | 2009-11-21 08:51:07 +0000 | [diff] [blame] | 1526 | SourceLocation Loc, |
| 1527 | NamedDecl *D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1528 | |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1529 | virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc, |
| 1530 | tok::TokenKind Kind); |
| 1531 | virtual OwningExprResult ActOnNumericConstant(const Token &); |
| 1532 | virtual OwningExprResult ActOnCharacterConstant(const Token &); |
| 1533 | virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, |
| 1534 | ExprArg Val); |
Fariborz Jahanian | f88f7ab | 2009-11-25 01:26:41 +0000 | [diff] [blame] | 1535 | virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L, |
Nate Begeman | 2ef13e5 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 1536 | SourceLocation R, |
Fariborz Jahanian | f88f7ab | 2009-11-25 01:26:41 +0000 | [diff] [blame] | 1537 | MultiExprArg Val, |
| 1538 | TypeTy *TypeOfCast=0); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1539 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1540 | /// ActOnStringLiteral - The specified tokens were lexed as pasted string |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1541 | /// fragments (e.g. "foo" "bar" L"baz"). |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1542 | virtual OwningExprResult ActOnStringLiteral(const Token *Toks, |
| 1543 | unsigned NumToks); |
Sebastian Redl | cd965b9 | 2009-01-18 18:53:16 +0000 | [diff] [blame] | 1544 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1545 | // Binary/Unary Operators. 'Tok' is the token for the operator. |
Douglas Gregor | bc736fc | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 1546 | OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1547 | unsigned OpcIn, |
Douglas Gregor | bc736fc | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 1548 | ExprArg InputArg); |
Douglas Gregor | 6ca7cfb | 2009-11-05 00:51:44 +0000 | [diff] [blame] | 1549 | OwningExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1550 | UnaryOperator::Opcode Opc, ExprArg input); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1551 | virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1552 | tok::TokenKind Op, ExprArg Input); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 1553 | |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 1554 | OwningExprResult CreateSizeOfAlignOfExpr(TypeSourceInfo *T, |
John McCall | 5ab7517 | 2009-11-04 07:28:41 +0000 | [diff] [blame] | 1555 | SourceLocation OpLoc, |
Douglas Gregor | ba49817 | 2009-03-13 21:01:28 +0000 | [diff] [blame] | 1556 | bool isSizeOf, SourceRange R); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1557 | OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc, |
Douglas Gregor | ba49817 | 2009-03-13 21:01:28 +0000 | [diff] [blame] | 1558 | bool isSizeOf, SourceRange R); |
Douglas Gregor | bc736fc | 2009-03-13 23:49:33 +0000 | [diff] [blame] | 1559 | virtual OwningExprResult |
| 1560 | ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType, |
| 1561 | void *TyOrEx, const SourceRange &ArgRange); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1562 | |
Chris Lattner | 31e21e0 | 2009-01-24 20:17:12 +0000 | [diff] [blame] | 1563 | bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R); |
Sebastian Redl | 0518999 | 2008-11-11 17:56:53 +0000 | [diff] [blame] | 1564 | bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc, |
| 1565 | const SourceRange &R, bool isSizeof); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1566 | |
| 1567 | virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, |
| 1568 | tok::TokenKind Kind, |
| 1569 | ExprArg Input); |
| 1570 | |
| 1571 | virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base, |
| 1572 | SourceLocation LLoc, |
| 1573 | ExprArg Idx, |
| 1574 | SourceLocation RLoc); |
Sebastian Redl | f322ed6 | 2009-10-29 20:17:01 +0000 | [diff] [blame] | 1575 | OwningExprResult CreateBuiltinArraySubscriptExpr(ExprArg Base, |
| 1576 | SourceLocation LLoc, |
| 1577 | ExprArg Idx, |
| 1578 | SourceLocation RLoc); |
Douglas Gregor | c4bf26f | 2009-09-01 00:37:14 +0000 | [diff] [blame] | 1579 | |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1580 | OwningExprResult BuildMemberReferenceExpr(ExprArg Base, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1581 | QualType BaseType, |
Douglas Gregor | c4bf26f | 2009-09-01 00:37:14 +0000 | [diff] [blame] | 1582 | SourceLocation OpLoc, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1583 | bool IsArrow, |
| 1584 | const CXXScopeSpec &SS, |
| 1585 | NamedDecl *FirstQualifierInScope, |
| 1586 | DeclarationName Name, |
| 1587 | SourceLocation NameLoc, |
| 1588 | const TemplateArgumentListInfo *TemplateArgs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1589 | |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1590 | OwningExprResult BuildMemberReferenceExpr(ExprArg Base, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1591 | QualType BaseType, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1592 | SourceLocation OpLoc, bool IsArrow, |
| 1593 | const CXXScopeSpec &SS, |
| 1594 | LookupResult &R, |
| 1595 | const TemplateArgumentListInfo *TemplateArgs); |
| 1596 | |
| 1597 | OwningExprResult LookupMemberExpr(LookupResult &R, Expr *&Base, |
John McCall | 812c154 | 2009-12-07 22:46:59 +0000 | [diff] [blame] | 1598 | bool &IsArrow, SourceLocation OpLoc, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1599 | const CXXScopeSpec &SS, |
| 1600 | NamedDecl *FirstQualifierInScope, |
| 1601 | DeclPtrTy ObjCImpDecl); |
| 1602 | |
| 1603 | bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, |
John McCall | 2f841ba | 2009-12-02 03:53:29 +0000 | [diff] [blame] | 1604 | const CXXScopeSpec &SS, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1605 | const LookupResult &R); |
| 1606 | |
| 1607 | OwningExprResult ActOnDependentMemberExpr(ExprArg Base, |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1608 | QualType BaseType, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1609 | bool IsArrow, |
Anders Carlsson | 8f28f99 | 2009-08-26 18:25:21 +0000 | [diff] [blame] | 1610 | SourceLocation OpLoc, |
John McCall | 129e2df | 2009-11-30 22:42:35 +0000 | [diff] [blame] | 1611 | const CXXScopeSpec &SS, |
| 1612 | NamedDecl *FirstQualifierInScope, |
| 1613 | DeclarationName Name, |
| 1614 | SourceLocation NameLoc, |
| 1615 | const TemplateArgumentListInfo *TemplateArgs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1616 | |
Douglas Gregor | 2d1c214 | 2009-11-03 19:44:04 +0000 | [diff] [blame] | 1617 | virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base, |
| 1618 | SourceLocation OpLoc, |
| 1619 | tok::TokenKind OpKind, |
| 1620 | const CXXScopeSpec &SS, |
| 1621 | UnqualifiedId &Member, |
| 1622 | DeclPtrTy ObjCImpDecl, |
| 1623 | bool HasTrailingLParen); |
| 1624 | |
Fariborz Jahanian | 393612e | 2009-07-21 22:36:06 +0000 | [diff] [blame] | 1625 | virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1626 | bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1627 | FunctionDecl *FDecl, |
Douglas Gregor | 72564e7 | 2009-02-26 23:50:07 +0000 | [diff] [blame] | 1628 | const FunctionProtoType *Proto, |
Douglas Gregor | 88a3514 | 2008-12-22 05:46:06 +0000 | [diff] [blame] | 1629 | Expr **Args, unsigned NumArgs, |
| 1630 | SourceLocation RParenLoc); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1631 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1632 | /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1633 | /// This provides the location of the left/right parens and a list of comma |
| 1634 | /// locations. |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1635 | virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn, |
| 1636 | SourceLocation LParenLoc, |
| 1637 | MultiExprArg Args, |
| 1638 | SourceLocation *CommaLocs, |
| 1639 | SourceLocation RParenLoc); |
John McCall | aa81e16 | 2009-12-01 22:10:20 +0000 | [diff] [blame] | 1640 | OwningExprResult BuildResolvedCallExpr(Expr *Fn, |
| 1641 | NamedDecl *NDecl, |
| 1642 | SourceLocation LParenLoc, |
| 1643 | Expr **Args, unsigned NumArgs, |
| 1644 | SourceLocation RParenLoc); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 1645 | |
Nate Begeman | 2ef13e5 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 1646 | virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, |
| 1647 | TypeTy *Ty, SourceLocation RParenLoc, |
| 1648 | ExprArg Op); |
Fariborz Jahanian | a79f8b3 | 2009-11-23 19:51:43 +0000 | [diff] [blame] | 1649 | virtual bool TypeIsVectorType(TypeTy *Ty) { |
| 1650 | return GetTypeFromParser(Ty)->isVectorType(); |
| 1651 | } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1652 | |
Nate Begeman | 2ef13e5 | 2009-08-10 23:49:36 +0000 | [diff] [blame] | 1653 | OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME); |
| 1654 | OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc, |
| 1655 | SourceLocation RParenLoc, ExprArg E, |
| 1656 | QualType Ty); |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1657 | |
| 1658 | virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, |
| 1659 | TypeTy *Ty, |
| 1660 | SourceLocation RParenLoc, |
| 1661 | ExprArg Op); |
| 1662 | |
| 1663 | virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc, |
| 1664 | MultiExprArg InitList, |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1665 | SourceLocation RParenLoc); |
| 1666 | |
Douglas Gregor | 05c13a3 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 1667 | virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig, |
| 1668 | SourceLocation Loc, |
Douglas Gregor | eeae8f0 | 2009-03-28 00:41:23 +0000 | [diff] [blame] | 1669 | bool GNUSyntax, |
Douglas Gregor | 05c13a3 | 2009-01-22 00:58:24 +0000 | [diff] [blame] | 1670 | OwningExprResult Init); |
| 1671 | |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1672 | virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, |
| 1673 | tok::TokenKind Kind, |
| 1674 | ExprArg LHS, ExprArg RHS); |
Douglas Gregor | 6ca7cfb | 2009-11-05 00:51:44 +0000 | [diff] [blame] | 1675 | OwningExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, |
| 1676 | BinaryOperator::Opcode Opc, |
| 1677 | Expr *lhs, Expr *rhs); |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1678 | OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc, |
| 1679 | unsigned Opc, Expr *lhs, Expr *rhs); |
Douglas Gregor | eaebc75 | 2008-11-06 23:29:22 +0000 | [diff] [blame] | 1680 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 1681 | /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1682 | /// in the case of a the GNU conditional expr extension. |
Sebastian Redl | b8a6aca | 2009-01-19 22:31:54 +0000 | [diff] [blame] | 1683 | virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc, |
| 1684 | SourceLocation ColonLoc, |
| 1685 | ExprArg Cond, ExprArg LHS, |
| 1686 | ExprArg RHS); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1687 | |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1688 | /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1689 | virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc, |
| 1690 | SourceLocation LabLoc, |
| 1691 | IdentifierInfo *LabelII); |
| 1692 | |
| 1693 | virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt, |
| 1694 | SourceLocation RPLoc); // "({..})" |
Chris Lattner | 73d0d4f | 2007-08-30 17:45:32 +0000 | [diff] [blame] | 1695 | |
| 1696 | /// __builtin_offsetof(type, a.b[123][456].c) |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1697 | virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S, |
| 1698 | SourceLocation BuiltinLoc, |
| 1699 | SourceLocation TypeLoc, |
| 1700 | TypeTy *Arg1, |
| 1701 | OffsetOfComponent *CompPtr, |
| 1702 | unsigned NumComponents, |
| 1703 | SourceLocation RParenLoc); |
| 1704 | |
Steve Naroff | d34e915 | 2007-08-01 22:05:33 +0000 | [diff] [blame] | 1705 | // __builtin_types_compatible_p(type1, type2) |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1706 | virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc, |
| 1707 | TypeTy *arg1, TypeTy *arg2, |
| 1708 | SourceLocation RPLoc); |
| 1709 | |
Steve Naroff | d04fdd5 | 2007-08-03 21:21:27 +0000 | [diff] [blame] | 1710 | // __builtin_choose_expr(constExpr, expr1, expr2) |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1711 | virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, |
| 1712 | ExprArg cond, ExprArg expr1, |
| 1713 | ExprArg expr2, SourceLocation RPLoc); |
| 1714 | |
Anders Carlsson | 7c50aca | 2007-10-15 20:28:48 +0000 | [diff] [blame] | 1715 | // __builtin_va_arg(expr, type) |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1716 | virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc, |
| 1717 | ExprArg expr, TypeTy *type, |
| 1718 | SourceLocation RPLoc); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1719 | |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 1720 | // __null |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1721 | virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc); |
Douglas Gregor | 2d8b273 | 2008-11-29 04:51:27 +0000 | [diff] [blame] | 1722 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1723 | //===------------------------- "Block" Extension ------------------------===// |
| 1724 | |
| 1725 | /// ActOnBlockStart - This callback is invoked when a block literal is |
| 1726 | /// started. |
Steve Naroff | 090276f | 2008-10-10 01:28:17 +0000 | [diff] [blame] | 1727 | virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope); |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1728 | |
Steve Naroff | 090276f | 2008-10-10 01:28:17 +0000 | [diff] [blame] | 1729 | /// ActOnBlockArguments - This callback allows processing of block arguments. |
| 1730 | /// If there are no arguments, this is still invoked. |
Mike Stump | 98eb8a7 | 2009-02-04 22:31:32 +0000 | [diff] [blame] | 1731 | virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope); |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1732 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1733 | /// ActOnBlockError - If there is an error parsing a block, this callback |
| 1734 | /// is invoked to pop the information about the block from the action impl. |
| 1735 | virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope); |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1736 | |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1737 | /// ActOnBlockStmtExpr - This is called when the body of a block statement |
| 1738 | /// literal was successfully completed. ^(int x){...} |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1739 | virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, |
| 1740 | StmtArg Body, Scope *CurScope); |
Steve Naroff | 4eb206b | 2008-09-03 18:15:37 +0000 | [diff] [blame] | 1741 | |
Chris Lattner | 76a642f | 2009-02-15 22:43:40 +0000 | [diff] [blame] | 1742 | //===---------------------------- C++ Features --------------------------===// |
| 1743 | |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 1744 | // Act on C++ namespaces |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1745 | virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc, |
| 1746 | IdentifierInfo *Ident, |
| 1747 | SourceLocation LBrace); |
| 1748 | virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace); |
Argyrios Kyrtzidis | 2d1c5d3 | 2008-04-27 13:50:30 +0000 | [diff] [blame] | 1749 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1750 | virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope, |
| 1751 | SourceLocation UsingLoc, |
| 1752 | SourceLocation NamespcLoc, |
| 1753 | const CXXScopeSpec &SS, |
| 1754 | SourceLocation IdentLoc, |
| 1755 | IdentifierInfo *NamespcName, |
| 1756 | AttributeList *AttrList); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1757 | |
Douglas Gregor | 2a3009a | 2009-02-03 19:21:40 +0000 | [diff] [blame] | 1758 | void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir); |
| 1759 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1760 | virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope, |
Anders Carlsson | 03bd5a1 | 2009-03-28 22:53:22 +0000 | [diff] [blame] | 1761 | SourceLocation NamespaceLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1762 | SourceLocation AliasLoc, |
| 1763 | IdentifierInfo *Alias, |
| 1764 | const CXXScopeSpec &SS, |
Anders Carlsson | 03bd5a1 | 2009-03-28 22:53:22 +0000 | [diff] [blame] | 1765 | SourceLocation IdentLoc, |
| 1766 | IdentifierInfo *Ident); |
Douglas Gregor | 9cfbe48 | 2009-06-20 00:51:54 +0000 | [diff] [blame] | 1767 | |
John McCall | 9f54ad4 | 2009-12-10 09:41:52 +0000 | [diff] [blame] | 1768 | void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow); |
| 1769 | bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, |
| 1770 | const LookupResult &PreviousDecls); |
| 1771 | UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD, |
| 1772 | NamedDecl *Target); |
John McCall | 604e7f1 | 2009-12-08 07:46:18 +0000 | [diff] [blame] | 1773 | |
John McCall | 9f54ad4 | 2009-12-10 09:41:52 +0000 | [diff] [blame] | 1774 | bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, |
| 1775 | bool isTypeName, |
| 1776 | const CXXScopeSpec &SS, |
| 1777 | SourceLocation NameLoc, |
| 1778 | const LookupResult &Previous); |
John McCall | ed97649 | 2009-12-04 22:46:56 +0000 | [diff] [blame] | 1779 | bool CheckUsingDeclQualifier(SourceLocation UsingLoc, |
| 1780 | const CXXScopeSpec &SS, |
| 1781 | SourceLocation NameLoc); |
| 1782 | |
John McCall | 9488ea1 | 2009-11-17 05:59:44 +0000 | [diff] [blame] | 1783 | NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS, |
| 1784 | SourceLocation UsingLoc, |
Anders Carlsson | c72160b | 2009-08-28 05:40:36 +0000 | [diff] [blame] | 1785 | const CXXScopeSpec &SS, |
| 1786 | SourceLocation IdentLoc, |
| 1787 | DeclarationName Name, |
| 1788 | AttributeList *AttrList, |
John McCall | 7ba107a | 2009-11-18 02:36:19 +0000 | [diff] [blame] | 1789 | bool IsInstantiation, |
| 1790 | bool IsTypeName, |
| 1791 | SourceLocation TypenameLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1792 | |
Douglas Gregor | 9cfbe48 | 2009-06-20 00:51:54 +0000 | [diff] [blame] | 1793 | virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope, |
Anders Carlsson | 595adc1 | 2009-08-29 19:54:19 +0000 | [diff] [blame] | 1794 | AccessSpecifier AS, |
John McCall | 60fa3cf | 2009-12-11 02:10:03 +0000 | [diff] [blame] | 1795 | bool HasUsingKeyword, |
Anders Carlsson | c72160b | 2009-08-28 05:40:36 +0000 | [diff] [blame] | 1796 | SourceLocation UsingLoc, |
| 1797 | const CXXScopeSpec &SS, |
Douglas Gregor | 12c118a | 2009-11-04 16:30:06 +0000 | [diff] [blame] | 1798 | UnqualifiedId &Name, |
Anders Carlsson | c72160b | 2009-08-28 05:40:36 +0000 | [diff] [blame] | 1799 | AttributeList *AttrList, |
John McCall | 7ba107a | 2009-11-18 02:36:19 +0000 | [diff] [blame] | 1800 | bool IsTypeName, |
| 1801 | SourceLocation TypenameLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1802 | |
| 1803 | /// AddCXXDirectInitializerToDecl - This action is called immediately after |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1804 | /// ActOnDeclarator, when a C++ direct initializer is present. |
| 1805 | /// e.g: "int x(1);" |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 1806 | virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl, |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1807 | SourceLocation LParenLoc, |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1808 | MultiExprArg Exprs, |
Argyrios Kyrtzidis | 73a0d88 | 2008-10-06 17:10:33 +0000 | [diff] [blame] | 1809 | SourceLocation *CommaLocs, |
| 1810 | SourceLocation RParenLoc); |
| 1811 | |
Anders Carlsson | 49d4401 | 2009-04-24 05:16:06 +0000 | [diff] [blame] | 1812 | /// InitializeVarWithConstructor - Creates an CXXConstructExpr |
| 1813 | /// and sets it as the initializer for the the passed in VarDecl. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1814 | bool InitializeVarWithConstructor(VarDecl *VD, |
Anders Carlsson | 930e8d0 | 2009-04-16 23:50:50 +0000 | [diff] [blame] | 1815 | CXXConstructorDecl *Constructor, |
Anders Carlsson | f47511a | 2009-09-07 22:23:31 +0000 | [diff] [blame] | 1816 | MultiExprArg Exprs); |
Anders Carlsson | 9abf2ae | 2009-08-16 05:13:48 +0000 | [diff] [blame] | 1817 | |
Anders Carlsson | ec8e5ea | 2009-09-05 07:40:38 +0000 | [diff] [blame] | 1818 | /// BuildCXXConstructExpr - Creates a complete call to a constructor, |
| 1819 | /// including handling of its default argument expressions. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1820 | OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, |
Anders Carlsson | ec8e5ea | 2009-09-05 07:40:38 +0000 | [diff] [blame] | 1821 | QualType DeclInitType, |
Anders Carlsson | da3f4e2 | 2009-08-25 05:12:04 +0000 | [diff] [blame] | 1822 | CXXConstructorDecl *Constructor, |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 1823 | MultiExprArg Exprs, |
| 1824 | bool RequiresZeroInit = false); |
Anders Carlsson | 9abf2ae | 2009-08-16 05:13:48 +0000 | [diff] [blame] | 1825 | |
Anders Carlsson | ec8e5ea | 2009-09-05 07:40:38 +0000 | [diff] [blame] | 1826 | // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if |
| 1827 | // the constructor can be elidable? |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1828 | OwningExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, |
Anders Carlsson | ec8e5ea | 2009-09-05 07:40:38 +0000 | [diff] [blame] | 1829 | QualType DeclInitType, |
Anders Carlsson | da3f4e2 | 2009-08-25 05:12:04 +0000 | [diff] [blame] | 1830 | CXXConstructorDecl *Constructor, |
| 1831 | bool Elidable, |
Douglas Gregor | 16006c9 | 2009-12-16 18:50:27 +0000 | [diff] [blame] | 1832 | MultiExprArg Exprs, |
| 1833 | bool RequiresZeroInit = false); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1834 | |
| 1835 | OwningExprResult BuildCXXTemporaryObjectExpr(CXXConstructorDecl *Cons, |
| 1836 | QualType writtenTy, |
| 1837 | SourceLocation tyBeginLoc, |
Anders Carlsson | e7624a7 | 2009-08-27 05:08:22 +0000 | [diff] [blame] | 1838 | MultiExprArg Args, |
| 1839 | SourceLocation rParenLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1840 | |
Anders Carlsson | 0aebc81 | 2009-09-09 21:33:21 +0000 | [diff] [blame] | 1841 | OwningExprResult BuildCXXCastArgument(SourceLocation CastLoc, |
| 1842 | QualType Ty, |
| 1843 | CastExpr::CastKind Kind, |
| 1844 | CXXMethodDecl *Method, |
| 1845 | ExprArg Arg); |
| 1846 | |
Anders Carlsson | 56c5e33 | 2009-08-25 03:49:14 +0000 | [diff] [blame] | 1847 | /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating |
| 1848 | /// the default expr if needed. |
| 1849 | OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, |
| 1850 | FunctionDecl *FD, |
| 1851 | ParmVarDecl *Param); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1852 | |
Fariborz Jahanian | a83f7ed | 2009-08-03 19:13:25 +0000 | [diff] [blame] | 1853 | /// FinalizeVarWithDestructor - Prepare for calling destructor on the |
| 1854 | /// constructed variable. |
| 1855 | void FinalizeVarWithDestructor(VarDecl *VD, QualType DeclInitType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1856 | |
| 1857 | /// DefineImplicitDefaultConstructor - Checks for feasibility of |
Fariborz Jahanian | f8dcb86 | 2009-06-19 19:55:27 +0000 | [diff] [blame] | 1858 | /// defining this constructor as the default constructor. |
| 1859 | void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, |
| 1860 | CXXConstructorDecl *Constructor); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1861 | |
| 1862 | /// DefineImplicitDestructor - Checks for feasibility of |
Fariborz Jahanian | 8d2b356 | 2009-06-26 23:49:16 +0000 | [diff] [blame] | 1863 | /// defining this destructor as the default destructor. |
| 1864 | void DefineImplicitDestructor(SourceLocation CurrentLocation, |
| 1865 | CXXDestructorDecl *Destructor); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1866 | |
| 1867 | /// DefineImplicitCopyConstructor - Checks for feasibility of |
Fariborz Jahanian | 485f087 | 2009-06-22 23:34:40 +0000 | [diff] [blame] | 1868 | /// defining this constructor as the copy constructor. |
| 1869 | void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, |
| 1870 | CXXConstructorDecl *Constructor, |
| 1871 | unsigned TypeQuals); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1872 | |
Fariborz Jahanian | c75bc2d | 2009-06-25 21:45:19 +0000 | [diff] [blame] | 1873 | /// DefineImplicitOverloadedAssign - Checks for feasibility of |
| 1874 | /// defining implicit this overloaded assignment operator. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1875 | void DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, |
Fariborz Jahanian | c75bc2d | 2009-06-25 21:45:19 +0000 | [diff] [blame] | 1876 | CXXMethodDecl *MethodDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1877 | |
Fariborz Jahanian | c75bc2d | 2009-06-25 21:45:19 +0000 | [diff] [blame] | 1878 | /// getAssignOperatorMethod - Returns the default copy assignmment operator |
| 1879 | /// for the class. |
Anders Carlsson | b6cc91b | 2009-12-09 03:01:51 +0000 | [diff] [blame] | 1880 | CXXMethodDecl *getAssignOperatorMethod(SourceLocation CurrentLocation, |
| 1881 | ParmVarDecl *Decl, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1882 | CXXRecordDecl *ClassDecl); |
Anders Carlsson | def1199 | 2009-05-30 20:36:53 +0000 | [diff] [blame] | 1883 | |
| 1884 | /// MaybeBindToTemporary - If the passed in expression has a record type with |
| 1885 | /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise |
| 1886 | /// it simply returns the passed in expression. |
| 1887 | OwningExprResult MaybeBindToTemporary(Expr *E); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1888 | |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 1889 | CXXConstructorDecl * |
Douglas Gregor | 19aeac6 | 2009-11-14 03:27:21 +0000 | [diff] [blame] | 1890 | TryInitializationByConstructor(QualType ClassType, |
| 1891 | Expr **Args, unsigned NumArgs, |
| 1892 | SourceLocation Loc, |
| 1893 | InitializationKind Kind); |
| 1894 | |
| 1895 | CXXConstructorDecl * |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1896 | PerformInitializationByConstructor(QualType ClassType, |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1897 | MultiExprArg ArgsPtr, |
Douglas Gregor | f03d7c7 | 2008-11-05 15:29:30 +0000 | [diff] [blame] | 1898 | SourceLocation Loc, SourceRange Range, |
Chris Lattner | d9d22dd | 2008-11-24 05:29:24 +0000 | [diff] [blame] | 1899 | DeclarationName InitEntity, |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1900 | InitializationKind Kind, |
| 1901 | ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs); |
Douglas Gregor | 18fe568 | 2008-11-03 20:45:27 +0000 | [diff] [blame] | 1902 | |
Douglas Gregor | 39da0b8 | 2009-09-09 23:08:42 +0000 | [diff] [blame] | 1903 | bool CompleteConstructorCall(CXXConstructorDecl *Constructor, |
| 1904 | MultiExprArg ArgsPtr, |
| 1905 | SourceLocation Loc, |
| 1906 | ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs); |
| 1907 | |
Douglas Gregor | 49badde | 2008-10-27 19:41:14 +0000 | [diff] [blame] | 1908 | /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's. |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1909 | virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc, |
| 1910 | tok::TokenKind Kind, |
| 1911 | SourceLocation LAngleBracketLoc, |
| 1912 | TypeTy *Ty, |
| 1913 | SourceLocation RAngleBracketLoc, |
| 1914 | SourceLocation LParenLoc, |
| 1915 | ExprArg E, |
| 1916 | SourceLocation RParenLoc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 1917 | |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1918 | /// ActOnCXXTypeid - Parse typeid( something ). |
| 1919 | virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc, |
| 1920 | SourceLocation LParenLoc, bool isType, |
| 1921 | void *TyOrExpr, |
| 1922 | SourceLocation RParenLoc); |
Sebastian Redl | c42e118 | 2008-11-11 11:37:55 +0000 | [diff] [blame] | 1923 | |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1924 | //// ActOnCXXThis - Parse 'this' pointer. |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1925 | virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc); |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 1926 | |
Steve Naroff | 1b273c4 | 2007-09-16 14:56:35 +0000 | [diff] [blame] | 1927 | /// ActOnCXXBoolLiteral - Parse {true,false} literals. |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1928 | virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, |
| 1929 | tok::TokenKind Kind); |
| 1930 | |
Sebastian Redl | 6e8ed16 | 2009-05-10 18:38:11 +0000 | [diff] [blame] | 1931 | /// ActOnCXXNullPtrLiteral - Parse 'nullptr'. |
| 1932 | virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc); |
| 1933 | |
Chris Lattner | 50dd289 | 2008-02-26 00:51:44 +0000 | [diff] [blame] | 1934 | //// ActOnCXXThrow - Parse throw expressions. |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1935 | virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc, |
| 1936 | ExprArg expr); |
Sebastian Redl | 972041f | 2009-04-27 20:27:31 +0000 | [diff] [blame] | 1937 | bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E); |
Chris Lattner | 50dd289 | 2008-02-26 00:51:44 +0000 | [diff] [blame] | 1938 | |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1939 | /// ActOnCXXTypeConstructExpr - Parse construction of a specified type. |
| 1940 | /// Can be interpreted either as function-style casting ("int(x)") |
| 1941 | /// or class type construction ("ClassType(x,y,z)") |
| 1942 | /// or creation of a value-initialized type ("int()"). |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1943 | virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange, |
| 1944 | TypeTy *TypeRep, |
| 1945 | SourceLocation LParenLoc, |
| 1946 | MultiExprArg Exprs, |
| 1947 | SourceLocation *CommaLocs, |
| 1948 | SourceLocation RParenLoc); |
Argyrios Kyrtzidis | 987a14b | 2008-08-22 15:38:55 +0000 | [diff] [blame] | 1949 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1950 | /// ActOnCXXNew - Parsed a C++ 'new' expression. |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1951 | virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, |
| 1952 | SourceLocation PlacementLParen, |
| 1953 | MultiExprArg PlacementArgs, |
| 1954 | SourceLocation PlacementRParen, |
| 1955 | bool ParenTypeId, Declarator &D, |
| 1956 | SourceLocation ConstructorLParen, |
| 1957 | MultiExprArg ConstructorArgs, |
| 1958 | SourceLocation ConstructorRParen); |
Douglas Gregor | 3433cf7 | 2009-05-21 00:00:09 +0000 | [diff] [blame] | 1959 | OwningExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, |
| 1960 | SourceLocation PlacementLParen, |
| 1961 | MultiExprArg PlacementArgs, |
| 1962 | SourceLocation PlacementRParen, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1963 | bool ParenTypeId, |
Douglas Gregor | 3433cf7 | 2009-05-21 00:00:09 +0000 | [diff] [blame] | 1964 | QualType AllocType, |
| 1965 | SourceLocation TypeLoc, |
| 1966 | SourceRange TypeRange, |
| 1967 | ExprArg ArraySize, |
| 1968 | SourceLocation ConstructorLParen, |
| 1969 | MultiExprArg ConstructorArgs, |
| 1970 | SourceLocation ConstructorRParen); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 1971 | |
Douglas Gregor | 3433cf7 | 2009-05-21 00:00:09 +0000 | [diff] [blame] | 1972 | bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, |
| 1973 | SourceRange R); |
Sebastian Redl | 00e68e2 | 2009-02-09 18:24:27 +0000 | [diff] [blame] | 1974 | bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, |
| 1975 | bool UseGlobal, QualType AllocType, bool IsArray, |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 1976 | Expr **PlaceArgs, unsigned NumPlaceArgs, |
| 1977 | FunctionDecl *&OperatorNew, |
| 1978 | FunctionDecl *&OperatorDelete); |
Sebastian Redl | 00e68e2 | 2009-02-09 18:24:27 +0000 | [diff] [blame] | 1979 | bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, |
| 1980 | DeclarationName Name, Expr** Args, |
| 1981 | unsigned NumArgs, DeclContext *Ctx, |
Sebastian Redl | 7f66239 | 2008-12-04 22:20:51 +0000 | [diff] [blame] | 1982 | bool AllowMissing, FunctionDecl *&Operator); |
Sebastian Redl | b5a57a6 | 2008-12-03 20:26:15 +0000 | [diff] [blame] | 1983 | void DeclareGlobalNewDelete(); |
| 1984 | void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, |
Nuno Lopes | fc28448 | 2009-12-16 16:59:22 +0000 | [diff] [blame] | 1985 | QualType Argument, |
| 1986 | bool addMallocAttr = false); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1987 | |
Anders Carlsson | 78f7455 | 2009-11-15 18:45:20 +0000 | [diff] [blame] | 1988 | bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, |
Anders Carlsson | 5ec02ae | 2009-12-02 17:15:43 +0000 | [diff] [blame] | 1989 | DeclarationName Name, FunctionDecl* &Operator); |
Anders Carlsson | 78f7455 | 2009-11-15 18:45:20 +0000 | [diff] [blame] | 1990 | |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1991 | /// ActOnCXXDelete - Parsed a C++ 'delete' expression |
Sebastian Redl | f53597f | 2009-03-15 17:47:39 +0000 | [diff] [blame] | 1992 | virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc, |
| 1993 | bool UseGlobal, bool ArrayForm, |
| 1994 | ExprArg Operand); |
Sebastian Redl | 4c5d320 | 2008-11-21 19:14:01 +0000 | [diff] [blame] | 1995 | |
Douglas Gregor | 99e9b4d | 2009-11-25 00:27:52 +0000 | [diff] [blame] | 1996 | virtual DeclResult ActOnCXXConditionDeclaration(Scope *S, |
| 1997 | Declarator &D); |
Douglas Gregor | 8cfe5a7 | 2009-11-23 23:44:04 +0000 | [diff] [blame] | 1998 | OwningExprResult CheckConditionVariable(VarDecl *ConditionVar); |
| 1999 | |
Sebastian Redl | 64b45f7 | 2009-01-05 20:52:13 +0000 | [diff] [blame] | 2000 | /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support |
| 2001 | /// pseudo-functions. |
| 2002 | virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, |
| 2003 | SourceLocation KWLoc, |
| 2004 | SourceLocation LParen, |
| 2005 | TypeTy *Ty, |
| 2006 | SourceLocation RParen); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2007 | |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 2008 | virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S, |
| 2009 | ExprArg Base, |
| 2010 | SourceLocation OpLoc, |
| 2011 | tok::TokenKind OpKind, |
| 2012 | TypeTy *&ObjectType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2013 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2014 | /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is |
Anders Carlsson | 99ba36d | 2009-06-05 15:38:08 +0000 | [diff] [blame] | 2015 | /// non-empty, will create a new CXXExprWithTemporaries expression. |
| 2016 | /// Otherwise, just returs the passed in expression. |
Anders Carlsson | 0ece491 | 2009-12-15 20:51:39 +0000 | [diff] [blame] | 2017 | Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr); |
Douglas Gregor | 90f9382 | 2009-12-22 22:17:25 +0000 | [diff] [blame] | 2018 | OwningExprResult MaybeCreateCXXExprWithTemporaries(OwningExprResult SubExpr); |
Anders Carlsson | 5ee56e9 | 2009-12-16 02:09:40 +0000 | [diff] [blame] | 2019 | FullExpr CreateFullExpr(Expr *SubExpr); |
| 2020 | |
Anders Carlsson | 165a0a0 | 2009-05-17 18:41:29 +0000 | [diff] [blame] | 2021 | virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr); |
| 2022 | |
Douglas Gregor | 4fdf1fa | 2009-03-11 16:48:53 +0000 | [diff] [blame] | 2023 | bool RequireCompleteDeclContext(const CXXScopeSpec &SS); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2024 | |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 2025 | DeclContext *computeDeclContext(QualType T); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2026 | DeclContext *computeDeclContext(const CXXScopeSpec &SS, |
Douglas Gregor | f59a56e | 2009-07-21 23:53:31 +0000 | [diff] [blame] | 2027 | bool EnteringContext = false); |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 2028 | bool isDependentScopeSpecifier(const CXXScopeSpec &SS); |
Douglas Gregor | 42af25f | 2009-05-11 19:58:34 +0000 | [diff] [blame] | 2029 | CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS); |
| 2030 | bool isUnknownSpecialization(const CXXScopeSpec &SS); |
Douglas Gregor | ca5e77f | 2009-03-18 00:36:05 +0000 | [diff] [blame] | 2031 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 2032 | /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the |
| 2033 | /// global scope ('::'). |
| 2034 | virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S, |
| 2035 | SourceLocation CCLoc); |
| 2036 | |
Douglas Gregor | 374929f | 2009-09-18 15:37:17 +0000 | [diff] [blame] | 2037 | bool isAcceptableNestedNameSpecifier(NamedDecl *SD); |
Douglas Gregor | c68afe2 | 2009-09-03 21:38:09 +0000 | [diff] [blame] | 2038 | NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2039 | |
Douglas Gregor | c68afe2 | 2009-09-03 21:38:09 +0000 | [diff] [blame] | 2040 | |
| 2041 | CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S, |
| 2042 | const CXXScopeSpec &SS, |
| 2043 | SourceLocation IdLoc, |
| 2044 | SourceLocation CCLoc, |
| 2045 | IdentifierInfo &II, |
| 2046 | QualType ObjectType, |
| 2047 | NamedDecl *ScopeLookupResult, |
Chris Lattner | 4664649 | 2009-12-07 01:36:53 +0000 | [diff] [blame] | 2048 | bool EnteringContext, |
| 2049 | bool ErrorRecoveryLookup); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2050 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 2051 | virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, |
| 2052 | const CXXScopeSpec &SS, |
| 2053 | SourceLocation IdLoc, |
| 2054 | SourceLocation CCLoc, |
Douglas Gregor | 495c35d | 2009-08-25 22:51:20 +0000 | [diff] [blame] | 2055 | IdentifierInfo &II, |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 2056 | TypeTy *ObjectType, |
Douglas Gregor | 495c35d | 2009-08-25 22:51:20 +0000 | [diff] [blame] | 2057 | bool EnteringContext); |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 2058 | |
Chris Lattner | 4664649 | 2009-12-07 01:36:53 +0000 | [diff] [blame] | 2059 | virtual bool IsInvalidUnlessNestedName(Scope *S, |
| 2060 | const CXXScopeSpec &SS, |
| 2061 | IdentifierInfo &II, |
| 2062 | TypeTy *ObjectType, |
| 2063 | bool EnteringContext); |
| 2064 | |
Douglas Gregor | 39a8de1 | 2009-02-25 19:37:18 +0000 | [diff] [blame] | 2065 | /// ActOnCXXNestedNameSpecifier - Called during parsing of a |
| 2066 | /// nested-name-specifier that involves a template-id, e.g., |
| 2067 | /// "foo::bar<int, float>::", and now we need to build a scope |
| 2068 | /// specifier. \p SS is empty or the previously parsed nested-name |
| 2069 | /// part ("foo::"), \p Type is the already-parsed class template |
| 2070 | /// specialization (or other template-id that names a type), \p |
| 2071 | /// TypeRange is the source range where the type is located, and \p |
| 2072 | /// CCLoc is the location of the trailing '::'. |
| 2073 | virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S, |
| 2074 | const CXXScopeSpec &SS, |
| 2075 | TypeTy *Type, |
| 2076 | SourceRange TypeRange, |
| 2077 | SourceLocation CCLoc); |
| 2078 | |
John McCall | e7e278b | 2009-12-11 20:04:54 +0000 | [diff] [blame] | 2079 | virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
| 2080 | |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 2081 | /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global |
| 2082 | /// scope or nested-name-specifier) is parsed, part of a declarator-id. |
| 2083 | /// After this method is called, according to [C++ 3.4.3p3], names should be |
| 2084 | /// looked up in the declarator-id's scope, until the declarator is parsed and |
| 2085 | /// ActOnCXXExitDeclaratorScope is called. |
| 2086 | /// The 'SS' should be a non-empty valid CXXScopeSpec. |
Douglas Gregor | 7dfd0fb | 2009-09-24 23:39:01 +0000 | [diff] [blame] | 2087 | virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 2088 | |
| 2089 | /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously |
| 2090 | /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same |
| 2091 | /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. |
| 2092 | /// Used to indicate that names should revert to being looked up in the |
| 2093 | /// defining scope. |
Douglas Gregor | 0a59acb | 2008-12-16 00:38:16 +0000 | [diff] [blame] | 2094 | virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS); |
Argyrios Kyrtzidis | ef6e647 | 2008-11-08 17:17:31 +0000 | [diff] [blame] | 2095 | |
Argyrios Kyrtzidis | 0ffd9ff | 2009-06-17 22:50:06 +0000 | [diff] [blame] | 2096 | /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an |
| 2097 | /// initializer for the declaration 'Dcl'. |
| 2098 | /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a |
| 2099 | /// static data member of class X, names should be looked up in the scope of |
| 2100 | /// class X. |
| 2101 | virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl); |
| 2102 | |
| 2103 | /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an |
| 2104 | /// initializer for the declaration 'Dcl'. |
| 2105 | virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl); |
| 2106 | |
Anders Carlsson | 5508518 | 2007-08-21 17:43:55 +0000 | [diff] [blame] | 2107 | // ParseObjCStringLiteral - Parse Objective-C string literals. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2108 | virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, |
Chris Lattner | b3a99cd | 2007-12-12 01:04:12 +0000 | [diff] [blame] | 2109 | ExprTy **Strings, |
| 2110 | unsigned NumStrings); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2111 | |
| 2112 | Expr *BuildObjCEncodeExpression(SourceLocation AtLoc, |
Anders Carlsson | fc0f021 | 2009-06-07 18:45:35 +0000 | [diff] [blame] | 2113 | QualType EncodedType, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2114 | SourceLocation RParenLoc); |
Fariborz Jahanian | b740023 | 2009-09-28 23:23:40 +0000 | [diff] [blame] | 2115 | CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp, CXXMethodDecl *Method); |
| 2116 | |
Anders Carlsson | f9bcf01 | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 2117 | virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, |
Chris Lattner | 674af95 | 2007-10-16 22:51:17 +0000 | [diff] [blame] | 2118 | SourceLocation EncodeLoc, |
Anders Carlsson | f9bcf01 | 2007-08-22 15:14:15 +0000 | [diff] [blame] | 2119 | SourceLocation LParenLoc, |
| 2120 | TypeTy *Ty, |
| 2121 | SourceLocation RParenLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2122 | |
Fariborz Jahanian | b62f681 | 2007-10-16 20:40:23 +0000 | [diff] [blame] | 2123 | // ParseObjCSelectorExpression - Build selector expression for @selector |
| 2124 | virtual ExprResult ParseObjCSelectorExpression(Selector Sel, |
| 2125 | SourceLocation AtLoc, |
Fariborz Jahanian | 2a35fa9 | 2007-10-16 23:21:02 +0000 | [diff] [blame] | 2126 | SourceLocation SelLoc, |
Fariborz Jahanian | b62f681 | 2007-10-16 20:40:23 +0000 | [diff] [blame] | 2127 | SourceLocation LParenLoc, |
| 2128 | SourceLocation RParenLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2129 | |
Fariborz Jahanian | 390d50a | 2007-10-17 16:58:11 +0000 | [diff] [blame] | 2130 | // ParseObjCProtocolExpression - Build protocol expression for @protocol |
| 2131 | virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, |
| 2132 | SourceLocation AtLoc, |
| 2133 | SourceLocation ProtoLoc, |
| 2134 | SourceLocation LParenLoc, |
| 2135 | SourceLocation RParenLoc); |
Douglas Gregor | e37ac4f | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 2136 | |
| 2137 | //===--------------------------------------------------------------------===// |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 2138 | // C++ Declarations |
| 2139 | // |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2140 | virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S, |
| 2141 | SourceLocation ExternLoc, |
| 2142 | SourceLocation LangLoc, |
| 2143 | const char *Lang, |
| 2144 | unsigned StrSize, |
| 2145 | SourceLocation LBraceLoc); |
| 2146 | virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S, |
| 2147 | DeclPtrTy LinkageSpec, |
| 2148 | SourceLocation RBraceLoc); |
Douglas Gregor | 074149e | 2009-01-05 19:45:36 +0000 | [diff] [blame] | 2149 | |
| 2150 | |
| 2151 | //===--------------------------------------------------------------------===// |
Douglas Gregor | e37ac4f | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 2152 | // C++ Classes |
| 2153 | // |
Argyrios Kyrtzidis | eb83ecd | 2008-11-08 16:45:02 +0000 | [diff] [blame] | 2154 | virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S, |
| 2155 | const CXXScopeSpec *SS); |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 2156 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2157 | virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, |
| 2158 | Declarator &D, |
Douglas Gregor | 37b372b | 2009-08-20 22:52:58 +0000 | [diff] [blame] | 2159 | MultiTemplateParamsArg TemplateParameterLists, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2160 | ExprTy *BitfieldWidth, |
Sebastian Redl | d1a7846 | 2009-11-24 23:38:44 +0000 | [diff] [blame] | 2161 | ExprTy *Init, bool IsDefinition, |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 2162 | bool Deleted = false); |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 2163 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2164 | virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD, |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 2165 | Scope *S, |
Fariborz Jahanian | bcfad54 | 2009-06-30 23:26:25 +0000 | [diff] [blame] | 2166 | const CXXScopeSpec &SS, |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 2167 | IdentifierInfo *MemberOrBase, |
Fariborz Jahanian | 9617433 | 2009-07-01 19:21:19 +0000 | [diff] [blame] | 2168 | TypeTy *TemplateTypeTy, |
Douglas Gregor | 7ad8390 | 2008-11-05 04:29:56 +0000 | [diff] [blame] | 2169 | SourceLocation IdLoc, |
| 2170 | SourceLocation LParenLoc, |
| 2171 | ExprTy **Args, unsigned NumArgs, |
| 2172 | SourceLocation *CommaLocs, |
| 2173 | SourceLocation RParenLoc); |
| 2174 | |
Eli Friedman | 59c0437 | 2009-07-29 19:44:27 +0000 | [diff] [blame] | 2175 | MemInitResult BuildMemberInitializer(FieldDecl *Member, Expr **Args, |
| 2176 | unsigned NumArgs, SourceLocation IdLoc, |
Douglas Gregor | 802ab45 | 2009-12-02 22:36:29 +0000 | [diff] [blame] | 2177 | SourceLocation LParenLoc, |
Eli Friedman | 59c0437 | 2009-07-29 19:44:27 +0000 | [diff] [blame] | 2178 | SourceLocation RParenLoc); |
| 2179 | |
Douglas Gregor | 802ab45 | 2009-12-02 22:36:29 +0000 | [diff] [blame] | 2180 | MemInitResult BuildBaseInitializer(QualType BaseType, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 2181 | TypeSourceInfo *BaseTInfo, |
Douglas Gregor | 802ab45 | 2009-12-02 22:36:29 +0000 | [diff] [blame] | 2182 | Expr **Args, unsigned NumArgs, |
| 2183 | SourceLocation LParenLoc, |
Eli Friedman | 59c0437 | 2009-07-29 19:44:27 +0000 | [diff] [blame] | 2184 | SourceLocation RParenLoc, |
| 2185 | CXXRecordDecl *ClassDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2186 | |
Benjamin Kramer | 3f17a37 | 2009-11-09 20:14:44 +0000 | [diff] [blame] | 2187 | bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor, |
Fariborz Jahanian | 80545ad | 2009-09-03 19:36:46 +0000 | [diff] [blame] | 2188 | CXXBaseOrMemberInitializer **Initializers, |
| 2189 | unsigned NumInitializers, |
Eli Friedman | 49c16da | 2009-11-09 01:05:47 +0000 | [diff] [blame] | 2190 | bool IsImplicitConstructor); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2191 | |
Anders Carlsson | 9f853df | 2009-11-17 04:44:12 +0000 | [diff] [blame] | 2192 | /// MarkBaseAndMemberDestructorsReferenced - Given a destructor decl, |
| 2193 | /// mark all its non-trivial member and base destructor declarations |
| 2194 | /// as referenced. |
| 2195 | void MarkBaseAndMemberDestructorsReferenced(CXXDestructorDecl *Destructor); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2196 | |
Anders Carlsson | d6a637f | 2009-12-07 08:24:59 +0000 | [diff] [blame] | 2197 | /// ClassesWithUnmarkedVirtualMembers - Contains record decls whose virtual |
Douglas Gregor | 159ef1e | 2010-01-06 04:44:19 +0000 | [diff] [blame] | 2198 | /// members need to be marked as referenced at the end of the translation |
| 2199 | /// unit. It will contain polymorphic classes that do not have a key |
| 2200 | /// function or have a key function that has been defined. |
| 2201 | llvm::SmallVector<std::pair<CXXRecordDecl *, SourceLocation>, 4> |
| 2202 | ClassesWithUnmarkedVirtualMembers; |
Anders Carlsson | d6a637f | 2009-12-07 08:24:59 +0000 | [diff] [blame] | 2203 | |
| 2204 | /// MaybeMarkVirtualMembersReferenced - If the passed in method is the |
Anders Carlsson | 5ec02ae | 2009-12-02 17:15:43 +0000 | [diff] [blame] | 2205 | /// key function of the record decl, will mark virtual member functions as |
| 2206 | /// referenced. |
Anders Carlsson | d6a637f | 2009-12-07 08:24:59 +0000 | [diff] [blame] | 2207 | void MaybeMarkVirtualMembersReferenced(SourceLocation Loc, CXXMethodDecl *MD); |
| 2208 | |
| 2209 | /// MarkVirtualMembersReferenced - Will mark all virtual members of the given |
| 2210 | /// CXXRecordDecl referenced. |
| 2211 | void MarkVirtualMembersReferenced(SourceLocation Loc, CXXRecordDecl *RD); |
| 2212 | |
| 2213 | /// ProcessPendingClassesWithUnmarkedVirtualMembers - Will process classes |
| 2214 | /// that might need to have their virtual members marked as referenced. |
| 2215 | /// Returns false if no work was done. |
| 2216 | bool ProcessPendingClassesWithUnmarkedVirtualMembers(); |
Anders Carlsson | 5ec02ae | 2009-12-02 17:15:43 +0000 | [diff] [blame] | 2217 | |
Douglas Gregor | 396b7cd | 2008-11-03 17:51:48 +0000 | [diff] [blame] | 2218 | void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl); |
| 2219 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2220 | virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl, |
Anders Carlsson | a7b3521 | 2009-03-25 02:58:17 +0000 | [diff] [blame] | 2221 | SourceLocation ColonLoc, |
| 2222 | MemInitTy **MemInits, unsigned NumMemInits); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2223 | |
Douglas Gregor | 1ab537b | 2009-12-03 18:33:45 +0000 | [diff] [blame] | 2224 | void CheckCompletedCXXClass(CXXRecordDecl *Record); |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 2225 | virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2226 | DeclPtrTy TagDecl, |
Argyrios Kyrtzidis | 0795232 | 2008-07-01 10:37:29 +0000 | [diff] [blame] | 2227 | SourceLocation LBrac, |
| 2228 | SourceLocation RBrac); |
| 2229 | |
Douglas Gregor | 6569d68 | 2009-05-27 23:11:45 +0000 | [diff] [blame] | 2230 | virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template); |
John McCall | 7a1dc56 | 2009-12-19 10:49:29 +0000 | [diff] [blame] | 2231 | virtual void ActOnStartDelayedMemberDeclarations(Scope *S, |
| 2232 | DeclPtrTy Record); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2233 | virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S, |
| 2234 | DeclPtrTy Method); |
| 2235 | virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param); |
| 2236 | virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, |
| 2237 | DeclPtrTy Method); |
John McCall | 7a1dc56 | 2009-12-19 10:49:29 +0000 | [diff] [blame] | 2238 | virtual void ActOnFinishDelayedMemberDeclarations(Scope *S, |
| 2239 | DeclPtrTy Record); |
Douglas Gregor | 72b505b | 2008-12-16 21:30:33 +0000 | [diff] [blame] | 2240 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2241 | virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2242 | ExprArg AssertExpr, |
| 2243 | ExprArg AssertMessageExpr); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2244 | |
John McCall | dd4a3b0 | 2009-09-16 22:47:08 +0000 | [diff] [blame] | 2245 | DeclPtrTy ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, |
| 2246 | MultiTemplateParamsArg TemplateParams); |
John McCall | bbbcdd9 | 2009-09-11 21:02:39 +0000 | [diff] [blame] | 2247 | DeclPtrTy ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition, |
| 2248 | MultiTemplateParamsArg TemplateParams); |
Anders Carlsson | 0033836 | 2009-05-11 22:55:49 +0000 | [diff] [blame] | 2249 | |
Chris Lattner | 6540180 | 2009-04-25 08:28:21 +0000 | [diff] [blame] | 2250 | QualType CheckConstructorDeclarator(Declarator &D, QualType R, |
| 2251 | FunctionDecl::StorageClass& SC); |
Chris Lattner | 6e47501 | 2009-04-25 08:35:12 +0000 | [diff] [blame] | 2252 | void CheckConstructor(CXXConstructorDecl *Constructor); |
Chris Lattner | 6540180 | 2009-04-25 08:28:21 +0000 | [diff] [blame] | 2253 | QualType CheckDestructorDeclarator(Declarator &D, |
| 2254 | FunctionDecl::StorageClass& SC); |
Anders Carlsson | 5ec02ae | 2009-12-02 17:15:43 +0000 | [diff] [blame] | 2255 | bool CheckDestructor(CXXDestructorDecl *Destructor); |
Chris Lattner | 6e47501 | 2009-04-25 08:35:12 +0000 | [diff] [blame] | 2256 | void CheckConversionDeclarator(Declarator &D, QualType &R, |
Douglas Gregor | 2f1bc52 | 2008-11-07 20:08:42 +0000 | [diff] [blame] | 2257 | FunctionDecl::StorageClass& SC); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2258 | DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion); |
Douglas Gregor | e961afb | 2009-10-22 07:08:30 +0000 | [diff] [blame] | 2259 | |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 2260 | //===--------------------------------------------------------------------===// |
| 2261 | // C++ Derived Classes |
| 2262 | // |
| 2263 | |
| 2264 | /// ActOnBaseSpecifier - Parsed a base specifier |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2265 | CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class, |
| 2266 | SourceRange SpecifierRange, |
| 2267 | bool Virtual, AccessSpecifier Access, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2268 | QualType BaseType, |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2269 | SourceLocation BaseLoc); |
Anders Carlsson | 51f9404 | 2009-12-03 17:49:57 +0000 | [diff] [blame] | 2270 | |
| 2271 | /// SetClassDeclAttributesFromBase - Copies class decl traits |
| 2272 | /// (such as whether the class has a trivial constructor, |
| 2273 | /// trivial destructor etc) from the given base class. |
| 2274 | void SetClassDeclAttributesFromBase(CXXRecordDecl *Class, |
| 2275 | const CXXRecordDecl *BaseClass, |
| 2276 | bool BaseIsVirtual); |
| 2277 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2278 | virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl, |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 2279 | SourceRange SpecifierRange, |
| 2280 | bool Virtual, AccessSpecifier Access, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2281 | TypeTy *basetype, SourceLocation |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2282 | BaseLoc); |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 2283 | |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2284 | bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, |
| 2285 | unsigned NumBases); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2286 | virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases, |
Douglas Gregor | bc0805a | 2008-10-23 00:40:37 +0000 | [diff] [blame] | 2287 | unsigned NumBases); |
| 2288 | |
| 2289 | bool IsDerivedFrom(QualType Derived, QualType Base); |
Douglas Gregor | a8f32e0 | 2009-10-06 17:59:45 +0000 | [diff] [blame] | 2290 | bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths); |
| 2291 | |
Douglas Gregor | 0575d4a | 2008-10-24 16:17:19 +0000 | [diff] [blame] | 2292 | bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, |
Sebastian Redl | a82e4ae | 2009-11-14 21:15:49 +0000 | [diff] [blame] | 2293 | SourceLocation Loc, SourceRange Range, |
| 2294 | bool IgnoreAccess = false); |
Anders Carlsson | d8f9cb0 | 2009-05-13 21:11:42 +0000 | [diff] [blame] | 2295 | bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, |
| 2296 | unsigned InaccessibleBaseID, |
| 2297 | unsigned AmbigiousBaseConvID, |
| 2298 | SourceLocation Loc, SourceRange Range, |
| 2299 | DeclarationName Name); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2300 | |
Douglas Gregor | a8f32e0 | 2009-10-06 17:59:45 +0000 | [diff] [blame] | 2301 | std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2302 | |
Sebastian Redl | 23c7d06 | 2009-07-07 20:29:57 +0000 | [diff] [blame] | 2303 | /// CheckOverridingFunctionReturnType - Checks whether the return types are |
| 2304 | /// covariant, according to C++ [class.virtual]p5. |
| 2305 | bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, |
Anders Carlsson | d7ba27d | 2009-05-14 01:09:04 +0000 | [diff] [blame] | 2306 | const CXXMethodDecl *Old); |
Sebastian Redl | 23c7d06 | 2009-07-07 20:29:57 +0000 | [diff] [blame] | 2307 | |
| 2308 | /// CheckOverridingFunctionExceptionSpec - Checks whether the exception |
| 2309 | /// spec is a subset of base spec. |
| 2310 | bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, |
| 2311 | const CXXMethodDecl *Old); |
Douglas Gregor | e37ac4f | 2008-04-13 21:30:24 +0000 | [diff] [blame] | 2312 | |
Sean Hunt | bbd37c6 | 2009-11-21 08:43:09 +0000 | [diff] [blame] | 2313 | /// CheckOverridingFunctionAttributes - Checks whether attributes are |
| 2314 | /// incompatible or prevent overriding. |
| 2315 | bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New, |
| 2316 | const CXXMethodDecl *Old); |
| 2317 | |
Douglas Gregor | 4ba3136 | 2009-12-01 17:24:26 +0000 | [diff] [blame] | 2318 | bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange); |
Anders Carlsson | 29f006b | 2009-03-27 05:05:05 +0000 | [diff] [blame] | 2319 | //===--------------------------------------------------------------------===// |
| 2320 | // C++ Access Control |
| 2321 | // |
Sebastian Redl | 726212f | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2322 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2323 | bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, |
Anders Carlsson | 29f006b | 2009-03-27 05:05:05 +0000 | [diff] [blame] | 2324 | NamedDecl *PrevMemberDecl, |
| 2325 | AccessSpecifier LexicalAS); |
Sebastian Redl | 726212f | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2326 | |
| 2327 | const CXXBaseSpecifier *FindInaccessibleBase(QualType Derived, QualType Base, |
Douglas Gregor | a8f32e0 | 2009-10-06 17:59:45 +0000 | [diff] [blame] | 2328 | CXXBasePaths &Paths, |
Sebastian Redl | 726212f | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2329 | bool NoPrivileges = false); |
| 2330 | |
| 2331 | bool CheckBaseClassAccess(QualType Derived, QualType Base, |
Anders Carlsson | d8f9cb0 | 2009-05-13 21:11:42 +0000 | [diff] [blame] | 2332 | unsigned InaccessibleBaseID, |
Douglas Gregor | a8f32e0 | 2009-10-06 17:59:45 +0000 | [diff] [blame] | 2333 | CXXBasePaths& Paths, SourceLocation AccessLoc, |
Anders Carlsson | d8f9cb0 | 2009-05-13 21:11:42 +0000 | [diff] [blame] | 2334 | DeclarationName Name); |
Sebastian Redl | 726212f | 2009-07-18 14:32:15 +0000 | [diff] [blame] | 2335 | |
| 2336 | |
Anders Carlsson | 8211eff | 2009-03-24 01:19:16 +0000 | [diff] [blame] | 2337 | enum AbstractDiagSelID { |
| 2338 | AbstractNone = -1, |
| 2339 | AbstractReturnType, |
| 2340 | AbstractParamType, |
| 2341 | AbstractVariableType, |
| 2342 | AbstractFieldType |
| 2343 | }; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2344 | |
Anders Carlsson | a6ec7ad | 2009-08-27 00:13:57 +0000 | [diff] [blame] | 2345 | bool RequireNonAbstractType(SourceLocation Loc, QualType T, |
| 2346 | const PartialDiagnostic &PD, |
| 2347 | const CXXRecordDecl *CurrentRD = 0); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2348 | |
| 2349 | bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, |
Anders Carlsson | e65a3c8 | 2009-03-24 17:23:42 +0000 | [diff] [blame] | 2350 | AbstractDiagSelID SelID = AbstractNone, |
| 2351 | const CXXRecordDecl *CurrentRD = 0); |
Anders Carlsson | 4681ebd | 2009-03-22 20:18:17 +0000 | [diff] [blame] | 2352 | |
Douglas Gregor | 1cd1b1e | 2008-11-06 22:13:31 +0000 | [diff] [blame] | 2353 | //===--------------------------------------------------------------------===// |
| 2354 | // C++ Overloaded Operators [C++ 13.5] |
| 2355 | // |
| 2356 | |
| 2357 | bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl); |
| 2358 | |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 2359 | //===--------------------------------------------------------------------===// |
| 2360 | // C++ Templates [C++ 14] |
| 2361 | // |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 2362 | void LookupTemplateName(LookupResult &R, Scope *S, const CXXScopeSpec &SS, |
| 2363 | QualType ObjectType, bool EnteringContext); |
| 2364 | |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 2365 | virtual TemplateNameKind isTemplateName(Scope *S, |
Douglas Gregor | 014e88d | 2009-11-03 23:16:33 +0000 | [diff] [blame] | 2366 | const CXXScopeSpec &SS, |
| 2367 | UnqualifiedId &Name, |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 2368 | TypeTy *ObjectType, |
Douglas Gregor | 495c35d | 2009-08-25 22:51:20 +0000 | [diff] [blame] | 2369 | bool EnteringContext, |
| 2370 | TemplateTy &Template); |
Douglas Gregor | 84d0a19 | 2010-01-12 21:28:44 +0000 | [diff] [blame] | 2371 | |
| 2372 | virtual bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, |
| 2373 | SourceLocation IILoc, |
| 2374 | Scope *S, |
| 2375 | const CXXScopeSpec *SS, |
| 2376 | TemplateTy &SuggestedTemplate, |
| 2377 | TemplateNameKind &SuggestedKind); |
| 2378 | |
Douglas Gregor | 72c3f31 | 2008-12-05 18:15:24 +0000 | [diff] [blame] | 2379 | bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2380 | TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 2381 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2382 | virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, |
Anders Carlsson | 941df7d | 2009-06-12 19:58:00 +0000 | [diff] [blame] | 2383 | SourceLocation EllipsisLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2384 | SourceLocation KeyLoc, |
| 2385 | IdentifierInfo *ParamName, |
| 2386 | SourceLocation ParamNameLoc, |
| 2387 | unsigned Depth, unsigned Position); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2388 | virtual void ActOnTypeParameterDefault(DeclPtrTy TypeParam, |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2389 | SourceLocation EqualLoc, |
| 2390 | SourceLocation DefaultLoc, |
| 2391 | TypeTy *Default); |
| 2392 | |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2393 | QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2394 | virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, |
| 2395 | unsigned Depth, |
| 2396 | unsigned Position); |
| 2397 | virtual void ActOnNonTypeTemplateParameterDefault(DeclPtrTy TemplateParam, |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2398 | SourceLocation EqualLoc, |
| 2399 | ExprArg Default); |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2400 | virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S, |
| 2401 | SourceLocation TmpLoc, |
| 2402 | TemplateParamsTy *Params, |
| 2403 | IdentifierInfo *ParamName, |
| 2404 | SourceLocation ParamNameLoc, |
| 2405 | unsigned Depth, |
| 2406 | unsigned Position); |
| 2407 | virtual void ActOnTemplateTemplateParameterDefault(DeclPtrTy TemplateParam, |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2408 | SourceLocation EqualLoc, |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 2409 | const ParsedTemplateArgument &Default); |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2410 | |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 2411 | virtual TemplateParamsTy * |
| 2412 | ActOnTemplateParameterList(unsigned Depth, |
| 2413 | SourceLocation ExportLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2414 | SourceLocation TemplateLoc, |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 2415 | SourceLocation LAngleLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 2416 | DeclPtrTy *Params, unsigned NumParams, |
Douglas Gregor | c4b4e7b | 2008-12-24 02:52:09 +0000 | [diff] [blame] | 2417 | SourceLocation RAngleLoc); |
Douglas Gregor | 5b6d70e | 2009-11-25 17:50:39 +0000 | [diff] [blame] | 2418 | |
| 2419 | /// \brief The context in which we are checking a template parameter |
| 2420 | /// list. |
| 2421 | enum TemplateParamListContext { |
| 2422 | TPC_ClassTemplate, |
| 2423 | TPC_FunctionTemplate, |
| 2424 | TPC_ClassTemplateMember, |
| 2425 | TPC_FriendFunctionTemplate |
| 2426 | }; |
| 2427 | |
Douglas Gregor | d684b00 | 2009-02-10 19:49:53 +0000 | [diff] [blame] | 2428 | bool CheckTemplateParameterList(TemplateParameterList *NewParams, |
Douglas Gregor | 5b6d70e | 2009-11-25 17:50:39 +0000 | [diff] [blame] | 2429 | TemplateParameterList *OldParams, |
| 2430 | TemplateParamListContext TPC); |
Douglas Gregor | f59a56e | 2009-07-21 23:53:31 +0000 | [diff] [blame] | 2431 | TemplateParameterList * |
| 2432 | MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, |
| 2433 | const CXXScopeSpec &SS, |
| 2434 | TemplateParameterList **ParamLists, |
Douglas Gregor | 1fef4e6 | 2009-10-07 22:35:40 +0000 | [diff] [blame] | 2435 | unsigned NumParamLists, |
| 2436 | bool &IsExplicitSpecialization); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2437 | |
John McCall | 0f434ec | 2009-07-31 02:45:11 +0000 | [diff] [blame] | 2438 | DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, |
Douglas Gregor | bd1099e | 2009-07-23 16:36:45 +0000 | [diff] [blame] | 2439 | SourceLocation KWLoc, const CXXScopeSpec &SS, |
| 2440 | IdentifierInfo *Name, SourceLocation NameLoc, |
| 2441 | AttributeList *Attr, |
Douglas Gregor | 05396e2 | 2009-08-25 17:23:04 +0000 | [diff] [blame] | 2442 | TemplateParameterList *TemplateParams, |
Douglas Gregor | bd1099e | 2009-07-23 16:36:45 +0000 | [diff] [blame] | 2443 | AccessSpecifier AS); |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2444 | |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2445 | void translateTemplateArguments(const ASTTemplateArgsPtr &In, |
| 2446 | TemplateArgumentListInfo &Out); |
Douglas Gregor | 0b60d9e | 2009-09-25 23:53:26 +0000 | [diff] [blame] | 2447 | |
Douglas Gregor | 7532dc6 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2448 | QualType CheckTemplateIdType(TemplateName Template, |
| 2449 | SourceLocation TemplateLoc, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2450 | const TemplateArgumentListInfo &TemplateArgs); |
Douglas Gregor | 40808ce | 2009-03-09 23:48:35 +0000 | [diff] [blame] | 2451 | |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2452 | virtual TypeResult |
Douglas Gregor | 7532dc6 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2453 | ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc, |
| 2454 | SourceLocation LAngleLoc, |
| 2455 | ASTTemplateArgsPtr TemplateArgs, |
John McCall | 6b2becf | 2009-09-08 17:47:29 +0000 | [diff] [blame] | 2456 | SourceLocation RAngleLoc); |
| 2457 | |
| 2458 | virtual TypeResult ActOnTagTemplateIdType(TypeResult Type, |
| 2459 | TagUseKind TUK, |
| 2460 | DeclSpec::TST TagSpec, |
| 2461 | SourceLocation TagLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2462 | |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 2463 | OwningExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, |
| 2464 | LookupResult &R, |
| 2465 | bool RequiresADL, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2466 | const TemplateArgumentListInfo &TemplateArgs); |
John McCall | f7a1a74 | 2009-11-24 19:00:30 +0000 | [diff] [blame] | 2467 | OwningExprResult BuildQualifiedTemplateIdExpr(const CXXScopeSpec &SS, |
| 2468 | DeclarationName Name, |
| 2469 | SourceLocation NameLoc, |
| 2470 | const TemplateArgumentListInfo &TemplateArgs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2471 | |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 2472 | virtual TemplateTy ActOnDependentTemplateName(SourceLocation TemplateKWLoc, |
Douglas Gregor | 2dd078a | 2009-09-02 22:59:36 +0000 | [diff] [blame] | 2473 | const CXXScopeSpec &SS, |
Douglas Gregor | 014e88d | 2009-11-03 23:16:33 +0000 | [diff] [blame] | 2474 | UnqualifiedId &Name, |
Douglas Gregor | a481edb | 2009-11-20 23:39:24 +0000 | [diff] [blame] | 2475 | TypeTy *ObjectType, |
| 2476 | bool EnteringContext); |
Douglas Gregor | c45c232 | 2009-03-31 00:43:58 +0000 | [diff] [blame] | 2477 | |
Douglas Gregor | e94866f | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 2478 | bool CheckClassTemplatePartialSpecializationArgs( |
| 2479 | TemplateParameterList *TemplateParams, |
Anders Carlsson | 6360be7 | 2009-06-13 18:20:51 +0000 | [diff] [blame] | 2480 | const TemplateArgumentListBuilder &TemplateArgs, |
Douglas Gregor | 6aa75cf | 2009-06-12 22:08:06 +0000 | [diff] [blame] | 2481 | bool &MirrorsPrimaryTemplate); |
Douglas Gregor | e94866f | 2009-06-12 21:21:02 +0000 | [diff] [blame] | 2482 | |
Douglas Gregor | 212e81c | 2009-03-25 00:13:59 +0000 | [diff] [blame] | 2483 | virtual DeclResult |
John McCall | 0f434ec | 2009-07-31 02:45:11 +0000 | [diff] [blame] | 2484 | ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2485 | SourceLocation KWLoc, |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2486 | const CXXScopeSpec &SS, |
Douglas Gregor | 7532dc6 | 2009-03-30 22:58:21 +0000 | [diff] [blame] | 2487 | TemplateTy Template, |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2488 | SourceLocation TemplateNameLoc, |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2489 | SourceLocation LAngleLoc, |
Douglas Gregor | 5908e9f | 2009-02-09 19:34:22 +0000 | [diff] [blame] | 2490 | ASTTemplateArgsPtr TemplateArgs, |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2491 | SourceLocation RAngleLoc, |
Douglas Gregor | cc63668 | 2009-02-17 23:15:12 +0000 | [diff] [blame] | 2492 | AttributeList *Attr, |
| 2493 | MultiTemplateParamsArg TemplateParameterLists); |
Douglas Gregor | 55f6b14 | 2009-02-09 18:46:07 +0000 | [diff] [blame] | 2494 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2495 | virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S, |
Douglas Gregor | e542c86 | 2009-06-23 23:11:28 +0000 | [diff] [blame] | 2496 | MultiTemplateParamsArg TemplateParameterLists, |
| 2497 | Declarator &D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2498 | |
| 2499 | virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope, |
Douglas Gregor | 52591bf | 2009-06-24 00:54:41 +0000 | [diff] [blame] | 2500 | MultiTemplateParamsArg TemplateParameterLists, |
| 2501 | Declarator &D); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2502 | |
Douglas Gregor | 0d03514 | 2009-10-27 18:42:08 +0000 | [diff] [blame] | 2503 | bool |
| 2504 | CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, |
| 2505 | TemplateSpecializationKind NewTSK, |
| 2506 | NamedDecl *PrevDecl, |
| 2507 | TemplateSpecializationKind PrevTSK, |
| 2508 | SourceLocation PrevPointOfInstantiation, |
| 2509 | bool &SuppressNew); |
| 2510 | |
Douglas Gregor | b9aa6b2 | 2009-09-24 23:14:47 +0000 | [diff] [blame] | 2511 | bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2512 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
John McCall | 6826314 | 2009-11-18 22:49:29 +0000 | [diff] [blame] | 2513 | LookupResult &Previous); |
| 2514 | bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous); |
Douglas Gregor | b9aa6b2 | 2009-09-24 23:14:47 +0000 | [diff] [blame] | 2515 | |
Douglas Gregor | 93dfdb1 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 2516 | virtual DeclResult |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2517 | ActOnExplicitInstantiation(Scope *S, |
Douglas Gregor | 45f9655 | 2009-09-04 06:33:52 +0000 | [diff] [blame] | 2518 | SourceLocation ExternLoc, |
| 2519 | SourceLocation TemplateLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2520 | unsigned TagSpec, |
Douglas Gregor | 93dfdb1 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 2521 | SourceLocation KWLoc, |
| 2522 | const CXXScopeSpec &SS, |
| 2523 | TemplateTy Template, |
| 2524 | SourceLocation TemplateNameLoc, |
| 2525 | SourceLocation LAngleLoc, |
| 2526 | ASTTemplateArgsPtr TemplateArgs, |
Douglas Gregor | 93dfdb1 | 2009-05-13 00:25:59 +0000 | [diff] [blame] | 2527 | SourceLocation RAngleLoc, |
| 2528 | AttributeList *Attr); |
| 2529 | |
Douglas Gregor | 3f5b61c | 2009-05-14 00:28:11 +0000 | [diff] [blame] | 2530 | virtual DeclResult |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2531 | ActOnExplicitInstantiation(Scope *S, |
Douglas Gregor | 45f9655 | 2009-09-04 06:33:52 +0000 | [diff] [blame] | 2532 | SourceLocation ExternLoc, |
| 2533 | SourceLocation TemplateLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2534 | unsigned TagSpec, |
Douglas Gregor | 3f5b61c | 2009-05-14 00:28:11 +0000 | [diff] [blame] | 2535 | SourceLocation KWLoc, |
| 2536 | const CXXScopeSpec &SS, |
| 2537 | IdentifierInfo *Name, |
| 2538 | SourceLocation NameLoc, |
| 2539 | AttributeList *Attr); |
| 2540 | |
Douglas Gregor | d5a423b | 2009-09-25 18:43:00 +0000 | [diff] [blame] | 2541 | virtual DeclResult ActOnExplicitInstantiation(Scope *S, |
| 2542 | SourceLocation ExternLoc, |
| 2543 | SourceLocation TemplateLoc, |
| 2544 | Declarator &D); |
| 2545 | |
Douglas Gregor | 51ffb0c | 2009-11-25 18:55:14 +0000 | [diff] [blame] | 2546 | TemplateArgumentLoc |
| 2547 | SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, |
| 2548 | SourceLocation TemplateLoc, |
| 2549 | SourceLocation RAngleLoc, |
| 2550 | Decl *Param, |
| 2551 | TemplateArgumentListBuilder &Converted); |
| 2552 | |
Douglas Gregor | e752641 | 2009-11-11 19:31:23 +0000 | [diff] [blame] | 2553 | bool CheckTemplateArgument(NamedDecl *Param, |
| 2554 | const TemplateArgumentLoc &Arg, |
Douglas Gregor | e752641 | 2009-11-11 19:31:23 +0000 | [diff] [blame] | 2555 | TemplateDecl *Template, |
| 2556 | SourceLocation TemplateLoc, |
Douglas Gregor | e752641 | 2009-11-11 19:31:23 +0000 | [diff] [blame] | 2557 | SourceLocation RAngleLoc, |
| 2558 | TemplateArgumentListBuilder &Converted); |
| 2559 | |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2560 | bool CheckTemplateArgumentList(TemplateDecl *Template, |
| 2561 | SourceLocation TemplateLoc, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2562 | const TemplateArgumentListInfo &TemplateArgs, |
Douglas Gregor | 16134c6 | 2009-07-01 00:28:38 +0000 | [diff] [blame] | 2563 | bool PartialTemplateArgs, |
Anders Carlsson | 1c5976e | 2009-06-05 03:43:12 +0000 | [diff] [blame] | 2564 | TemplateArgumentListBuilder &Converted); |
Douglas Gregor | c15cb38 | 2009-02-09 23:23:08 +0000 | [diff] [blame] | 2565 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2566 | bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 2567 | const TemplateArgumentLoc &Arg, |
Anders Carlsson | 436b156 | 2009-06-13 00:33:33 +0000 | [diff] [blame] | 2568 | TemplateArgumentListBuilder &Converted); |
| 2569 | |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 2570 | bool CheckTemplateArgument(TemplateTypeParmDecl *Param, |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 2571 | TypeSourceInfo *Arg); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2572 | bool CheckTemplateArgumentAddressOfObjectOrFunction(Expr *Arg, |
Douglas Gregor | 3e00bad | 2009-02-17 01:05:43 +0000 | [diff] [blame] | 2573 | NamedDecl *&Entity); |
Douglas Gregor | caddba0 | 2009-11-12 18:38:13 +0000 | [diff] [blame] | 2574 | bool CheckTemplateArgumentPointerToMember(Expr *Arg, |
| 2575 | TemplateArgument &Converted); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2576 | bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param, |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 2577 | QualType InstantiatedParamType, Expr *&Arg, |
Douglas Gregor | 02cbbd2 | 2009-06-11 18:10:32 +0000 | [diff] [blame] | 2578 | TemplateArgument &Converted); |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 2579 | bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, |
| 2580 | const TemplateArgumentLoc &Arg); |
Douglas Gregor | fb898e1 | 2009-11-12 16:20:59 +0000 | [diff] [blame] | 2581 | |
| 2582 | /// \brief Enumeration describing how template parameter lists are compared |
| 2583 | /// for equality. |
| 2584 | enum TemplateParameterListEqualKind { |
| 2585 | /// \brief We are matching the template parameter lists of two templates |
| 2586 | /// that might be redeclarations. |
| 2587 | /// |
| 2588 | /// \code |
| 2589 | /// template<typename T> struct X; |
| 2590 | /// template<typename T> struct X; |
| 2591 | /// \endcode |
| 2592 | TPL_TemplateMatch, |
| 2593 | |
| 2594 | /// \brief We are matching the template parameter lists of two template |
| 2595 | /// template parameters as part of matching the template parameter lists |
| 2596 | /// of two templates that might be redeclarations. |
| 2597 | /// |
| 2598 | /// \code |
| 2599 | /// template<template<int I> class TT> struct X; |
| 2600 | /// template<template<int Value> class Other> struct X; |
| 2601 | /// \endcode |
| 2602 | TPL_TemplateTemplateParmMatch, |
| 2603 | |
| 2604 | /// \brief We are matching the template parameter lists of a template |
| 2605 | /// template argument against the template parameter lists of a template |
| 2606 | /// template parameter. |
| 2607 | /// |
| 2608 | /// \code |
| 2609 | /// template<template<int Value> class Metafun> struct X; |
| 2610 | /// template<int Value> struct integer_c; |
| 2611 | /// X<integer_c> xic; |
| 2612 | /// \endcode |
| 2613 | TPL_TemplateTemplateArgumentMatch |
| 2614 | }; |
| 2615 | |
Douglas Gregor | ddc29e1 | 2009-02-06 22:42:48 +0000 | [diff] [blame] | 2616 | bool TemplateParameterListsAreEqual(TemplateParameterList *New, |
| 2617 | TemplateParameterList *Old, |
| 2618 | bool Complain, |
Douglas Gregor | fb898e1 | 2009-11-12 16:20:59 +0000 | [diff] [blame] | 2619 | TemplateParameterListEqualKind Kind, |
Douglas Gregor | dd0574e | 2009-02-10 00:24:35 +0000 | [diff] [blame] | 2620 | SourceLocation TemplateArgLoc |
Douglas Gregor | 788cd06 | 2009-11-11 01:00:40 +0000 | [diff] [blame] | 2621 | = SourceLocation()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2622 | |
Douglas Gregor | 05396e2 | 2009-08-25 17:23:04 +0000 | [diff] [blame] | 2623 | bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams); |
Douglas Gregor | aaba5e3 | 2009-02-04 19:02:06 +0000 | [diff] [blame] | 2624 | |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 2625 | /// \brief Called when the parser has parsed a C++ typename |
| 2626 | /// specifier, e.g., "typename T::type". |
| 2627 | /// |
| 2628 | /// \param TypenameLoc the location of the 'typename' keyword |
| 2629 | /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). |
| 2630 | /// \param II the identifier we're retrieving (e.g., 'type' in the example). |
| 2631 | /// \param IdLoc the location of the identifier. |
| 2632 | virtual TypeResult |
| 2633 | ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS, |
| 2634 | const IdentifierInfo &II, SourceLocation IdLoc); |
Douglas Gregor | 1734317 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 2635 | |
| 2636 | /// \brief Called when the parser has parsed a C++ typename |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2637 | /// specifier that ends in a template-id, e.g., |
Douglas Gregor | 1734317 | 2009-04-01 00:28:59 +0000 | [diff] [blame] | 2638 | /// "typename MetaFun::template apply<T1, T2>". |
| 2639 | /// |
| 2640 | /// \param TypenameLoc the location of the 'typename' keyword |
| 2641 | /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). |
| 2642 | /// \param TemplateLoc the location of the 'template' keyword, if any. |
| 2643 | /// \param Ty the type that the typename specifier refers to. |
| 2644 | virtual TypeResult |
| 2645 | ActOnTypenameType(SourceLocation TypenameLoc, const CXXScopeSpec &SS, |
| 2646 | SourceLocation TemplateLoc, TypeTy *Ty); |
| 2647 | |
Douglas Gregor | d57959a | 2009-03-27 23:10:48 +0000 | [diff] [blame] | 2648 | QualType CheckTypenameType(NestedNameSpecifier *NNS, |
| 2649 | const IdentifierInfo &II, |
| 2650 | SourceRange Range); |
Douglas Gregor | c8ab256 | 2009-05-31 09:31:02 +0000 | [diff] [blame] | 2651 | |
Douglas Gregor | 4a959d8 | 2009-08-06 16:20:37 +0000 | [diff] [blame] | 2652 | QualType RebuildTypeInCurrentInstantiation(QualType T, SourceLocation Loc, |
| 2653 | DeclarationName Name); |
| 2654 | |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 2655 | std::string |
| 2656 | getTemplateArgumentBindingsText(const TemplateParameterList *Params, |
| 2657 | const TemplateArgumentList &Args); |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2658 | |
| 2659 | std::string |
| 2660 | getTemplateArgumentBindingsText(const TemplateParameterList *Params, |
| 2661 | const TemplateArgument *Args, |
| 2662 | unsigned NumArgs); |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 2663 | |
Douglas Gregor | f67875d | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2664 | /// \brief Describes the result of template argument deduction. |
| 2665 | /// |
| 2666 | /// The TemplateDeductionResult enumeration describes the result of |
| 2667 | /// template argument deduction, as returned from |
| 2668 | /// DeduceTemplateArguments(). The separate TemplateDeductionInfo |
| 2669 | /// structure provides additional information about the results of |
| 2670 | /// template argument deduction, e.g., the deduced template argument |
| 2671 | /// list (if successful) or the specific template parameters or |
| 2672 | /// deduced arguments that were involved in the failure. |
| 2673 | enum TemplateDeductionResult { |
| 2674 | /// \brief Template argument deduction was successful. |
| 2675 | TDK_Success = 0, |
| 2676 | /// \brief Template argument deduction exceeded the maximum template |
| 2677 | /// instantiation depth (which has already been diagnosed). |
| 2678 | TDK_InstantiationDepth, |
| 2679 | /// \brief Template argument deduction did not deduce a value |
| 2680 | /// for every template parameter. |
| 2681 | TDK_Incomplete, |
| 2682 | /// \brief Template argument deduction produced inconsistent |
| 2683 | /// deduced values for the given template parameter. |
| 2684 | TDK_Inconsistent, |
| 2685 | /// \brief Template argument deduction failed due to inconsistent |
| 2686 | /// cv-qualifiers on a template parameter type that would |
| 2687 | /// otherwise be deduced, e.g., we tried to deduce T in "const T" |
| 2688 | /// but were given a non-const "X". |
| 2689 | TDK_InconsistentQuals, |
| 2690 | /// \brief Substitution of the deduced template argument values |
| 2691 | /// resulted in an error. |
| 2692 | TDK_SubstitutionFailure, |
| 2693 | /// \brief Substitution of the deduced template argument values |
| 2694 | /// into a non-deduced context produced a type or value that |
| 2695 | /// produces a type that does not match the original template |
| 2696 | /// arguments provided. |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2697 | TDK_NonDeducedMismatch, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2698 | /// \brief When performing template argument deduction for a function |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2699 | /// template, there were too many call arguments. |
| 2700 | TDK_TooManyArguments, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2701 | /// \brief When performing template argument deduction for a function |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2702 | /// template, there were too few call arguments. |
Douglas Gregor | 6db8ed4 | 2009-06-30 23:57:56 +0000 | [diff] [blame] | 2703 | TDK_TooFewArguments, |
| 2704 | /// \brief The explicitly-specified template arguments were not valid |
| 2705 | /// template arguments for the given template. |
Douglas Gregor | 4b52e25 | 2009-12-21 23:17:24 +0000 | [diff] [blame] | 2706 | TDK_InvalidExplicitArguments, |
| 2707 | /// \brief The arguments included an overloaded function name that could |
| 2708 | /// not be resolved to a suitable function. |
| 2709 | TDK_FailedOverloadResolution |
Douglas Gregor | f67875d | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2710 | }; |
| 2711 | |
| 2712 | /// \brief Provides information about an attempted template argument |
| 2713 | /// deduction, whose success or failure was described by a |
| 2714 | /// TemplateDeductionResult value. |
| 2715 | class TemplateDeductionInfo { |
| 2716 | /// \brief The context in which the template arguments are stored. |
| 2717 | ASTContext &Context; |
| 2718 | |
| 2719 | /// \brief The deduced template argument list. |
| 2720 | /// |
| 2721 | TemplateArgumentList *Deduced; |
| 2722 | |
| 2723 | // do not implement these |
| 2724 | TemplateDeductionInfo(const TemplateDeductionInfo&); |
| 2725 | TemplateDeductionInfo &operator=(const TemplateDeductionInfo&); |
| 2726 | |
| 2727 | public: |
| 2728 | TemplateDeductionInfo(ASTContext &Context) : Context(Context), Deduced(0) { } |
| 2729 | |
| 2730 | ~TemplateDeductionInfo() { |
| 2731 | // FIXME: if (Deduced) Deduced->Destroy(Context); |
| 2732 | } |
| 2733 | |
| 2734 | /// \brief Take ownership of the deduced template argument list. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2735 | TemplateArgumentList *take() { |
Douglas Gregor | f67875d | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2736 | TemplateArgumentList *Result = Deduced; |
| 2737 | Deduced = 0; |
| 2738 | return Result; |
| 2739 | } |
| 2740 | |
| 2741 | /// \brief Provide a new template argument list that contains the |
| 2742 | /// results of template argument deduction. |
| 2743 | void reset(TemplateArgumentList *NewDeduced) { |
| 2744 | // FIXME: if (Deduced) Deduced->Destroy(Context); |
| 2745 | Deduced = NewDeduced; |
| 2746 | } |
| 2747 | |
| 2748 | /// \brief The template parameter to which a template argument |
| 2749 | /// deduction failure refers. |
| 2750 | /// |
| 2751 | /// Depending on the result of template argument deduction, this |
| 2752 | /// template parameter may have different meanings: |
| 2753 | /// |
| 2754 | /// TDK_Incomplete: this is the first template parameter whose |
| 2755 | /// corresponding template argument was not deduced. |
| 2756 | /// |
| 2757 | /// TDK_Inconsistent: this is the template parameter for which |
| 2758 | /// two different template argument values were deduced. |
| 2759 | TemplateParameter Param; |
| 2760 | |
| 2761 | /// \brief The first template argument to which the template |
| 2762 | /// argument deduction failure refers. |
| 2763 | /// |
| 2764 | /// Depending on the result of the template argument deduction, |
| 2765 | /// this template argument may have different meanings: |
| 2766 | /// |
| 2767 | /// TDK_Inconsistent: this argument is the first value deduced |
| 2768 | /// for the corresponding template parameter. |
| 2769 | /// |
| 2770 | /// TDK_SubstitutionFailure: this argument is the template |
| 2771 | /// argument we were instantiating when we encountered an error. |
| 2772 | /// |
| 2773 | /// TDK_NonDeducedMismatch: this is the template argument |
| 2774 | /// provided in the source code. |
| 2775 | TemplateArgument FirstArg; |
| 2776 | |
| 2777 | /// \brief The second template argument to which the template |
| 2778 | /// argument deduction failure refers. |
| 2779 | /// |
| 2780 | /// FIXME: Finish documenting this. |
| 2781 | TemplateArgument SecondArg; |
| 2782 | }; |
| 2783 | |
| 2784 | TemplateDeductionResult |
Douglas Gregor | 199d991 | 2009-06-05 00:53:49 +0000 | [diff] [blame] | 2785 | DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, |
Douglas Gregor | f67875d | 2009-06-12 18:26:56 +0000 | [diff] [blame] | 2786 | const TemplateArgumentList &TemplateArgs, |
| 2787 | TemplateDeductionInfo &Info); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2788 | |
Douglas Gregor | 83314aa | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2789 | TemplateDeductionResult |
| 2790 | SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2791 | const TemplateArgumentListInfo &ExplicitTemplateArgs, |
Douglas Gregor | 83314aa | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2792 | llvm::SmallVectorImpl<TemplateArgument> &Deduced, |
| 2793 | llvm::SmallVectorImpl<QualType> &ParamTypes, |
| 2794 | QualType *FunctionType, |
| 2795 | TemplateDeductionInfo &Info); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2796 | |
| 2797 | TemplateDeductionResult |
Douglas Gregor | 83314aa | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2798 | FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, |
| 2799 | llvm::SmallVectorImpl<TemplateArgument> &Deduced, |
| 2800 | FunctionDecl *&Specialization, |
| 2801 | TemplateDeductionInfo &Info); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2802 | |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2803 | TemplateDeductionResult |
| 2804 | DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2805 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
Douglas Gregor | e53060f | 2009-06-25 22:08:12 +0000 | [diff] [blame] | 2806 | Expr **Args, unsigned NumArgs, |
| 2807 | FunctionDecl *&Specialization, |
| 2808 | TemplateDeductionInfo &Info); |
Douglas Gregor | 83314aa | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2809 | |
| 2810 | TemplateDeductionResult |
| 2811 | DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
John McCall | d5532b6 | 2009-11-23 01:53:49 +0000 | [diff] [blame] | 2812 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
Douglas Gregor | 83314aa | 2009-07-08 20:55:45 +0000 | [diff] [blame] | 2813 | QualType ArgFunctionType, |
| 2814 | FunctionDecl *&Specialization, |
| 2815 | TemplateDeductionInfo &Info); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2816 | |
Douglas Gregor | 65ec1fd | 2009-08-21 23:19:43 +0000 | [diff] [blame] | 2817 | TemplateDeductionResult |
| 2818 | DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
| 2819 | QualType ToType, |
| 2820 | CXXConversionDecl *&Specialization, |
| 2821 | TemplateDeductionInfo &Info); |
| 2822 | |
Douglas Gregor | 4b52e25 | 2009-12-21 23:17:24 +0000 | [diff] [blame] | 2823 | TemplateDeductionResult |
| 2824 | DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, |
| 2825 | const TemplateArgumentListInfo *ExplicitTemplateArgs, |
| 2826 | FunctionDecl *&Specialization, |
| 2827 | TemplateDeductionInfo &Info); |
| 2828 | |
Douglas Gregor | 65ec1fd | 2009-08-21 23:19:43 +0000 | [diff] [blame] | 2829 | FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, |
| 2830 | FunctionTemplateDecl *FT2, |
Douglas Gregor | 8a51491 | 2009-09-14 18:39:43 +0000 | [diff] [blame] | 2831 | TemplatePartialOrderingContext TPOC); |
Douglas Gregor | d5a423b | 2009-09-25 18:43:00 +0000 | [diff] [blame] | 2832 | FunctionDecl *getMostSpecialized(FunctionDecl **Specializations, |
| 2833 | unsigned NumSpecializations, |
| 2834 | TemplatePartialOrderingContext TPOC, |
| 2835 | SourceLocation Loc, |
| 2836 | const PartialDiagnostic &NoneDiag, |
| 2837 | const PartialDiagnostic &AmbigDiag, |
| 2838 | const PartialDiagnostic &CandidateDiag, |
| 2839 | unsigned *Index = 0); |
| 2840 | |
Douglas Gregor | bf4ea56 | 2009-09-15 16:23:51 +0000 | [diff] [blame] | 2841 | ClassTemplatePartialSpecializationDecl * |
| 2842 | getMoreSpecializedPartialSpecialization( |
| 2843 | ClassTemplatePartialSpecializationDecl *PS1, |
| 2844 | ClassTemplatePartialSpecializationDecl *PS2); |
| 2845 | |
Douglas Gregor | e73bb60 | 2009-09-14 21:25:05 +0000 | [diff] [blame] | 2846 | void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, |
| 2847 | bool OnlyDeduced, |
Douglas Gregor | ed9c0f9 | 2009-10-29 00:04:11 +0000 | [diff] [blame] | 2848 | unsigned Depth, |
Douglas Gregor | 63f07c5 | 2009-09-18 23:21:38 +0000 | [diff] [blame] | 2849 | llvm::SmallVectorImpl<bool> &Used); |
| 2850 | void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate, |
| 2851 | llvm::SmallVectorImpl<bool> &Deduced); |
| 2852 | |
Douglas Gregor | 99ebf65 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 2853 | //===--------------------------------------------------------------------===// |
| 2854 | // C++ Template Instantiation |
| 2855 | // |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2856 | |
Douglas Gregor | 0f8716b | 2009-11-09 19:17:50 +0000 | [diff] [blame] | 2857 | MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, |
| 2858 | const TemplateArgumentList *Innermost = 0); |
Douglas Gregor | 54dabfc | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 2859 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2860 | /// \brief A template instantiation that is currently in progress. |
| 2861 | struct ActiveTemplateInstantiation { |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2862 | /// \brief The kind of template instantiation we are performing |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2863 | enum InstantiationKind { |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2864 | /// We are instantiating a template declaration. The entity is |
Douglas Gregor | b9f1b8d | 2009-05-15 00:01:03 +0000 | [diff] [blame] | 2865 | /// the declaration we're instantiating (e.g., a CXXRecordDecl). |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2866 | TemplateInstantiation, |
| 2867 | |
| 2868 | /// We are instantiating a default argument for a template |
| 2869 | /// parameter. The Entity is the template, and |
| 2870 | /// TemplateArgs/NumTemplateArguments provides the template |
| 2871 | /// arguments as specified. |
Douglas Gregor | 637a409 | 2009-06-10 23:47:09 +0000 | [diff] [blame] | 2872 | /// FIXME: Use a TemplateArgumentList |
| 2873 | DefaultTemplateArgumentInstantiation, |
| 2874 | |
Anders Carlsson | 25cae7f | 2009-09-05 05:14:19 +0000 | [diff] [blame] | 2875 | /// We are instantiating a default argument for a function. |
| 2876 | /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs |
| 2877 | /// provides the template arguments as specified. |
| 2878 | DefaultFunctionArgumentInstantiation, |
| 2879 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2880 | /// We are substituting explicit template arguments provided for |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2881 | /// a function template. The entity is a FunctionTemplateDecl. |
| 2882 | ExplicitTemplateArgumentSubstitution, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2883 | |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2884 | /// We are substituting template argument determined as part of |
| 2885 | /// template argument deduction for either a class template |
| 2886 | /// partial specialization or a function template. The |
| 2887 | /// Entity is either a ClassTemplatePartialSpecializationDecl or |
| 2888 | /// a FunctionTemplateDecl. |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2889 | DeducedTemplateArgumentSubstitution, |
| 2890 | |
| 2891 | /// We are substituting prior template arguments into a new |
| 2892 | /// template parameter. The template parameter itself is either a |
| 2893 | /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl. |
Douglas Gregor | f35f828 | 2009-11-11 21:54:23 +0000 | [diff] [blame] | 2894 | PriorTemplateArgumentSubstitution, |
| 2895 | |
| 2896 | /// We are checking the validity of a default template argument that |
| 2897 | /// has been used when naming a template-id. |
| 2898 | DefaultTemplateArgumentChecking |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2899 | } Kind; |
| 2900 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2901 | /// \brief The point of instantiation within the source code. |
| 2902 | SourceLocation PointOfInstantiation; |
| 2903 | |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2904 | /// \brief The template in which we are performing the instantiation, |
| 2905 | /// for substitutions of prior template arguments. |
| 2906 | TemplateDecl *Template; |
| 2907 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2908 | /// \brief The entity that is being instantiated. |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2909 | uintptr_t Entity; |
| 2910 | |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2911 | /// \brief The list of template arguments we are substituting, if they |
| 2912 | /// are not part of the entity. |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2913 | const TemplateArgument *TemplateArgs; |
| 2914 | |
| 2915 | /// \brief The number of template arguments in TemplateArgs. |
| 2916 | unsigned NumTemplateArgs; |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2917 | |
| 2918 | /// \brief The source range that covers the construct that cause |
| 2919 | /// the instantiation, e.g., the template-id that causes a class |
| 2920 | /// template instantiation. |
| 2921 | SourceRange InstantiationRange; |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2922 | |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2923 | ActiveTemplateInstantiation() |
| 2924 | : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0), |
| 2925 | NumTemplateArgs(0) {} |
Eli Friedman | 2ebcc6b | 2009-08-15 22:50:33 +0000 | [diff] [blame] | 2926 | |
Douglas Gregor | f35f828 | 2009-11-11 21:54:23 +0000 | [diff] [blame] | 2927 | /// \brief Determines whether this template is an actual instantiation |
| 2928 | /// that should be counted toward the maximum instantiation depth. |
| 2929 | bool isInstantiationRecord() const; |
| 2930 | |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2931 | friend bool operator==(const ActiveTemplateInstantiation &X, |
| 2932 | const ActiveTemplateInstantiation &Y) { |
| 2933 | if (X.Kind != Y.Kind) |
| 2934 | return false; |
| 2935 | |
| 2936 | if (X.Entity != Y.Entity) |
| 2937 | return false; |
| 2938 | |
| 2939 | switch (X.Kind) { |
| 2940 | case TemplateInstantiation: |
| 2941 | return true; |
| 2942 | |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2943 | case PriorTemplateArgumentSubstitution: |
Douglas Gregor | f35f828 | 2009-11-11 21:54:23 +0000 | [diff] [blame] | 2944 | case DefaultTemplateArgumentChecking: |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 2945 | if (X.Template != Y.Template) |
| 2946 | return false; |
| 2947 | |
| 2948 | // Fall through |
| 2949 | |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2950 | case DefaultTemplateArgumentInstantiation: |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 2951 | case ExplicitTemplateArgumentSubstitution: |
| 2952 | case DeducedTemplateArgumentSubstitution: |
Anders Carlsson | 25cae7f | 2009-09-05 05:14:19 +0000 | [diff] [blame] | 2953 | case DefaultFunctionArgumentInstantiation: |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2954 | return X.TemplateArgs == Y.TemplateArgs; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2955 | |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2956 | } |
| 2957 | |
| 2958 | return true; |
| 2959 | } |
| 2960 | |
| 2961 | friend bool operator!=(const ActiveTemplateInstantiation &X, |
| 2962 | const ActiveTemplateInstantiation &Y) { |
| 2963 | return !(X == Y); |
| 2964 | } |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2965 | }; |
| 2966 | |
| 2967 | /// \brief List of active template instantiations. |
| 2968 | /// |
| 2969 | /// This vector is treated as a stack. As one template instantiation |
| 2970 | /// requires another template instantiation, additional |
| 2971 | /// instantiations are pushed onto the stack up to a |
| 2972 | /// user-configurable limit LangOptions::InstantiationDepth. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 2973 | llvm::SmallVector<ActiveTemplateInstantiation, 16> |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2974 | ActiveTemplateInstantiations; |
| 2975 | |
Douglas Gregor | f35f828 | 2009-11-11 21:54:23 +0000 | [diff] [blame] | 2976 | /// \brief The number of ActiveTemplateInstantiation entries in |
| 2977 | /// \c ActiveTemplateInstantiations that are not actual instantiations and, |
| 2978 | /// therefore, should not be counted as part of the instantiation depth. |
| 2979 | unsigned NonInstantiationEntries; |
| 2980 | |
Douglas Gregor | 27b152f | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 2981 | /// \brief The last template from which a template instantiation |
| 2982 | /// error or warning was produced. |
| 2983 | /// |
| 2984 | /// This value is used to suppress printing of redundant template |
| 2985 | /// instantiation backtraces when there are multiple errors in the |
| 2986 | /// same instantiation. FIXME: Does this belong in Sema? It's tough |
| 2987 | /// to implement it anywhere else. |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 2988 | ActiveTemplateInstantiation LastTemplateInstantiationErrorContext; |
Douglas Gregor | 27b152f | 2009-03-10 18:52:44 +0000 | [diff] [blame] | 2989 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 2990 | /// \brief A stack object to be created when performing template |
| 2991 | /// instantiation. |
| 2992 | /// |
| 2993 | /// Construction of an object of type \c InstantiatingTemplate |
| 2994 | /// pushes the current instantiation onto the stack of active |
| 2995 | /// instantiations. If the size of this stack exceeds the maximum |
| 2996 | /// number of recursive template instantiations, construction |
| 2997 | /// produces an error and evaluates true. |
| 2998 | /// |
| 2999 | /// Destruction of this object will pop the named instantiation off |
| 3000 | /// the stack. |
| 3001 | struct InstantiatingTemplate { |
Douglas Gregor | f3e7ce4 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 3002 | /// \brief Note that we are instantiating a class template, |
| 3003 | /// function template, or a member thereof. |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 3004 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
Douglas Gregor | f3e7ce4 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 3005 | Decl *Entity, |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 3006 | SourceRange InstantiationRange = SourceRange()); |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 3007 | |
| 3008 | /// \brief Note that we are instantiating a default argument in a |
| 3009 | /// template-id. |
| 3010 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3011 | TemplateDecl *Template, |
| 3012 | const TemplateArgument *TemplateArgs, |
| 3013 | unsigned NumTemplateArgs, |
| 3014 | SourceRange InstantiationRange = SourceRange()); |
| 3015 | |
Douglas Gregor | cca9e96 | 2009-07-01 22:01:06 +0000 | [diff] [blame] | 3016 | /// \brief Note that we are instantiating a default argument in a |
| 3017 | /// template-id. |
| 3018 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3019 | FunctionTemplateDecl *FunctionTemplate, |
| 3020 | const TemplateArgument *TemplateArgs, |
| 3021 | unsigned NumTemplateArgs, |
| 3022 | ActiveTemplateInstantiation::InstantiationKind Kind, |
| 3023 | SourceRange InstantiationRange = SourceRange()); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3024 | |
Douglas Gregor | 637a409 | 2009-06-10 23:47:09 +0000 | [diff] [blame] | 3025 | /// \brief Note that we are instantiating as part of template |
| 3026 | /// argument deduction for a class template partial |
| 3027 | /// specialization. |
| 3028 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3029 | ClassTemplatePartialSpecializationDecl *PartialSpec, |
| 3030 | const TemplateArgument *TemplateArgs, |
| 3031 | unsigned NumTemplateArgs, |
| 3032 | SourceRange InstantiationRange = SourceRange()); |
| 3033 | |
Anders Carlsson | 25cae7f | 2009-09-05 05:14:19 +0000 | [diff] [blame] | 3034 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3035 | ParmVarDecl *Param, |
| 3036 | const TemplateArgument *TemplateArgs, |
| 3037 | unsigned NumTemplateArgs, |
| 3038 | SourceRange InstantiationRange = SourceRange()); |
| 3039 | |
Douglas Gregor | 9148c3f | 2009-11-11 19:13:48 +0000 | [diff] [blame] | 3040 | /// \brief Note that we are substituting prior template arguments into a |
| 3041 | /// non-type or template template parameter. |
| 3042 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3043 | TemplateDecl *Template, |
| 3044 | NonTypeTemplateParmDecl *Param, |
| 3045 | const TemplateArgument *TemplateArgs, |
| 3046 | unsigned NumTemplateArgs, |
| 3047 | SourceRange InstantiationRange); |
| 3048 | |
| 3049 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3050 | TemplateDecl *Template, |
| 3051 | TemplateTemplateParmDecl *Param, |
| 3052 | const TemplateArgument *TemplateArgs, |
| 3053 | unsigned NumTemplateArgs, |
| 3054 | SourceRange InstantiationRange); |
| 3055 | |
Douglas Gregor | f35f828 | 2009-11-11 21:54:23 +0000 | [diff] [blame] | 3056 | /// \brief Note that we are checking the default template argument |
| 3057 | /// against the template parameter for a given template-id. |
| 3058 | InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, |
| 3059 | TemplateDecl *Template, |
| 3060 | NamedDecl *Param, |
| 3061 | const TemplateArgument *TemplateArgs, |
| 3062 | unsigned NumTemplateArgs, |
| 3063 | SourceRange InstantiationRange); |
| 3064 | |
| 3065 | |
Douglas Gregor | f3e7ce4 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 3066 | /// \brief Note that we have finished instantiating this template. |
| 3067 | void Clear(); |
| 3068 | |
| 3069 | ~InstantiatingTemplate() { Clear(); } |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 3070 | |
| 3071 | /// \brief Determines whether we have exceeded the maximum |
| 3072 | /// recursive template instantiations. |
| 3073 | operator bool() const { return Invalid; } |
| 3074 | |
| 3075 | private: |
| 3076 | Sema &SemaRef; |
| 3077 | bool Invalid; |
| 3078 | |
Douglas Gregor | df667e7 | 2009-03-10 20:44:00 +0000 | [diff] [blame] | 3079 | bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, |
| 3080 | SourceRange InstantiationRange); |
| 3081 | |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 3082 | InstantiatingTemplate(const InstantiatingTemplate&); // not implemented |
| 3083 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3084 | InstantiatingTemplate& |
Douglas Gregor | 26dce44 | 2009-03-10 00:06:19 +0000 | [diff] [blame] | 3085 | operator=(const InstantiatingTemplate&); // not implemented |
| 3086 | }; |
| 3087 | |
Douglas Gregor | ee1828a | 2009-03-10 18:03:33 +0000 | [diff] [blame] | 3088 | void PrintInstantiationStack(); |
| 3089 | |
Douglas Gregor | 5e9f35c | 2009-06-14 07:33:30 +0000 | [diff] [blame] | 3090 | /// \brief Determines whether we are currently in a context where |
| 3091 | /// template argument substitution failures are not considered |
| 3092 | /// errors. |
| 3093 | /// |
| 3094 | /// When this routine returns true, the emission of most diagnostics |
| 3095 | /// will be suppressed and there will be no local error recovery. |
| 3096 | bool isSFINAEContext() const; |
| 3097 | |
Douglas Gregor | bb26041 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 3098 | /// \brief RAII class used to determine whether SFINAE has |
| 3099 | /// trapped any errors that occur during template argument |
| 3100 | /// deduction. |
| 3101 | class SFINAETrap { |
| 3102 | Sema &SemaRef; |
| 3103 | unsigned PrevSFINAEErrors; |
| 3104 | public: |
| 3105 | explicit SFINAETrap(Sema &SemaRef) |
| 3106 | : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors) { } |
| 3107 | |
| 3108 | ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; } |
| 3109 | |
| 3110 | /// \brief Determine whether any SFINAE errors have been trapped. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3111 | bool hasErrorOccurred() const { |
| 3112 | return SemaRef.NumSFINAEErrors > PrevSFINAEErrors; |
Douglas Gregor | bb26041 | 2009-06-14 08:02:22 +0000 | [diff] [blame] | 3113 | } |
| 3114 | }; |
| 3115 | |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3116 | /// \brief A stack-allocated class that identifies which local |
| 3117 | /// variable declaration instantiations are present in this scope. |
| 3118 | /// |
| 3119 | /// A new instance of this class type will be created whenever we |
| 3120 | /// instantiate a new function declaration, which will have its own |
| 3121 | /// set of parameter declarations. |
| 3122 | class LocalInstantiationScope { |
| 3123 | /// \brief Reference to the semantic analysis that is performing |
| 3124 | /// this template instantiation. |
| 3125 | Sema &SemaRef; |
| 3126 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 3127 | /// \brief A mapping from local declarations that occur |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3128 | /// within a template to their instantiations. |
| 3129 | /// |
| 3130 | /// This mapping is used during instantiation to keep track of, |
| 3131 | /// e.g., function parameter and variable declarations. For example, |
| 3132 | /// given: |
| 3133 | /// |
| 3134 | /// \code |
| 3135 | /// template<typename T> T add(T x, T y) { return x + y; } |
| 3136 | /// \endcode |
| 3137 | /// |
| 3138 | /// when we instantiate add<int>, we will introduce a mapping from |
| 3139 | /// the ParmVarDecl for 'x' that occurs in the template to the |
| 3140 | /// instantiated ParmVarDecl for 'x'. |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 3141 | llvm::DenseMap<const Decl *, Decl *> LocalDecls; |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3142 | |
| 3143 | /// \brief The outer scope, in which contains local variable |
Douglas Gregor | 550d9b2 | 2009-10-31 17:21:17 +0000 | [diff] [blame] | 3144 | /// definitions from some other instantiation (that may not be |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3145 | /// relevant to this particular scope). |
| 3146 | LocalInstantiationScope *Outer; |
| 3147 | |
| 3148 | // This class is non-copyable |
| 3149 | LocalInstantiationScope(const LocalInstantiationScope &); |
| 3150 | LocalInstantiationScope &operator=(const LocalInstantiationScope &); |
| 3151 | |
| 3152 | public: |
Douglas Gregor | 550d9b2 | 2009-10-31 17:21:17 +0000 | [diff] [blame] | 3153 | LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3154 | : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope) { |
Douglas Gregor | 550d9b2 | 2009-10-31 17:21:17 +0000 | [diff] [blame] | 3155 | if (!CombineWithOuterScope) |
| 3156 | SemaRef.CurrentInstantiationScope = this; |
| 3157 | else |
| 3158 | assert(SemaRef.CurrentInstantiationScope && |
| 3159 | "No outer instantiation scope?"); |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3160 | } |
| 3161 | |
| 3162 | ~LocalInstantiationScope() { |
| 3163 | SemaRef.CurrentInstantiationScope = Outer; |
| 3164 | } |
| 3165 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 3166 | Decl *getInstantiationOf(const Decl *D) { |
| 3167 | Decl *Result = LocalDecls[D]; |
| 3168 | assert(Result && "declaration was not instantiated in this scope!"); |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3169 | return Result; |
| 3170 | } |
| 3171 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 3172 | VarDecl *getInstantiationOf(const VarDecl *Var) { |
| 3173 | return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var))); |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3174 | } |
| 3175 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 3176 | ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) { |
| 3177 | return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var))); |
| 3178 | } |
| 3179 | |
Douglas Gregor | 550d9b2 | 2009-10-31 17:21:17 +0000 | [diff] [blame] | 3180 | NonTypeTemplateParmDecl *getInstantiationOf( |
| 3181 | const NonTypeTemplateParmDecl *Var) { |
| 3182 | return cast<NonTypeTemplateParmDecl>(getInstantiationOf(cast<Decl>(Var))); |
| 3183 | } |
| 3184 | |
Douglas Gregor | 815215d | 2009-05-27 05:35:12 +0000 | [diff] [blame] | 3185 | void InstantiatedLocal(const Decl *D, Decl *Inst) { |
| 3186 | Decl *&Stored = LocalDecls[D]; |
| 3187 | assert(!Stored && "Already instantiated this local"); |
| 3188 | Stored = Inst; |
Douglas Gregor | 48dd19b | 2009-05-14 21:44:34 +0000 | [diff] [blame] | 3189 | } |
| 3190 | }; |
| 3191 | |
| 3192 | /// \brief The current instantiation scope used to store local |
| 3193 | /// variables. |
| 3194 | LocalInstantiationScope *CurrentInstantiationScope; |
| 3195 | |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 3196 | /// \brief An entity for which implicit template instantiation is required. |
| 3197 | /// |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3198 | /// The source location associated with the declaration is the first place in |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 3199 | /// the source code where the declaration was "used". It is not necessarily |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3200 | /// the point of instantiation (which will be either before or after the |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 3201 | /// namespace-scope declaration that triggered this implicit instantiation), |
| 3202 | /// However, it is the location that diagnostics should generally refer to, |
| 3203 | /// because users will need to know what code triggered the instantiation. |
| 3204 | typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3205 | |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 3206 | /// \brief The queue of implicit template instantiations that are required |
| 3207 | /// but have not yet been performed. |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 3208 | std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations; |
Douglas Gregor | d7f37bf | 2009-06-22 23:06:13 +0000 | [diff] [blame] | 3209 | |
| 3210 | void PerformPendingImplicitInstantiations(); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3211 | |
John McCall | a93c934 | 2009-12-07 02:54:59 +0000 | [diff] [blame] | 3212 | TypeSourceInfo *SubstType(TypeSourceInfo *T, |
John McCall | cd7ba1c | 2009-10-21 00:58:09 +0000 | [diff] [blame] | 3213 | const MultiLevelTemplateArgumentList &TemplateArgs, |
| 3214 | SourceLocation Loc, DeclarationName Entity); |
| 3215 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3216 | QualType SubstType(QualType T, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3217 | const MultiLevelTemplateArgumentList &TemplateArgs, |
John McCall | ce3ff2b | 2009-08-25 22:02:44 +0000 | [diff] [blame] | 3218 | SourceLocation Loc, DeclarationName Entity); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3219 | |
| 3220 | OwningExprResult SubstExpr(Expr *E, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3221 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Douglas Gregor | a0e500d | 2009-03-12 16:53:44 +0000 | [diff] [blame] | 3222 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3223 | OwningStmtResult SubstStmt(Stmt *S, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3224 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Douglas Gregor | 54dabfc | 2009-05-14 23:26:13 +0000 | [diff] [blame] | 3225 | |
John McCall | ce3ff2b | 2009-08-25 22:02:44 +0000 | [diff] [blame] | 3226 | Decl *SubstDecl(Decl *D, DeclContext *Owner, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3227 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Douglas Gregor | 8dbc269 | 2009-03-17 21:15:40 +0000 | [diff] [blame] | 3228 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3229 | bool |
John McCall | ce3ff2b | 2009-08-25 22:02:44 +0000 | [diff] [blame] | 3230 | SubstBaseSpecifiers(CXXRecordDecl *Instantiation, |
| 3231 | CXXRecordDecl *Pattern, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3232 | const MultiLevelTemplateArgumentList &TemplateArgs); |
John McCall | e29ba20 | 2009-08-20 01:44:21 +0000 | [diff] [blame] | 3233 | |
| 3234 | bool |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 3235 | InstantiateClass(SourceLocation PointOfInstantiation, |
| 3236 | CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3237 | const MultiLevelTemplateArgumentList &TemplateArgs, |
Douglas Gregor | d0e3daf | 2009-09-04 22:48:11 +0000 | [diff] [blame] | 3238 | TemplateSpecializationKind TSK, |
Douglas Gregor | 5842ba9 | 2009-08-24 15:23:48 +0000 | [diff] [blame] | 3239 | bool Complain = true); |
Douglas Gregor | d475b8d | 2009-03-25 21:17:03 +0000 | [diff] [blame] | 3240 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3241 | bool |
Douglas Gregor | 972e6ce | 2009-10-27 06:26:26 +0000 | [diff] [blame] | 3242 | InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, |
Douglas Gregor | 2943aed | 2009-03-03 04:44:36 +0000 | [diff] [blame] | 3243 | ClassTemplateSpecializationDecl *ClassTemplateSpec, |
Douglas Gregor | d0e3daf | 2009-09-04 22:48:11 +0000 | [diff] [blame] | 3244 | TemplateSpecializationKind TSK, |
| 3245 | bool Complain = true); |
Douglas Gregor | 99ebf65 | 2009-02-27 19:31:52 +0000 | [diff] [blame] | 3246 | |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 3247 | void InstantiateClassMembers(SourceLocation PointOfInstantiation, |
| 3248 | CXXRecordDecl *Instantiation, |
Douglas Gregor | d0e3daf | 2009-09-04 22:48:11 +0000 | [diff] [blame] | 3249 | const MultiLevelTemplateArgumentList &TemplateArgs, |
| 3250 | TemplateSpecializationKind TSK); |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 3251 | |
| 3252 | void InstantiateClassTemplateSpecializationMembers( |
| 3253 | SourceLocation PointOfInstantiation, |
Douglas Gregor | d0e3daf | 2009-09-04 22:48:11 +0000 | [diff] [blame] | 3254 | ClassTemplateSpecializationDecl *ClassTemplateSpec, |
| 3255 | TemplateSpecializationKind TSK); |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 3256 | |
Douglas Gregor | ab452ba | 2009-03-26 23:50:42 +0000 | [diff] [blame] | 3257 | NestedNameSpecifier * |
John McCall | ce3ff2b | 2009-08-25 22:02:44 +0000 | [diff] [blame] | 3258 | SubstNestedNameSpecifier(NestedNameSpecifier *NNS, |
| 3259 | SourceRange Range, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3260 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Douglas Gregor | 5953d8b | 2009-03-19 17:26:29 +0000 | [diff] [blame] | 3261 | |
Douglas Gregor | de650ae | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 3262 | TemplateName |
John McCall | ce3ff2b | 2009-08-25 22:02:44 +0000 | [diff] [blame] | 3263 | SubstTemplateName(TemplateName Name, SourceLocation Loc, |
Douglas Gregor | d6350ae | 2009-08-28 20:31:08 +0000 | [diff] [blame] | 3264 | const MultiLevelTemplateArgumentList &TemplateArgs); |
John McCall | 833ca99 | 2009-10-29 08:12:44 +0000 | [diff] [blame] | 3265 | bool Subst(const TemplateArgumentLoc &Arg, TemplateArgumentLoc &Result, |
| 3266 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Douglas Gregor | de650ae | 2009-03-31 18:38:02 +0000 | [diff] [blame] | 3267 | |
Douglas Gregor | f3e7ce4 | 2009-05-18 17:01:57 +0000 | [diff] [blame] | 3268 | void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, |
Douglas Gregor | b33fe2f | 2009-06-30 17:20:14 +0000 | [diff] [blame] | 3269 | FunctionDecl *Function, |
Douglas Gregor | e2d3a3d | 2009-10-15 14:05:49 +0000 | [diff] [blame] | 3270 | bool Recursive = false, |
| 3271 | bool DefinitionRequired = false); |
Douglas Gregor | 7caa682 | 2009-07-24 20:34:43 +0000 | [diff] [blame] | 3272 | void InstantiateStaticDataMemberDefinition( |
John McCall | ce3ff2b | 2009-08-25 22:02:44 +0000 | [diff] [blame] | 3273 | SourceLocation PointOfInstantiation, |
| 3274 | VarDecl *Var, |
Douglas Gregor | e2d3a3d | 2009-10-15 14:05:49 +0000 | [diff] [blame] | 3275 | bool Recursive = false, |
| 3276 | bool DefinitionRequired = false); |
Douglas Gregor | a58861f | 2009-05-13 20:28:22 +0000 | [diff] [blame] | 3277 | |
Anders Carlsson | 0902531 | 2009-08-29 05:16:22 +0000 | [diff] [blame] | 3278 | void InstantiateMemInitializers(CXXConstructorDecl *New, |
| 3279 | const CXXConstructorDecl *Tmpl, |
| 3280 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3281 | |
Douglas Gregor | e95b409 | 2009-09-16 18:34:49 +0000 | [diff] [blame] | 3282 | NamedDecl *FindInstantiatedDecl(NamedDecl *D, |
| 3283 | const MultiLevelTemplateArgumentList &TemplateArgs); |
| 3284 | DeclContext *FindInstantiatedContext(DeclContext *DC, |
| 3285 | const MultiLevelTemplateArgumentList &TemplateArgs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3286 | |
Steve Naroff | 3536b44 | 2007-09-06 21:24:23 +0000 | [diff] [blame] | 3287 | // Objective-C declarations. |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3288 | virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc, |
| 3289 | IdentifierInfo *ClassName, |
| 3290 | SourceLocation ClassLoc, |
| 3291 | IdentifierInfo *SuperName, |
| 3292 | SourceLocation SuperLoc, |
| 3293 | const DeclPtrTy *ProtoRefs, |
| 3294 | unsigned NumProtoRefs, |
| 3295 | SourceLocation EndProtoLoc, |
| 3296 | AttributeList *AttrList); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3297 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3298 | virtual DeclPtrTy ActOnCompatiblityAlias( |
Fariborz Jahanian | 243b64b | 2007-10-11 23:42:27 +0000 | [diff] [blame] | 3299 | SourceLocation AtCompatibilityAliasLoc, |
| 3300 | IdentifierInfo *AliasName, SourceLocation AliasLocation, |
| 3301 | IdentifierInfo *ClassName, SourceLocation ClassLocation); |
Steve Naroff | 61d6852 | 2009-03-05 15:22:01 +0000 | [diff] [blame] | 3302 | |
| 3303 | void CheckForwardProtocolDeclarationForCircularDependency( |
| 3304 | IdentifierInfo *PName, |
| 3305 | SourceLocation &PLoc, SourceLocation PrevLoc, |
| 3306 | const ObjCList<ObjCProtocolDecl> &PList); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3307 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3308 | virtual DeclPtrTy ActOnStartProtocolInterface( |
Nate Begeman | 1abc7f6 | 2008-02-20 22:57:40 +0000 | [diff] [blame] | 3309 | SourceLocation AtProtoInterfaceLoc, |
Fariborz Jahanian | 25e077d | 2007-09-17 21:07:36 +0000 | [diff] [blame] | 3310 | IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3311 | const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs, |
Daniel Dunbar | 246e70f | 2008-09-26 04:48:09 +0000 | [diff] [blame] | 3312 | SourceLocation EndProtoLoc, |
| 3313 | AttributeList *AttrList); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3314 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3315 | virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, |
| 3316 | IdentifierInfo *ClassName, |
| 3317 | SourceLocation ClassLoc, |
| 3318 | IdentifierInfo *CategoryName, |
| 3319 | SourceLocation CategoryLoc, |
| 3320 | const DeclPtrTy *ProtoRefs, |
| 3321 | unsigned NumProtoRefs, |
| 3322 | SourceLocation EndProtoLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3323 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3324 | virtual DeclPtrTy ActOnStartClassImplementation( |
Nate Begeman | 1abc7f6 | 2008-02-20 22:57:40 +0000 | [diff] [blame] | 3325 | SourceLocation AtClassImplLoc, |
Fariborz Jahanian | ccb4f31 | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 3326 | IdentifierInfo *ClassName, SourceLocation ClassLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3327 | IdentifierInfo *SuperClassname, |
Fariborz Jahanian | ccb4f31 | 2007-09-25 18:38:09 +0000 | [diff] [blame] | 3328 | SourceLocation SuperClassLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3329 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3330 | virtual DeclPtrTy ActOnStartCategoryImplementation( |
Fariborz Jahanian | 8f3fde0 | 2007-10-02 16:38:50 +0000 | [diff] [blame] | 3331 | SourceLocation AtCatImplLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3332 | IdentifierInfo *ClassName, |
Fariborz Jahanian | 8f3fde0 | 2007-10-02 16:38:50 +0000 | [diff] [blame] | 3333 | SourceLocation ClassLoc, |
| 3334 | IdentifierInfo *CatName, |
| 3335 | SourceLocation CatLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3336 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3337 | virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, |
Ted Kremenek | c09cba6 | 2009-11-17 23:12:20 +0000 | [diff] [blame] | 3338 | IdentifierInfo **IdentList, |
| 3339 | SourceLocation *IdentLocs, |
| 3340 | unsigned NumElts); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3341 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3342 | virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, |
Chris Lattner | 7caeabd | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 3343 | const IdentifierLocPair *IdentList, |
Fariborz Jahanian | bc1c877 | 2008-12-17 01:07:27 +0000 | [diff] [blame] | 3344 | unsigned NumElts, |
| 3345 | AttributeList *attrList); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3346 | |
Chris Lattner | e13b959 | 2008-07-26 04:03:38 +0000 | [diff] [blame] | 3347 | virtual void FindProtocolDeclaration(bool WarnOnDeclarations, |
Chris Lattner | 7caeabd | 2008-07-21 22:17:28 +0000 | [diff] [blame] | 3348 | const IdentifierLocPair *ProtocolId, |
Fariborz Jahanian | 4b6c905 | 2007-10-11 00:55:41 +0000 | [diff] [blame] | 3349 | unsigned NumProtocols, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3350 | llvm::SmallVectorImpl<DeclPtrTy> &Protocols); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3351 | |
| 3352 | /// Ensure attributes are consistent with type. |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 3353 | /// \param [in, out] Attributes The attributes to check; they will |
| 3354 | /// be modified to be consistent with \arg PropertyTy. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3355 | void CheckObjCPropertyAttributes(QualType PropertyTy, |
Daniel Dunbar | 95e61fb | 2008-09-23 21:53:23 +0000 | [diff] [blame] | 3356 | SourceLocation Loc, |
| 3357 | unsigned &Attributes); |
Steve Naroff | 0701bbb | 2009-01-08 17:28:14 +0000 | [diff] [blame] | 3358 | void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3359 | void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 3360 | ObjCPropertyDecl *SuperProperty, |
Chris Lattner | 8ec03f5 | 2008-11-24 03:54:41 +0000 | [diff] [blame] | 3361 | const IdentifierInfo *Name); |
Fariborz Jahanian | 02edb98 | 2008-05-01 00:03:38 +0000 | [diff] [blame] | 3362 | void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3363 | |
| 3364 | void CompareMethodParamsInBaseAndSuper(Decl *IDecl, |
Fariborz Jahanian | dbdec8b | 2009-08-04 01:07:16 +0000 | [diff] [blame] | 3365 | ObjCMethodDecl *MethodDecl, |
| 3366 | bool IsInstance); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3367 | |
Fariborz Jahanian | 1ac2bc4 | 2008-12-06 23:03:39 +0000 | [diff] [blame] | 3368 | void MergeProtocolPropertiesIntoClass(Decl *CDecl, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3369 | DeclPtrTy MergeProtocols); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3370 | |
| 3371 | void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, |
Fariborz Jahanian | b7f95f5 | 2009-03-02 19:05:07 +0000 | [diff] [blame] | 3372 | ObjCInterfaceDecl *ID); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3373 | |
Fariborz Jahanian | 1ac2bc4 | 2008-12-06 23:03:39 +0000 | [diff] [blame] | 3374 | void MergeOneProtocolPropertiesIntoClass(Decl *CDecl, |
Fariborz Jahanian | aebf0cb | 2008-05-02 19:17:30 +0000 | [diff] [blame] | 3375 | ObjCProtocolDecl *PDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3376 | |
Ted Kremenek | 782f2f5 | 2010-01-07 01:20:12 +0000 | [diff] [blame] | 3377 | virtual void ActOnAtEnd(SourceRange AtEnd, |
| 3378 | DeclPtrTy classDecl, |
| 3379 | DeclPtrTy *allMethods = 0, unsigned allNum = 0, |
| 3380 | DeclPtrTy *allProperties = 0, unsigned pNum = 0, |
| 3381 | DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3382 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3383 | virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc, |
| 3384 | FieldDeclarator &FD, ObjCDeclSpec &ODS, |
| 3385 | Selector GetterSel, Selector SetterSel, |
| 3386 | DeclPtrTy ClassCategory, |
| 3387 | bool *OverridingProperty, |
| 3388 | tok::ObjCKeywordKind MethodImplKind); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3389 | |
| 3390 | virtual DeclPtrTy ActOnPropertyImplDecl(SourceLocation AtLoc, |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3391 | SourceLocation PropertyLoc, |
| 3392 | bool ImplKind,DeclPtrTy ClassImplDecl, |
| 3393 | IdentifierInfo *PropertyId, |
| 3394 | IdentifierInfo *PropertyIvar); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3395 | |
Chris Lattner | b28317a | 2009-03-28 19:18:32 +0000 | [diff] [blame] | 3396 | virtual DeclPtrTy ActOnMethodDeclaration( |
Steve Naroff | bef1185 | 2007-10-26 20:53:56 +0000 | [diff] [blame] | 3397 | SourceLocation BeginLoc, // location of the + or -. |
| 3398 | SourceLocation EndLoc, // location of the ; or {. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3399 | tok::TokenKind MethodType, |
| 3400 | DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType, |
Fariborz Jahanian | f1de0ca | 2007-10-31 23:53:01 +0000 | [diff] [blame] | 3401 | Selector Sel, |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 3402 | // optional arguments. The number of types/arguments is obtained |
| 3403 | // from the Sel.getNumArgs(). |
Chris Lattner | e294d3f | 2009-04-11 18:57:04 +0000 | [diff] [blame] | 3404 | ObjCArgInfo *ArgInfo, |
Fariborz Jahanian | 439c658 | 2009-01-09 00:38:19 +0000 | [diff] [blame] | 3405 | llvm::SmallVectorImpl<Declarator> &Cdecls, |
Steve Naroff | 335eafa | 2007-11-15 12:35:21 +0000 | [diff] [blame] | 3406 | AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, |
| 3407 | bool isVariadic = false); |
Steve Naroff | 81bfde9 | 2007-10-16 23:12:48 +0000 | [diff] [blame] | 3408 | |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 3409 | // Helper method for ActOnClassMethod/ActOnInstanceMethod. |
| 3410 | // Will search "local" class/category implementations for a method decl. |
Fariborz Jahanian | 175ba1e | 2009-03-04 18:15:57 +0000 | [diff] [blame] | 3411 | // Will also search in class's root looking for instance method. |
Steve Naroff | f1afaf6 | 2009-02-26 15:55:06 +0000 | [diff] [blame] | 3412 | // Returns 0 if no method is found. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3413 | ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel, |
Steve Naroff | 5609ec0 | 2009-03-08 18:56:13 +0000 | [diff] [blame] | 3414 | ObjCInterfaceDecl *CDecl); |
| 3415 | ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel, |
| 3416 | ObjCInterfaceDecl *ClassDecl); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3417 | |
Steve Naroff | 61f72cb | 2009-03-09 21:12:44 +0000 | [diff] [blame] | 3418 | virtual OwningExprResult ActOnClassPropertyRefExpr( |
| 3419 | IdentifierInfo &receiverName, |
| 3420 | IdentifierInfo &propertyName, |
| 3421 | SourceLocation &receiverNameLoc, |
| 3422 | SourceLocation &propertyNameLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3423 | |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 3424 | // ActOnClassMessage - used for both unary and keyword messages. |
| 3425 | // ArgExprs is optional - if it is present, the number of expressions |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 3426 | // is obtained from NumArgs. |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 3427 | virtual ExprResult ActOnClassMessage( |
Fariborz Jahanian | 0523aaf | 2007-11-12 20:13:27 +0000 | [diff] [blame] | 3428 | Scope *S, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3429 | IdentifierInfo *receivingClassName, Selector Sel, SourceLocation lbrac, |
| 3430 | SourceLocation receiverLoc, SourceLocation selectorLoc,SourceLocation rbrac, |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 3431 | ExprTy **ArgExprs, unsigned NumArgs); |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 3432 | |
| 3433 | // ActOnInstanceMessage - used for both unary and keyword messages. |
| 3434 | // ArgExprs is optional - if it is present, the number of expressions |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 3435 | // is obtained from NumArgs. |
Steve Naroff | 68d331a | 2007-09-27 14:38:14 +0000 | [diff] [blame] | 3436 | virtual ExprResult ActOnInstanceMessage( |
Steve Naroff | bcfb06a | 2007-09-28 22:22:11 +0000 | [diff] [blame] | 3437 | ExprTy *receiver, Selector Sel, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3438 | SourceLocation lbrac, SourceLocation receiverLoc, SourceLocation rbrac, |
Steve Naroff | 49f109c | 2007-11-15 13:05:42 +0000 | [diff] [blame] | 3439 | ExprTy **ArgExprs, unsigned NumArgs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3440 | |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 3441 | /// ActOnPragmaPack - Called on well formed #pragma pack(...). |
| 3442 | virtual void ActOnPragmaPack(PragmaPackKind Kind, |
| 3443 | IdentifierInfo *Name, |
| 3444 | ExprTy *Alignment, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3445 | SourceLocation PragmaLoc, |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 3446 | SourceLocation LParenLoc, |
| 3447 | SourceLocation RParenLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3448 | |
Ted Kremenek | 4726d03 | 2009-03-23 22:28:25 +0000 | [diff] [blame] | 3449 | /// ActOnPragmaUnused - Called on well-formed '#pragma unused'. |
Ted Kremenek | 7a02a37 | 2009-08-03 23:24:57 +0000 | [diff] [blame] | 3450 | virtual void ActOnPragmaUnused(const Token *Identifiers, |
| 3451 | unsigned NumIdentifiers, Scope *curScope, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3452 | SourceLocation PragmaLoc, |
Ted Kremenek | 4726d03 | 2009-03-23 22:28:25 +0000 | [diff] [blame] | 3453 | SourceLocation LParenLoc, |
| 3454 | SourceLocation RParenLoc); |
Eli Friedman | c49f19b | 2009-06-05 02:44:36 +0000 | [diff] [blame] | 3455 | |
Ryan Flynn | 7b1fdbd | 2009-07-31 02:52:19 +0000 | [diff] [blame] | 3456 | NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II); |
| 3457 | void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W); |
Ryan Flynn | e25ff83 | 2009-07-30 03:15:39 +0000 | [diff] [blame] | 3458 | |
Eli Friedman | dec7c76 | 2009-06-05 06:28:29 +0000 | [diff] [blame] | 3459 | /// ActOnPragmaWeakID - Called on well formed #pragma weak ident. |
Eli Friedman | c49f19b | 2009-06-05 02:44:36 +0000 | [diff] [blame] | 3460 | virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName, |
| 3461 | SourceLocation PragmaLoc, |
| 3462 | SourceLocation WeakNameLoc); |
| 3463 | |
Eli Friedman | dec7c76 | 2009-06-05 06:28:29 +0000 | [diff] [blame] | 3464 | /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident. |
Eli Friedman | c49f19b | 2009-06-05 02:44:36 +0000 | [diff] [blame] | 3465 | virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName, |
| 3466 | IdentifierInfo* AliasName, |
| 3467 | SourceLocation PragmaLoc, |
| 3468 | SourceLocation WeakNameLoc, |
| 3469 | SourceLocation AliasNameLoc); |
| 3470 | |
Chris Lattner | 574aa40 | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 3471 | /// getPragmaPackAlignment() - Return the current alignment as specified by |
| 3472 | /// the current #pragma pack directive, or 0 if none is currently active. |
| 3473 | unsigned getPragmaPackAlignment() const; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3474 | |
Chris Lattner | 574aa40 | 2009-02-17 01:09:29 +0000 | [diff] [blame] | 3475 | /// FreePackedContext - Deallocate and null out PackContext. |
| 3476 | void FreePackedContext(); |
Daniel Dunbar | 4cde927 | 2008-10-14 05:35:18 +0000 | [diff] [blame] | 3477 | |
Chris Lattner | 1e0a390 | 2008-01-16 19:17:22 +0000 | [diff] [blame] | 3478 | /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit |
| 3479 | /// cast. If there is already an implicit cast, merge into the existing one. |
Douglas Gregor | eb8f306 | 2008-11-12 17:17:38 +0000 | [diff] [blame] | 3480 | /// If isLvalue, the result of the cast is an lvalue. |
Eli Friedman | 73c39ab | 2009-10-20 08:27:19 +0000 | [diff] [blame] | 3481 | void ImpCastExprToType(Expr *&Expr, QualType Type, CastExpr::CastKind Kind, |
Anders Carlsson | 3503d04 | 2009-07-31 01:23:52 +0000 | [diff] [blame] | 3482 | bool isLvalue = false); |
Chris Lattner | 1e0a390 | 2008-01-16 19:17:22 +0000 | [diff] [blame] | 3483 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3484 | // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 3485 | // functions and arrays to their respective pointers (C99 6.3.2.1). |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3486 | Expr *UsualUnaryConversions(Expr *&expr); |
Eli Friedman | 3c0eb16 | 2008-05-27 03:33:27 +0000 | [diff] [blame] | 3487 | |
Steve Naroff | c80b4ee | 2007-07-16 21:54:35 +0000 | [diff] [blame] | 3488 | // DefaultFunctionArrayConversion - converts functions and arrays |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3489 | // to their respective pointers (C99 6.3.2.1). |
Steve Naroff | c80b4ee | 2007-07-16 21:54:35 +0000 | [diff] [blame] | 3490 | void DefaultFunctionArrayConversion(Expr *&expr); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3491 | |
Steve Naroff | b291ab6 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 3492 | // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3493 | // do not have a prototype. Integer promotions are performed on each |
Steve Naroff | b291ab6 | 2007-08-28 23:30:39 +0000 | [diff] [blame] | 3494 | // argument, and arguments that have type float are promoted to double. |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 3495 | void DefaultArgumentPromotion(Expr *&Expr); |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 3496 | |
| 3497 | // Used for emitting the right warning by DefaultVariadicArgumentPromotion |
| 3498 | enum VariadicCallType { |
| 3499 | VariadicFunction, |
| 3500 | VariadicBlock, |
Anders Carlsson | d74d414 | 2009-09-08 01:48:42 +0000 | [diff] [blame] | 3501 | VariadicMethod, |
Fariborz Jahanian | 4cd1c70 | 2009-11-24 19:27:49 +0000 | [diff] [blame] | 3502 | VariadicConstructor, |
| 3503 | VariadicDoesNotApply |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 3504 | }; |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3505 | |
Fariborz Jahanian | 4cd1c70 | 2009-11-24 19:27:49 +0000 | [diff] [blame] | 3506 | /// GatherArgumentsForCall - Collector argument expressions for various |
| 3507 | /// form of call prototypes. |
| 3508 | bool GatherArgumentsForCall(SourceLocation CallLoc, |
| 3509 | FunctionDecl *FDecl, |
| 3510 | const FunctionProtoType *Proto, |
| 3511 | unsigned FirstProtoArg, |
| 3512 | Expr **Args, unsigned NumArgs, |
| 3513 | llvm::SmallVector<Expr *, 8> &AllArgs, |
Fariborz Jahanian | 4cd1c70 | 2009-11-24 19:27:49 +0000 | [diff] [blame] | 3514 | VariadicCallType CallType = VariadicDoesNotApply); |
| 3515 | |
Anders Carlsson | dce5e2c | 2009-01-16 16:48:51 +0000 | [diff] [blame] | 3516 | // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but |
| 3517 | // will warn if the resulting type is not a POD type. |
Chris Lattner | 312531a | 2009-04-12 08:11:20 +0000 | [diff] [blame] | 3518 | bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3519 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3520 | // UsualArithmeticConversions - performs the UsualUnaryConversions on it's |
| 3521 | // operands and then handles various conversions that are common to binary |
| 3522 | // operators (C99 6.3.1.8). If both operands aren't arithmetic, this |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3523 | // routine returns the first non-arithmetic type found. The client is |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3524 | // responsible for emitting appropriate error diagnostics. |
Steve Naroff | 9f5fa9b | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 3525 | QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr, |
| 3526 | bool isCompAssign = false); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3527 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3528 | /// AssignConvertType - All of the 'assignment' semantic checks return this |
| 3529 | /// enum to indicate whether the assignment was allowed. These checks are |
| 3530 | /// done for simple assignments, as well as initialization, return from |
| 3531 | /// function, argument passing, etc. The query is phrased in terms of a |
| 3532 | /// source and destination type. |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3533 | enum AssignConvertType { |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3534 | /// Compatible - the types are compatible according to the standard. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3535 | Compatible, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3536 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3537 | /// PointerToInt - The assignment converts a pointer to an int, which we |
| 3538 | /// accept as an extension. |
| 3539 | PointerToInt, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3540 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3541 | /// IntToPointer - The assignment converts an int to a pointer, which we |
| 3542 | /// accept as an extension. |
| 3543 | IntToPointer, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3544 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3545 | /// FunctionVoidPointer - The assignment is between a function pointer and |
| 3546 | /// void*, which the standard doesn't allow, but we accept as an extension. |
Chris Lattner | bfe639e | 2008-01-03 22:56:36 +0000 | [diff] [blame] | 3547 | FunctionVoidPointer, |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3548 | |
| 3549 | /// IncompatiblePointer - The assignment is between two pointers types that |
| 3550 | /// are not compatible, but we accept them as an extension. |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3551 | IncompatiblePointer, |
Eli Friedman | f05c05d | 2009-03-22 23:59:44 +0000 | [diff] [blame] | 3552 | |
| 3553 | /// IncompatiblePointer - The assignment is between two pointers types which |
| 3554 | /// point to integers which have a different sign, but are otherwise identical. |
| 3555 | /// This is a subset of the above, but broken out because it's by far the most |
| 3556 | /// common case of incompatible pointers. |
| 3557 | IncompatiblePointerSign, |
| 3558 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3559 | /// CompatiblePointerDiscardsQualifiers - The assignment discards |
| 3560 | /// c/v/r qualifiers, which we accept as an extension. |
| 3561 | CompatiblePointerDiscardsQualifiers, |
Fariborz Jahanian | 36a862f | 2009-11-07 20:20:40 +0000 | [diff] [blame] | 3562 | |
Sean Hunt | c9132b6 | 2009-11-08 07:46:34 +0000 | [diff] [blame] | 3563 | /// IncompatibleNestedPointerQualifiers - The assignment is between two |
| 3564 | /// nested pointer types, and the qualifiers other than the first two |
Fariborz Jahanian | d288baf | 2009-11-09 22:28:08 +0000 | [diff] [blame] | 3565 | /// levels differ e.g. char ** -> const char **, but we accept them as an |
| 3566 | /// extension. |
Sean Hunt | c9132b6 | 2009-11-08 07:46:34 +0000 | [diff] [blame] | 3567 | IncompatibleNestedPointerQualifiers, |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3568 | |
Anders Carlsson | b0f90cc | 2009-01-30 23:17:46 +0000 | [diff] [blame] | 3569 | /// IncompatibleVectors - The assignment is between two vector types that |
| 3570 | /// have the same size, which we accept as an extension. |
| 3571 | IncompatibleVectors, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3572 | |
| 3573 | /// IntToBlockPointer - The assignment converts an int to a block |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3574 | /// pointer. We disallow this. |
| 3575 | IntToBlockPointer, |
| 3576 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3577 | /// IncompatibleBlockPointer - The assignment is between two block |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3578 | /// pointers types that are not compatible. |
| 3579 | IncompatibleBlockPointer, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3580 | |
Steve Naroff | 3957907 | 2008-10-14 22:18:38 +0000 | [diff] [blame] | 3581 | /// IncompatibleObjCQualifiedId - The assignment is between a qualified |
| 3582 | /// id type and something else (that is incompatible with it). For example, |
| 3583 | /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol. |
| 3584 | IncompatibleObjCQualifiedId, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3585 | |
Chris Lattner | b7b6115 | 2008-01-04 18:22:42 +0000 | [diff] [blame] | 3586 | /// Incompatible - We reject this conversion outright, it is invalid to |
| 3587 | /// represent it in the AST. |
| 3588 | Incompatible |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3589 | }; |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 3590 | |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3591 | /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the |
| 3592 | /// assignment conversion type specified by ConvTy. This returns true if the |
| 3593 | /// conversion was invalid or false if the conversion was accepted. |
| 3594 | bool DiagnoseAssignmentResult(AssignConvertType ConvTy, |
| 3595 | SourceLocation Loc, |
| 3596 | QualType DstType, QualType SrcType, |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 3597 | Expr *SrcExpr, AssignmentAction Action); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3598 | |
| 3599 | /// CheckAssignmentConstraints - Perform type checking for assignment, |
| 3600 | /// argument passing, variable initialization, and function return values. |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3601 | /// This routine is only used by the following two methods. C99 6.5.16. |
| 3602 | AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3603 | |
| 3604 | // CheckSingleAssignmentConstraints - Currently used by |
| 3605 | // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking, |
Steve Naroff | 90045e8 | 2007-07-13 23:32:42 +0000 | [diff] [blame] | 3606 | // this routine performs the default function/array converions. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3607 | AssignConvertType CheckSingleAssignmentConstraints(QualType lhs, |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3608 | Expr *&rExpr); |
Douglas Gregor | 0c74e8a | 2009-04-29 22:16:16 +0000 | [diff] [blame] | 3609 | |
| 3610 | // \brief If the lhs type is a transparent union, check whether we |
| 3611 | // can initialize the transparent union with the given expression. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3612 | AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs, |
Douglas Gregor | 0c74e8a | 2009-04-29 22:16:16 +0000 | [diff] [blame] | 3613 | Expr *&rExpr); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3614 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3615 | // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1) |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3616 | AssignConvertType CheckPointerTypesForAssignment(QualType lhsType, |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 3617 | QualType rhsType); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3618 | |
Fariborz Jahanian | 52efc3f | 2009-12-08 18:24:49 +0000 | [diff] [blame] | 3619 | AssignConvertType CheckObjCPointerTypesForAssignment(QualType lhsType, |
| 3620 | QualType rhsType); |
| 3621 | |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3622 | // Helper function for CheckAssignmentConstraints involving two |
Sebastian Redl | d1bd7fc | 2009-04-19 19:26:31 +0000 | [diff] [blame] | 3623 | // block pointer types. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3624 | AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType, |
Steve Naroff | 1c7d067 | 2008-09-04 15:10:53 +0000 | [diff] [blame] | 3625 | QualType rhsType); |
Douglas Gregor | 77a5223 | 2008-09-12 00:47:35 +0000 | [diff] [blame] | 3626 | |
| 3627 | bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType); |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 3628 | |
Sebastian Redl | 2c7588f | 2009-10-10 12:04:10 +0000 | [diff] [blame] | 3629 | bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType); |
| 3630 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3631 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 3632 | AssignmentAction Action, |
Sebastian Redl | e2b6833 | 2009-04-12 17:16:29 +0000 | [diff] [blame] | 3633 | bool AllowExplicit = false, |
| 3634 | bool Elidable = false); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3635 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 3636 | AssignmentAction Action, |
Fariborz Jahanian | 51bebc8 | 2009-09-23 20:55:32 +0000 | [diff] [blame] | 3637 | bool AllowExplicit, |
| 3638 | bool Elidable, |
| 3639 | ImplicitConversionSequence& ICS); |
| 3640 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 09f41cf | 2009-01-14 15:45:31 +0000 | [diff] [blame] | 3641 | const ImplicitConversionSequence& ICS, |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 3642 | AssignmentAction Action, |
Sebastian Redl | a82e4ae | 2009-11-14 21:15:49 +0000 | [diff] [blame] | 3643 | bool IgnoreBaseAccess = false); |
Douglas Gregor | 94b1dd2 | 2008-10-24 04:54:22 +0000 | [diff] [blame] | 3644 | bool PerformImplicitConversion(Expr *&From, QualType ToType, |
Douglas Gregor | 45920e8 | 2008-12-19 17:40:08 +0000 | [diff] [blame] | 3645 | const StandardConversionSequence& SCS, |
Douglas Gregor | 6864748 | 2009-12-16 03:45:30 +0000 | [diff] [blame] | 3646 | AssignmentAction Action, bool IgnoreBaseAccess); |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3647 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3648 | /// the following "Check" methods will return a valid/converted QualType |
| 3649 | /// or a null QualType (indicating an error diagnostic was issued). |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3650 | |
| 3651 | /// type checking binary operators (subroutines of CreateBuiltinBinOp). |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3652 | QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
Sebastian Redl | 7c8bd60 | 2009-02-07 20:10:22 +0000 | [diff] [blame] | 3653 | QualType CheckPointerToMemberOperands( // C++ 5.5 |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3654 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3655 | QualType CheckMultiplyDivideOperands( // C99 6.5.5 |
Chris Lattner | 7ef655a | 2010-01-12 21:23:57 +0000 | [diff] [blame] | 3656 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign, |
| 3657 | bool isDivide); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3658 | QualType CheckRemainderOperands( // C99 6.5.5 |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3659 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3660 | QualType CheckAdditionOperands( // C99 6.5.6 |
Eli Friedman | ab3a852 | 2009-03-28 01:22:36 +0000 | [diff] [blame] | 3661 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3662 | QualType CheckSubtractionOperands( // C99 6.5.6 |
Eli Friedman | ab3a852 | 2009-03-28 01:22:36 +0000 | [diff] [blame] | 3663 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3664 | QualType CheckShiftOperands( // C99 6.5.7 |
Steve Naroff | 9f5fa9b | 2007-08-24 19:07:16 +0000 | [diff] [blame] | 3665 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3666 | QualType CheckCompareOperands( // C99 6.5.8/9 |
Douglas Gregor | a86b832 | 2009-04-06 18:45:53 +0000 | [diff] [blame] | 3667 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc, bool isRelational); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3668 | QualType CheckBitwiseOperands( // C99 6.5.[10...12] |
Sebastian Redl | 2246050 | 2009-02-07 00:15:38 +0000 | [diff] [blame] | 3669 | Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3670 | QualType CheckLogicalOperands( // C99 6.5.[13,14] |
Steve Naroff | 49b4526 | 2007-07-13 16:58:59 +0000 | [diff] [blame] | 3671 | Expr *&lex, Expr *&rex, SourceLocation OpLoc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3672 | // CheckAssignmentOperands is used for both simple and compound assignment. |
| 3673 | // For simple assignment, pass both expressions and a null converted type. |
| 3674 | // For compound assignment, pass both expressions and the converted type. |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3675 | QualType CheckAssignmentOperands( // C99 6.5.16.[1,2] |
Steve Naroff | f1120de | 2007-08-24 22:33:52 +0000 | [diff] [blame] | 3676 | Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3677 | QualType CheckCommaOperands( // C99 6.5.17 |
Chris Lattner | 29a1cfb | 2008-11-18 01:30:42 +0000 | [diff] [blame] | 3678 | Expr *lex, Expr *&rex, SourceLocation OpLoc); |
Douglas Gregor | df03251 | 2009-03-12 22:46:12 +0000 | [diff] [blame] | 3679 | QualType CheckConditionalOperands( // C99 6.5.15 |
Steve Naroff | 49b4526 | 2007-07-13 16:58:59 +0000 | [diff] [blame] | 3680 | Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc); |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 3681 | QualType CXXCheckConditionalOperands( // C++ 5.16 |
| 3682 | Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc); |
Sebastian Redl | d1bd7fc | 2009-04-19 19:26:31 +0000 | [diff] [blame] | 3683 | QualType FindCompositePointerType(Expr *&E1, Expr *&E2); // C++ 5.9 |
Nate Begeman | be2341d | 2008-07-14 18:02:46 +0000 | [diff] [blame] | 3684 | |
Fariborz Jahanian | eebc475 | 2009-12-10 19:47:41 +0000 | [diff] [blame] | 3685 | QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS, |
| 3686 | SourceLocation questionLoc); |
| 3687 | |
Nate Begeman | be2341d | 2008-07-14 18:02:46 +0000 | [diff] [blame] | 3688 | /// type checking for vector binary operators. |
| 3689 | inline QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex); |
| 3690 | inline QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx, |
| 3691 | SourceLocation l, bool isRel); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3692 | |
Steve Naroff | f69936d | 2007-09-16 03:34:24 +0000 | [diff] [blame] | 3693 | /// type checking unary operators (subroutines of ActOnUnaryOp). |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3694 | /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4 |
Sebastian Redl | e6d5a4a | 2008-12-20 09:35:34 +0000 | [diff] [blame] | 3695 | QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc, |
| 3696 | bool isInc); |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3697 | QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc); |
| 3698 | QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc); |
Chris Lattner | ba27e2a | 2009-02-17 08:12:06 +0000 | [diff] [blame] | 3699 | QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3700 | |
Steve Naroff | e1b31fe | 2007-07-27 22:15:19 +0000 | [diff] [blame] | 3701 | /// type checking primary expressions. |
Nate Begeman | 213541a | 2008-04-18 23:10:10 +0000 | [diff] [blame] | 3702 | QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3703 | const IdentifierInfo *Comp, |
Anders Carlsson | 8f28f99 | 2009-08-26 18:25:21 +0000 | [diff] [blame] | 3704 | SourceLocation CmpLoc); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3705 | |
Steve Naroff | f009063 | 2007-09-02 02:04:30 +0000 | [diff] [blame] | 3706 | /// type checking declaration initializers (C99 6.7.8) |
Douglas Gregor | cb57fb9 | 2009-12-16 06:35:08 +0000 | [diff] [blame] | 3707 | bool CheckInitList(const InitializedEntity &Entity, |
| 3708 | InitListExpr *&InitList, QualType &DeclType); |
Steve Naroff | d0091aa | 2008-01-10 22:15:12 +0000 | [diff] [blame] | 3709 | bool CheckForConstantInitializer(Expr *e, QualType t); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3710 | |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 3711 | // type checking C++ declaration initializers (C++ [dcl.init]). |
| 3712 | |
| 3713 | /// ReferenceCompareResult - Expresses the result of comparing two |
| 3714 | /// types (cv1 T1 and cv2 T2) to determine their compatibility for the |
| 3715 | /// purposes of initialization by reference (C++ [dcl.init.ref]p4). |
| 3716 | enum ReferenceCompareResult { |
| 3717 | /// Ref_Incompatible - The two types are incompatible, so direct |
| 3718 | /// reference binding is not possible. |
| 3719 | Ref_Incompatible = 0, |
| 3720 | /// Ref_Related - The two types are reference-related, which means |
| 3721 | /// that their unqualified forms (T1 and T2) are either the same |
| 3722 | /// or T1 is a base class of T2. |
| 3723 | Ref_Related, |
| 3724 | /// Ref_Compatible_With_Added_Qualification - The two types are |
| 3725 | /// reference-compatible with added qualification, meaning that |
| 3726 | /// they are reference-compatible and the qualifiers on T1 (cv1) |
| 3727 | /// are greater than the qualifiers on T2 (cv2). |
| 3728 | Ref_Compatible_With_Added_Qualification, |
| 3729 | /// Ref_Compatible - The two types are reference-compatible and |
| 3730 | /// have equivalent qualifiers (cv1 == cv2). |
| 3731 | Ref_Compatible |
| 3732 | }; |
| 3733 | |
Douglas Gregor | 393896f | 2009-11-05 13:06:35 +0000 | [diff] [blame] | 3734 | ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, |
| 3735 | QualType T1, QualType T2, |
Douglas Gregor | 15da57e | 2008-10-29 02:00:59 +0000 | [diff] [blame] | 3736 | bool& DerivedToBase); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 3737 | |
Sebastian Redl | 3201f6b | 2009-04-16 17:51:27 +0000 | [diff] [blame] | 3738 | bool CheckReferenceInit(Expr *&simpleInit_or_initList, QualType declType, |
Douglas Gregor | 739d828 | 2009-09-23 23:04:10 +0000 | [diff] [blame] | 3739 | SourceLocation DeclLoc, |
Anders Carlsson | 2de3ace | 2009-08-27 17:30:43 +0000 | [diff] [blame] | 3740 | bool SuppressUserConversions, |
| 3741 | bool AllowExplicit, |
| 3742 | bool ForceRValue, |
Sebastian Redl | a82e4ae | 2009-11-14 21:15:49 +0000 | [diff] [blame] | 3743 | ImplicitConversionSequence *ICS = 0, |
| 3744 | bool IgnoreBaseAccess = false); |
Douglas Gregor | 27c8dc0 | 2008-10-29 00:13:59 +0000 | [diff] [blame] | 3745 | |
Sebastian Redl | 9cc11e7 | 2009-07-25 15:41:38 +0000 | [diff] [blame] | 3746 | /// CheckCastTypes - Check type constraints for casting between types under |
Sebastian Redl | ef0cb8e | 2009-07-29 13:50:23 +0000 | [diff] [blame] | 3747 | /// C semantics, or forward to CXXCheckCStyleCast in C++. |
| 3748 | bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3749 | CastExpr::CastKind &Kind, |
Fariborz Jahanian | e9f4208 | 2009-08-26 18:55:36 +0000 | [diff] [blame] | 3750 | CXXMethodDecl *& ConversionDecl, |
| 3751 | bool FunctionalStyle = false); |
Sebastian Redl | 9cc11e7 | 2009-07-25 15:41:38 +0000 | [diff] [blame] | 3752 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3753 | // CheckVectorCast - check type constraints for vectors. |
Anders Carlsson | 584b247 | 2007-11-27 07:16:40 +0000 | [diff] [blame] | 3754 | // Since vectors are an extension, there are no C standard reference for this. |
| 3755 | // We allow casting between vectors and integer datatypes of the same size. |
Anders Carlsson | a64db8f | 2007-11-27 05:51:55 +0000 | [diff] [blame] | 3756 | // returns true if the cast is invalid |
Anders Carlsson | c351632 | 2009-10-16 02:48:28 +0000 | [diff] [blame] | 3757 | bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, |
| 3758 | CastExpr::CastKind &Kind); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3759 | |
| 3760 | // CheckExtVectorCast - check type constraints for extended vectors. |
Nate Begeman | 58d29a4 | 2009-06-26 00:50:28 +0000 | [diff] [blame] | 3761 | // Since vectors are an extension, there are no C standard reference for this. |
| 3762 | // We allow casting between vectors and integer datatypes of the same size, |
| 3763 | // or vectors and the element type of that vector. |
| 3764 | // returns true if the cast is invalid |
Anders Carlsson | 16a8904 | 2009-10-16 05:23:41 +0000 | [diff] [blame] | 3765 | bool CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *&CastExpr, |
| 3766 | CastExpr::CastKind &Kind); |
Sebastian Redl | 9cc11e7 | 2009-07-25 15:41:38 +0000 | [diff] [blame] | 3767 | |
| 3768 | /// CXXCheckCStyleCast - Check constraints of a C-style or function-style |
| 3769 | /// cast under C++ semantics. |
Sebastian Redl | ef0cb8e | 2009-07-29 13:50:23 +0000 | [diff] [blame] | 3770 | bool CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr, |
Fariborz Jahanian | e9f4208 | 2009-08-26 18:55:36 +0000 | [diff] [blame] | 3771 | CastExpr::CastKind &Kind, bool FunctionalStyle, |
| 3772 | CXXMethodDecl *&ConversionDecl); |
Sebastian Redl | 9cc11e7 | 2009-07-25 15:41:38 +0000 | [diff] [blame] | 3773 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3774 | /// CheckMessageArgumentTypes - Check types in an Obj-C message send. |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 3775 | /// \param Method - May be null. |
| 3776 | /// \param [out] ReturnType - The return type of the send. |
| 3777 | /// \return true iff there were any incompatible types. |
Daniel Dunbar | 91e19b2 | 2008-09-11 00:50:25 +0000 | [diff] [blame] | 3778 | bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel, |
Chris Lattner | 077bf5e | 2008-11-24 03:33:13 +0000 | [diff] [blame] | 3779 | ObjCMethodDecl *Method, bool isClassMessage, |
Daniel Dunbar | 637cebb | 2008-09-11 00:01:56 +0000 | [diff] [blame] | 3780 | SourceLocation lbrac, SourceLocation rbrac, |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3781 | QualType &ReturnType); |
Argyrios Kyrtzidis | 5921093 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 3782 | |
John McCall | 5a881bb | 2009-10-12 21:59:07 +0000 | [diff] [blame] | 3783 | /// CheckBooleanCondition - Diagnose problems involving the use of |
| 3784 | /// the given expression as a boolean condition (e.g. in an if |
| 3785 | /// statement). Also performs the standard function and array |
| 3786 | /// decays, possibly changing the input variable. |
| 3787 | /// |
| 3788 | /// \param Loc - A location associated with the condition, e.g. the |
| 3789 | /// 'if' keyword. |
| 3790 | /// \return true iff there were any errors |
| 3791 | bool CheckBooleanCondition(Expr *&CondExpr, SourceLocation Loc); |
| 3792 | |
| 3793 | /// DiagnoseAssignmentAsCondition - Given that an expression is |
| 3794 | /// being used as a boolean condition, warn if it's an assignment. |
| 3795 | void DiagnoseAssignmentAsCondition(Expr *E); |
| 3796 | |
Argyrios Kyrtzidis | 5921093 | 2008-09-10 02:17:11 +0000 | [diff] [blame] | 3797 | /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid. |
| 3798 | bool CheckCXXBooleanCondition(Expr *&CondExpr); |
Sebastian Redl | 9cc11e7 | 2009-07-25 15:41:38 +0000 | [diff] [blame] | 3799 | |
Chris Lattner | f4021e7 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 3800 | /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have |
| 3801 | /// the specified width and sign. If an overflow occurs, detect it and emit |
| 3802 | /// the specified diagnostic. |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3803 | void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal, |
Chris Lattner | f4021e7 | 2007-08-23 05:46:52 +0000 | [diff] [blame] | 3804 | unsigned NewWidth, bool NewSign, |
| 3805 | SourceLocation Loc, unsigned DiagID); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3806 | |
Anders Carlsson | 1528145 | 2008-11-04 16:57:32 +0000 | [diff] [blame] | 3807 | /// Checks that the Objective-C declaration is declared in the global scope. |
| 3808 | /// Emits an error and marks the declaration as invalid if it's not declared |
| 3809 | /// in the global scope. |
| 3810 | bool CheckObjCDeclScope(Decl *D); |
| 3811 | |
Anders Carlsson | 7c50aca | 2007-10-15 20:28:48 +0000 | [diff] [blame] | 3812 | void InitBuiltinVaListType(); |
Eli Friedman | 1b76ada | 2008-06-03 21:01:11 +0000 | [diff] [blame] | 3813 | |
Anders Carlsson | e21555e | 2008-11-30 19:50:32 +0000 | [diff] [blame] | 3814 | /// VerifyIntegerConstantExpression - verifies that an expression is an ICE, |
| 3815 | /// and reports the appropriate diagnostics. Returns false on success. |
| 3816 | /// Can optionally return the value of the expression. |
Anders Carlsson | 9f1e572 | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 3817 | bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0); |
Anders Carlsson | 4000ea6 | 2008-12-01 02:17:22 +0000 | [diff] [blame] | 3818 | |
Anders Carlsson | 9f1e572 | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 3819 | /// VerifyBitField - verifies that a bit field expression is an ICE and has |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3820 | /// the correct width, and that the field type is valid. |
Anders Carlsson | 9f1e572 | 2008-12-06 20:33:04 +0000 | [diff] [blame] | 3821 | /// Returns false on success. |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 3822 | /// Can optionally return whether the bit-field is of width 0 |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3823 | bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, |
| 3824 | QualType FieldTy, const Expr *BitWidth, |
Eli Friedman | 1d954f6 | 2009-08-15 21:55:26 +0000 | [diff] [blame] | 3825 | bool *ZeroWidth = 0); |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 3826 | |
Douglas Gregor | 81b747b | 2009-09-17 21:32:03 +0000 | [diff] [blame] | 3827 | /// \name Code completion |
| 3828 | //@{ |
Douglas Gregor | 01dfea0 | 2010-01-10 23:08:15 +0000 | [diff] [blame] | 3829 | virtual void CodeCompleteOrdinaryName(Scope *S, |
| 3830 | CodeCompletionContext CompletionContext); |
Douglas Gregor | 81b747b | 2009-09-17 21:32:03 +0000 | [diff] [blame] | 3831 | virtual void CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *Base, |
| 3832 | SourceLocation OpLoc, |
| 3833 | bool IsArrow); |
Douglas Gregor | 374929f | 2009-09-18 15:37:17 +0000 | [diff] [blame] | 3834 | virtual void CodeCompleteTag(Scope *S, unsigned TagSpec); |
Douglas Gregor | 3e1005f | 2009-09-21 18:10:23 +0000 | [diff] [blame] | 3835 | virtual void CodeCompleteCase(Scope *S); |
Douglas Gregor | 9c6a0e9 | 2009-09-22 15:41:20 +0000 | [diff] [blame] | 3836 | virtual void CodeCompleteCall(Scope *S, ExprTy *Fn, |
| 3837 | ExprTy **Args, unsigned NumArgs); |
Douglas Gregor | 81b747b | 2009-09-17 21:32:03 +0000 | [diff] [blame] | 3838 | virtual void CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS, |
| 3839 | bool EnteringContext); |
Douglas Gregor | 49f40bd | 2009-09-18 19:03:04 +0000 | [diff] [blame] | 3840 | virtual void CodeCompleteUsing(Scope *S); |
| 3841 | virtual void CodeCompleteUsingDirective(Scope *S); |
| 3842 | virtual void CodeCompleteNamespaceDecl(Scope *S); |
| 3843 | virtual void CodeCompleteNamespaceAliasDecl(Scope *S); |
Douglas Gregor | ed8d322 | 2009-09-18 20:05:18 +0000 | [diff] [blame] | 3844 | virtual void CodeCompleteOperatorName(Scope *S); |
Steve Naroff | ece8e71 | 2009-10-08 21:55:05 +0000 | [diff] [blame] | 3845 | |
Douglas Gregor | c464ae8 | 2009-12-07 09:27:33 +0000 | [diff] [blame] | 3846 | virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl, |
| 3847 | bool InInterface); |
Douglas Gregor | 9a0c85e | 2009-12-07 09:51:25 +0000 | [diff] [blame] | 3848 | virtual void CodeCompleteObjCAtStatement(Scope *S); |
| 3849 | virtual void CodeCompleteObjCAtExpression(Scope *S); |
Douglas Gregor | a93b108 | 2009-11-18 23:08:07 +0000 | [diff] [blame] | 3850 | virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS); |
Douglas Gregor | 4ad9685 | 2009-11-19 07:41:15 +0000 | [diff] [blame] | 3851 | virtual void CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl, |
| 3852 | DeclPtrTy *Methods, |
| 3853 | unsigned NumMethods); |
| 3854 | virtual void CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ClassDecl, |
| 3855 | DeclPtrTy *Methods, |
| 3856 | unsigned NumMethods); |
| 3857 | |
Douglas Gregor | 60b01cc | 2009-11-17 23:31:36 +0000 | [diff] [blame] | 3858 | virtual void CodeCompleteObjCClassMessage(Scope *S, IdentifierInfo *FName, |
Douglas Gregor | d3c6854 | 2009-11-19 01:08:35 +0000 | [diff] [blame] | 3859 | SourceLocation FNameLoc, |
| 3860 | IdentifierInfo **SelIdents, |
| 3861 | unsigned NumSelIdents); |
| 3862 | virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver, |
| 3863 | IdentifierInfo **SelIdents, |
| 3864 | unsigned NumSelIdents); |
Douglas Gregor | 55385fe | 2009-11-18 04:19:12 +0000 | [diff] [blame] | 3865 | virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols, |
| 3866 | unsigned NumProtocols); |
Douglas Gregor | 083128f | 2009-11-18 04:49:41 +0000 | [diff] [blame] | 3867 | virtual void CodeCompleteObjCProtocolDecl(Scope *S); |
Douglas Gregor | 3b49aca | 2009-11-18 16:26:39 +0000 | [diff] [blame] | 3868 | virtual void CodeCompleteObjCInterfaceDecl(Scope *S); |
| 3869 | virtual void CodeCompleteObjCSuperclass(Scope *S, |
| 3870 | IdentifierInfo *ClassName); |
| 3871 | virtual void CodeCompleteObjCImplementationDecl(Scope *S); |
Douglas Gregor | 33ced0b | 2009-11-18 19:08:43 +0000 | [diff] [blame] | 3872 | virtual void CodeCompleteObjCInterfaceCategory(Scope *S, |
| 3873 | IdentifierInfo *ClassName); |
| 3874 | virtual void CodeCompleteObjCImplementationCategory(Scope *S, |
| 3875 | IdentifierInfo *ClassName); |
Douglas Gregor | 424b2a5 | 2009-11-18 22:56:13 +0000 | [diff] [blame] | 3876 | virtual void CodeCompleteObjCPropertyDefinition(Scope *S, |
Douglas Gregor | 322328b | 2009-11-18 22:32:06 +0000 | [diff] [blame] | 3877 | DeclPtrTy ObjCImpDecl); |
| 3878 | virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, |
| 3879 | IdentifierInfo *PropertyName, |
| 3880 | DeclPtrTy ObjCImpDecl); |
Douglas Gregor | 3b49aca | 2009-11-18 16:26:39 +0000 | [diff] [blame] | 3881 | //@} |
Douglas Gregor | 81b747b | 2009-09-17 21:32:03 +0000 | [diff] [blame] | 3882 | |
Chris Lattner | 59907c4 | 2007-08-10 20:18:51 +0000 | [diff] [blame] | 3883 | //===--------------------------------------------------------------------===// |
| 3884 | // Extra semantic analysis beyond the C type system |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 3885 | private: |
Anders Carlsson | d406bf0 | 2009-08-16 01:56:34 +0000 | [diff] [blame] | 3886 | bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall); |
| 3887 | bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3888 | |
Chris Lattner | 6080008 | 2009-02-18 17:49:48 +0000 | [diff] [blame] | 3889 | SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, |
| 3890 | unsigned ByteNo) const; |
Ryan Flynn | 4403a5e | 2009-08-06 03:00:50 +0000 | [diff] [blame] | 3891 | bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall); |
Chris Lattner | 6903981 | 2009-02-18 06:01:06 +0000 | [diff] [blame] | 3892 | bool CheckObjCString(Expr *Arg); |
Anders Carlsson | d406bf0 | 2009-08-16 01:56:34 +0000 | [diff] [blame] | 3893 | |
| 3894 | Action::OwningExprResult CheckBuiltinFunctionCall(unsigned BuiltinID, |
| 3895 | CallExpr *TheCall); |
Chris Lattner | 925e60d | 2007-12-28 05:29:59 +0000 | [diff] [blame] | 3896 | bool SemaBuiltinVAStart(CallExpr *TheCall); |
| 3897 | bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); |
Eli Friedman | 9ac6f62 | 2009-08-31 20:06:00 +0000 | [diff] [blame] | 3898 | bool SemaBuiltinUnaryFP(CallExpr *TheCall); |
Eli Friedman | 6cfda23 | 2008-05-20 08:23:37 +0000 | [diff] [blame] | 3899 | bool SemaBuiltinStackAddress(CallExpr *TheCall); |
Douglas Gregor | cde0173 | 2009-05-19 22:10:17 +0000 | [diff] [blame] | 3900 | |
| 3901 | public: |
| 3902 | // Used by C++ template instantiation. |
Sebastian Redl | 0eb2330 | 2009-01-19 00:08:26 +0000 | [diff] [blame] | 3903 | Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall); |
Douglas Gregor | cde0173 | 2009-05-19 22:10:17 +0000 | [diff] [blame] | 3904 | |
| 3905 | private: |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3906 | bool SemaBuiltinPrefetch(CallExpr *TheCall); |
Eli Friedman | d875fed | 2009-05-03 04:46:36 +0000 | [diff] [blame] | 3907 | bool SemaBuiltinObjectSize(CallExpr *TheCall); |
| 3908 | bool SemaBuiltinLongjmp(CallExpr *TheCall); |
Chris Lattner | 5caa370 | 2009-05-08 06:58:22 +0000 | [diff] [blame] | 3909 | bool SemaBuiltinAtomicOverloaded(CallExpr *TheCall); |
Chris Lattner | 21fb98e | 2009-09-23 06:06:36 +0000 | [diff] [blame] | 3910 | bool SemaBuiltinEHReturnDataRegNo(CallExpr *TheCall); |
Ted Kremenek | 082d936 | 2009-03-20 21:35:28 +0000 | [diff] [blame] | 3911 | bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, |
| 3912 | bool HasVAListArg, unsigned format_idx, |
| 3913 | unsigned firstDataArg); |
| 3914 | void CheckPrintfString(const StringLiteral *FExpr, const Expr *OrigFormatExpr, |
| 3915 | const CallExpr *TheCall, bool HasVAListArg, |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 3916 | unsigned format_idx, unsigned firstDataArg); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3917 | void CheckNonNullArguments(const NonNullAttr *NonNull, |
Fariborz Jahanian | e898f8a | 2009-05-21 18:48:51 +0000 | [diff] [blame] | 3918 | const CallExpr *TheCall); |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3919 | void CheckPrintfArguments(const CallExpr *TheCall, bool HasVAListArg, |
Douglas Gregor | 3c385e5 | 2009-02-14 18:57:46 +0000 | [diff] [blame] | 3920 | unsigned format_idx, unsigned firstDataArg); |
Ted Kremenek | 06de276 | 2007-08-17 16:46:58 +0000 | [diff] [blame] | 3921 | void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, |
| 3922 | SourceLocation ReturnLoc); |
Ted Kremenek | 588e5eb | 2007-11-25 00:58:00 +0000 | [diff] [blame] | 3923 | void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex); |
John McCall | 51313c3 | 2010-01-04 23:31:57 +0000 | [diff] [blame] | 3924 | void CheckSignCompare(Expr *LHS, Expr *RHS, SourceLocation Loc, |
| 3925 | const PartialDiagnostic &PD, |
| 3926 | bool Equality = false); |
| 3927 | void CheckImplicitConversion(Expr *E, QualType Target); |
| 3928 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3929 | }; |
| 3930 | |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 3931 | //===--------------------------------------------------------------------===// |
| 3932 | // Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers). |
| 3933 | template <typename T> |
| 3934 | class ExprOwningPtr : public Action::ExprArg { |
| 3935 | public: |
Douglas Gregor | a0e500d | 2009-03-12 16:53:44 +0000 | [diff] [blame] | 3936 | ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {} |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3937 | |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 3938 | void reset(T* p) { Action::ExprArg::operator=(p); } |
| 3939 | T* get() const { return static_cast<T*>(Action::ExprArg::get()); } |
| 3940 | T* take() { return static_cast<T*>(Action::ExprArg::take()); } |
| 3941 | T* release() { return take(); } |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 3942 | |
Ted Kremenek | 8189cde | 2009-02-07 01:47:29 +0000 | [diff] [blame] | 3943 | T& operator*() const { return *get(); } |
| 3944 | T* operator->() const { return get(); } |
| 3945 | }; |
Douglas Gregor | d7e2705 | 2009-05-20 22:33:37 +0000 | [diff] [blame] | 3946 | |
Reid Spencer | 5f016e2 | 2007-07-11 17:01:13 +0000 | [diff] [blame] | 3947 | } // end namespace clang |
| 3948 | |
| 3949 | #endif |