blob: 6167668b861fa7b62ca2deaa4f9320ea98ebf888 [file] [log] [blame]
Reid Spencer5f016e22007-07-11 17:01:13 +00001//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner0bc735f2007-12-29 19:59:25 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Reid Spencer5f016e22007-07-11 17:01:13 +00007//
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 Lattner7f925cc2008-04-11 07:00:53 +000018#include "IdentifierResolver.h"
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +000019#include "CXXFieldCollector.h"
Douglas Gregor8e9bebd2008-10-21 16:13:35 +000020#include "SemaOverload.h"
Douglas Gregord1102432009-08-28 17:37:35 +000021#include "SemaTemplate.h"
Ted Kremenekd064fdc2010-03-23 00:13:23 +000022#include "AnalysisBasedWarnings.h"
Douglas Gregore0762c92009-06-19 23:52:42 +000023#include "clang/AST/Attr.h"
Douglas Gregoreb11cd02009-01-14 22:20:51 +000024#include "clang/AST/DeclBase.h"
Douglas Gregore0762c92009-06-19 23:52:42 +000025#include "clang/AST/Decl.h"
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +000026#include "clang/AST/DeclObjC.h"
Anders Carlsson1c5976e2009-06-05 03:43:12 +000027#include "clang/AST/DeclTemplate.h"
Anders Carlsson72e96fd2010-05-02 22:54:08 +000028#include "clang/AST/ExprCXX.h"
Anders Carlsson5ee56e92009-12-16 02:09:40 +000029#include "clang/AST/FullExpr.h"
Reid Spencer5f016e22007-07-11 17:01:13 +000030#include "clang/Parse/Action.h"
Chris Lattner500d3292009-01-29 05:15:15 +000031#include "clang/Sema/SemaDiagnostic.h"
Anders Carlssonc1fcb772007-07-22 07:07:56 +000032#include "llvm/ADT/SmallVector.h"
Fariborz Jahanian85ff2642007-10-05 18:00:57 +000033#include "llvm/ADT/DenseSet.h"
Chris Lattnerf3876682007-10-07 01:13:46 +000034#include "llvm/ADT/SmallPtrSet.h"
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +000035#include "llvm/ADT/OwningPtr.h"
Douglas Gregorb33fe2f2009-06-30 17:20:14 +000036#include <deque>
Douglas Gregorac7610d2009-06-22 20:57:11 +000037#include <list>
Anders Carlssond6a637f2009-12-07 08:24:59 +000038#include <map>
Douglas Gregor4dc6b1c2009-01-16 00:38:09 +000039#include <string>
Douglas Gregor94b1dd22008-10-24 04:54:22 +000040#include <vector>
Reid Spencer5f016e22007-07-11 17:01:13 +000041
Chris Lattnerf4021e72007-08-23 05:46:52 +000042namespace llvm {
43 class APSInt;
44}
45
Reid Spencer5f016e22007-07-11 17:01:13 +000046namespace clang {
47 class ASTContext;
Chris Lattner2ae34ed2008-02-06 00:46:58 +000048 class ASTConsumer;
Douglas Gregor81b747b2009-09-17 21:32:03 +000049 class CodeCompleteConsumer;
Reid Spencer5f016e22007-07-11 17:01:13 +000050 class Preprocessor;
51 class Decl;
Chris Lattnerb048c982008-04-06 04:47:34 +000052 class DeclContext;
Daniel Dunbar12bc6922008-08-11 03:27:53 +000053 class DeclSpec;
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +000054 class ExternalSemaSource;
Steve Naroffe8043c32008-04-01 23:04:06 +000055 class NamedDecl;
Sebastian Redl798d1192008-12-13 16:23:55 +000056 class Stmt;
Reid Spencer5f016e22007-07-11 17:01:13 +000057 class Expr;
Steve Naroff6f9f3072007-09-02 15:34:30 +000058 class InitListExpr;
Nate Begeman2ef13e52009-08-10 23:49:36 +000059 class ParenListExpr;
Douglas Gregor05c13a32009-01-22 00:58:24 +000060 class DesignatedInitExpr;
Chris Lattner925e60d2007-12-28 05:29:59 +000061 class CallExpr;
Douglas Gregor1a49af92009-01-06 05:10:23 +000062 class DeclRefExpr;
John McCall3b4294e2009-12-16 12:17:52 +000063 class UnresolvedLookupExpr;
John McCallc373d482010-01-27 01:50:18 +000064 class UnresolvedMemberExpr;
Reid Spencer5f016e22007-07-11 17:01:13 +000065 class VarDecl;
66 class ParmVarDecl;
67 class TypedefDecl;
68 class FunctionDecl;
69 class QualType;
Sebastian Redl43af76e2009-03-07 12:16:37 +000070 class LangOptions;
Chris Lattnerd2177732007-07-20 16:59:19 +000071 class Token;
Reid Spencer5f016e22007-07-11 17:01:13 +000072 class IntegerLiteral;
Steve Naroffa49e1fa2008-01-22 00:55:40 +000073 class StringLiteral;
Reid Spencer5f016e22007-07-11 17:01:13 +000074 class ArrayType;
75 class LabelStmt;
Anders Carlssonc1fcb772007-07-22 07:07:56 +000076 class SwitchStmt;
Sebastian Redl13e88542009-04-27 21:33:24 +000077 class CXXTryStmt;
Nate Begeman213541a2008-04-18 23:10:10 +000078 class ExtVectorType;
Steve Naroffbea0b342007-07-29 16:33:31 +000079 class TypedefDecl;
Douglas Gregoraaba5e32009-02-04 19:02:06 +000080 class TemplateDecl;
Douglas Gregor3e00bad2009-02-17 01:05:43 +000081 class TemplateArgument;
John McCall833ca992009-10-29 08:12:44 +000082 class TemplateArgumentLoc;
Douglas Gregor7e063902009-05-11 23:53:27 +000083 class TemplateArgumentList;
Douglas Gregorddc29e12009-02-06 22:42:48 +000084 class TemplateParameterList;
Douglas Gregorc15cb382009-02-09 23:23:08 +000085 class TemplateTemplateParmDecl;
Douglas Gregorc8ab2562009-05-31 09:31:02 +000086 class ClassTemplatePartialSpecializationDecl;
Douglas Gregor88b70942009-02-25 22:02:03 +000087 class ClassTemplateDecl;
Ted Kremeneka526c5c2008-01-07 19:49:32 +000088 class ObjCInterfaceDecl;
Steve Naroffe8043c32008-04-01 23:04:06 +000089 class ObjCCompatibleAliasDecl;
Ted Kremeneka526c5c2008-01-07 19:49:32 +000090 class ObjCProtocolDecl;
Chris Lattnercddc8882009-03-01 00:56:52 +000091 class ObjCImplDecl;
Ted Kremeneka526c5c2008-01-07 19:49:32 +000092 class ObjCImplementationDecl;
93 class ObjCCategoryImplDecl;
94 class ObjCCategoryDecl;
95 class ObjCIvarDecl;
96 class ObjCMethodDecl;
Fariborz Jahanian02edb982008-05-01 00:03:38 +000097 class ObjCPropertyDecl;
Steve Naroff0701bbb2009-01-08 17:28:14 +000098 class ObjCContainerDecl;
Douglas Gregora2e7dd22010-02-25 01:56:36 +000099 class PseudoDestructorTypeStorage;
Sebastian Redl4994d2d2009-07-04 11:39:00 +0000100 class FunctionProtoType;
John McCall6b2accb2010-02-10 09:31:12 +0000101 class CXXBasePath;
Douglas Gregora8f32e02009-10-06 17:59:45 +0000102 class CXXBasePaths;
Anders Carlssonff6b3d62009-05-30 21:05:25 +0000103 class CXXTemporary;
John McCall7d384dd2009-11-18 07:57:50 +0000104 class LookupResult;
Douglas Gregor20093b42009-12-09 23:02:17 +0000105 class InitializedEntity;
106 class InitializationKind;
107 class InitializationSequence;
Douglas Gregor546be3c2009-12-30 17:04:44 +0000108 class VisibleDeclConsumer;
Anton Korobeynikov82d0a412010-01-10 12:58:08 +0000109 class TargetAttributesSema;
John McCall7edb5fd2010-01-26 07:16:45 +0000110 class ADLResult;
Douglas Gregor546be3c2009-12-30 17:04:44 +0000111
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000112/// \brief Retains information about a function, method, or block that is
Douglas Gregor076ceb02010-03-01 20:44:28 +0000113/// currently being parsed.
114struct FunctionScopeInfo {
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000115 /// \brief Whether this scope information structure defined information for
116 /// a block.
117 bool IsBlockInfo;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000118
John McCallb60a77e2010-08-01 00:26:45 +0000119 /// \brief Whether this function contains a VLA, @try, try, C++
120 /// initializer, or anything else that can't be jumped past.
121 bool HasBranchProtectedScope;
122
123 /// \brief Whether this function contains any switches or direct gotos.
124 bool HasBranchIntoScope;
125
126 /// \brief Whether this function contains any indirect gotos.
127 bool HasIndirectGoto;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000128
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000129 /// \brief The number of errors that had occurred before starting this
130 /// function or block.
131 unsigned NumErrorsAtStartOfFunction;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000132
Douglas Gregor076ceb02010-03-01 20:44:28 +0000133 /// LabelMap - This is a mapping from label identifiers to the LabelStmt for
134 /// it (which acts like the label decl in some ways). Forward referenced
135 /// labels have a LabelStmt created for them with a null location & SubStmt.
136 llvm::DenseMap<IdentifierInfo*, LabelStmt*> LabelMap;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000137
Douglas Gregor076ceb02010-03-01 20:44:28 +0000138 /// SwitchStack - This is the current set of active switch statements in the
139 /// block.
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000140 llvm::SmallVector<SwitchStmt*, 8> SwitchStack;
141
Douglas Gregor5077c382010-05-15 06:01:05 +0000142 /// \brief The list of return statements that occur within the function or
143 /// block, if there is any chance of applying the named return value
144 /// optimization.
145 llvm::SmallVector<ReturnStmt *, 4> Returns;
John McCallb60a77e2010-08-01 00:26:45 +0000146
147 bool NeedsScopeChecking() const {
148 return HasIndirectGoto ||
149 (HasBranchProtectedScope && HasBranchIntoScope);
150 }
Douglas Gregor5077c382010-05-15 06:01:05 +0000151
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000152 FunctionScopeInfo(unsigned NumErrors)
John McCallb60a77e2010-08-01 00:26:45 +0000153 : IsBlockInfo(false),
154 HasBranchProtectedScope(false),
155 HasBranchIntoScope(false),
156 HasIndirectGoto(false),
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000157 NumErrorsAtStartOfFunction(NumErrors) { }
158
159 virtual ~FunctionScopeInfo();
160
161 /// \brief Clear out the information in this function scope, making it
162 /// suitable for reuse.
163 void Clear(unsigned NumErrors);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000164
165 static bool classof(const FunctionScopeInfo *FSI) { return true; }
Douglas Gregor076ceb02010-03-01 20:44:28 +0000166};
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000167
168
Douglas Gregor076ceb02010-03-01 20:44:28 +0000169/// \brief Retains information about a block that is currently being parsed.
170struct BlockScopeInfo : FunctionScopeInfo {
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000171 bool hasBlockDeclRefExprs;
Mike Stump1eb44332009-09-09 15:08:12 +0000172
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000173 BlockDecl *TheDecl;
Fariborz Jahaniana729da22010-07-09 18:44:02 +0000174
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000175 /// TheScope - This is the scope for the block itself, which contains
176 /// arguments etc.
177 Scope *TheScope;
Mike Stump1eb44332009-09-09 15:08:12 +0000178
John McCallc71a4912010-06-04 19:02:56 +0000179 /// ReturnType - The return type of the block, or null if the block
180 /// signature didn't provide an explicit return type.
Fariborz Jahanian7d5c74e2009-06-19 23:37:08 +0000181 QualType ReturnType;
Mike Stump1eb44332009-09-09 15:08:12 +0000182
John McCallc71a4912010-06-04 19:02:56 +0000183 /// BlockType - The function type of the block, if one was given.
184 /// Its return type may be BuiltinType::Dependent.
185 QualType FunctionType;
186
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000187 BlockScopeInfo(unsigned NumErrors, Scope *BlockScope, BlockDecl *Block)
John McCallc71a4912010-06-04 19:02:56 +0000188 : FunctionScopeInfo(NumErrors), hasBlockDeclRefExprs(false),
189 TheDecl(Block), TheScope(BlockScope)
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000190 {
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000191 IsBlockInfo = true;
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000192 }
Mike Stump1eb44332009-09-09 15:08:12 +0000193
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000194 virtual ~BlockScopeInfo();
195
Douglas Gregor076ceb02010-03-01 20:44:28 +0000196 static bool classof(const FunctionScopeInfo *FSI) { return FSI->IsBlockInfo; }
197 static bool classof(const BlockScopeInfo *BSI) { return true; }
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000198};
199
John McCalla93c9342009-12-07 02:54:59 +0000200/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
Argyrios Kyrtzidis1bb8a452009-08-19 01:28:17 +0000201/// parsing.
202///
203/// LocInfoType is a "transient" type, only needed for passing to/from Parser
204/// and Sema, when we want to preserve type source info for a parsed type.
205/// It will not participate in the type system semantics in any way.
206class LocInfoType : public Type {
207 enum {
208 // The last number that can fit in Type's TC.
Mike Stump1eb44332009-09-09 15:08:12 +0000209 // Avoids conflict with an existing Type class.
John McCall27935ee2010-02-12 03:41:30 +0000210 LocInfo = Type::TypeLast + 1
Argyrios Kyrtzidis1bb8a452009-08-19 01:28:17 +0000211 };
212
John McCalla93c9342009-12-07 02:54:59 +0000213 TypeSourceInfo *DeclInfo;
Argyrios Kyrtzidis1bb8a452009-08-19 01:28:17 +0000214
John McCalla93c9342009-12-07 02:54:59 +0000215 LocInfoType(QualType ty, TypeSourceInfo *TInfo)
216 : Type((TypeClass)LocInfo, ty, ty->isDependentType()), DeclInfo(TInfo) {
Argyrios Kyrtzidis1bb8a452009-08-19 01:28:17 +0000217 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
218 }
219 friend class Sema;
220
221public:
222 QualType getType() const { return getCanonicalTypeInternal(); }
John McCalla93c9342009-12-07 02:54:59 +0000223 TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
Argyrios Kyrtzidis1bb8a452009-08-19 01:28:17 +0000224
225 virtual void getAsStringInternal(std::string &Str,
226 const PrintingPolicy &Policy) const;
227
228 static bool classof(const Type *T) {
229 return T->getTypeClass() == (TypeClass)LocInfo;
230 }
231 static bool classof(const LocInfoType *) { return true; }
232};
233
Reid Spencer5f016e22007-07-11 17:01:13 +0000234/// Sema - This implements semantic analysis and AST building for C.
235class Sema : public Action {
Chris Lattnerf50adff2009-02-17 00:58:30 +0000236 Sema(const Sema&); // DO NOT IMPLEMENT
237 void operator=(const Sema&); // DO NOT IMPLEMENT
Anton Korobeynikov82d0a412010-01-10 12:58:08 +0000238 mutable const TargetAttributesSema* TheTargetAttributesSema;
Chris Lattner0b2f4da2008-06-29 00:28:59 +0000239public:
Chris Lattner53ebff32009-01-22 19:21:44 +0000240 const LangOptions &LangOpts;
Reid Spencer5f016e22007-07-11 17:01:13 +0000241 Preprocessor &PP;
Reid Spencer5f016e22007-07-11 17:01:13 +0000242 ASTContext &Context;
Chris Lattner2ae34ed2008-02-06 00:46:58 +0000243 ASTConsumer &Consumer;
Chris Lattner3cfa9282008-11-22 08:28:49 +0000244 Diagnostic &Diags;
245 SourceManager &SourceMgr;
Steve Naroff03300712007-11-12 13:56:41 +0000246
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +0000247 /// \brief Source of additional semantic information.
248 ExternalSemaSource *ExternalSource;
249
Douglas Gregor81b747b2009-09-17 21:32:03 +0000250 /// \brief Code-completion consumer.
251 CodeCompleteConsumer *CodeCompleter;
252
Argyrios Kyrtzidis53d0ea52008-06-28 06:07:14 +0000253 /// CurContext - This is the current declaration context of parsing.
Chris Lattnerb048c982008-04-06 04:47:34 +0000254 DeclContext *CurContext;
Chris Lattner0ed844b2008-04-04 06:12:32 +0000255
John McCallc7e04da2010-05-28 18:45:08 +0000256 /// VAListTagName - The declaration name corresponding to __va_list_tag.
257 /// This is used as part of a hack to omit that class from ADL results.
258 DeclarationName VAListTagName;
259
John McCallf5813822010-04-29 00:35:03 +0000260 /// A RAII object to temporarily push a declaration context.
261 class ContextRAII {
262 private:
263 Sema &S;
264 DeclContext *SavedContext;
265
266 public:
267 ContextRAII(Sema &S, DeclContext *ContextToPush)
268 : S(S), SavedContext(S.CurContext) {
269 assert(ContextToPush && "pushing null context");
270 S.CurContext = ContextToPush;
271 }
272
273 void pop() {
274 if (!SavedContext) return;
275 S.CurContext = SavedContext;
276 SavedContext = 0;
277 }
278
279 ~ContextRAII() {
280 pop();
281 }
282 };
283
Daniel Dunbar4cde9272008-10-14 05:35:18 +0000284 /// PackContext - Manages the stack for #pragma pack. An alignment
285 /// of 0 indicates default alignment.
Chris Lattner574aa402009-02-17 01:09:29 +0000286 void *PackContext; // Really a "PragmaPackStack*"
Daniel Dunbar4cde9272008-10-14 05:35:18 +0000287
Eli Friedmanaa8b0d12010-08-05 06:57:20 +0000288 /// VisContext - Manages the stack for #pragma GCC visibility.
289 void *VisContext; // Really a "PragmaVisStack*"
290
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000291 /// \brief Stack containing information about each of the nested function,
292 /// block, and method scopes that are currently active.
293 llvm::SmallVector<FunctionScopeInfo *, 4> FunctionScopes;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000294
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000295 /// \brief Cached function scope object used for the top function scope
296 /// and when there is no function scope (in error cases).
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000297 ///
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000298 /// This should never be accessed directly; rather, it's address will be
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000299 /// pushed into \c FunctionScopes when we want to re-use it.
300 FunctionScopeInfo TopFunctionScope;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000301
Mike Stump1eb44332009-09-09 15:08:12 +0000302 /// ExprTemporaries - This is the stack of temporaries that are created by
Anders Carlsson165a0a02009-05-17 18:41:29 +0000303 /// the current full expression.
Anders Carlssonff6b3d62009-05-30 21:05:25 +0000304 llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries;
Anders Carlsson165a0a02009-05-17 18:41:29 +0000305
Nate Begeman213541a2008-04-18 23:10:10 +0000306 /// ExtVectorDecls - This is a list all the extended vector types. This allows
307 /// us to associate a raw vector type with one of the ext_vector type names.
Steve Naroffbea0b342007-07-29 16:33:31 +0000308 /// This is only necessary for issuing pretty diagnostics.
Nate Begeman213541a2008-04-18 23:10:10 +0000309 llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
Mike Stump1eb44332009-09-09 15:08:12 +0000310
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +0000311 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
312 llvm::OwningPtr<CXXFieldCollector> FieldCollector;
313
Anders Carlsson4681ebd2009-03-22 20:18:17 +0000314 typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
Mike Stump1eb44332009-09-09 15:08:12 +0000315
316 /// PureVirtualClassDiagSet - a set of class declarations which we have
Anders Carlsson4681ebd2009-03-22 20:18:17 +0000317 /// emitted a list of pure virtual functions. Used to prevent emitting the
318 /// same list more than once.
319 llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet;
Mike Stump1eb44332009-09-09 15:08:12 +0000320
Douglas Gregor63935192009-03-02 00:19:53 +0000321 /// \brief A mapping from external names to the most recent
322 /// locally-scoped external declaration with that name.
323 ///
324 /// This map contains external declarations introduced in local
325 /// scoped, e.g.,
326 ///
327 /// \code
328 /// void f() {
329 /// void foo(int, int);
330 /// }
331 /// \endcode
332 ///
333 /// Here, the name "foo" will be associated with the declaration on
334 /// "foo" within f. This name is not visible outside of
335 /// "f". However, we still find it in two cases:
336 ///
337 /// - If we are declaring another external with the name "foo", we
338 /// can find "foo" as a previous declaration, so that the types
339 /// of this external declaration can be checked for
340 /// compatibility.
341 ///
342 /// - If we would implicitly declare "foo" (e.g., due to a call to
343 /// "foo" in C when no prototype or definition is visible), then
344 /// we find this declaration of "foo" and complain that it is
345 /// not visible.
346 llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls;
347
Sebastian Redle9d12b62010-01-31 22:27:38 +0000348 /// \brief All the tentative definitions encountered in the TU.
349 std::vector<VarDecl *> TentativeDefinitions;
Douglas Gregorb6c8c8b2009-04-21 17:11:58 +0000350
Tanya Lattnere6bbc012010-02-12 00:07:30 +0000351 /// \brief The set of static functions seen so far that have not been used.
352 std::vector<FunctionDecl*> UnusedStaticFuncs;
Ted Kremenekd064fdc2010-03-23 00:13:23 +0000353
John McCall6b2accb2010-02-10 09:31:12 +0000354 class AccessedEntity {
355 public:
John McCall58e6f342010-03-16 05:22:47 +0000356 /// A member declaration found through lookup. The target is the
357 /// member.
358 enum MemberNonce { Member };
John McCall6b2accb2010-02-10 09:31:12 +0000359
John McCall58e6f342010-03-16 05:22:47 +0000360 /// A hierarchy (base-to-derived or derived-to-base) conversion.
361 /// The target is the base class.
362 enum BaseNonce { Base };
John McCall6b2accb2010-02-10 09:31:12 +0000363
John McCall58e6f342010-03-16 05:22:47 +0000364 bool isMemberAccess() const { return IsMember; }
John McCall6b2accb2010-02-10 09:31:12 +0000365
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000366 AccessedEntity(ASTContext &Context,
Douglas Gregorfe6b2d42010-03-29 23:34:08 +0000367 MemberNonce _,
John McCall58e6f342010-03-16 05:22:47 +0000368 CXXRecordDecl *NamingClass,
John McCall161755a2010-04-06 21:38:20 +0000369 DeclAccessPair FoundDecl,
370 QualType BaseObjectType)
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000371 : Access(FoundDecl.getAccess()), IsMember(true),
John McCall9aa472c2010-03-19 07:35:19 +0000372 Target(FoundDecl.getDecl()), NamingClass(NamingClass),
John McCall161755a2010-04-06 21:38:20 +0000373 BaseObjectType(BaseObjectType), Diag(0, Context.getDiagAllocator()) {
John McCall9aa472c2010-03-19 07:35:19 +0000374 }
375
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000376 AccessedEntity(ASTContext &Context,
Douglas Gregorfe6b2d42010-03-29 23:34:08 +0000377 BaseNonce _,
John McCall58e6f342010-03-16 05:22:47 +0000378 CXXRecordDecl *BaseClass,
379 CXXRecordDecl *DerivedClass,
380 AccessSpecifier Access)
381 : Access(Access), IsMember(false),
382 Target(BaseClass), NamingClass(DerivedClass),
Douglas Gregorfe6b2d42010-03-29 23:34:08 +0000383 Diag(0, Context.getDiagAllocator()) {
John McCall6b2accb2010-02-10 09:31:12 +0000384 }
385
John McCall58e6f342010-03-16 05:22:47 +0000386 bool isQuiet() const { return Diag.getDiagID() == 0; }
387
John McCall6b2accb2010-02-10 09:31:12 +0000388 AccessSpecifier getAccess() const { return AccessSpecifier(Access); }
389
390 // These apply to member decls...
391 NamedDecl *getTargetDecl() const { return Target; }
392 CXXRecordDecl *getNamingClass() const { return NamingClass; }
393
394 // ...and these apply to hierarchy conversions.
395 CXXRecordDecl *getBaseClass() const { return cast<CXXRecordDecl>(Target); }
396 CXXRecordDecl *getDerivedClass() const { return NamingClass; }
397
John McCall161755a2010-04-06 21:38:20 +0000398 /// Retrieves the base object type, important when accessing
399 /// an instance member.
400 QualType getBaseObjectType() const { return BaseObjectType; }
401
John McCall58e6f342010-03-16 05:22:47 +0000402 /// Sets a diagnostic to be performed. The diagnostic is given
403 /// four (additional) arguments:
404 /// %0 - 0 if the entity was private, 1 if protected
405 /// %1 - the DeclarationName of the entity
406 /// %2 - the TypeDecl type of the naming class
407 /// %3 - the TypeDecl type of the declaring class
408 void setDiag(const PartialDiagnostic &PDiag) {
409 assert(isQuiet() && "partial diagnostic already defined");
410 Diag = PDiag;
411 }
412 PartialDiagnostic &setDiag(unsigned DiagID) {
413 assert(isQuiet() && "partial diagnostic already defined");
414 assert(DiagID && "creating null diagnostic");
Douglas Gregorfe6b2d42010-03-29 23:34:08 +0000415 Diag.Reset(DiagID);
John McCall58e6f342010-03-16 05:22:47 +0000416 return Diag;
417 }
418 const PartialDiagnostic &getDiag() const {
419 return Diag;
420 }
421
John McCall6b2accb2010-02-10 09:31:12 +0000422 private:
John McCall6b2accb2010-02-10 09:31:12 +0000423 unsigned Access : 2;
John McCall58e6f342010-03-16 05:22:47 +0000424 bool IsMember;
John McCall6b2accb2010-02-10 09:31:12 +0000425 NamedDecl *Target;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000426 CXXRecordDecl *NamingClass;
John McCall161755a2010-04-06 21:38:20 +0000427 QualType BaseObjectType;
John McCall58e6f342010-03-16 05:22:47 +0000428 PartialDiagnostic Diag;
John McCall6b2accb2010-02-10 09:31:12 +0000429 };
430
John McCall2f514482010-01-27 03:50:35 +0000431 struct DelayedDiagnostic {
432 enum DDKind { Deprecation, Access };
433
434 unsigned char Kind; // actually a DDKind
435 bool Triggered;
436
437 SourceLocation Loc;
438
439 union {
440 /// Deprecation.
441 struct { NamedDecl *Decl; } DeprecationData;
442
443 /// Access control.
John McCall58e6f342010-03-16 05:22:47 +0000444 char AccessData[sizeof(AccessedEntity)];
John McCall2f514482010-01-27 03:50:35 +0000445 };
446
John McCall58e6f342010-03-16 05:22:47 +0000447 void destroy() {
448 switch (Kind) {
449 case Access: getAccessData().~AccessedEntity(); break;
450 case Deprecation: break;
451 }
452 }
453
John McCall2f514482010-01-27 03:50:35 +0000454 static DelayedDiagnostic makeDeprecation(SourceLocation Loc,
455 NamedDecl *D) {
456 DelayedDiagnostic DD;
457 DD.Kind = Deprecation;
458 DD.Triggered = false;
459 DD.Loc = Loc;
460 DD.DeprecationData.Decl = D;
461 return DD;
462 }
463
464 static DelayedDiagnostic makeAccess(SourceLocation Loc,
John McCall6b2accb2010-02-10 09:31:12 +0000465 const AccessedEntity &Entity) {
John McCall2f514482010-01-27 03:50:35 +0000466 DelayedDiagnostic DD;
467 DD.Kind = Access;
468 DD.Triggered = false;
469 DD.Loc = Loc;
John McCall58e6f342010-03-16 05:22:47 +0000470 new (&DD.getAccessData()) AccessedEntity(Entity);
John McCall2f514482010-01-27 03:50:35 +0000471 return DD;
472 }
473
John McCall58e6f342010-03-16 05:22:47 +0000474 AccessedEntity &getAccessData() {
475 return *reinterpret_cast<AccessedEntity*>(AccessData);
476 }
477 const AccessedEntity &getAccessData() const {
478 return *reinterpret_cast<const AccessedEntity*>(AccessData);
479 }
John McCall2f514482010-01-27 03:50:35 +0000480 };
481
482 /// \brief The stack of diagnostics that were delayed due to being
483 /// produced during the parsing of a declaration.
484 llvm::SmallVector<DelayedDiagnostic, 8> DelayedDiagnostics;
John McCall54abf7d2009-11-04 02:18:39 +0000485
486 /// \brief The depth of the current ParsingDeclaration stack.
487 /// If nonzero, we are currently parsing a declaration (and
488 /// hence should delay deprecation warnings).
489 unsigned ParsingDeclDepth;
490
Ryan Flynne25ff832009-07-30 03:15:39 +0000491 /// WeakUndeclaredIdentifiers - Identifiers contained in
492 /// #pragma weak before declared. rare. may alias another
493 /// identifier, declared or undeclared
494 class WeakInfo {
495 IdentifierInfo *alias; // alias (optional)
496 SourceLocation loc; // for diagnostics
497 bool used; // identifier later declared?
498 public:
499 WeakInfo()
500 : alias(0), loc(SourceLocation()), used(false) {}
501 WeakInfo(IdentifierInfo *Alias, SourceLocation Loc)
502 : alias(Alias), loc(Loc), used(false) {}
503 inline IdentifierInfo * getAlias() const { return alias; }
504 inline SourceLocation getLocation() const { return loc; }
505 void setUsed(bool Used=true) { used = Used; }
506 inline bool getUsed() { return used; }
507 bool operator==(WeakInfo RHS) const {
508 return alias == RHS.getAlias() && loc == RHS.getLocation();
509 }
510 bool operator!=(WeakInfo RHS) const { return !(*this == RHS); }
511 };
512 llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers;
513
Ryan Flynn7b1fdbd2009-07-31 02:52:19 +0000514 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
515 /// #pragma weak during processing of other Decls.
516 /// I couldn't figure out a clean way to generate these in-line, so
517 /// we store them here and handle separately -- which is a hack.
518 /// It would be best to refactor this.
519 llvm::SmallVector<Decl*,2> WeakTopLevelDecl;
520
Chris Lattner7f925cc2008-04-11 07:00:53 +0000521 IdentifierResolver IdResolver;
522
Steve Naroffe440eb82007-10-10 17:32:04 +0000523 /// Translation Unit Scope - useful to Objective-C actions that need
524 /// to lookup file scope declarations in the "ordinary" C decl namespace.
525 /// For example, user-defined classes, built-in "id" type, etc.
Steve Naroffb216c882007-10-09 22:01:59 +0000526 Scope *TUScope;
Sebastian Redlc42e1182008-11-11 11:37:55 +0000527
Douglas Gregor7adb10f2009-09-15 22:30:29 +0000528 /// \brief The C++ "std" namespace, where the standard library resides.
Argyrios Kyrtzidis76c38d32010-08-02 07:14:54 +0000529 LazyDeclPtr StdNamespace;
Sebastian Redlb5a57a62008-12-03 20:26:15 +0000530
Douglas Gregor7adb10f2009-09-15 22:30:29 +0000531 /// \brief The C++ "std::bad_alloc" class, which is defined by the C++
532 /// standard library.
Argyrios Kyrtzidis76c38d32010-08-02 07:14:54 +0000533 LazyDeclPtr StdBadAlloc;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000534
Sebastian Redlb5a57a62008-12-03 20:26:15 +0000535 /// A flag to remember whether the implicit forms of operator new and delete
536 /// have been declared.
537 bool GlobalNewDeleteDeclared;
Douglas Gregorf807fe02009-04-14 16:27:31 +0000538
Douglas Gregor2afce722009-11-26 00:44:06 +0000539 /// \brief The set of declarations that have been referenced within
540 /// a potentially evaluated expression.
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000541 typedef std::vector<std::pair<SourceLocation, Decl *> >
Douglas Gregorac7610d2009-06-22 20:57:11 +0000542 PotentiallyReferencedDecls;
Mike Stump1eb44332009-09-09 15:08:12 +0000543
Douglas Gregor06d33692009-12-12 07:57:52 +0000544 /// \brief A set of diagnostics that may be emitted.
545 typedef std::vector<std::pair<SourceLocation, PartialDiagnostic> >
546 PotentiallyEmittedDiagnostics;
547
Douglas Gregor2afce722009-11-26 00:44:06 +0000548 /// \brief Data structure used to record current or nested
549 /// expression evaluation contexts.
550 struct ExpressionEvaluationContextRecord {
551 /// \brief The expression evaluation context.
552 ExpressionEvaluationContext Context;
553
554 /// \brief The number of temporaries that were active when we
555 /// entered this expression evaluation context.
556 unsigned NumTemporaries;
557
558 /// \brief The set of declarations referenced within a
559 /// potentially potentially-evaluated context.
560 ///
561 /// When leaving a potentially potentially-evaluated context, each
562 /// of these elements will be as referenced if the corresponding
563 /// potentially potentially evaluated expression is potentially
564 /// evaluated.
565 PotentiallyReferencedDecls *PotentiallyReferenced;
566
Douglas Gregor06d33692009-12-12 07:57:52 +0000567 /// \brief The set of diagnostics to emit should this potentially
568 /// potentially-evaluated context become evaluated.
569 PotentiallyEmittedDiagnostics *PotentiallyDiagnosed;
570
Douglas Gregor2afce722009-11-26 00:44:06 +0000571 ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000572 unsigned NumTemporaries)
573 : Context(Context), NumTemporaries(NumTemporaries),
Douglas Gregor06d33692009-12-12 07:57:52 +0000574 PotentiallyReferenced(0), PotentiallyDiagnosed(0) { }
Douglas Gregor2afce722009-11-26 00:44:06 +0000575
576 void addReferencedDecl(SourceLocation Loc, Decl *Decl) {
577 if (!PotentiallyReferenced)
578 PotentiallyReferenced = new PotentiallyReferencedDecls;
579 PotentiallyReferenced->push_back(std::make_pair(Loc, Decl));
580 }
581
Douglas Gregor06d33692009-12-12 07:57:52 +0000582 void addDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) {
583 if (!PotentiallyDiagnosed)
584 PotentiallyDiagnosed = new PotentiallyEmittedDiagnostics;
585 PotentiallyDiagnosed->push_back(std::make_pair(Loc, PD));
586 }
587
Douglas Gregor2afce722009-11-26 00:44:06 +0000588 void Destroy() {
589 delete PotentiallyReferenced;
Douglas Gregor06d33692009-12-12 07:57:52 +0000590 delete PotentiallyDiagnosed;
Douglas Gregor2afce722009-11-26 00:44:06 +0000591 PotentiallyReferenced = 0;
Douglas Gregor06d33692009-12-12 07:57:52 +0000592 PotentiallyDiagnosed = 0;
Douglas Gregor2afce722009-11-26 00:44:06 +0000593 }
594 };
595
596 /// A stack of expression evaluation contexts.
597 llvm::SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts;
Mike Stump1eb44332009-09-09 15:08:12 +0000598
Douglas Gregorf807fe02009-04-14 16:27:31 +0000599 /// \brief Whether the code handled by Sema should be considered a
600 /// complete translation unit or not.
601 ///
602 /// When true (which is generally the case), Sema will perform
603 /// end-of-translation-unit semantic tasks (such as creating
604 /// initializers for tentative definitions in C) once parsing has
605 /// completed. This flag will be false when building PCH files,
606 /// since a PCH file is by definition not a complete translation
607 /// unit.
608 bool CompleteTranslationUnit;
609
Argyrios Kyrtzidis1bb8a452009-08-19 01:28:17 +0000610 llvm::BumpPtrAllocator BumpAlloc;
611
Douglas Gregorbb260412009-06-14 08:02:22 +0000612 /// \brief The number of SFINAE diagnostics that have been trapped.
613 unsigned NumSFINAEErrors;
614
Sebastian Redldb9d2142010-08-02 23:18:59 +0000615 typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods;
616 typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool;
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +0000617
Sebastian Redldb9d2142010-08-02 23:18:59 +0000618 /// Method Pool - allows efficient lookup when typechecking messages to "id".
619 /// We need to maintain a list, since selectors can have differing signatures
620 /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
621 /// of selectors are "overloaded").
622 GlobalMethodPool MethodPool;
Mike Stump1eb44332009-09-09 15:08:12 +0000623
Fariborz Jahanian3fe10412010-07-22 18:24:20 +0000624 /// Method selectors used in a @selector expression. Used for implementation
625 /// of -Wselector.
626 llvm::DenseMap<Selector, SourceLocation> ReferencedSelectors;
627
628
Sebastian Redldb9d2142010-08-02 23:18:59 +0000629 GlobalMethodPool::iterator ReadMethodPool(Selector Sel);
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +0000630
Steve Naroff6b9dfd42009-03-04 15:11:40 +0000631 /// Private Helper predicate to check for 'self'.
632 bool isSelfExpr(Expr *RExpr);
Reid Spencer5f016e22007-07-11 17:01:13 +0000633public:
Douglas Gregorf807fe02009-04-14 16:27:31 +0000634 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
Daniel Dunbar3a2838d2009-11-13 08:58:20 +0000635 bool CompleteTranslationUnit = true,
636 CodeCompleteConsumer *CompletionConsumer = 0);
Anton Korobeynikov82d0a412010-01-10 12:58:08 +0000637 ~Sema();
Mike Stump1eb44332009-09-09 15:08:12 +0000638
Chris Lattner53ebff32009-01-22 19:21:44 +0000639 const LangOptions &getLangOptions() const { return LangOpts; }
Chris Lattner3cfa9282008-11-22 08:28:49 +0000640 Diagnostic &getDiagnostics() const { return Diags; }
641 SourceManager &getSourceManager() const { return SourceMgr; }
Anton Korobeynikov82d0a412010-01-10 12:58:08 +0000642 const TargetAttributesSema &getTargetAttributesSema() const;
Chris Lattner3cfa9282008-11-22 08:28:49 +0000643
Douglas Gregor25a88bb2009-03-20 22:48:49 +0000644 /// \brief Helper class that creates diagnostics with optional
645 /// template instantiation stacks.
646 ///
647 /// This class provides a wrapper around the basic DiagnosticBuilder
648 /// class that emits diagnostics. SemaDiagnosticBuilder is
649 /// responsible for emitting the diagnostic (as DiagnosticBuilder
650 /// does) and, if the diagnostic comes from inside a template
651 /// instantiation, printing the template instantiation stack as
652 /// well.
653 class SemaDiagnosticBuilder : public DiagnosticBuilder {
654 Sema &SemaRef;
655 unsigned DiagID;
656
657 public:
658 SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
659 : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
660
Mike Stump1eb44332009-09-09 15:08:12 +0000661 explicit SemaDiagnosticBuilder(Sema &SemaRef)
Douglas Gregor5e9f35c2009-06-14 07:33:30 +0000662 : DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { }
663
Douglas Gregor25a88bb2009-03-20 22:48:49 +0000664 ~SemaDiagnosticBuilder();
665 };
666
667 /// \brief Emit a diagnostic.
Douglas Gregoreab5d1e2010-03-25 22:17:48 +0000668 SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
Reid Spencer5f016e22007-07-11 17:01:13 +0000669
Anders Carlsson91a0cc92009-08-26 22:33:56 +0000670 /// \brief Emit a partial diagnostic.
671 SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD);
672
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000673 /// \brief Build a partial diagnostic.
Douglas Gregorfe6b2d42010-03-29 23:34:08 +0000674 PartialDiagnostic PDiag(unsigned DiagID = 0) {
675 return PartialDiagnostic(DiagID, Context.getDiagAllocator());
676 }
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000677
Chris Lattner394a3fd2007-08-31 04:53:24 +0000678 virtual void DeleteExpr(ExprTy *E);
679 virtual void DeleteStmt(StmtTy *S);
680
John McCall129e2df2009-11-30 22:42:35 +0000681 OwningExprResult Owned(Expr* E) {
682 assert(!E || E->isRetained());
683 return OwningExprResult(*this, E);
684 }
Sebastian Redl0eb23302009-01-19 00:08:26 +0000685 OwningExprResult Owned(ExprResult R) {
Douglas Gregor5ac8aff2009-01-26 22:44:13 +0000686 if (R.isInvalid())
Steve Naroff872b9ac2009-01-21 22:32:33 +0000687 return ExprError();
John McCall129e2df2009-11-30 22:42:35 +0000688 assert(!R.get() || ((Expr*) R.get())->isRetained());
Douglas Gregor5ac8aff2009-01-26 22:44:13 +0000689 return OwningExprResult(*this, R.get());
Sebastian Redl0eb23302009-01-19 00:08:26 +0000690 }
John McCall129e2df2009-11-30 22:42:35 +0000691 OwningStmtResult Owned(Stmt* S) {
692 assert(!S || S->isRetained());
693 return OwningStmtResult(*this, S);
694 }
Sebastian Redl798d1192008-12-13 16:23:55 +0000695
Chris Lattner9299f3f2008-08-23 03:19:52 +0000696 virtual void ActOnEndOfTranslationUnit();
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000697
Douglas Gregor23c94db2010-07-02 17:43:08 +0000698 Scope *getScopeForContext(DeclContext *Ctx);
699
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000700 void PushFunctionScope();
701 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
702 void PopFunctionOrBlockScope();
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000703
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000704 /// getLabelMap() - Return the current label map. If we're in a block, we
705 /// return it.
706 llvm::DenseMap<IdentifierInfo*, LabelStmt*> &getLabelMap() {
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000707 if (FunctionScopes.empty())
708 return TopFunctionScope.LabelMap;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000709
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000710 return FunctionScopes.back()->LabelMap;
Chris Lattnerea29a3a2009-04-18 20:01:55 +0000711 }
Mike Stump1eb44332009-09-09 15:08:12 +0000712
Chris Lattnerbcfce662009-04-18 20:10:59 +0000713 /// getSwitchStack - This is returns the switch stack for the current block or
714 /// function.
715 llvm::SmallVector<SwitchStmt*,8> &getSwitchStack() {
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000716 if (FunctionScopes.empty())
717 return TopFunctionScope.SwitchStack;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000718
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000719 return FunctionScopes.back()->SwitchStack;
Chris Lattnerbcfce662009-04-18 20:10:59 +0000720 }
Ryan Flynn7b1fdbd2009-07-31 02:52:19 +0000721
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000722 /// \brief Determine whether the current function or block needs scope
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000723 /// checking.
John McCallb60a77e2010-08-01 00:26:45 +0000724 bool FunctionNeedsScopeChecking() {
725 if (!FunctionScopes.empty())
726 return FunctionScopes.back()->NeedsScopeChecking();
727 return false;
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000728 }
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000729
John McCallb60a77e2010-08-01 00:26:45 +0000730 void setFunctionHasBranchIntoScope() {
731 if (!FunctionScopes.empty())
732 FunctionScopes.back()->HasBranchIntoScope = true;
733 }
734
735 void setFunctionHasBranchProtectedScope() {
736 if (!FunctionScopes.empty())
737 FunctionScopes.back()->HasBranchProtectedScope = true;
738 }
739
740 void setFunctionHasIndirectGoto() {
741 if (!FunctionScopes.empty())
742 FunctionScopes.back()->HasIndirectGoto = true;
743 }
744
745
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000746 bool hasAnyErrorsInThisFunction() const;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000747
Douglas Gregor9ea9bdb2010-03-01 23:15:13 +0000748 /// \brief Retrieve the current block, if any.
749 BlockScopeInfo *getCurBlock();
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000750
Ryan Flynn7b1fdbd2009-07-31 02:52:19 +0000751 /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
752 llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
Mike Stump1eb44332009-09-09 15:08:12 +0000753
Reid Spencer5f016e22007-07-11 17:01:13 +0000754 //===--------------------------------------------------------------------===//
755 // Type Analysis / Processing: SemaType.cpp.
756 //
John McCall04a67a62010-02-05 21:31:56 +0000757
Douglas Gregor2dc0e642009-03-23 23:06:20 +0000758 QualType adjustParameterType(QualType T);
John McCall28654742010-06-05 06:41:15 +0000759 QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs);
760 QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVR) {
761 return BuildQualifiedType(T, Loc, Qualifiers::fromCVRMask(CVR));
762 }
763 QualType BuildPointerType(QualType T,
Douglas Gregorcd281c32009-02-28 00:25:32 +0000764 SourceLocation Loc, DeclarationName Entity);
John McCall28654742010-06-05 06:41:15 +0000765 QualType BuildReferenceType(QualType T, bool LValueRef,
Douglas Gregorcd281c32009-02-28 00:25:32 +0000766 SourceLocation Loc, DeclarationName Entity);
767 QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
768 Expr *ArraySize, unsigned Quals,
Douglas Gregor7e7eb3d2009-07-06 15:59:29 +0000769 SourceRange Brackets, DeclarationName Entity);
Mike Stump1eb44332009-09-09 15:08:12 +0000770 QualType BuildExtVectorType(QualType T, ExprArg ArraySize,
Douglas Gregor9cdda0c2009-06-17 21:51:59 +0000771 SourceLocation AttrLoc);
Douglas Gregor724651c2009-02-28 01:04:19 +0000772 QualType BuildFunctionType(QualType T,
773 QualType *ParamTypes, unsigned NumParamTypes,
774 bool Variadic, unsigned Quals,
Eli Friedmanfa869542010-08-05 02:54:05 +0000775 SourceLocation Loc, DeclarationName Entity,
776 const FunctionType::ExtInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +0000777 QualType BuildMemberPointerType(QualType T, QualType Class,
John McCall28654742010-06-05 06:41:15 +0000778 SourceLocation Loc,
Douglas Gregor949bf692009-06-09 22:17:39 +0000779 DeclarationName Entity);
John McCall28654742010-06-05 06:41:15 +0000780 QualType BuildBlockPointerType(QualType T,
Anders Carlsson9a917e42009-06-12 22:56:54 +0000781 SourceLocation Loc, DeclarationName Entity);
John McCallbf1a0282010-06-04 23:28:52 +0000782 TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S,
783 TagDecl **OwnedDecl = 0);
Douglas Gregor05baacb2010-04-12 23:19:01 +0000784 TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T,
785 TypeSourceInfo *ReturnTypeInfo);
John McCalla93c9342009-12-07 02:54:59 +0000786 /// \brief Create a LocInfoType to hold the given QualType and TypeSourceInfo.
787 QualType CreateLocInfoType(QualType T, TypeSourceInfo *TInfo);
Douglas Gregor10bd3682008-11-17 22:58:34 +0000788 DeclarationName GetNameForDeclarator(Declarator &D);
John McCall129e2df2009-11-30 22:42:35 +0000789 DeclarationName GetNameFromUnqualifiedId(const UnqualifiedId &Name);
John McCalla93c9342009-12-07 02:54:59 +0000790 static QualType GetTypeFromParser(TypeTy *Ty, TypeSourceInfo **TInfo = 0);
Sebastian Redlef65f062009-05-29 18:02:33 +0000791 bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range);
Sebastian Redl6a7330c2009-05-29 15:01:05 +0000792 bool CheckDistantExceptionSpec(QualType T);
Douglas Gregore13ad832010-02-12 07:32:17 +0000793 bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
Sebastian Redl4994d2d2009-07-04 11:39:00 +0000794 bool CheckEquivalentExceptionSpec(
795 const FunctionProtoType *Old, SourceLocation OldLoc,
796 const FunctionProtoType *New, SourceLocation NewLoc);
Sebastian Redl37c38ec2009-10-14 16:09:29 +0000797 bool CheckEquivalentExceptionSpec(
798 const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
Sebastian Redldced2262009-10-11 09:03:14 +0000799 const FunctionProtoType *Old, SourceLocation OldLoc,
Douglas Gregore13ad832010-02-12 07:32:17 +0000800 const FunctionProtoType *New, SourceLocation NewLoc,
Douglas Gregor2eef8292010-03-24 07:14:45 +0000801 bool *MissingExceptionSpecification = 0,
Douglas Gregore13ad832010-02-12 07:32:17 +0000802 bool *MissingEmptyExceptionSpecification = 0);
Sebastian Redl37c38ec2009-10-14 16:09:29 +0000803 bool CheckExceptionSpecSubset(
804 const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
Sebastian Redl23c7d062009-07-07 20:29:57 +0000805 const FunctionProtoType *Superset, SourceLocation SuperLoc,
806 const FunctionProtoType *Subset, SourceLocation SubLoc);
Sebastian Redl37c38ec2009-10-14 16:09:29 +0000807 bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID,
Sebastian Redldced2262009-10-11 09:03:14 +0000808 const FunctionProtoType *Target, SourceLocation TargetLoc,
809 const FunctionProtoType *Source, SourceLocation SourceLoc);
Douglas Gregor10bd3682008-11-17 22:58:34 +0000810
Sebastian Redlcee63fb2008-12-02 14:43:59 +0000811 virtual TypeResult ActOnTypeName(Scope *S, Declarator &D);
Sebastian Redl37d6de32008-11-08 13:00:26 +0000812
Anders Carlsson91a0cc92009-08-26 22:33:56 +0000813 bool RequireCompleteType(SourceLocation Loc, QualType T,
Anders Carlsson8c8d9192009-10-09 23:51:55 +0000814 const PartialDiagnostic &PD,
Douglas Gregorfe6b2d42010-03-29 23:34:08 +0000815 std::pair<SourceLocation, PartialDiagnostic> Note);
816 bool RequireCompleteType(SourceLocation Loc, QualType T,
817 const PartialDiagnostic &PD);
818 bool RequireCompleteType(SourceLocation Loc, QualType T,
819 unsigned DiagID);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000820
Abramo Bagnara465d41b2010-05-11 21:36:43 +0000821 QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
822 const CXXScopeSpec &SS, QualType T);
Douglas Gregore6258932009-03-19 00:39:20 +0000823
Anders Carlssonaf017e62009-06-29 22:58:55 +0000824 QualType BuildTypeofExprType(Expr *E);
825 QualType BuildDecltypeType(Expr *E);
Mike Stump1eb44332009-09-09 15:08:12 +0000826
Reid Spencer5f016e22007-07-11 17:01:13 +0000827 //===--------------------------------------------------------------------===//
828 // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
829 //
Chris Lattner21ff9c92009-03-05 01:25:28 +0000830
831 /// getDeclName - Return a pretty name for the specified decl if possible, or
Mike Stump1eb44332009-09-09 15:08:12 +0000832 /// an empty string if not. This is used for pretty crash reporting.
Chris Lattnerb28317a2009-03-28 19:18:32 +0000833 virtual std::string getDeclName(DeclPtrTy D);
Mike Stump1eb44332009-09-09 15:08:12 +0000834
Chris Lattner682bf922009-03-29 16:50:03 +0000835 DeclGroupPtrTy ConvertDeclToDeclGroup(DeclPtrTy Ptr);
836
Fariborz Jahanian3fe10412010-07-22 18:24:20 +0000837 void DiagnoseUseOfUnimplementedSelectors();
838
Mike Stump1eb44332009-09-09 15:08:12 +0000839 virtual TypeTy *getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +0000840 Scope *S, CXXScopeSpec *SS,
Douglas Gregorf6e6fc82009-11-20 22:03:38 +0000841 bool isClassName = false,
842 TypeTy *ObjectType = 0);
Chris Lattner4c97d762009-04-12 21:49:30 +0000843 virtual DeclSpec::TST isTagName(IdentifierInfo &II, Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000844 virtual bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
Douglas Gregora786fdb2009-10-13 23:27:22 +0000845 SourceLocation IILoc,
846 Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +0000847 CXXScopeSpec *SS,
Douglas Gregora786fdb2009-10-13 23:27:22 +0000848 TypeTy *&SuggestedType);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000849
Chris Lattner682bf922009-03-29 16:50:03 +0000850 virtual DeclPtrTy ActOnDeclarator(Scope *S, Declarator &D) {
Douglas Gregore542c862009-06-23 23:11:28 +0000851 return HandleDeclarator(S, D, MultiTemplateParamsArg(*this), false);
Douglas Gregor584049d2008-12-15 23:53:10 +0000852 }
Mike Stump1eb44332009-09-09 15:08:12 +0000853
854 DeclPtrTy HandleDeclarator(Scope *S, Declarator &D,
Douglas Gregore542c862009-06-23 23:11:28 +0000855 MultiTemplateParamsArg TemplateParameterLists,
856 bool IsFunctionDefinition);
John McCall68263142009-11-18 22:49:29 +0000857 void RegisterLocallyScopedExternCDecl(NamedDecl *ND,
858 const LookupResult &Previous,
Douglas Gregor63935192009-03-02 00:19:53 +0000859 Scope *S);
Eli Friedman85a53192009-04-07 19:37:57 +0000860 void DiagnoseFunctionSpecifiers(Declarator& D);
John McCall053f4bd2010-03-22 09:20:08 +0000861 void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R);
862 void CheckShadow(Scope *S, VarDecl *D);
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000863 NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
John McCalla93c9342009-12-07 02:54:59 +0000864 QualType R, TypeSourceInfo *TInfo,
John McCall68263142009-11-18 22:49:29 +0000865 LookupResult &Previous, bool &Redeclaration);
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000866 NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
John McCalla93c9342009-12-07 02:54:59 +0000867 QualType R, TypeSourceInfo *TInfo,
John McCall68263142009-11-18 22:49:29 +0000868 LookupResult &Previous,
Douglas Gregordfe3f2d2009-07-22 17:18:37 +0000869 MultiTemplateParamsArg TemplateParamLists,
Douglas Gregorcda9c672009-02-16 17:45:42 +0000870 bool &Redeclaration);
John McCall68263142009-11-18 22:49:29 +0000871 void CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous,
Douglas Gregor3d7a12a2009-03-25 23:32:15 +0000872 bool &Redeclaration);
Douglas Gregor4afa39d2009-01-20 01:17:11 +0000873 NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
John McCalla93c9342009-12-07 02:54:59 +0000874 QualType R, TypeSourceInfo *TInfo,
John McCall68263142009-11-18 22:49:29 +0000875 LookupResult &Previous,
Douglas Gregore542c862009-06-23 23:11:28 +0000876 MultiTemplateParamsArg TemplateParamLists,
Douglas Gregor04495c82009-02-24 01:23:02 +0000877 bool IsFunctionDefinition,
Chris Lattnereaaebc72009-04-25 08:06:05 +0000878 bool &Redeclaration);
Sebastian Redla165da02009-11-18 21:51:29 +0000879 void AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
John McCall9f54ad42009-12-10 09:41:52 +0000880 void CheckFunctionDeclaration(Scope *S,
881 FunctionDecl *NewFD, LookupResult &Previous,
Douglas Gregorfd056bc2009-10-13 16:30:37 +0000882 bool IsExplicitSpecialization,
Mike Stump1eb44332009-09-09 15:08:12 +0000883 bool &Redeclaration,
Douglas Gregor2dc0e642009-03-23 23:06:20 +0000884 bool &OverloadableAttrRequired);
John McCall8c4859a2009-07-24 03:03:21 +0000885 void CheckMain(FunctionDecl *FD);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000886 virtual DeclPtrTy ActOnParamDeclarator(Scope *S, Declarator &D);
John McCall82dc0092010-06-04 11:21:44 +0000887 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC,
888 SourceLocation Loc,
889 QualType T);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000890 ParmVarDecl *CheckParameter(DeclContext *DC,
Douglas Gregorcb27b0f2010-04-12 07:48:19 +0000891 TypeSourceInfo *TSInfo, QualType T,
892 IdentifierInfo *Name,
893 SourceLocation NameLoc,
Douglas Gregor16573fa2010-04-19 22:54:31 +0000894 VarDecl::StorageClass StorageClass,
895 VarDecl::StorageClass StorageClassAsWritten);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000896 virtual void ActOnParamDefaultArgument(DeclPtrTy param,
Chris Lattner04421082008-04-08 04:40:51 +0000897 SourceLocation EqualLoc,
Sebastian Redlf53597f2009-03-15 17:47:39 +0000898 ExprArg defarg);
Mike Stump1eb44332009-09-09 15:08:12 +0000899 virtual void ActOnParamUnparsedDefaultArgument(DeclPtrTy param,
Anders Carlsson5e300d12009-06-12 16:51:40 +0000900 SourceLocation EqualLoc,
901 SourceLocation ArgLoc);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000902 virtual void ActOnParamDefaultArgumentError(DeclPtrTy param);
Anders Carlssoned961f92009-08-25 02:29:20 +0000903 bool SetParamDefaultArgument(ParmVarDecl *Param, ExprArg DefaultArg,
904 SourceLocation EqualLoc);
905
Mike Stump1eb44332009-09-09 15:08:12 +0000906
Anders Carlsson5e300d12009-06-12 16:51:40 +0000907 // Contains the locations of the beginning of unparsed default
908 // argument locations.
909 llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs;
910
Anders Carlsson9abf2ae2009-08-16 05:13:48 +0000911 virtual void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000912 void AddInitializerToDecl(DeclPtrTy dcl, ExprArg init, bool DirectInit);
Anders Carlsson6a75cd92009-07-11 00:34:39 +0000913 void ActOnUninitializedDecl(DeclPtrTy dcl, bool TypeContainsUndeducedAuto);
John McCall7727acf2010-03-31 02:13:20 +0000914 virtual void ActOnInitializerError(DeclPtrTy Dcl);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000915 virtual void SetDeclDeleted(DeclPtrTy dcl, SourceLocation DelLoc);
Eli Friedmanc1dc6532009-05-29 01:49:24 +0000916 virtual DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
917 DeclPtrTy *Group,
Chris Lattner682bf922009-03-29 16:50:03 +0000918 unsigned NumDecls);
Douglas Gregora3a83512009-04-01 23:51:29 +0000919 virtual void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
920 SourceLocation LocAfterDecls);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000921 virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, Declarator &D);
922 virtual DeclPtrTy ActOnStartOfFunctionDef(Scope *S, DeclPtrTy D);
923 virtual void ActOnStartOfObjCMethodDef(Scope *S, DeclPtrTy D);
Sebastian Redlb8a6aca2009-01-19 22:31:54 +0000924
Chris Lattnerb28317a2009-03-28 19:18:32 +0000925 virtual DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body);
Douglas Gregore2c31ff2009-05-15 17:59:04 +0000926 DeclPtrTy ActOnFinishFunctionBody(DeclPtrTy Decl, StmtArg Body,
927 bool IsInstantiation);
Mike Stump1eb44332009-09-09 15:08:12 +0000928
Douglas Gregore0762c92009-06-19 23:52:42 +0000929 /// \brief Diagnose any unused parameters in the given sequence of
930 /// ParmVarDecl pointers.
931 template<typename InputIterator>
932 void DiagnoseUnusedParameters(InputIterator Param, InputIterator ParamEnd) {
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000933 if (Diags.getDiagnosticLevel(diag::warn_unused_parameter) ==
Douglas Gregorfc2ca562010-04-07 20:29:57 +0000934 Diagnostic::Ignored)
935 return;
Douglas Gregorc077e452010-04-19 23:56:20 +0000936
937 // Don't diagnose unused-parameter errors in template instantiations; we
938 // will already have done so in the template itself.
939 if (!ActiveTemplateInstantiations.empty())
940 return;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +0000941
Douglas Gregore0762c92009-06-19 23:52:42 +0000942 for (; Param != ParamEnd; ++Param) {
Mike Stump1eb44332009-09-09 15:08:12 +0000943 if (!(*Param)->isUsed() && (*Param)->getDeclName() &&
Douglas Gregorc077e452010-04-19 23:56:20 +0000944 !(*Param)->template hasAttr<UnusedAttr>()) {
Douglas Gregore0762c92009-06-19 23:52:42 +0000945 Diag((*Param)->getLocation(), diag::warn_unused_parameter)
946 << (*Param)->getDeclName();
Douglas Gregorc077e452010-04-19 23:56:20 +0000947 }
Douglas Gregore0762c92009-06-19 23:52:42 +0000948 }
949 }
Mike Stump1eb44332009-09-09 15:08:12 +0000950
Chris Lattner5af280c2009-04-19 04:46:21 +0000951 void DiagnoseInvalidJumps(Stmt *Body);
Chris Lattnerb28317a2009-03-28 19:18:32 +0000952 virtual DeclPtrTy ActOnFileScopeAsmDecl(SourceLocation Loc, ExprArg expr);
Anders Carlssondfab6cb2008-02-08 00:33:21 +0000953
Steve Naroffb216c882007-10-09 22:01:59 +0000954 /// Scope actions.
955 virtual void ActOnPopScope(SourceLocation Loc, Scope *S);
956 virtual void ActOnTranslationUnitScope(SourceLocation Loc, Scope *S);
Reid Spencer5f016e22007-07-11 17:01:13 +0000957
958 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
959 /// no declarator (e.g. "struct foo;") is parsed.
John McCallaec03712010-05-21 20:45:30 +0000960 virtual DeclPtrTy ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
961 DeclSpec &DS);
Mike Stump1eb44332009-09-09 15:08:12 +0000962
Mike Stump1eb44332009-09-09 15:08:12 +0000963 virtual DeclPtrTy BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
John McCallaec03712010-05-21 20:45:30 +0000964 AccessSpecifier AS,
Chris Lattnerb28317a2009-03-28 19:18:32 +0000965 RecordDecl *Record);
Douglas Gregorbcbffc42009-01-07 00:43:41 +0000966
Mike Stump1eb44332009-09-09 15:08:12 +0000967 bool isAcceptableTagRedeclaration(const TagDecl *Previous,
Douglas Gregor501c5ce2009-05-14 16:41:31 +0000968 TagDecl::TagKind NewTag,
969 SourceLocation NewTagLoc,
970 const IdentifierInfo &Name);
Douglas Gregored4ec8f2009-05-03 17:18:57 +0000971
John McCall0f434ec2009-07-31 02:45:11 +0000972 virtual DeclPtrTy ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +0000973 SourceLocation KWLoc, CXXScopeSpec &SS,
Chris Lattnerb28317a2009-03-28 19:18:32 +0000974 IdentifierInfo *Name, SourceLocation NameLoc,
Douglas Gregor402abb52009-05-28 23:31:59 +0000975 AttributeList *Attr, AccessSpecifier AS,
Douglas Gregor7cdbc582009-07-22 23:48:44 +0000976 MultiTemplateParamsArg TemplateParameterLists,
John McCallc4e70192009-09-11 04:59:25 +0000977 bool &OwnedDecl, bool &IsDependent);
978
979 virtual TypeResult ActOnDependentTag(Scope *S,
980 unsigned TagSpec,
981 TagUseKind TUK,
982 const CXXScopeSpec &SS,
983 IdentifierInfo *Name,
984 SourceLocation TagLoc,
985 SourceLocation NameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +0000986
Chris Lattnerb28317a2009-03-28 19:18:32 +0000987 virtual void ActOnDefs(Scope *S, DeclPtrTy TagD, SourceLocation DeclStart,
Chris Lattner06f54852008-08-23 02:00:52 +0000988 IdentifierInfo *ClassName,
Chris Lattnerb28317a2009-03-28 19:18:32 +0000989 llvm::SmallVectorImpl<DeclPtrTy> &Decls);
990 virtual DeclPtrTy ActOnField(Scope *S, DeclPtrTy TagD,
991 SourceLocation DeclStart,
992 Declarator &D, ExprTy *BitfieldWidth);
Chris Lattner24793662009-03-05 22:45:59 +0000993
994 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
Douglas Gregor4dd55f52009-03-11 20:50:30 +0000995 Declarator &D, Expr *BitfieldWidth,
996 AccessSpecifier AS);
Chris Lattner24793662009-03-05 22:45:59 +0000997
Argyrios Kyrtzidisa1d56622009-08-19 01:27:57 +0000998 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
John McCalla93c9342009-12-07 02:54:59 +0000999 TypeSourceInfo *TInfo,
Douglas Gregor3cf538d2009-03-11 18:59:21 +00001000 RecordDecl *Record, SourceLocation Loc,
1001 bool Mutable, Expr *BitfieldWidth,
Steve Naroffea218b82009-07-14 14:58:18 +00001002 SourceLocation TSSL,
Douglas Gregor4dd55f52009-03-11 20:50:30 +00001003 AccessSpecifier AS, NamedDecl *PrevDecl,
Douglas Gregor3cf538d2009-03-11 18:59:21 +00001004 Declarator *D = 0);
Douglas Gregor1f2023a2009-07-22 18:25:24 +00001005
1006 enum CXXSpecialMember {
Anders Carlsson3b8c53b2010-04-22 05:40:53 +00001007 CXXInvalid = -1,
1008 CXXConstructor = 0,
Douglas Gregor1f2023a2009-07-22 18:25:24 +00001009 CXXCopyConstructor = 1,
1010 CXXCopyAssignment = 2,
1011 CXXDestructor = 3
1012 };
1013 void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem);
Anders Carlsson3b8c53b2010-04-22 05:40:53 +00001014 CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);
Mike Stump1eb44332009-09-09 15:08:12 +00001015
Chris Lattnerb28317a2009-03-28 19:18:32 +00001016 virtual DeclPtrTy ActOnIvar(Scope *S, SourceLocation DeclStart,
Fariborz Jahanian496b5a82009-06-05 18:16:35 +00001017 DeclPtrTy IntfDecl,
Chris Lattnerb28317a2009-03-28 19:18:32 +00001018 Declarator &D, ExprTy *BitfieldWidth,
1019 tok::ObjCKeywordKind visibility);
Fariborz Jahanian1d78cc42008-04-10 23:32:45 +00001020
Steve Narofff13271f2007-09-14 23:09:53 +00001021 // This is used for both record definitions and ObjC interface declarations.
Fariborz Jahanian9d048ff2007-09-29 00:54:24 +00001022 virtual void ActOnFields(Scope* S,
Chris Lattnerb28317a2009-03-28 19:18:32 +00001023 SourceLocation RecLoc, DeclPtrTy TagDecl,
1024 DeclPtrTy *Fields, unsigned NumFields,
Daniel Dunbar1bfe1c22008-10-03 02:03:53 +00001025 SourceLocation LBrac, SourceLocation RBrac,
1026 AttributeList *AttrList);
Douglas Gregor72de6672009-01-08 20:45:30 +00001027
1028 /// ActOnTagStartDefinition - Invoked when we have entered the
1029 /// scope of a tag's definition (e.g., for an enumeration, class,
1030 /// struct, or union).
Chris Lattnerb28317a2009-03-28 19:18:32 +00001031 virtual void ActOnTagStartDefinition(Scope *S, DeclPtrTy TagDecl);
Douglas Gregor72de6672009-01-08 20:45:30 +00001032
John McCallf9368152009-12-20 07:58:13 +00001033 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
1034 /// C++ record definition's base-specifiers clause and are starting its
1035 /// member declarations.
1036 virtual void ActOnStartCXXMemberDeclarations(Scope *S, DeclPtrTy TagDecl,
1037 SourceLocation LBraceLoc);
1038
Douglas Gregor72de6672009-01-08 20:45:30 +00001039 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
1040 /// the definition of a tag (enumeration, class, struct, or union).
Argyrios Kyrtzidis07a5b282009-07-14 03:17:52 +00001041 virtual void ActOnTagFinishDefinition(Scope *S, DeclPtrTy TagDecl,
1042 SourceLocation RBraceLoc);
Douglas Gregor72de6672009-01-08 20:45:30 +00001043
John McCalldb7bb4a2010-03-17 00:38:33 +00001044 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
1045 /// error parsing the definition of a tag.
1046 virtual void ActOnTagDefinitionError(Scope *S, DeclPtrTy TagDecl);
1047
Douglas Gregor879fd492009-03-17 19:05:46 +00001048 EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
1049 EnumConstantDecl *LastEnumConst,
1050 SourceLocation IdLoc,
1051 IdentifierInfo *Id,
1052 ExprArg val);
1053
Chris Lattnerb28317a2009-03-28 19:18:32 +00001054 virtual DeclPtrTy ActOnEnumConstant(Scope *S, DeclPtrTy EnumDecl,
1055 DeclPtrTy LastEnumConstant,
1056 SourceLocation IdLoc, IdentifierInfo *Id,
1057 SourceLocation EqualLoc, ExprTy *Val);
Mike Stumpc6e35aa2009-05-16 07:06:02 +00001058 virtual void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
1059 SourceLocation RBraceLoc, DeclPtrTy EnumDecl,
Edward O'Callaghanfee13812009-08-08 14:36:57 +00001060 DeclPtrTy *Elements, unsigned NumElements,
1061 Scope *S, AttributeList *Attr);
Sebastian Redl37d6de32008-11-08 13:00:26 +00001062
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00001063 DeclContext *getContainingDC(DeclContext *DC);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00001064
Chris Lattner0ed844b2008-04-04 06:12:32 +00001065 /// Set the current declaration context until it gets popped.
Douglas Gregor44b43212008-12-11 16:49:14 +00001066 void PushDeclContext(Scope *S, DeclContext *DC);
Chris Lattnerb048c982008-04-06 04:47:34 +00001067 void PopDeclContext();
Mike Stump1eb44332009-09-09 15:08:12 +00001068
Argyrios Kyrtzidis1d175532009-06-17 23:15:40 +00001069 /// EnterDeclaratorContext - Used when we must lookup names in the context
1070 /// of a declarator's nested name specifier.
1071 void EnterDeclaratorContext(Scope *S, DeclContext *DC);
1072 void ExitDeclaratorContext(Scope *S);
Mike Stump1eb44332009-09-09 15:08:12 +00001073
Anders Carlsson8517d9b2009-08-08 17:45:02 +00001074 DeclContext *getFunctionLevelDeclContext();
Mike Stump1eb44332009-09-09 15:08:12 +00001075
Chris Lattner371f2582008-12-04 23:50:19 +00001076 /// getCurFunctionDecl - If inside of a function body, this returns a pointer
1077 /// to the function decl for the function being parsed. If we're currently
1078 /// in a 'block', this returns the containing context.
1079 FunctionDecl *getCurFunctionDecl();
Mike Stump1eb44332009-09-09 15:08:12 +00001080
Chris Lattner371f2582008-12-04 23:50:19 +00001081 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1082 /// the method decl for the method being parsed. If we're currently
1083 /// in a 'block', this returns the containing context.
Daniel Dunbarc4a1dea2008-08-11 05:35:13 +00001084 ObjCMethodDecl *getCurMethodDecl();
Chris Lattner0ed844b2008-04-04 06:12:32 +00001085
Chris Lattner371f2582008-12-04 23:50:19 +00001086 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1087 /// or C function we're in, otherwise return null. If we're currently
1088 /// in a 'block', this returns the containing context.
1089 NamedDecl *getCurFunctionOrMethodDecl();
1090
Argyrios Kyrtzidis87f3ff02008-04-12 00:47:19 +00001091 /// Add this decl to the scope shadowed decl chains.
John McCallab88d972009-08-31 22:39:49 +00001092 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
Argyrios Kyrtzidis87f3ff02008-04-12 00:47:19 +00001093
Argyrios Kyrtzidis15a12d02008-09-09 21:18:04 +00001094 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
1095 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
1096 /// true if 'D' belongs to the given declaration context.
Douglas Gregor2531c2d2009-09-28 00:47:05 +00001097 bool isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S = 0);
Argyrios Kyrtzidis15a12d02008-09-09 21:18:04 +00001098
John McCallab88d972009-08-31 22:39:49 +00001099 /// Finds the scope corresponding to the given decl context, if it
1100 /// happens to be an enclosing scope. Otherwise return NULL.
1101 Scope *getScopeForDeclContext(Scope *S, DeclContext *DC) {
John McCall1a26c272009-09-02 01:07:03 +00001102 DeclContext *TargetDC = DC->getPrimaryContext();
John McCallab88d972009-08-31 22:39:49 +00001103 do {
John McCall1a26c272009-09-02 01:07:03 +00001104 if (DeclContext *ScopeDC = (DeclContext*) S->getEntity())
1105 if (ScopeDC->getPrimaryContext() == TargetDC)
1106 return S;
John McCallab88d972009-08-31 22:39:49 +00001107 } while ((S = S->getParent()));
1108
1109 return NULL;
1110 }
1111
Chris Lattnerf1d705c2008-02-21 01:07:18 +00001112 /// Subroutines of ActOnDeclarator().
John McCallba6a9bd2009-10-24 08:00:42 +00001113 TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
John McCalla93c9342009-12-07 02:54:59 +00001114 TypeSourceInfo *TInfo);
John McCall68263142009-11-18 22:49:29 +00001115 void MergeTypeDefDecl(TypedefDecl *New, LookupResult &OldDecls);
Douglas Gregorcda9c672009-02-16 17:45:42 +00001116 bool MergeFunctionDecl(FunctionDecl *New, Decl *Old);
Douglas Gregor04495c82009-02-24 01:23:02 +00001117 bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old);
John McCall68263142009-11-18 22:49:29 +00001118 void MergeVarDecl(VarDecl *New, LookupResult &OldDecls);
Douglas Gregorcda9c672009-02-16 17:45:42 +00001119 bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001120
Douglas Gregor68647482009-12-16 03:45:30 +00001121 // AssignmentAction - This is used by all the assignment diagnostic functions
1122 // to represent what is actually causing the operation
1123 enum AssignmentAction {
1124 AA_Assigning,
1125 AA_Passing,
1126 AA_Returning,
1127 AA_Converting,
1128 AA_Initializing,
1129 AA_Sending,
1130 AA_Casting
1131 };
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001132
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001133 /// C++ Overloading.
John McCall871b2e72009-12-09 03:35:25 +00001134 enum OverloadKind {
1135 /// This is a legitimate overload: the existing declarations are
1136 /// functions or function templates with different signatures.
1137 Ovl_Overload,
1138
1139 /// This is not an overload because the signature exactly matches
1140 /// an existing declaration.
1141 Ovl_Match,
1142
1143 /// This is not an overload because the lookup results contain a
1144 /// non-function.
1145 Ovl_NonFunction
1146 };
John McCallad00b772010-06-16 08:42:20 +00001147 OverloadKind CheckOverload(Scope *S,
1148 FunctionDecl *New,
John McCall9f54ad42009-12-10 09:41:52 +00001149 const LookupResult &OldDecls,
John McCallad00b772010-06-16 08:42:20 +00001150 NamedDecl *&OldDecl,
1151 bool IsForUsingDecl);
1152 bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl);
John McCall68263142009-11-18 22:49:29 +00001153
John McCall369371c2010-06-04 02:29:22 +00001154 bool TryImplicitConversion(InitializationSequence &Sequence,
1155 const InitializedEntity &Entity,
1156 Expr *From,
1157 bool SuppressUserConversions,
1158 bool AllowExplicit,
1159 bool InOverloadResolution);
1160
Mike Stump1eb44332009-09-09 15:08:12 +00001161 ImplicitConversionSequence
Anders Carlsson2974b5c2009-08-27 17:14:02 +00001162 TryImplicitConversion(Expr* From, QualType ToType,
Anders Carlssonda7a18b2009-08-27 17:24:15 +00001163 bool SuppressUserConversions,
1164 bool AllowExplicit,
Douglas Gregor3fbaf3e2010-04-17 22:01:05 +00001165 bool InOverloadResolution);
Anders Carlsson08972922009-08-28 15:33:32 +00001166 bool IsStandardConversion(Expr *From, QualType ToType,
1167 bool InOverloadResolution,
Douglas Gregor60d62c22008-10-31 16:23:19 +00001168 StandardConversionSequence& SCS);
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001169 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
1170 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
Douglas Gregor5cdf8212009-02-12 00:15:05 +00001171 bool IsComplexPromotion(QualType FromType, QualType ToType);
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001172 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
Anders Carlsson08972922009-08-28 15:33:32 +00001173 bool InOverloadResolution,
Douglas Gregor45920e82008-12-19 17:40:08 +00001174 QualType& ConvertedType, bool &IncompatibleObjC);
Douglas Gregorc7887512008-12-19 19:13:09 +00001175 bool isObjCPointerConversion(QualType FromType, QualType ToType,
1176 QualType& ConvertedType, bool &IncompatibleObjC);
Fariborz Jahaniand8d34412010-05-03 21:06:18 +00001177 bool FunctionArgTypesAreEqual (FunctionProtoType* OldType,
1178 FunctionProtoType* NewType);
1179
Sebastian Redla82e4ae2009-11-14 21:15:49 +00001180 bool CheckPointerConversion(Expr *From, QualType ToType,
1181 CastExpr::CastKind &Kind,
John McCallf871d0c2010-08-07 06:22:56 +00001182 CXXCastPath& BasePath,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00001183 bool IgnoreBaseAccess);
Sebastian Redl4433aaf2009-01-25 19:43:20 +00001184 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
Douglas Gregorce940492009-09-25 04:25:58 +00001185 bool InOverloadResolution,
Sebastian Redl4433aaf2009-01-25 19:43:20 +00001186 QualType &ConvertedType);
Anders Carlsson27a5b9b2009-08-22 23:33:40 +00001187 bool CheckMemberPointerConversion(Expr *From, QualType ToType,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00001188 CastExpr::CastKind &Kind,
John McCallf871d0c2010-08-07 06:22:56 +00001189 CXXCastPath &BasePath,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00001190 bool IgnoreBaseAccess);
Douglas Gregor98cd5992008-10-21 23:43:52 +00001191 bool IsQualificationConversion(QualType FromType, QualType ToType);
Fariborz Jahanian34acd3e2009-09-15 19:12:21 +00001192 OverloadingResult IsUserDefinedConversion(Expr *From, QualType ToType,
Douglas Gregor09f41cf2009-01-14 15:45:31 +00001193 UserDefinedConversionSequence& User,
Fariborz Jahanian78cf9a22009-09-15 00:10:11 +00001194 OverloadCandidateSet& Conversions,
Douglas Gregor3fbaf3e2010-04-17 22:01:05 +00001195 bool AllowExplicit);
Fariborz Jahaniancc5306a2009-11-18 18:26:29 +00001196 bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001197
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001198
Mike Stump1eb44332009-09-09 15:08:12 +00001199 ImplicitConversionSequence::CompareKind
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001200 CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
1201 const ImplicitConversionSequence& ICS2);
1202
Mike Stump1eb44332009-09-09 15:08:12 +00001203 ImplicitConversionSequence::CompareKind
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001204 CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
1205 const StandardConversionSequence& SCS2);
1206
Mike Stump1eb44332009-09-09 15:08:12 +00001207 ImplicitConversionSequence::CompareKind
Douglas Gregor57373262008-10-22 14:17:15 +00001208 CompareQualificationConversions(const StandardConversionSequence& SCS1,
1209 const StandardConversionSequence& SCS2);
1210
Douglas Gregorbc0805a2008-10-23 00:40:37 +00001211 ImplicitConversionSequence::CompareKind
1212 CompareDerivedToBaseConversions(const StandardConversionSequence& SCS1,
1213 const StandardConversionSequence& SCS2);
1214
Douglas Gregor18ef5e22009-12-18 05:02:21 +00001215 OwningExprResult PerformCopyInitialization(const InitializedEntity &Entity,
1216 SourceLocation EqualLoc,
1217 OwningExprResult Init);
Douglas Gregor96176b32008-11-18 23:14:02 +00001218 ImplicitConversionSequence
John McCall701c89e2009-12-03 04:06:58 +00001219 TryObjectArgumentInitialization(QualType FromType, CXXMethodDecl *Method,
1220 CXXRecordDecl *ActingContext);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001221 bool PerformObjectArgumentInitialization(Expr *&From,
Douglas Gregor5fccd362010-03-03 23:55:11 +00001222 NestedNameSpecifier *Qualifier,
John McCall6bb80172010-03-30 21:47:33 +00001223 NamedDecl *FoundDecl,
Douglas Gregor5fccd362010-03-03 23:55:11 +00001224 CXXMethodDecl *Method);
Douglas Gregor96176b32008-11-18 23:14:02 +00001225
Douglas Gregor09f41cf2009-01-14 15:45:31 +00001226 ImplicitConversionSequence TryContextuallyConvertToBool(Expr *From);
1227 bool PerformContextuallyConvertToBool(Expr *&From);
Mike Stump1eb44332009-09-09 15:08:12 +00001228
Fariborz Jahanian79d3f042010-05-12 23:29:11 +00001229 ImplicitConversionSequence TryContextuallyConvertToObjCId(Expr *From);
1230 bool PerformContextuallyConvertToObjCId(Expr *&From);
1231
Douglas Gregorc30614b2010-06-29 23:17:37 +00001232 OwningExprResult
1233 ConvertToIntegralOrEnumerationType(SourceLocation Loc, ExprArg FromE,
1234 const PartialDiagnostic &NotIntDiag,
1235 const PartialDiagnostic &IncompleteDiag,
1236 const PartialDiagnostic &ExplicitConvDiag,
1237 const PartialDiagnostic &ExplicitConvNote,
1238 const PartialDiagnostic &AmbigDiag,
Douglas Gregor6bc574d2010-06-30 00:20:43 +00001239 const PartialDiagnostic &AmbigNote,
1240 const PartialDiagnostic &ConvDiag);
Douglas Gregorc30614b2010-06-29 23:17:37 +00001241
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001242 bool PerformObjectMemberConversion(Expr *&From,
Douglas Gregor5fccd362010-03-03 23:55:11 +00001243 NestedNameSpecifier *Qualifier,
John McCall6bb80172010-03-30 21:47:33 +00001244 NamedDecl *FoundDecl,
Douglas Gregor5fccd362010-03-03 23:55:11 +00001245 NamedDecl *Member);
Douglas Gregor09f41cf2009-01-14 15:45:31 +00001246
John McCall6ff07852009-08-07 22:18:02 +00001247 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
1248 // TODO: make this is a typesafe union.
1249 typedef llvm::SmallPtrSet<DeclContext *, 16> AssociatedNamespaceSet;
Douglas Gregor063daf62009-03-13 18:40:31 +00001250 typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
1251
John McCall6e266892010-01-26 03:27:55 +00001252 void AddOverloadCandidate(NamedDecl *Function,
John McCall9aa472c2010-03-19 07:35:19 +00001253 DeclAccessPair FoundDecl,
John McCall6e266892010-01-26 03:27:55 +00001254 Expr **Args, unsigned NumArgs,
1255 OverloadCandidateSet &CandidateSet);
1256
Mike Stump1eb44332009-09-09 15:08:12 +00001257 void AddOverloadCandidate(FunctionDecl *Function,
John McCall9aa472c2010-03-19 07:35:19 +00001258 DeclAccessPair FoundDecl,
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001259 Expr **Args, unsigned NumArgs,
Douglas Gregor225c41e2008-11-03 19:09:14 +00001260 OverloadCandidateSet& CandidateSet,
Sebastian Redle2b68332009-04-12 17:16:29 +00001261 bool SuppressUserConversions = false,
Douglas Gregor9c6a0e92009-09-22 15:41:20 +00001262 bool PartialOverloading = false);
John McCall6e266892010-01-26 03:27:55 +00001263 void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
Douglas Gregor063daf62009-03-13 18:40:31 +00001264 Expr **Args, unsigned NumArgs,
1265 OverloadCandidateSet& CandidateSet,
1266 bool SuppressUserConversions = false);
John McCall9aa472c2010-03-19 07:35:19 +00001267 void AddMethodCandidate(DeclAccessPair FoundDecl,
John McCall86820f52010-01-26 01:37:31 +00001268 QualType ObjectType,
1269 Expr **Args, unsigned NumArgs,
John McCall314be4e2009-11-17 07:50:12 +00001270 OverloadCandidateSet& CandidateSet,
Douglas Gregor7ec77522010-04-16 17:33:27 +00001271 bool SuppressUserConversion = false);
John McCall9aa472c2010-03-19 07:35:19 +00001272 void AddMethodCandidate(CXXMethodDecl *Method,
1273 DeclAccessPair FoundDecl,
John McCall86820f52010-01-26 01:37:31 +00001274 CXXRecordDecl *ActingContext, QualType ObjectType,
1275 Expr **Args, unsigned NumArgs,
Douglas Gregor96176b32008-11-18 23:14:02 +00001276 OverloadCandidateSet& CandidateSet,
Douglas Gregor7ec77522010-04-16 17:33:27 +00001277 bool SuppressUserConversions = false);
Douglas Gregor6b906862009-08-21 00:16:32 +00001278 void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
John McCall9aa472c2010-03-19 07:35:19 +00001279 DeclAccessPair FoundDecl,
John McCall701c89e2009-12-03 04:06:58 +00001280 CXXRecordDecl *ActingContext,
John McCalld5532b62009-11-23 01:53:49 +00001281 const TemplateArgumentListInfo *ExplicitTemplateArgs,
John McCall701c89e2009-12-03 04:06:58 +00001282 QualType ObjectType,
1283 Expr **Args, unsigned NumArgs,
Douglas Gregor6b906862009-08-21 00:16:32 +00001284 OverloadCandidateSet& CandidateSet,
Douglas Gregor7ec77522010-04-16 17:33:27 +00001285 bool SuppressUserConversions = false);
Douglas Gregore53060f2009-06-25 22:08:12 +00001286 void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
John McCall9aa472c2010-03-19 07:35:19 +00001287 DeclAccessPair FoundDecl,
John McCalld5532b62009-11-23 01:53:49 +00001288 const TemplateArgumentListInfo *ExplicitTemplateArgs,
Douglas Gregore53060f2009-06-25 22:08:12 +00001289 Expr **Args, unsigned NumArgs,
1290 OverloadCandidateSet& CandidateSet,
Douglas Gregor7ec77522010-04-16 17:33:27 +00001291 bool SuppressUserConversions = false);
Douglas Gregorf1991ea2008-11-07 22:36:19 +00001292 void AddConversionCandidate(CXXConversionDecl *Conversion,
John McCall9aa472c2010-03-19 07:35:19 +00001293 DeclAccessPair FoundDecl,
John McCall701c89e2009-12-03 04:06:58 +00001294 CXXRecordDecl *ActingContext,
Douglas Gregorf1991ea2008-11-07 22:36:19 +00001295 Expr *From, QualType ToType,
1296 OverloadCandidateSet& CandidateSet);
Douglas Gregor65ec1fd2009-08-21 23:19:43 +00001297 void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
John McCall9aa472c2010-03-19 07:35:19 +00001298 DeclAccessPair FoundDecl,
John McCall701c89e2009-12-03 04:06:58 +00001299 CXXRecordDecl *ActingContext,
Douglas Gregor65ec1fd2009-08-21 23:19:43 +00001300 Expr *From, QualType ToType,
1301 OverloadCandidateSet &CandidateSet);
Douglas Gregor106c6eb2008-11-19 22:57:39 +00001302 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
John McCall9aa472c2010-03-19 07:35:19 +00001303 DeclAccessPair FoundDecl,
John McCall701c89e2009-12-03 04:06:58 +00001304 CXXRecordDecl *ActingContext,
Douglas Gregor72564e72009-02-26 23:50:07 +00001305 const FunctionProtoType *Proto,
John McCall701c89e2009-12-03 04:06:58 +00001306 QualType ObjectTy, Expr **Args, unsigned NumArgs,
Douglas Gregor106c6eb2008-11-19 22:57:39 +00001307 OverloadCandidateSet& CandidateSet);
Douglas Gregor063daf62009-03-13 18:40:31 +00001308 void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
1309 SourceLocation OpLoc,
1310 Expr **Args, unsigned NumArgs,
1311 OverloadCandidateSet& CandidateSet,
1312 SourceRange OpRange = SourceRange());
Mike Stump1eb44332009-09-09 15:08:12 +00001313 void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
Douglas Gregoreb8f3062008-11-12 17:17:38 +00001314 Expr **Args, unsigned NumArgs,
Douglas Gregor88b4bf22009-01-13 00:52:54 +00001315 OverloadCandidateSet& CandidateSet,
Douglas Gregor09f41cf2009-01-14 15:45:31 +00001316 bool IsAssignmentOperator = false,
1317 unsigned NumContextualBoolArguments = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00001318 void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
Douglas Gregor573d9c32009-10-21 23:19:44 +00001319 SourceLocation OpLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00001320 Expr **Args, unsigned NumArgs,
Douglas Gregor74253732008-11-19 15:42:04 +00001321 OverloadCandidateSet& CandidateSet);
Douglas Gregorfa047642009-02-04 00:32:51 +00001322 void AddArgumentDependentLookupCandidates(DeclarationName Name,
John McCall6e266892010-01-26 03:27:55 +00001323 bool Operator,
Douglas Gregorfa047642009-02-04 00:32:51 +00001324 Expr **Args, unsigned NumArgs,
John McCalld5532b62009-11-23 01:53:49 +00001325 const TemplateArgumentListInfo *ExplicitTemplateArgs,
Douglas Gregor9c6a0e92009-09-22 15:41:20 +00001326 OverloadCandidateSet& CandidateSet,
1327 bool PartialOverloading = false);
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001328 bool isBetterOverloadCandidate(const OverloadCandidate& Cand1,
John McCall5769d612010-02-08 23:07:23 +00001329 const OverloadCandidate& Cand2,
1330 SourceLocation Loc);
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001331 OverloadingResult BestViableFunction(OverloadCandidateSet& CandidateSet,
Douglas Gregore0762c92009-06-19 23:52:42 +00001332 SourceLocation Loc,
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001333 OverloadCandidateSet::iterator& Best);
John McCall81201622010-01-08 04:41:39 +00001334
1335 enum OverloadCandidateDisplayKind {
1336 /// Requests that all candidates be shown. Viable candidates will
1337 /// be printed first.
1338 OCD_AllCandidates,
1339
1340 /// Requests that only viable candidates be shown.
1341 OCD_ViableCandidates
1342 };
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001343 void PrintOverloadCandidates(OverloadCandidateSet& CandidateSet,
John McCall81201622010-01-08 04:41:39 +00001344 OverloadCandidateDisplayKind OCD,
John McCallcbce6062010-01-12 07:18:19 +00001345 Expr **Args, unsigned NumArgs,
John McCall81201622010-01-08 04:41:39 +00001346 const char *Opc = 0,
1347 SourceLocation Loc = SourceLocation());
1348
John McCallb1622a12010-01-06 09:43:14 +00001349 void NoteOverloadCandidate(FunctionDecl *Fn);
John McCall1d318332010-01-12 00:44:57 +00001350 void DiagnoseAmbiguousConversion(const ImplicitConversionSequence &ICS,
1351 SourceLocation CaretLoc,
1352 const PartialDiagnostic &PDiag);
Mike Stump1eb44332009-09-09 15:08:12 +00001353
Douglas Gregor904eed32008-11-10 20:40:00 +00001354 FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType,
John McCall6bb80172010-03-30 21:47:33 +00001355 bool Complain,
1356 DeclAccessPair &Found);
Douglas Gregor4b52e252009-12-21 23:17:24 +00001357 FunctionDecl *ResolveSingleFunctionTemplateSpecialization(Expr *From);
1358
John McCall6bb80172010-03-30 21:47:33 +00001359 Expr *FixOverloadedFunctionReference(Expr *E,
John McCall161755a2010-04-06 21:38:20 +00001360 DeclAccessPair FoundDecl,
John McCall6bb80172010-03-30 21:47:33 +00001361 FunctionDecl *Fn);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001362 OwningExprResult FixOverloadedFunctionReference(OwningExprResult,
John McCall161755a2010-04-06 21:38:20 +00001363 DeclAccessPair FoundDecl,
Douglas Gregor20093b42009-12-09 23:02:17 +00001364 FunctionDecl *Fn);
Douglas Gregor904eed32008-11-10 20:40:00 +00001365
John McCall3b4294e2009-12-16 12:17:52 +00001366 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
Douglas Gregor9c6a0e92009-09-22 15:41:20 +00001367 Expr **Args, unsigned NumArgs,
1368 OverloadCandidateSet &CandidateSet,
1369 bool PartialOverloading = false);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001370
Douglas Gregor1aae80b2010-04-14 20:27:54 +00001371 OwningExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
Nuno Lopes9a84ac22009-12-16 14:20:08 +00001372 UnresolvedLookupExpr *ULE,
John McCall3b4294e2009-12-16 12:17:52 +00001373 SourceLocation LParenLoc,
1374 Expr **Args, unsigned NumArgs,
1375 SourceLocation *CommaLocs,
1376 SourceLocation RParenLoc);
Douglas Gregor063daf62009-03-13 18:40:31 +00001377
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001378 OwningExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
1379 unsigned Opc,
John McCall6e266892010-01-26 03:27:55 +00001380 const UnresolvedSetImpl &Fns,
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001381 ExprArg input);
1382
Douglas Gregor063daf62009-03-13 18:40:31 +00001383 OwningExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
1384 unsigned Opc,
John McCall6e266892010-01-26 03:27:55 +00001385 const UnresolvedSetImpl &Fns,
Douglas Gregor063daf62009-03-13 18:40:31 +00001386 Expr *LHS, Expr *RHS);
1387
Sebastian Redlf322ed62009-10-29 20:17:01 +00001388 OwningExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
1389 SourceLocation RLoc,
1390 ExprArg Base,ExprArg Idx);
1391
John McCallaa81e162009-12-01 22:10:20 +00001392 OwningExprResult
Douglas Gregor88a35142008-12-22 05:46:06 +00001393 BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
Mike Stump1eb44332009-09-09 15:08:12 +00001394 SourceLocation LParenLoc, Expr **Args,
Douglas Gregor88a35142008-12-22 05:46:06 +00001395 unsigned NumArgs, SourceLocation *CommaLocs,
1396 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00001397 ExprResult
Douglas Gregor5c37de72008-12-06 00:22:45 +00001398 BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
Douglas Gregorf9eb9052008-11-19 21:05:33 +00001399 Expr **Args, unsigned NumArgs,
Mike Stump1eb44332009-09-09 15:08:12 +00001400 SourceLocation *CommaLocs,
Douglas Gregorf9eb9052008-11-19 21:05:33 +00001401 SourceLocation RParenLoc);
Douglas Gregor8e9bebd2008-10-21 16:13:35 +00001402
Douglas Gregorfe85ced2009-08-06 03:17:00 +00001403 OwningExprResult BuildOverloadedArrowExpr(Scope *S, ExprArg Base,
1404 SourceLocation OpLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00001405
Anders Carlsson8c8d9192009-10-09 23:51:55 +00001406 /// CheckCallReturnType - Checks that a call expression's return type is
1407 /// complete. Returns true on failure. The location passed in is the location
1408 /// that best represents the call.
1409 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
1410 CallExpr *CE, FunctionDecl *FD);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001411
Mike Stump56925862009-07-28 22:04:01 +00001412 /// Helpers for dealing with blocks and functions.
Chris Lattner04421082008-04-08 04:40:51 +00001413 bool CheckParmsForFunctionDef(FunctionDecl *FD);
Chris Lattner04421082008-04-08 04:40:51 +00001414 void CheckCXXDefaultArguments(FunctionDecl *FD);
Douglas Gregor6d6eb572008-05-07 04:49:29 +00001415 void CheckExtraCXXDefaultArguments(Declarator &D);
Douglas Gregor1a0d31a2009-01-12 18:45:55 +00001416 Scope *getNonFieldDeclScope(Scope *S);
1417
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001418 /// \name Name lookup
1419 ///
1420 /// These routines provide name lookup that is used during semantic
1421 /// analysis to resolve the various kinds of names (identifiers,
1422 /// overloaded operator names, constructor names, etc.) into zero or
1423 /// more declarations within a particular scope. The major entry
1424 /// points are LookupName, which performs unqualified name lookup,
Mike Stump1eb44332009-09-09 15:08:12 +00001425 /// and LookupQualifiedName, which performs qualified name lookup.
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001426 ///
1427 /// All name lookup is performed based on some specific criteria,
1428 /// which specify what names will be visible to name lookup and how
1429 /// far name lookup should work. These criteria are important both
1430 /// for capturing language semantics (certain lookups will ignore
1431 /// certain names, for example) and for performance, since name
1432 /// lookup is often a bottleneck in the compilation of C++. Name
Douglas Gregor4c921ae2009-01-30 01:04:22 +00001433 /// lookup criteria is specified via the LookupCriteria enumeration.
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001434 ///
1435 /// The results of name lookup can vary based on the kind of name
1436 /// lookup performed, the current language, and the translation
1437 /// unit. In C, for example, name lookup will either return nothing
1438 /// (no entity found) or a single declaration. In C++, name lookup
1439 /// can additionally refer to a set of overloaded functions or
1440 /// result in an ambiguity. All of the possible results of name
1441 /// lookup are captured by the LookupResult class, which provides
1442 /// the ability to distinguish among them.
1443 //@{
Douglas Gregorf780abc2008-12-30 03:27:21 +00001444
Douglas Gregor4c921ae2009-01-30 01:04:22 +00001445 /// @brief Describes the kind of name lookup to perform.
1446 enum LookupNameKind {
1447 /// Ordinary name lookup, which finds ordinary names (functions,
1448 /// variables, typedefs, etc.) in C and most kinds of names
1449 /// (functions, variables, members, types, etc.) in C++.
1450 LookupOrdinaryName = 0,
1451 /// Tag name lookup, which finds the names of enums, classes,
1452 /// structs, and unions.
1453 LookupTagName,
1454 /// Member name lookup, which finds the names of
1455 /// class/struct/union members.
1456 LookupMemberName,
Douglas Gregorf680a0f2009-02-04 16:44:47 +00001457 // Look up of an operator name (e.g., operator+) for use with
1458 // operator overloading. This lookup is similar to ordinary name
1459 // lookup, but will ignore any declarations that are class
1460 // members.
1461 LookupOperatorName,
Douglas Gregor4c921ae2009-01-30 01:04:22 +00001462 /// Look up of a name that precedes the '::' scope resolution
Eli Friedmanb1df3332009-12-21 01:26:45 +00001463 /// operator in C++. This lookup completely ignores operator, object,
Douglas Gregor4c921ae2009-01-30 01:04:22 +00001464 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
1465 LookupNestedNameSpecifierName,
1466 /// Look up a namespace name within a C++ using directive or
1467 /// namespace alias definition, ignoring non-namespace names (C++
1468 /// [basic.lookup.udir]p1).
Douglas Gregord6f7e9d2009-02-24 20:03:32 +00001469 LookupNamespaceName,
John McCall9f54ad42009-12-10 09:41:52 +00001470 /// Look up all declarations in a scope with the given name,
1471 /// including resolved using declarations. This is appropriate
1472 /// for checking redeclarations for a using declaration.
1473 LookupUsingDeclName,
Douglas Gregor6e378de2009-04-23 23:18:26 +00001474 /// Look up an ordinary name that is going to be redeclared as a
1475 /// name with linkage. This lookup ignores any declarations that
Mike Stump1eb44332009-09-09 15:08:12 +00001476 /// are outside of the current scope unless they have linkage. See
Douglas Gregor6e378de2009-04-23 23:18:26 +00001477 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
1478 LookupRedeclarationWithLinkage,
1479 /// Look up the name of an Objective-C protocol.
Douglas Gregorbd4187b2010-04-22 23:19:50 +00001480 LookupObjCProtocolName
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001481 };
1482
Douglas Gregor48026d22010-01-11 18:40:55 +00001483 /// \brief Specifies whether (or how) name lookup is being performed for a
1484 /// redeclaration (vs. a reference).
John McCall7d384dd2009-11-18 07:57:50 +00001485 enum RedeclarationKind {
Douglas Gregor48026d22010-01-11 18:40:55 +00001486 /// \brief The lookup is a reference to this name that is not for the
1487 /// purpose of redeclaring the name.
1488 NotForRedeclaration = 0,
1489 /// \brief The lookup results will be used for redeclaration of a name,
1490 /// if an entity by that name already exists.
John McCall7d384dd2009-11-18 07:57:50 +00001491 ForRedeclaration
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001492 };
1493
Douglas Gregor2a3009a2009-02-03 19:21:40 +00001494private:
John McCalla24dc2e2009-11-17 02:14:36 +00001495 bool CppLookupName(LookupResult &R, Scope *S);
1496
Douglas Gregor2a3009a2009-02-03 19:21:40 +00001497public:
John McCallf36e02d2009-10-09 21:13:30 +00001498 /// \brief Look up a name, looking for a single declaration. Return
John McCall1bcee0a2009-12-02 08:25:40 +00001499 /// null if the results were absent, ambiguous, or overloaded.
John McCallf36e02d2009-10-09 21:13:30 +00001500 ///
1501 /// It is preferable to use the elaborated form and explicitly handle
1502 /// ambiguity and overloaded.
1503 NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
Douglas Gregorc83c6872010-04-15 22:33:43 +00001504 SourceLocation Loc,
John McCallf36e02d2009-10-09 21:13:30 +00001505 LookupNameKind NameKind,
John McCall7d384dd2009-11-18 07:57:50 +00001506 RedeclarationKind Redecl
1507 = NotForRedeclaration);
John McCallf36e02d2009-10-09 21:13:30 +00001508 bool LookupName(LookupResult &R, Scope *S,
John McCalla24dc2e2009-11-17 02:14:36 +00001509 bool AllowBuiltinCreation = false);
Douglas Gregor7d3f5762010-01-15 01:44:47 +00001510 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
1511 bool InUnqualifiedLookup = false);
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00001512 bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
John McCallf36e02d2009-10-09 21:13:30 +00001513 bool AllowBuiltinCreation = false,
John McCallf36e02d2009-10-09 21:13:30 +00001514 bool EnteringContext = false);
Douglas Gregorc83c6872010-04-15 22:33:43 +00001515 ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc);
Douglas Gregor6e378de2009-04-23 23:18:26 +00001516
Douglas Gregor3fd95ce2009-03-13 00:33:25 +00001517 void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
Mike Stump1eb44332009-09-09 15:08:12 +00001518 QualType T1, QualType T2,
John McCall6e266892010-01-26 03:27:55 +00001519 UnresolvedSetImpl &Functions);
Douglas Gregore5eee5a2010-07-02 23:12:18 +00001520 DeclContext::lookup_result LookupConstructors(CXXRecordDecl *Class);
Douglas Gregordb89f282010-07-01 22:47:18 +00001521 CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001522
Sebastian Redl644be852009-10-23 19:23:15 +00001523 void ArgumentDependentLookup(DeclarationName Name, bool Operator,
Douglas Gregor3fd95ce2009-03-13 00:33:25 +00001524 Expr **Args, unsigned NumArgs,
John McCall7edb5fd2010-01-26 07:16:45 +00001525 ADLResult &Functions);
Douglas Gregor3fd95ce2009-03-13 00:33:25 +00001526
Douglas Gregor546be3c2009-12-30 17:04:44 +00001527 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
1528 VisibleDeclConsumer &Consumer);
1529 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
1530 VisibleDeclConsumer &Consumer);
Douglas Gregordb89f282010-07-01 22:47:18 +00001531
Douglas Gregoraaf87162010-04-14 20:04:41 +00001532 /// \brief The context in which typo-correction occurs.
1533 ///
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001534 /// The typo-correction context affects which keywords (if any) are
Douglas Gregoraaf87162010-04-14 20:04:41 +00001535 /// considered when trying to correct for typos.
1536 enum CorrectTypoContext {
1537 /// \brief An unknown context, where any keyword might be valid.
1538 CTC_Unknown,
1539 /// \brief A context where no keywords are used (e.g. we expect an actual
1540 /// name).
1541 CTC_NoKeywords,
1542 /// \brief A context where we're correcting a type name.
1543 CTC_Type,
1544 /// \brief An expression context.
1545 CTC_Expression,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001546 /// \brief A type cast, or anything else that can be followed by a '<'.
Douglas Gregoraaf87162010-04-14 20:04:41 +00001547 CTC_CXXCasts,
1548 /// \brief A member lookup context.
1549 CTC_MemberLookup,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001550 /// \brief The receiver of an Objective-C message send within an
Douglas Gregoraaf87162010-04-14 20:04:41 +00001551 /// Objective-C method where 'super' is a valid keyword.
1552 CTC_ObjCMessageReceiver
1553 };
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001554
Douglas Gregor931f98a2010-04-14 17:09:22 +00001555 DeclarationName CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS,
1556 DeclContext *MemberContext = 0,
1557 bool EnteringContext = false,
Douglas Gregoraaf87162010-04-14 20:04:41 +00001558 CorrectTypoContext CTC = CTC_Unknown,
Douglas Gregor931f98a2010-04-14 17:09:22 +00001559 const ObjCObjectPointerType *OPT = 0);
Douglas Gregor546be3c2009-12-30 17:04:44 +00001560
Douglas Gregorfa047642009-02-04 00:32:51 +00001561 void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
1562 AssociatedNamespaceSet &AssociatedNamespaces,
John McCall6ff07852009-08-07 22:18:02 +00001563 AssociatedClassSet &AssociatedClasses);
Douglas Gregorfa047642009-02-04 00:32:51 +00001564
John McCalla24dc2e2009-11-17 02:14:36 +00001565 bool DiagnoseAmbiguousLookup(LookupResult &Result);
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001566 //@}
Mike Stump1eb44332009-09-09 15:08:12 +00001567
Douglas Gregorf06cdae2010-01-03 18:01:57 +00001568 ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
Douglas Gregorc83c6872010-04-15 22:33:43 +00001569 SourceLocation IdLoc,
1570 bool TypoCorrection = false);
Mike Stump1eb44332009-09-09 15:08:12 +00001571 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
Douglas Gregor3e41d602009-02-13 23:20:09 +00001572 Scope *S, bool ForRedeclaration,
1573 SourceLocation Loc);
Douglas Gregor4afa39d2009-01-20 01:17:11 +00001574 NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
1575 Scope *S);
Douglas Gregor3c385e52009-02-14 18:57:46 +00001576 void AddKnownFunctionAttributes(FunctionDecl *FD);
Douglas Gregoreb11cd02009-01-14 22:20:51 +00001577
1578 // More parsing and symbol table subroutines.
1579
Mike Stump1eb44332009-09-09 15:08:12 +00001580 // Decl attributes - this routine is the top level dispatcher.
Douglas Gregor9cdda0c2009-06-17 21:51:59 +00001581 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD);
Chris Lattner3d4b4822010-07-13 19:22:31 +00001582 void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL);
Christopher Lambebb97e92008-02-04 02:31:56 +00001583
Steve Naroff3c2eb662008-02-10 21:38:56 +00001584 void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
Fariborz Jahanian52146832010-03-31 18:23:33 +00001585 bool &IncompleteImpl, unsigned DiagID);
Fariborz Jahanian8daab972008-12-05 18:18:52 +00001586 void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod,
1587 ObjCMethodDecl *IntfMethod);
Sebastian Redlc42e1182008-11-11 11:37:55 +00001588
Fariborz Jahaniand1fa6442009-01-12 19:55:42 +00001589 bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl,
Steve Naroff22dc0b02009-02-26 19:11:32 +00001590 ObjCInterfaceDecl *IDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00001591
Chris Lattner823c44e2009-01-06 07:27:21 +00001592 /// CheckProtocolMethodDefs - This routine checks unimplemented
Daniel Dunbar7ad1b1f2008-09-04 20:01:15 +00001593 /// methods declared in protocol, and those referenced by it.
1594 /// \param IDecl - Used for checking for methods which may have been
1595 /// inherited.
Steve Naroffefe7f362008-02-08 22:06:17 +00001596 void CheckProtocolMethodDefs(SourceLocation ImpLoc,
1597 ObjCProtocolDecl *PDecl,
Fariborz Jahanianca3adf72007-10-02 20:06:01 +00001598 bool& IncompleteImpl,
Steve Naroffeefc4182007-10-08 21:05:34 +00001599 const llvm::DenseSet<Selector> &InsMap,
Daniel Dunbar7ad1b1f2008-09-04 20:01:15 +00001600 const llvm::DenseSet<Selector> &ClsMap,
Fariborz Jahanianf2838592010-03-27 21:10:05 +00001601 ObjCContainerDecl *CDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00001602
Steve Naroffa5997c42007-10-02 21:43:37 +00001603 /// CheckImplementationIvars - This routine checks if the instance variables
Mike Stump1eb44332009-09-09 15:08:12 +00001604 /// listed in the implelementation match those listed in the interface.
Ted Kremeneka526c5c2008-01-07 19:49:32 +00001605 void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
1606 ObjCIvarDecl **Fields, unsigned nIvars,
Steve Naroff3c2eb662008-02-10 21:38:56 +00001607 SourceLocation Loc);
Mike Stump1eb44332009-09-09 15:08:12 +00001608
Fariborz Jahanian8c74fa42007-09-29 17:14:55 +00001609 /// ImplMethodsVsClassMethods - This is main routine to warn if any method
Chris Lattnercddc8882009-03-01 00:56:52 +00001610 /// remains unimplemented in the class or category @implementation.
Fariborz Jahanian17cb3262010-05-05 21:52:17 +00001611 void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
Mike Stump1eb44332009-09-09 15:08:12 +00001612 ObjCContainerDecl* IDecl,
Chris Lattnercddc8882009-03-01 00:56:52 +00001613 bool IncompleteImpl = false);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001614
Fariborz Jahanian3ac1eda2010-01-20 01:51:55 +00001615 /// DiagnoseUnimplementedProperties - This routine warns on those properties
1616 /// which must be implemented by this implementation.
Fariborz Jahanian17cb3262010-05-05 21:52:17 +00001617 void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
Fariborz Jahanian3ac1eda2010-01-20 01:51:55 +00001618 ObjCContainerDecl *CDecl,
1619 const llvm::DenseSet<Selector>& InsMap);
Ted Kremeneke3d67bc2010-03-12 02:31:10 +00001620
Fariborz Jahanian509d4772010-05-14 18:35:57 +00001621 /// DefaultSynthesizeProperties - This routine default synthesizes all
1622 /// properties which must be synthesized in class's @implementation.
1623 void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
1624 ObjCInterfaceDecl *IDecl);
1625
Fariborz Jahanian3ac1eda2010-01-20 01:51:55 +00001626 /// CollectImmediateProperties - This routine collects all properties in
1627 /// the class and its conforming protocols; but not those it its super class.
1628 void CollectImmediateProperties(ObjCContainerDecl *CDecl,
Fariborz Jahaniancfa6a272010-06-29 18:12:32 +00001629 llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap,
1630 llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& SuperPropMap);
Fariborz Jahanian738698d2010-05-03 15:49:20 +00001631
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001632
Fariborz Jahanian412e7982010-02-09 19:31:38 +00001633 /// LookupPropertyDecl - Looks up a property in the current class and all
1634 /// its protocols.
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001635 ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl,
Fariborz Jahanian412e7982010-02-09 19:31:38 +00001636 IdentifierInfo *II);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001637
Ted Kremeneke3d67bc2010-03-12 02:31:10 +00001638 /// Called by ActOnProperty to handle @property declarations in
1639 //// class extensions.
1640 DeclPtrTy HandlePropertyInClassExtension(Scope *S,
1641 ObjCCategoryDecl *CDecl,
1642 SourceLocation AtLoc,
1643 FieldDeclarator &FD,
1644 Selector GetterSel,
1645 Selector SetterSel,
1646 const bool isAssign,
1647 const bool isReadWrite,
1648 const unsigned Attributes,
1649 bool *isOverridingProperty,
John McCall83a230c2010-06-04 20:50:08 +00001650 TypeSourceInfo *T,
Ted Kremeneke3d67bc2010-03-12 02:31:10 +00001651 tok::ObjCKeywordKind MethodImplKind);
1652
1653 /// Called by ActOnProperty and HandlePropertyInClassExtension to
1654 /// handle creating the ObjcPropertyDecl for a category or @interface.
1655 ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
1656 ObjCContainerDecl *CDecl,
1657 SourceLocation AtLoc,
1658 FieldDeclarator &FD,
1659 Selector GetterSel,
1660 Selector SetterSel,
1661 const bool isAssign,
1662 const bool isReadWrite,
John McCall83a230c2010-06-04 20:50:08 +00001663 const unsigned Attributes,
1664 TypeSourceInfo *T,
Ted Kremenek23173d72010-05-18 21:09:07 +00001665 tok::ObjCKeywordKind MethodImplKind,
1666 DeclContext *lexicalDC = 0);
Ted Kremeneke3d67bc2010-03-12 02:31:10 +00001667
Fariborz Jahanian7ca8b062009-11-11 22:40:11 +00001668 /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
1669 /// warning) when atomic property has one but not the other user-declared
1670 /// setter or getter.
1671 void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
1672 ObjCContainerDecl* IDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00001673
Fariborz Jahanianf914b972010-02-23 23:41:11 +00001674 void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
1675
Fariborz Jahanian85ff2642007-10-05 18:00:57 +00001676 /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
1677 /// true, or false, accordingly.
Mike Stump1eb44332009-09-09 15:08:12 +00001678 bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
Steve Narofffe6b0dc2008-10-21 10:37:50 +00001679 const ObjCMethodDecl *PrevMethod,
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001680 bool matchBasedOnSizeAndAlignment = false,
1681 bool matchBasedOnStrictEqulity = false);
Steve Naroff3b950172007-10-10 21:53:07 +00001682
Fariborz Jahanianb33f3ad2009-05-01 20:07:12 +00001683 /// MatchAllMethodDeclarations - Check methods declaraed in interface or
1684 /// or protocol against those declared in their implementations.
1685 void MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
1686 const llvm::DenseSet<Selector> &ClsMap,
1687 llvm::DenseSet<Selector> &InsMapSeen,
1688 llvm::DenseSet<Selector> &ClsMapSeen,
1689 ObjCImplDecl* IMPDecl,
1690 ObjCContainerDecl* IDecl,
1691 bool &IncompleteImpl,
1692 bool ImmediateClass);
1693
Sebastian Redldb9d2142010-08-02 23:18:59 +00001694private:
1695 /// AddMethodToGlobalPool - Add an instance or factory method to the global
1696 /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
1697 void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
1698
1699 /// LookupMethodInGlobalPool - Returns the instance or factory method and
1700 /// optionally warns if there are multiple signatures.
1701 ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001702 bool receiverIdOrClass,
Sebastian Redldb9d2142010-08-02 23:18:59 +00001703 bool warn, bool instance);
1704
1705public:
Steve Naroff58ff9e82007-10-14 00:58:41 +00001706 /// AddInstanceMethodToGlobalPool - All instance methods in a translation
1707 /// unit are added to a global pool. This allows us to efficiently associate
1708 /// a selector with a method declaraation for purposes of typechecking
1709 /// messages sent to "id" (where the class of the object is unknown).
Sebastian Redldb9d2142010-08-02 23:18:59 +00001710 void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
1711 AddMethodToGlobalPool(Method, impl, /*instance*/true);
1712 }
1713
1714 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
1715 void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
1716 AddMethodToGlobalPool(Method, impl, /*instance*/false);
1717 }
Mike Stump1eb44332009-09-09 15:08:12 +00001718
Steve Naroff037cda52008-09-30 14:38:43 +00001719 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
1720 /// there are multiple signatures.
Fariborz Jahanian835ed7f2009-08-22 21:13:55 +00001721 ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001722 bool receiverIdOrClass=false,
Sebastian Redldb9d2142010-08-02 23:18:59 +00001723 bool warn=true) {
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001724 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
1725 warn, /*instance*/true);
Sebastian Redldb9d2142010-08-02 23:18:59 +00001726 }
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +00001727
1728 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
1729 /// there are multiple signatures.
Fariborz Jahanian3fe10412010-07-22 18:24:20 +00001730 ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R,
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001731 bool receiverIdOrClass=false,
Sebastian Redldb9d2142010-08-02 23:18:59 +00001732 bool warn=true) {
Fariborz Jahanian6b308f62010-08-09 23:27:58 +00001733 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
1734 warn, /*instance*/false);
Sebastian Redldb9d2142010-08-02 23:18:59 +00001735 }
Fariborz Jahanian3fe10412010-07-22 18:24:20 +00001736
1737 /// LookupImplementedMethodInGlobalPool - Returns the method which has an
1738 /// implementation.
1739 ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
Mike Stump1eb44332009-09-09 15:08:12 +00001740
Fariborz Jahanian786cd152010-04-27 17:18:58 +00001741 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
Fariborz Jahaniane4498c62010-04-28 16:11:27 +00001742 /// initialization.
Fariborz Jahanian786cd152010-04-27 17:18:58 +00001743 void CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI,
Fariborz Jahaniane4498c62010-04-28 16:11:27 +00001744 llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars);
Reid Spencer5f016e22007-07-11 17:01:13 +00001745 //===--------------------------------------------------------------------===//
1746 // Statement Parsing Callbacks: SemaStmt.cpp.
1747public:
Anders Carlsson6b1d2832009-05-17 21:11:30 +00001748 virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr);
Sebastian Redla60528c2008-12-21 12:04:03 +00001749
1750 virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc);
1751 virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
1752 MultiStmtArg Elts,
1753 bool isStmtExpr);
Chris Lattner682bf922009-03-29 16:50:03 +00001754 virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
Chris Lattnerb28317a2009-03-28 19:18:32 +00001755 SourceLocation StartLoc,
Sebastian Redla60528c2008-12-21 12:04:03 +00001756 SourceLocation EndLoc);
Fariborz Jahaniana7cf23a2009-11-19 22:12:37 +00001757 virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
Sebastian Redl117054a2008-12-28 16:13:43 +00001758 virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal,
1759 SourceLocation DotDotDotLoc, ExprArg RHSVal,
Chris Lattner24e1e702009-03-04 04:23:07 +00001760 SourceLocation ColonLoc);
1761 virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt);
Mike Stump1eb44332009-09-09 15:08:12 +00001762
Sebastian Redl117054a2008-12-28 16:13:43 +00001763 virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
1764 SourceLocation ColonLoc,
1765 StmtArg SubStmt, Scope *CurScope);
Sebastian Redlde307472009-01-11 00:38:46 +00001766 virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
1767 IdentifierInfo *II,
1768 SourceLocation ColonLoc,
1769 StmtArg SubStmt);
Mike Stump1eb44332009-09-09 15:08:12 +00001770 virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001771 FullExprArg CondVal, DeclPtrTy CondVar,
1772 StmtArg ThenVal,
Anders Carlssona99fad82009-05-17 18:26:53 +00001773 SourceLocation ElseLoc, StmtArg ElseVal);
Douglas Gregor586596f2010-05-06 17:25:47 +00001774 virtual OwningStmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
1775 ExprArg Cond,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001776 DeclPtrTy CondVar);
Sebastian Redlde307472009-01-11 00:38:46 +00001777 virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
1778 StmtArg Switch, StmtArg Body);
Mike Stump1eb44332009-09-09 15:08:12 +00001779 virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001780 FullExprArg Cond,
1781 DeclPtrTy CondVar, StmtArg Body);
Sebastian Redlf05b1522009-01-16 23:28:06 +00001782 virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
Chris Lattner98913592009-06-12 23:04:47 +00001783 SourceLocation WhileLoc,
1784 SourceLocation CondLParen, ExprArg Cond,
1785 SourceLocation CondRParen);
Sebastian Redlf05b1522009-01-16 23:28:06 +00001786
1787 virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
1788 SourceLocation LParenLoc,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001789 StmtArg First, FullExprArg Second,
1790 DeclPtrTy SecondVar,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001791 FullExprArg Third,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001792 SourceLocation RParenLoc,
Sebastian Redlf05b1522009-01-16 23:28:06 +00001793 StmtArg Body);
1794 virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
1795 SourceLocation LParenLoc,
1796 StmtArg First, ExprArg Second,
1797 SourceLocation RParenLoc, StmtArg Body);
Sebastian Redl4cffe2f2009-01-18 13:19:59 +00001798
1799 virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
1800 SourceLocation LabelLoc,
1801 IdentifierInfo *LabelII);
1802 virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
1803 SourceLocation StarLoc,
1804 ExprArg DestExp);
1805 virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
1806 Scope *CurScope);
1807 virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
1808 Scope *CurScope);
1809
1810 virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
Anders Carlssonf53b4432009-08-18 16:11:00 +00001811 ExprArg RetValExp);
Sebastian Redl4cffe2f2009-01-18 13:19:59 +00001812 OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc,
1813 Expr *RetValExp);
1814
Sebastian Redl3037ed02009-01-18 16:53:17 +00001815 virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
1816 bool IsSimple,
1817 bool IsVolatile,
1818 unsigned NumOutputs,
1819 unsigned NumInputs,
Anders Carlssonff93dbd2010-01-30 22:25:16 +00001820 IdentifierInfo **Names,
Sebastian Redl3037ed02009-01-18 16:53:17 +00001821 MultiExprArg Constraints,
1822 MultiExprArg Exprs,
1823 ExprArg AsmString,
1824 MultiExprArg Clobbers,
Mike Stump3b11fd32010-01-04 22:37:17 +00001825 SourceLocation RParenLoc,
1826 bool MSAsm = false);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001827
Douglas Gregor160b5632010-04-26 17:32:49 +00001828
1829 VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
1830 IdentifierInfo *Name, SourceLocation NameLoc,
1831 bool Invalid = false);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001832
Douglas Gregor160b5632010-04-26 17:32:49 +00001833 virtual DeclPtrTy ActOnObjCExceptionDecl(Scope *S, Declarator &D);
1834
Sebastian Redl431e90e2009-01-18 17:43:11 +00001835 virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
1836 SourceLocation RParen,
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001837 DeclPtrTy Parm, StmtArg Body);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001838
1839 virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
1840 StmtArg Body);
1841
1842 virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
1843 StmtArg Try,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001844 MultiStmtArg Catch,
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001845 StmtArg Finally);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001846
Douglas Gregord1377b22010-04-22 21:44:01 +00001847 virtual OwningStmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc,
1848 ExprArg Throw);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001849 virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00001850 ExprArg Throw,
Steve Naroffe21dd6f2009-02-11 20:05:44 +00001851 Scope *CurScope);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001852 virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
1853 ExprArg SynchExpr,
1854 StmtArg SynchBody);
Sebastian Redla0fd8652008-12-21 16:41:36 +00001855
Douglas Gregord308e622009-05-18 20:51:54 +00001856 VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
John McCalla93c9342009-12-07 02:54:59 +00001857 TypeSourceInfo *TInfo,
Douglas Gregord308e622009-05-18 20:51:54 +00001858 IdentifierInfo *Name,
1859 SourceLocation Loc,
1860 SourceRange Range);
Chris Lattnerb28317a2009-03-28 19:18:32 +00001861 virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D);
Douglas Gregord308e622009-05-18 20:51:54 +00001862
Sebastian Redl4b07b292008-12-22 19:15:10 +00001863 virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00001864 DeclPtrTy ExDecl,
Sebastian Redl4b07b292008-12-22 19:15:10 +00001865 StmtArg HandlerBlock);
Sebastian Redl8351da02008-12-22 21:35:02 +00001866 virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
1867 StmtArg TryBlock,
1868 MultiStmtArg Handlers);
Sebastian Redl13e88542009-04-27 21:33:24 +00001869 void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
Sebastian Redla0fd8652008-12-21 16:41:36 +00001870
Anders Carlsson636463e2009-07-30 22:17:18 +00001871 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
1872 /// whose result is unused, warn.
1873 void DiagnoseUnusedExprResult(const Stmt *S);
Douglas Gregor5764f612010-05-08 23:05:03 +00001874 void DiagnoseUnusedDecl(const NamedDecl *ND);
1875
John McCall54abf7d2009-11-04 02:18:39 +00001876 ParsingDeclStackState PushParsingDeclaration();
1877 void PopParsingDeclaration(ParsingDeclStackState S, DeclPtrTy D);
1878 void EmitDeprecationWarning(NamedDecl *D, SourceLocation Loc);
1879
John McCall2f514482010-01-27 03:50:35 +00001880 void HandleDelayedDeprecationCheck(DelayedDiagnostic &DD, Decl *Ctx);
1881
Reid Spencer5f016e22007-07-11 17:01:13 +00001882 //===--------------------------------------------------------------------===//
1883 // Expression Parsing Callbacks: SemaExpr.cpp.
1884
John McCall54abf7d2009-11-04 02:18:39 +00001885 bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
Mike Stump1eb44332009-09-09 15:08:12 +00001886 bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
Fariborz Jahanianc001e892009-05-08 20:20:55 +00001887 ObjCMethodDecl *Getter,
1888 SourceLocation Loc);
Fariborz Jahanian5b530052009-05-13 18:09:35 +00001889 void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
1890 Expr **Args, unsigned NumArgs);
Chris Lattner76a642f2009-02-15 22:43:40 +00001891
Douglas Gregor2afce722009-11-26 00:44:06 +00001892 virtual void
Douglas Gregorac7610d2009-06-22 20:57:11 +00001893 PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
Mike Stump1eb44332009-09-09 15:08:12 +00001894
Douglas Gregor2afce722009-11-26 00:44:06 +00001895 virtual void PopExpressionEvaluationContext();
Mike Stump1eb44332009-09-09 15:08:12 +00001896
Douglas Gregore0762c92009-06-19 23:52:42 +00001897 void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
Douglas Gregorb4eeaff2010-05-07 23:12:07 +00001898 void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
Douglas Gregor1c7c3fb2009-12-22 01:01:55 +00001899 bool DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001900
Reid Spencer5f016e22007-07-11 17:01:13 +00001901 // Primary Expressions.
Douglas Gregor4b2d3f72009-02-26 21:00:50 +00001902 virtual SourceRange getExprRange(ExprTy *E) const;
1903
Douglas Gregor02a24ee2009-11-03 16:56:39 +00001904 virtual OwningExprResult ActOnIdExpression(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00001905 CXXScopeSpec &SS,
Douglas Gregor02a24ee2009-11-03 16:56:39 +00001906 UnqualifiedId &Name,
1907 bool HasTrailingLParen,
1908 bool IsAddressOfOperand);
John McCallf7a1a742009-11-24 19:00:30 +00001909
Douglas Gregor91f7ac72010-05-18 16:14:23 +00001910 bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
1911 CorrectTypoContext CTC = CTC_Unknown);
John McCall578b69b2009-12-16 08:11:27 +00001912
John McCallf7a1a742009-11-24 19:00:30 +00001913 OwningExprResult LookupInObjCMethod(LookupResult &R,
1914 Scope *S,
Fariborz Jahanian48c2d562010-01-12 23:58:59 +00001915 IdentifierInfo *II,
1916 bool AllowBuiltinCreation=false);
John McCallf7a1a742009-11-24 19:00:30 +00001917
1918 OwningExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
1919 DeclarationName Name,
1920 SourceLocation NameLoc,
John McCall2f841ba2009-12-02 03:53:29 +00001921 bool isAddressOfOperand,
John McCallf7a1a742009-11-24 19:00:30 +00001922 const TemplateArgumentListInfo *TemplateArgs);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001923
John McCalldbd872f2009-12-08 09:08:17 +00001924 OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
Douglas Gregor0da76df2009-11-23 11:41:28 +00001925 SourceLocation Loc,
Anders Carlssone41590d2009-06-24 00:10:43 +00001926 const CXXScopeSpec *SS = 0);
Douglas Gregorffb4b6e2009-04-15 06:41:24 +00001927 VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
1928 llvm::SmallVectorImpl<FieldDecl *> &Path);
Sebastian Redlcd965b92009-01-18 18:53:16 +00001929 OwningExprResult
Douglas Gregorbcbffc42009-01-07 00:43:41 +00001930 BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
1931 FieldDecl *Field,
1932 Expr *BaseObjectExpr = 0,
1933 SourceLocation OpLoc = SourceLocation());
John McCall3b4294e2009-12-16 12:17:52 +00001934 OwningExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
1935 LookupResult &R,
1936 const TemplateArgumentListInfo *TemplateArgs);
John McCallaa81e162009-12-01 22:10:20 +00001937 OwningExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
1938 LookupResult &R,
1939 const TemplateArgumentListInfo *TemplateArgs,
1940 bool IsDefiniteInstance);
John McCallf7a1a742009-11-24 19:00:30 +00001941 bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
John McCall5b3f9132009-11-22 01:44:31 +00001942 const LookupResult &R,
1943 bool HasTrailingLParen);
John McCallf7a1a742009-11-24 19:00:30 +00001944
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00001945 OwningExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
John McCallf7a1a742009-11-24 19:00:30 +00001946 DeclarationName Name,
1947 SourceLocation NameLoc);
1948 OwningExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
1949 DeclarationName Name,
1950 SourceLocation NameLoc,
1951 const TemplateArgumentListInfo *TemplateArgs);
1952
1953 OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
1954 LookupResult &R,
1955 bool ADL);
1956 OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
John McCallba135432009-11-21 08:51:07 +00001957 SourceLocation Loc,
1958 NamedDecl *D);
Mike Stump1eb44332009-09-09 15:08:12 +00001959
Sebastian Redlcd965b92009-01-18 18:53:16 +00001960 virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
1961 tok::TokenKind Kind);
1962 virtual OwningExprResult ActOnNumericConstant(const Token &);
1963 virtual OwningExprResult ActOnCharacterConstant(const Token &);
1964 virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
1965 ExprArg Val);
Fariborz Jahanianf88f7ab2009-11-25 01:26:41 +00001966 virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L,
Nate Begeman2ef13e52009-08-10 23:49:36 +00001967 SourceLocation R,
Fariborz Jahanianf88f7ab2009-11-25 01:26:41 +00001968 MultiExprArg Val,
1969 TypeTy *TypeOfCast=0);
Mike Stump1eb44332009-09-09 15:08:12 +00001970
Steve Narofff69936d2007-09-16 03:34:24 +00001971 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
Reid Spencer5f016e22007-07-11 17:01:13 +00001972 /// fragments (e.g. "foo" "bar" L"baz").
Sebastian Redl0eb23302009-01-19 00:08:26 +00001973 virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
1974 unsigned NumToks);
Sebastian Redlcd965b92009-01-18 18:53:16 +00001975
Reid Spencer5f016e22007-07-11 17:01:13 +00001976 // Binary/Unary Operators. 'Tok' is the token for the operator.
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001977 OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00001978 unsigned OpcIn,
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001979 ExprArg InputArg);
Douglas Gregor6ca7cfb2009-11-05 00:51:44 +00001980 OwningExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
1981 UnaryOperator::Opcode Opc, ExprArg input);
Sebastian Redl0eb23302009-01-19 00:08:26 +00001982 virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
1983 tok::TokenKind Op, ExprArg Input);
Sebastian Redl05189992008-11-11 17:56:53 +00001984
John McCalla93c9342009-12-07 02:54:59 +00001985 OwningExprResult CreateSizeOfAlignOfExpr(TypeSourceInfo *T,
John McCall5ab75172009-11-04 07:28:41 +00001986 SourceLocation OpLoc,
Douglas Gregorba498172009-03-13 21:01:28 +00001987 bool isSizeOf, SourceRange R);
Mike Stump1eb44332009-09-09 15:08:12 +00001988 OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
Douglas Gregorba498172009-03-13 21:01:28 +00001989 bool isSizeOf, SourceRange R);
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001990 virtual OwningExprResult
1991 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
1992 void *TyOrEx, const SourceRange &ArgRange);
Mike Stump1eb44332009-09-09 15:08:12 +00001993
Chris Lattner31e21e02009-01-24 20:17:12 +00001994 bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R);
Sebastian Redl05189992008-11-11 17:56:53 +00001995 bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc,
1996 const SourceRange &R, bool isSizeof);
Sebastian Redl0eb23302009-01-19 00:08:26 +00001997
1998 virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
1999 tok::TokenKind Kind,
2000 ExprArg Input);
2001
2002 virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
2003 SourceLocation LLoc,
2004 ExprArg Idx,
2005 SourceLocation RLoc);
Sebastian Redlf322ed62009-10-29 20:17:01 +00002006 OwningExprResult CreateBuiltinArraySubscriptExpr(ExprArg Base,
2007 SourceLocation LLoc,
2008 ExprArg Idx,
2009 SourceLocation RLoc);
Douglas Gregorc4bf26f2009-09-01 00:37:14 +00002010
John McCall129e2df2009-11-30 22:42:35 +00002011 OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
John McCallaa81e162009-12-01 22:10:20 +00002012 QualType BaseType,
Douglas Gregorc4bf26f2009-09-01 00:37:14 +00002013 SourceLocation OpLoc,
John McCall129e2df2009-11-30 22:42:35 +00002014 bool IsArrow,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002015 CXXScopeSpec &SS,
John McCall129e2df2009-11-30 22:42:35 +00002016 NamedDecl *FirstQualifierInScope,
2017 DeclarationName Name,
2018 SourceLocation NameLoc,
2019 const TemplateArgumentListInfo *TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00002020
John McCall129e2df2009-11-30 22:42:35 +00002021 OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
John McCallaa81e162009-12-01 22:10:20 +00002022 QualType BaseType,
John McCall129e2df2009-11-30 22:42:35 +00002023 SourceLocation OpLoc, bool IsArrow,
2024 const CXXScopeSpec &SS,
John McCallc2233c52010-01-15 08:34:02 +00002025 NamedDecl *FirstQualifierInScope,
John McCall129e2df2009-11-30 22:42:35 +00002026 LookupResult &R,
Douglas Gregor06a9f362010-05-01 20:49:11 +00002027 const TemplateArgumentListInfo *TemplateArgs,
2028 bool SuppressQualifierCheck = false);
John McCall129e2df2009-11-30 22:42:35 +00002029
2030 OwningExprResult LookupMemberExpr(LookupResult &R, Expr *&Base,
John McCall812c1542009-12-07 22:46:59 +00002031 bool &IsArrow, SourceLocation OpLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002032 CXXScopeSpec &SS,
John McCallad00b772010-06-16 08:42:20 +00002033 DeclPtrTy ObjCImpDecl,
2034 bool HasTemplateArgs);
John McCall129e2df2009-11-30 22:42:35 +00002035
2036 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
John McCall2f841ba2009-12-02 03:53:29 +00002037 const CXXScopeSpec &SS,
John McCall129e2df2009-11-30 22:42:35 +00002038 const LookupResult &R);
2039
2040 OwningExprResult ActOnDependentMemberExpr(ExprArg Base,
John McCallaa81e162009-12-01 22:10:20 +00002041 QualType BaseType,
John McCall129e2df2009-11-30 22:42:35 +00002042 bool IsArrow,
Anders Carlsson8f28f992009-08-26 18:25:21 +00002043 SourceLocation OpLoc,
John McCall129e2df2009-11-30 22:42:35 +00002044 const CXXScopeSpec &SS,
2045 NamedDecl *FirstQualifierInScope,
2046 DeclarationName Name,
2047 SourceLocation NameLoc,
2048 const TemplateArgumentListInfo *TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00002049
Douglas Gregor2d1c2142009-11-03 19:44:04 +00002050 virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base,
2051 SourceLocation OpLoc,
2052 tok::TokenKind OpKind,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002053 CXXScopeSpec &SS,
Douglas Gregor2d1c2142009-11-03 19:44:04 +00002054 UnqualifiedId &Member,
2055 DeclPtrTy ObjCImpDecl,
2056 bool HasTrailingLParen);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002057
Fariborz Jahanian393612e2009-07-21 22:36:06 +00002058 virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl);
Sebastian Redl0eb23302009-01-19 00:08:26 +00002059 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
Douglas Gregor88a35142008-12-22 05:46:06 +00002060 FunctionDecl *FDecl,
Douglas Gregor72564e72009-02-26 23:50:07 +00002061 const FunctionProtoType *Proto,
Douglas Gregor88a35142008-12-22 05:46:06 +00002062 Expr **Args, unsigned NumArgs,
2063 SourceLocation RParenLoc);
Sebastian Redl0eb23302009-01-19 00:08:26 +00002064
Steve Narofff69936d2007-09-16 03:34:24 +00002065 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Reid Spencer5f016e22007-07-11 17:01:13 +00002066 /// This provides the location of the left/right parens and a list of comma
2067 /// locations.
Sebastian Redl0eb23302009-01-19 00:08:26 +00002068 virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
2069 SourceLocation LParenLoc,
2070 MultiExprArg Args,
2071 SourceLocation *CommaLocs,
2072 SourceLocation RParenLoc);
John McCallaa81e162009-12-01 22:10:20 +00002073 OwningExprResult BuildResolvedCallExpr(Expr *Fn,
2074 NamedDecl *NDecl,
2075 SourceLocation LParenLoc,
2076 Expr **Args, unsigned NumArgs,
2077 SourceLocation RParenLoc);
Sebastian Redl0eb23302009-01-19 00:08:26 +00002078
Nate Begeman2ef13e52009-08-10 23:49:36 +00002079 virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
2080 TypeTy *Ty, SourceLocation RParenLoc,
2081 ExprArg Op);
John McCallb042fdf2010-01-15 18:56:44 +00002082 OwningExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
2083 TypeSourceInfo *Ty,
2084 SourceLocation RParenLoc,
2085 ExprArg Op);
2086
Fariborz Jahaniana79f8b32009-11-23 19:51:43 +00002087 virtual bool TypeIsVectorType(TypeTy *Ty) {
2088 return GetTypeFromParser(Ty)->isVectorType();
2089 }
Mike Stump1eb44332009-09-09 15:08:12 +00002090
Nate Begeman2ef13e52009-08-10 23:49:36 +00002091 OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
2092 OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
2093 SourceLocation RParenLoc, ExprArg E,
John McCall42f56b52010-01-18 19:35:47 +00002094 TypeSourceInfo *TInfo);
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002095
2096 virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
2097 TypeTy *Ty,
2098 SourceLocation RParenLoc,
2099 ExprArg Op);
2100
John McCall42f56b52010-01-18 19:35:47 +00002101 OwningExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
2102 TypeSourceInfo *TInfo,
2103 SourceLocation RParenLoc,
2104 ExprArg InitExpr);
2105
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002106 virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
2107 MultiExprArg InitList,
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002108 SourceLocation RParenLoc);
2109
Douglas Gregor05c13a32009-01-22 00:58:24 +00002110 virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig,
2111 SourceLocation Loc,
Douglas Gregoreeae8f02009-03-28 00:41:23 +00002112 bool GNUSyntax,
Douglas Gregor05c13a32009-01-22 00:58:24 +00002113 OwningExprResult Init);
2114
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002115 virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
2116 tok::TokenKind Kind,
2117 ExprArg LHS, ExprArg RHS);
Douglas Gregor6ca7cfb2009-11-05 00:51:44 +00002118 OwningExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
2119 BinaryOperator::Opcode Opc,
2120 Expr *lhs, Expr *rhs);
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002121 OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc,
2122 unsigned Opc, Expr *lhs, Expr *rhs);
Douglas Gregoreaebc752008-11-06 23:29:22 +00002123
Steve Narofff69936d2007-09-16 03:34:24 +00002124 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
Reid Spencer5f016e22007-07-11 17:01:13 +00002125 /// in the case of a the GNU conditional expr extension.
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002126 virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
2127 SourceLocation ColonLoc,
2128 ExprArg Cond, ExprArg LHS,
2129 ExprArg RHS);
Reid Spencer5f016e22007-07-11 17:01:13 +00002130
Steve Naroff1b273c42007-09-16 14:56:35 +00002131 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Sebastian Redlf53597f2009-03-15 17:47:39 +00002132 virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc,
2133 SourceLocation LabLoc,
2134 IdentifierInfo *LabelII);
2135
2136 virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt,
2137 SourceLocation RPLoc); // "({..})"
Chris Lattner73d0d4f2007-08-30 17:45:32 +00002138
2139 /// __builtin_offsetof(type, a.b[123][456].c)
Douglas Gregor8ecdb652010-04-28 22:16:22 +00002140 OwningExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
2141 TypeSourceInfo *TInfo,
2142 OffsetOfComponent *CompPtr,
2143 unsigned NumComponents,
2144 SourceLocation RParenLoc);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002145 virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
2146 SourceLocation BuiltinLoc,
2147 SourceLocation TypeLoc,
2148 TypeTy *Arg1,
2149 OffsetOfComponent *CompPtr,
2150 unsigned NumComponents,
2151 SourceLocation RParenLoc);
2152
Steve Naroffd34e9152007-08-01 22:05:33 +00002153 // __builtin_types_compatible_p(type1, type2)
Sebastian Redlf53597f2009-03-15 17:47:39 +00002154 virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
2155 TypeTy *arg1, TypeTy *arg2,
2156 SourceLocation RPLoc);
Abramo Bagnara3fcb73d2010-08-10 08:50:03 +00002157 OwningExprResult BuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
2158 TypeSourceInfo *argTInfo1,
2159 TypeSourceInfo *argTInfo2,
2160 SourceLocation RPLoc);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002161
Steve Naroffd04fdd52007-08-03 21:21:27 +00002162 // __builtin_choose_expr(constExpr, expr1, expr2)
Sebastian Redlf53597f2009-03-15 17:47:39 +00002163 virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
2164 ExprArg cond, ExprArg expr1,
2165 ExprArg expr2, SourceLocation RPLoc);
2166
Anders Carlsson7c50aca2007-10-15 20:28:48 +00002167 // __builtin_va_arg(expr, type)
Sebastian Redlf53597f2009-03-15 17:47:39 +00002168 virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
2169 ExprArg expr, TypeTy *type,
2170 SourceLocation RPLoc);
Abramo Bagnara2cad9002010-08-10 10:06:15 +00002171 OwningExprResult BuildVAArgExpr(SourceLocation BuiltinLoc,
2172 ExprArg expr, TypeSourceInfo *TInfo,
2173 SourceLocation RPLoc);
Steve Naroff4eb206b2008-09-03 18:15:37 +00002174
Douglas Gregor2d8b2732008-11-29 04:51:27 +00002175 // __null
Sebastian Redlf53597f2009-03-15 17:47:39 +00002176 virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
Douglas Gregor2d8b2732008-11-29 04:51:27 +00002177
Steve Naroff4eb206b2008-09-03 18:15:37 +00002178 //===------------------------- "Block" Extension ------------------------===//
2179
2180 /// ActOnBlockStart - This callback is invoked when a block literal is
2181 /// started.
Steve Naroff090276f2008-10-10 01:28:17 +00002182 virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002183
Steve Naroff090276f2008-10-10 01:28:17 +00002184 /// ActOnBlockArguments - This callback allows processing of block arguments.
2185 /// If there are no arguments, this is still invoked.
Mike Stump98eb8a72009-02-04 22:31:32 +00002186 virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002187
Steve Naroff4eb206b2008-09-03 18:15:37 +00002188 /// ActOnBlockError - If there is an error parsing a block, this callback
2189 /// is invoked to pop the information about the block from the action impl.
2190 virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002191
Steve Naroff4eb206b2008-09-03 18:15:37 +00002192 /// ActOnBlockStmtExpr - This is called when the body of a block statement
2193 /// literal was successfully completed. ^(int x){...}
Sebastian Redlf53597f2009-03-15 17:47:39 +00002194 virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc,
2195 StmtArg Body, Scope *CurScope);
Steve Naroff4eb206b2008-09-03 18:15:37 +00002196
Chris Lattner76a642f2009-02-15 22:43:40 +00002197 //===---------------------------- C++ Features --------------------------===//
2198
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +00002199 // Act on C++ namespaces
Chris Lattnerb28317a2009-03-28 19:18:32 +00002200 virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
2201 IdentifierInfo *Ident,
Anders Carlsson2a3503d2010-02-07 01:09:23 +00002202 SourceLocation LBrace,
2203 AttributeList *AttrList);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002204 virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace);
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +00002205
Argyrios Kyrtzidis76c38d32010-08-02 07:14:54 +00002206 NamespaceDecl *getStdNamespace() const {
2207 return cast_or_null<NamespaceDecl>(
2208 StdNamespace.get(Context.getExternalSource()));
2209 }
Argyrios Kyrtzidis26faaac2010-08-02 07:14:39 +00002210 NamespaceDecl *getOrCreateStdNamespace();
Argyrios Kyrtzidis76c38d32010-08-02 07:14:54 +00002211
2212 CXXRecordDecl *getStdBadAlloc() const {
2213 return cast_or_null<CXXRecordDecl>(
2214 StdBadAlloc.get(Context.getExternalSource()));
2215 }
2216
Chris Lattnerb28317a2009-03-28 19:18:32 +00002217 virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
2218 SourceLocation UsingLoc,
2219 SourceLocation NamespcLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002220 CXXScopeSpec &SS,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002221 SourceLocation IdentLoc,
2222 IdentifierInfo *NamespcName,
2223 AttributeList *AttrList);
Mike Stump1eb44332009-09-09 15:08:12 +00002224
Douglas Gregor2a3009a2009-02-03 19:21:40 +00002225 void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
2226
Chris Lattnerb28317a2009-03-28 19:18:32 +00002227 virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
Anders Carlsson03bd5a12009-03-28 22:53:22 +00002228 SourceLocation NamespaceLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002229 SourceLocation AliasLoc,
2230 IdentifierInfo *Alias,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002231 CXXScopeSpec &SS,
Anders Carlsson03bd5a12009-03-28 22:53:22 +00002232 SourceLocation IdentLoc,
2233 IdentifierInfo *Ident);
Douglas Gregor9cfbe482009-06-20 00:51:54 +00002234
John McCall9f54ad42009-12-10 09:41:52 +00002235 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
2236 bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
2237 const LookupResult &PreviousDecls);
2238 UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
2239 NamedDecl *Target);
John McCall604e7f12009-12-08 07:46:18 +00002240
John McCall9f54ad42009-12-10 09:41:52 +00002241 bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
2242 bool isTypeName,
2243 const CXXScopeSpec &SS,
2244 SourceLocation NameLoc,
2245 const LookupResult &Previous);
John McCalled976492009-12-04 22:46:56 +00002246 bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
2247 const CXXScopeSpec &SS,
2248 SourceLocation NameLoc);
2249
John McCall9488ea12009-11-17 05:59:44 +00002250 NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
2251 SourceLocation UsingLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002252 CXXScopeSpec &SS,
Anders Carlssonc72160b2009-08-28 05:40:36 +00002253 SourceLocation IdentLoc,
2254 DeclarationName Name,
2255 AttributeList *AttrList,
John McCall7ba107a2009-11-18 02:36:19 +00002256 bool IsInstantiation,
2257 bool IsTypeName,
2258 SourceLocation TypenameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002259
Douglas Gregor9cfbe482009-06-20 00:51:54 +00002260 virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
Anders Carlsson595adc12009-08-29 19:54:19 +00002261 AccessSpecifier AS,
John McCall60fa3cf2009-12-11 02:10:03 +00002262 bool HasUsingKeyword,
Anders Carlssonc72160b2009-08-28 05:40:36 +00002263 SourceLocation UsingLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002264 CXXScopeSpec &SS,
Douglas Gregor12c118a2009-11-04 16:30:06 +00002265 UnqualifiedId &Name,
Anders Carlssonc72160b2009-08-28 05:40:36 +00002266 AttributeList *AttrList,
John McCall7ba107a2009-11-18 02:36:19 +00002267 bool IsTypeName,
2268 SourceLocation TypenameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002269
2270 /// AddCXXDirectInitializerToDecl - This action is called immediately after
Argyrios Kyrtzidis73a0d882008-10-06 17:10:33 +00002271 /// ActOnDeclarator, when a C++ direct initializer is present.
2272 /// e.g: "int x(1);"
Chris Lattnerb28317a2009-03-28 19:18:32 +00002273 virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
Argyrios Kyrtzidis73a0d882008-10-06 17:10:33 +00002274 SourceLocation LParenLoc,
Sebastian Redlf53597f2009-03-15 17:47:39 +00002275 MultiExprArg Exprs,
Argyrios Kyrtzidis73a0d882008-10-06 17:10:33 +00002276 SourceLocation *CommaLocs,
2277 SourceLocation RParenLoc);
2278
Anders Carlsson49d44012009-04-24 05:16:06 +00002279 /// InitializeVarWithConstructor - Creates an CXXConstructExpr
2280 /// and sets it as the initializer for the the passed in VarDecl.
Mike Stump1eb44332009-09-09 15:08:12 +00002281 bool InitializeVarWithConstructor(VarDecl *VD,
Anders Carlsson930e8d02009-04-16 23:50:50 +00002282 CXXConstructorDecl *Constructor,
Anders Carlssonf47511a2009-09-07 22:23:31 +00002283 MultiExprArg Exprs);
Anders Carlsson9abf2ae2009-08-16 05:13:48 +00002284
Anders Carlssonec8e5ea2009-09-05 07:40:38 +00002285 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
2286 /// including handling of its default argument expressions.
Anders Carlsson72e96fd2010-05-02 22:54:08 +00002287 OwningExprResult
2288 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
2289 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
2290 bool RequiresZeroInit = false,
2291 CXXConstructExpr::ConstructionKind ConstructKind =
2292 CXXConstructExpr::CK_Complete);
Anders Carlsson9abf2ae2009-08-16 05:13:48 +00002293
Anders Carlssonec8e5ea2009-09-05 07:40:38 +00002294 // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
2295 // the constructor can be elidable?
Anders Carlsson72e96fd2010-05-02 22:54:08 +00002296 OwningExprResult
2297 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
2298 CXXConstructorDecl *Constructor, bool Elidable,
2299 MultiExprArg Exprs, bool RequiresZeroInit = false,
2300 CXXConstructExpr::ConstructionKind ConstructKind =
2301 CXXConstructExpr::CK_Complete);
Mike Stump1eb44332009-09-09 15:08:12 +00002302
Anders Carlsson56c5e332009-08-25 03:49:14 +00002303 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
2304 /// the default expr if needed.
2305 OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
2306 FunctionDecl *FD,
2307 ParmVarDecl *Param);
Mike Stump1eb44332009-09-09 15:08:12 +00002308
Fariborz Jahaniana83f7ed2009-08-03 19:13:25 +00002309 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
2310 /// constructed variable.
John McCall68c6c9a2010-02-02 09:10:11 +00002311 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
Mike Stump1eb44332009-09-09 15:08:12 +00002312
Douglas Gregor32df23e2010-07-01 22:02:46 +00002313 /// \brief Declare the implicit default constructor for the given class.
2314 ///
Douglas Gregor32df23e2010-07-01 22:02:46 +00002315 /// \param ClassDecl The class declaration into which the implicit
2316 /// default constructor will be added.
2317 ///
2318 /// \returns The implicitly-declared default constructor.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002319 CXXConstructorDecl *DeclareImplicitDefaultConstructor(
Douglas Gregor32df23e2010-07-01 22:02:46 +00002320 CXXRecordDecl *ClassDecl);
2321
Mike Stump1eb44332009-09-09 15:08:12 +00002322 /// DefineImplicitDefaultConstructor - Checks for feasibility of
Fariborz Jahanianf8dcb862009-06-19 19:55:27 +00002323 /// defining this constructor as the default constructor.
2324 void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
2325 CXXConstructorDecl *Constructor);
Mike Stump1eb44332009-09-09 15:08:12 +00002326
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002327 /// \brief Declare the implicit destructor for the given class.
2328 ///
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002329 /// \param ClassDecl The class declaration into which the implicit
2330 /// destructor will be added.
2331 ///
2332 /// \returns The implicitly-declared destructor.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002333 CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002334
Mike Stump1eb44332009-09-09 15:08:12 +00002335 /// DefineImplicitDestructor - Checks for feasibility of
Fariborz Jahanian8d2b3562009-06-26 23:49:16 +00002336 /// defining this destructor as the default destructor.
2337 void DefineImplicitDestructor(SourceLocation CurrentLocation,
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002338 CXXDestructorDecl *Destructor);
Mike Stump1eb44332009-09-09 15:08:12 +00002339
Douglas Gregor4a0c26f2010-07-01 17:57:27 +00002340 /// \brief Declare the implicit copy constructor for the given class.
2341 ///
2342 /// \param S The scope of the class, which may be NULL if this is a
2343 /// template instantiation.
2344 ///
2345 /// \param ClassDecl The class declaration into which the implicit
2346 /// copy constructor will be added.
2347 ///
2348 /// \returns The implicitly-declared copy constructor.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002349 CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
Douglas Gregor4a0c26f2010-07-01 17:57:27 +00002350
Mike Stump1eb44332009-09-09 15:08:12 +00002351 /// DefineImplicitCopyConstructor - Checks for feasibility of
Fariborz Jahanian485f0872009-06-22 23:34:40 +00002352 /// defining this constructor as the copy constructor.
2353 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
2354 CXXConstructorDecl *Constructor,
2355 unsigned TypeQuals);
Mike Stump1eb44332009-09-09 15:08:12 +00002356
Douglas Gregord3c35902010-07-01 16:36:15 +00002357 /// \brief Declare the implicit copy assignment operator for the given class.
2358 ///
2359 /// \param S The scope of the class, which may be NULL if this is a
2360 /// template instantiation.
2361 ///
2362 /// \param ClassDecl The class declaration into which the implicit
2363 /// copy-assignment operator will be added.
2364 ///
2365 /// \returns The implicitly-declared copy assignment operator.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002366 CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
Douglas Gregord3c35902010-07-01 16:36:15 +00002367
2368 /// \brief Defined an implicitly-declared copy assignment operator.
Douglas Gregor39957dc2010-05-01 15:04:51 +00002369 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
2370 CXXMethodDecl *MethodDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00002371
Douglas Gregor4923aa22010-07-02 20:37:36 +00002372 /// \brief Force the declaration of any implicitly-declared members of this
2373 /// class.
2374 void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
2375
Anders Carlssondef11992009-05-30 20:36:53 +00002376 /// MaybeBindToTemporary - If the passed in expression has a record type with
2377 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
2378 /// it simply returns the passed in expression.
2379 OwningExprResult MaybeBindToTemporary(Expr *E);
Mike Stump1eb44332009-09-09 15:08:12 +00002380
Douglas Gregor39da0b82009-09-09 23:08:42 +00002381 bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
2382 MultiExprArg ArgsPtr,
Douglas Gregor523d46a2010-04-18 07:40:54 +00002383 SourceLocation Loc,
Douglas Gregor39da0b82009-09-09 23:08:42 +00002384 ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002385
Douglas Gregor124b8782010-02-16 19:09:40 +00002386 virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
2387 IdentifierInfo &II, SourceLocation NameLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002388 Scope *S, CXXScopeSpec &SS,
Douglas Gregor124b8782010-02-16 19:09:40 +00002389 TypeTy *ObjectType,
2390 bool EnteringContext);
2391
Douglas Gregor49badde2008-10-27 19:41:14 +00002392 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002393 virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
2394 tok::TokenKind Kind,
2395 SourceLocation LAngleBracketLoc,
2396 TypeTy *Ty,
2397 SourceLocation RAngleBracketLoc,
2398 SourceLocation LParenLoc,
2399 ExprArg E,
2400 SourceLocation RParenLoc);
Reid Spencer5f016e22007-07-11 17:01:13 +00002401
John McCallc89724c2010-01-15 19:13:16 +00002402 OwningExprResult BuildCXXNamedCast(SourceLocation OpLoc,
2403 tok::TokenKind Kind,
2404 TypeSourceInfo *Ty,
2405 ExprArg E,
2406 SourceRange AngleBrackets,
2407 SourceRange Parens);
2408
Douglas Gregor57fdc8a2010-04-26 22:37:10 +00002409 OwningExprResult BuildCXXTypeId(QualType TypeInfoType,
2410 SourceLocation TypeidLoc,
2411 TypeSourceInfo *Operand,
2412 SourceLocation RParenLoc);
2413 OwningExprResult BuildCXXTypeId(QualType TypeInfoType,
2414 SourceLocation TypeidLoc,
2415 ExprArg Operand,
2416 SourceLocation RParenLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002417
Sebastian Redlf53597f2009-03-15 17:47:39 +00002418 /// ActOnCXXTypeid - Parse typeid( something ).
2419 virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc,
2420 SourceLocation LParenLoc, bool isType,
2421 void *TyOrExpr,
2422 SourceLocation RParenLoc);
Sebastian Redlc42e1182008-11-11 11:37:55 +00002423
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002424 //// ActOnCXXThis - Parse 'this' pointer.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002425 virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002426
Steve Naroff1b273c42007-09-16 14:56:35 +00002427 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002428 virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
2429 tok::TokenKind Kind);
2430
Sebastian Redl6e8ed162009-05-10 18:38:11 +00002431 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
2432 virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
2433
Chris Lattner50dd2892008-02-26 00:51:44 +00002434 //// ActOnCXXThrow - Parse throw expressions.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002435 virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc,
2436 ExprArg expr);
Sebastian Redl972041f2009-04-27 20:27:31 +00002437 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E);
Chris Lattner50dd2892008-02-26 00:51:44 +00002438
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +00002439 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
2440 /// Can be interpreted either as function-style casting ("int(x)")
2441 /// or class type construction ("ClassType(x,y,z)")
2442 /// or creation of a value-initialized type ("int()").
Sebastian Redlf53597f2009-03-15 17:47:39 +00002443 virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
2444 TypeTy *TypeRep,
2445 SourceLocation LParenLoc,
2446 MultiExprArg Exprs,
2447 SourceLocation *CommaLocs,
2448 SourceLocation RParenLoc);
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +00002449
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002450 /// ActOnCXXNew - Parsed a C++ 'new' expression.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002451 virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
2452 SourceLocation PlacementLParen,
2453 MultiExprArg PlacementArgs,
2454 SourceLocation PlacementRParen,
Douglas Gregor4bd40312010-07-13 15:54:32 +00002455 SourceRange TypeIdParens, Declarator &D,
Sebastian Redlf53597f2009-03-15 17:47:39 +00002456 SourceLocation ConstructorLParen,
2457 MultiExprArg ConstructorArgs,
2458 SourceLocation ConstructorRParen);
Douglas Gregor3433cf72009-05-21 00:00:09 +00002459 OwningExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
2460 SourceLocation PlacementLParen,
2461 MultiExprArg PlacementArgs,
2462 SourceLocation PlacementRParen,
Douglas Gregor4bd40312010-07-13 15:54:32 +00002463 SourceRange TypeIdParens,
Douglas Gregor3433cf72009-05-21 00:00:09 +00002464 QualType AllocType,
2465 SourceLocation TypeLoc,
2466 SourceRange TypeRange,
2467 ExprArg ArraySize,
2468 SourceLocation ConstructorLParen,
2469 MultiExprArg ConstructorArgs,
2470 SourceLocation ConstructorRParen);
Mike Stump1eb44332009-09-09 15:08:12 +00002471
Douglas Gregor3433cf72009-05-21 00:00:09 +00002472 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
2473 SourceRange R);
Sebastian Redl00e68e22009-02-09 18:24:27 +00002474 bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
2475 bool UseGlobal, QualType AllocType, bool IsArray,
Sebastian Redlb5a57a62008-12-03 20:26:15 +00002476 Expr **PlaceArgs, unsigned NumPlaceArgs,
2477 FunctionDecl *&OperatorNew,
2478 FunctionDecl *&OperatorDelete);
Sebastian Redl00e68e22009-02-09 18:24:27 +00002479 bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
2480 DeclarationName Name, Expr** Args,
2481 unsigned NumArgs, DeclContext *Ctx,
Sebastian Redl7f662392008-12-04 22:20:51 +00002482 bool AllowMissing, FunctionDecl *&Operator);
Sebastian Redlb5a57a62008-12-03 20:26:15 +00002483 void DeclareGlobalNewDelete();
2484 void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
Nuno Lopesfc284482009-12-16 16:59:22 +00002485 QualType Argument,
2486 bool addMallocAttr = false);
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002487
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002488 bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
Anders Carlsson5ec02ae2009-12-02 17:15:43 +00002489 DeclarationName Name, FunctionDecl* &Operator);
Anders Carlsson78f74552009-11-15 18:45:20 +00002490
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002491 /// ActOnCXXDelete - Parsed a C++ 'delete' expression
Sebastian Redlf53597f2009-03-15 17:47:39 +00002492 virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc,
2493 bool UseGlobal, bool ArrayForm,
2494 ExprArg Operand);
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002495
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00002496 virtual DeclResult ActOnCXXConditionDeclaration(Scope *S,
2497 Declarator &D);
Douglas Gregor586596f2010-05-06 17:25:47 +00002498 OwningExprResult CheckConditionVariable(VarDecl *ConditionVar,
2499 SourceLocation StmtLoc,
2500 bool ConvertToBoolean);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002501
Sebastian Redl64b45f72009-01-05 20:52:13 +00002502 /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
2503 /// pseudo-functions.
2504 virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
2505 SourceLocation KWLoc,
2506 SourceLocation LParen,
2507 TypeTy *Ty,
2508 SourceLocation RParen);
Mike Stump1eb44332009-09-09 15:08:12 +00002509
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002510 virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S,
2511 ExprArg Base,
2512 SourceLocation OpLoc,
2513 tok::TokenKind OpKind,
Douglas Gregord4dca082010-02-24 18:44:31 +00002514 TypeTy *&ObjectType,
2515 bool &MayBePseudoDestructor);
2516
Douglas Gregor77549082010-02-24 21:29:12 +00002517 OwningExprResult DiagnoseDtorReference(SourceLocation NameLoc,
2518 ExprArg MemExpr);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002519
Douglas Gregorb57fb492010-02-24 22:38:50 +00002520 OwningExprResult BuildPseudoDestructorExpr(ExprArg Base,
2521 SourceLocation OpLoc,
2522 tok::TokenKind OpKind,
2523 const CXXScopeSpec &SS,
2524 TypeSourceInfo *ScopeType,
2525 SourceLocation CCLoc,
Douglas Gregorfce46ee2010-02-24 23:50:37 +00002526 SourceLocation TildeLoc,
Douglas Gregora2e7dd22010-02-25 01:56:36 +00002527 PseudoDestructorTypeStorage DestroyedType,
Douglas Gregorb57fb492010-02-24 22:38:50 +00002528 bool HasTrailingLParen);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002529
Douglas Gregord4dca082010-02-24 18:44:31 +00002530 virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
2531 SourceLocation OpLoc,
2532 tok::TokenKind OpKind,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002533 CXXScopeSpec &SS,
Douglas Gregord4dca082010-02-24 18:44:31 +00002534 UnqualifiedId &FirstTypeName,
2535 SourceLocation CCLoc,
2536 SourceLocation TildeLoc,
2537 UnqualifiedId &SecondTypeName,
2538 bool HasTrailingLParen);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002539
Mike Stump1eb44332009-09-09 15:08:12 +00002540 /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
Anders Carlsson99ba36d2009-06-05 15:38:08 +00002541 /// non-empty, will create a new CXXExprWithTemporaries expression.
2542 /// Otherwise, just returs the passed in expression.
Anders Carlsson0ece4912009-12-15 20:51:39 +00002543 Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
Douglas Gregor90f93822009-12-22 22:17:25 +00002544 OwningExprResult MaybeCreateCXXExprWithTemporaries(OwningExprResult SubExpr);
Anders Carlsson5ee56e92009-12-16 02:09:40 +00002545 FullExpr CreateFullExpr(Expr *SubExpr);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002546
Anders Carlsson165a0a02009-05-17 18:41:29 +00002547 virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
2548
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002549 // Marks SS invalid if it represents an incomplete type.
John McCall77bb1aa2010-05-01 00:40:08 +00002550 bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
Mike Stump1eb44332009-09-09 15:08:12 +00002551
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002552 DeclContext *computeDeclContext(QualType T);
Mike Stump1eb44332009-09-09 15:08:12 +00002553 DeclContext *computeDeclContext(const CXXScopeSpec &SS,
Douglas Gregorf59a56e2009-07-21 23:53:31 +00002554 bool EnteringContext = false);
Douglas Gregor5953d8b2009-03-19 17:26:29 +00002555 bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
Douglas Gregor42af25f2009-05-11 19:58:34 +00002556 CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
2557 bool isUnknownSpecialization(const CXXScopeSpec &SS);
Douglas Gregorca5e77f2009-03-18 00:36:05 +00002558
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002559 /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the
2560 /// global scope ('::').
2561 virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S,
2562 SourceLocation CCLoc);
2563
Douglas Gregoredc90502010-02-25 04:46:04 +00002564 bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
Douglas Gregorc68afe22009-09-03 21:38:09 +00002565 NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
Mike Stump1eb44332009-09-09 15:08:12 +00002566
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002567 virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
Douglas Gregor77549082010-02-24 21:29:12 +00002568 SourceLocation IdLoc,
2569 IdentifierInfo &II,
2570 TypeTy *ObjectType);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002571
Douglas Gregorc68afe22009-09-03 21:38:09 +00002572 CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002573 CXXScopeSpec &SS,
Douglas Gregorc68afe22009-09-03 21:38:09 +00002574 SourceLocation IdLoc,
2575 SourceLocation CCLoc,
2576 IdentifierInfo &II,
2577 QualType ObjectType,
2578 NamedDecl *ScopeLookupResult,
Chris Lattner46646492009-12-07 01:36:53 +00002579 bool EnteringContext,
2580 bool ErrorRecoveryLookup);
Mike Stump1eb44332009-09-09 15:08:12 +00002581
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002582 virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002583 CXXScopeSpec &SS,
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002584 SourceLocation IdLoc,
2585 SourceLocation CCLoc,
Douglas Gregor495c35d2009-08-25 22:51:20 +00002586 IdentifierInfo &II,
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002587 TypeTy *ObjectType,
Douglas Gregor495c35d2009-08-25 22:51:20 +00002588 bool EnteringContext);
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002589
Chris Lattner46646492009-12-07 01:36:53 +00002590 virtual bool IsInvalidUnlessNestedName(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002591 CXXScopeSpec &SS,
Chris Lattner46646492009-12-07 01:36:53 +00002592 IdentifierInfo &II,
2593 TypeTy *ObjectType,
2594 bool EnteringContext);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002595
Douglas Gregor39a8de12009-02-25 19:37:18 +00002596 /// ActOnCXXNestedNameSpecifier - Called during parsing of a
2597 /// nested-name-specifier that involves a template-id, e.g.,
2598 /// "foo::bar<int, float>::", and now we need to build a scope
2599 /// specifier. \p SS is empty or the previously parsed nested-name
2600 /// part ("foo::"), \p Type is the already-parsed class template
2601 /// specialization (or other template-id that names a type), \p
2602 /// TypeRange is the source range where the type is located, and \p
2603 /// CCLoc is the location of the trailing '::'.
2604 virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
2605 const CXXScopeSpec &SS,
2606 TypeTy *Type,
2607 SourceRange TypeRange,
Douglas Gregoredc90502010-02-25 04:46:04 +00002608 SourceLocation CCLoc);
Douglas Gregor39a8de12009-02-25 19:37:18 +00002609
John McCalle7e278b2009-12-11 20:04:54 +00002610 virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2611
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002612 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2613 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2614 /// After this method is called, according to [C++ 3.4.3p3], names should be
2615 /// looked up in the declarator-id's scope, until the declarator is parsed and
2616 /// ActOnCXXExitDeclaratorScope is called.
2617 /// The 'SS' should be a non-empty valid CXXScopeSpec.
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002618 virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002619
2620 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2621 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2622 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2623 /// Used to indicate that names should revert to being looked up in the
2624 /// defining scope.
Douglas Gregor0a59acb2008-12-16 00:38:16 +00002625 virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002626
Argyrios Kyrtzidis0ffd9ff2009-06-17 22:50:06 +00002627 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
2628 /// initializer for the declaration 'Dcl'.
2629 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
2630 /// static data member of class X, names should be looked up in the scope of
2631 /// class X.
2632 virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl);
2633
2634 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
2635 /// initializer for the declaration 'Dcl'.
2636 virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl);
2637
Anders Carlsson55085182007-08-21 17:43:55 +00002638 // ParseObjCStringLiteral - Parse Objective-C string literals.
Mike Stump1eb44332009-09-09 15:08:12 +00002639 virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
Chris Lattnerb3a99cd2007-12-12 01:04:12 +00002640 ExprTy **Strings,
2641 unsigned NumStrings);
Mike Stump1eb44332009-09-09 15:08:12 +00002642
2643 Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
Douglas Gregor81d34662010-04-20 15:39:42 +00002644 TypeSourceInfo *EncodedTypeInfo,
Mike Stump1eb44332009-09-09 15:08:12 +00002645 SourceLocation RParenLoc);
John McCall6bb80172010-03-30 21:47:33 +00002646 CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp,
2647 NamedDecl *FoundDecl,
2648 CXXMethodDecl *Method);
Fariborz Jahanianb7400232009-09-28 23:23:40 +00002649
Anders Carlssonf9bcf012007-08-22 15:14:15 +00002650 virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
Chris Lattner674af952007-10-16 22:51:17 +00002651 SourceLocation EncodeLoc,
Anders Carlssonf9bcf012007-08-22 15:14:15 +00002652 SourceLocation LParenLoc,
2653 TypeTy *Ty,
2654 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002655
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00002656 // ParseObjCSelectorExpression - Build selector expression for @selector
2657 virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
2658 SourceLocation AtLoc,
Fariborz Jahanian2a35fa92007-10-16 23:21:02 +00002659 SourceLocation SelLoc,
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00002660 SourceLocation LParenLoc,
2661 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002662
Fariborz Jahanian390d50a2007-10-17 16:58:11 +00002663 // ParseObjCProtocolExpression - Build protocol expression for @protocol
2664 virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
2665 SourceLocation AtLoc,
2666 SourceLocation ProtoLoc,
2667 SourceLocation LParenLoc,
2668 SourceLocation RParenLoc);
Douglas Gregore37ac4f2008-04-13 21:30:24 +00002669
2670 //===--------------------------------------------------------------------===//
Douglas Gregor074149e2009-01-05 19:45:36 +00002671 // C++ Declarations
2672 //
Chris Lattnerb28317a2009-03-28 19:18:32 +00002673 virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S,
2674 SourceLocation ExternLoc,
2675 SourceLocation LangLoc,
Benjamin Kramerd5663812010-05-03 13:08:54 +00002676 llvm::StringRef Lang,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002677 SourceLocation LBraceLoc);
2678 virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S,
2679 DeclPtrTy LinkageSpec,
2680 SourceLocation RBraceLoc);
Douglas Gregor074149e2009-01-05 19:45:36 +00002681
2682
2683 //===--------------------------------------------------------------------===//
Douglas Gregore37ac4f2008-04-13 21:30:24 +00002684 // C++ Classes
2685 //
Argyrios Kyrtzidiseb83ecd2008-11-08 16:45:02 +00002686 virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
2687 const CXXScopeSpec *SS);
Sebastian Redle2b68332009-04-12 17:16:29 +00002688
Abramo Bagnara6206d532010-06-05 05:09:32 +00002689 virtual DeclPtrTy ActOnAccessSpecifier(AccessSpecifier Access,
2690 SourceLocation ASLoc,
2691 SourceLocation ColonLoc);
2692
Chris Lattnerb28317a2009-03-28 19:18:32 +00002693 virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
2694 Declarator &D,
Douglas Gregor37b372b2009-08-20 22:52:58 +00002695 MultiTemplateParamsArg TemplateParameterLists,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002696 ExprTy *BitfieldWidth,
Sebastian Redld1a78462009-11-24 23:38:44 +00002697 ExprTy *Init, bool IsDefinition,
Sebastian Redle2b68332009-04-12 17:16:29 +00002698 bool Deleted = false);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002699
Chris Lattnerb28317a2009-03-28 19:18:32 +00002700 virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
Douglas Gregor7ad83902008-11-05 04:29:56 +00002701 Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002702 CXXScopeSpec &SS,
Douglas Gregor7ad83902008-11-05 04:29:56 +00002703 IdentifierInfo *MemberOrBase,
Fariborz Jahanian96174332009-07-01 19:21:19 +00002704 TypeTy *TemplateTypeTy,
Douglas Gregor7ad83902008-11-05 04:29:56 +00002705 SourceLocation IdLoc,
2706 SourceLocation LParenLoc,
2707 ExprTy **Args, unsigned NumArgs,
2708 SourceLocation *CommaLocs,
2709 SourceLocation RParenLoc);
2710
Eli Friedman59c04372009-07-29 19:44:27 +00002711 MemInitResult BuildMemberInitializer(FieldDecl *Member, Expr **Args,
2712 unsigned NumArgs, SourceLocation IdLoc,
Douglas Gregor802ab452009-12-02 22:36:29 +00002713 SourceLocation LParenLoc,
Eli Friedman59c04372009-07-29 19:44:27 +00002714 SourceLocation RParenLoc);
2715
Douglas Gregor802ab452009-12-02 22:36:29 +00002716 MemInitResult BuildBaseInitializer(QualType BaseType,
John McCalla93c9342009-12-07 02:54:59 +00002717 TypeSourceInfo *BaseTInfo,
Douglas Gregor802ab452009-12-02 22:36:29 +00002718 Expr **Args, unsigned NumArgs,
2719 SourceLocation LParenLoc,
Eli Friedman59c04372009-07-29 19:44:27 +00002720 SourceLocation RParenLoc,
2721 CXXRecordDecl *ClassDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00002722
Benjamin Kramer3f17a372009-11-09 20:14:44 +00002723 bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
Douglas Gregor9db7dbb2010-01-31 09:12:51 +00002724 CXXBaseOrMemberInitializer **Initializers,
Anders Carlssonec3332b2010-04-02 03:43:34 +00002725 unsigned NumInitializers, bool AnyErrors);
Fariborz Jahaniane4498c62010-04-28 16:11:27 +00002726
2727 void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
2728
Mike Stump1eb44332009-09-09 15:08:12 +00002729
John McCallef027fe2010-03-16 21:39:52 +00002730 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
2731 /// mark all the non-trivial destructors of its members and bases as
2732 /// referenced.
2733 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
2734 CXXRecordDecl *Record);
Mike Stump1eb44332009-09-09 15:08:12 +00002735
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002736 /// \brief The list of classes whose vtables have been used within
2737 /// this translation unit, and the source locations at which the
2738 /// first use occurred.
2739 llvm::SmallVector<std::pair<CXXRecordDecl *, SourceLocation>, 16>
2740 VTableUses;
Anders Carlssond6a637f2009-12-07 08:24:59 +00002741
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002742 /// \brief The set of classes whose vtables have been used within
2743 /// this translation unit, and a bit that will be true if the vtable is
2744 /// required to be emitted (otherwise, it should be emitted only if needed
2745 /// by code generation).
2746 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
2747
2748 /// \brief A list of all of the dynamic classes in this translation
2749 /// unit.
2750 llvm::SmallVector<CXXRecordDecl *, 16> DynamicClasses;
2751
2752 /// \brief Note that the vtable for the given class was used at the
2753 /// given location.
2754 void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
2755 bool DefinitionRequired = false);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002756
Anders Carlssond6a637f2009-12-07 08:24:59 +00002757 /// MarkVirtualMembersReferenced - Will mark all virtual members of the given
2758 /// CXXRecordDecl referenced.
Rafael Espindola3e1ae932010-03-26 00:36:59 +00002759 void MarkVirtualMembersReferenced(SourceLocation Loc,
2760 const CXXRecordDecl *RD);
Anders Carlssond6a637f2009-12-07 08:24:59 +00002761
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002762 /// \brief Define all of the vtables that have been used in this
2763 /// translation unit and reference any virtual members used by those
2764 /// vtables.
2765 ///
2766 /// \returns true if any work was done, false otherwise.
2767 bool DefineUsedVTables();
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002768
Douglas Gregor23c94db2010-07-02 17:43:08 +00002769 void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
Douglas Gregor396b7cd2008-11-03 17:51:48 +00002770
Mike Stump1eb44332009-09-09 15:08:12 +00002771 virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
Anders Carlssona7b35212009-03-25 02:58:17 +00002772 SourceLocation ColonLoc,
Douglas Gregor9db7dbb2010-01-31 09:12:51 +00002773 MemInitTy **MemInits, unsigned NumMemInits,
2774 bool AnyErrors);
Mike Stump1eb44332009-09-09 15:08:12 +00002775
Douglas Gregor23c94db2010-07-02 17:43:08 +00002776 void CheckCompletedCXXClass(CXXRecordDecl *Record);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002777 virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002778 DeclPtrTy TagDecl,
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002779 SourceLocation LBrac,
Douglas Gregor0b4c9b52010-03-29 14:42:08 +00002780 SourceLocation RBrac,
2781 AttributeList *AttrList);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002782
Douglas Gregor6569d682009-05-27 23:11:45 +00002783 virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template);
John McCall7a1dc562009-12-19 10:49:29 +00002784 virtual void ActOnStartDelayedMemberDeclarations(Scope *S,
2785 DeclPtrTy Record);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002786 virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
2787 DeclPtrTy Method);
2788 virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param);
2789 virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
2790 DeclPtrTy Method);
John McCall7a1dc562009-12-19 10:49:29 +00002791 virtual void ActOnFinishDelayedMemberDeclarations(Scope *S,
2792 DeclPtrTy Record);
Douglas Gregor72b505b2008-12-16 21:30:33 +00002793
Mike Stump1eb44332009-09-09 15:08:12 +00002794 virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002795 ExprArg AssertExpr,
2796 ExprArg AssertMessageExpr);
Mike Stump1eb44332009-09-09 15:08:12 +00002797
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002798 FriendDecl *CheckFriendTypeDecl(SourceLocation FriendLoc,
Douglas Gregor1d869352010-04-07 16:53:43 +00002799 TypeSourceInfo *TSInfo);
John McCalldd4a3b02009-09-16 22:47:08 +00002800 DeclPtrTy ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
2801 MultiTemplateParamsArg TemplateParams);
John McCallbbbcdd92009-09-11 21:02:39 +00002802 DeclPtrTy ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition,
2803 MultiTemplateParamsArg TemplateParams);
Anders Carlsson00338362009-05-11 22:55:49 +00002804
Chris Lattner65401802009-04-25 08:28:21 +00002805 QualType CheckConstructorDeclarator(Declarator &D, QualType R,
2806 FunctionDecl::StorageClass& SC);
Chris Lattner6e475012009-04-25 08:35:12 +00002807 void CheckConstructor(CXXConstructorDecl *Constructor);
Douglas Gregord92ec472010-07-01 05:10:53 +00002808 QualType CheckDestructorDeclarator(Declarator &D, QualType R,
Chris Lattner65401802009-04-25 08:28:21 +00002809 FunctionDecl::StorageClass& SC);
Anders Carlsson5ec02ae2009-12-02 17:15:43 +00002810 bool CheckDestructor(CXXDestructorDecl *Destructor);
Chris Lattner6e475012009-04-25 08:35:12 +00002811 void CheckConversionDeclarator(Declarator &D, QualType &R,
Douglas Gregor2f1bc522008-11-07 20:08:42 +00002812 FunctionDecl::StorageClass& SC);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002813 DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002814
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002815 //===--------------------------------------------------------------------===//
2816 // C++ Derived Classes
2817 //
2818
2819 /// ActOnBaseSpecifier - Parsed a base specifier
Douglas Gregor2943aed2009-03-03 04:44:36 +00002820 CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
2821 SourceRange SpecifierRange,
2822 bool Virtual, AccessSpecifier Access,
Nick Lewycky56062202010-07-26 16:56:01 +00002823 TypeSourceInfo *TInfo);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002824
2825 /// SetClassDeclAttributesFromBase - Copies class decl traits
2826 /// (such as whether the class has a trivial constructor,
Anders Carlsson51f94042009-12-03 17:49:57 +00002827 /// trivial destructor etc) from the given base class.
2828 void SetClassDeclAttributesFromBase(CXXRecordDecl *Class,
2829 const CXXRecordDecl *BaseClass,
2830 bool BaseIsVirtual);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002831
Mike Stump1eb44332009-09-09 15:08:12 +00002832 virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002833 SourceRange SpecifierRange,
2834 bool Virtual, AccessSpecifier Access,
Mike Stump1eb44332009-09-09 15:08:12 +00002835 TypeTy *basetype, SourceLocation
Douglas Gregor2943aed2009-03-03 04:44:36 +00002836 BaseLoc);
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002837
Douglas Gregor2943aed2009-03-03 04:44:36 +00002838 bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
2839 unsigned NumBases);
Mike Stump1eb44332009-09-09 15:08:12 +00002840 virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002841 unsigned NumBases);
2842
2843 bool IsDerivedFrom(QualType Derived, QualType Base);
Douglas Gregora8f32e02009-10-06 17:59:45 +00002844 bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths);
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00002845
2846 // FIXME: I don't like this name.
John McCallf871d0c2010-08-07 06:22:56 +00002847 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00002848
John McCallf871d0c2010-08-07 06:22:56 +00002849 bool BasePathInvolvesVirtualBase(const CXXCastPath &BasePath);
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002850
Douglas Gregor0575d4a2008-10-24 16:17:19 +00002851 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00002852 SourceLocation Loc, SourceRange Range,
John McCallf871d0c2010-08-07 06:22:56 +00002853 CXXCastPath *BasePath = 0,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00002854 bool IgnoreAccess = false);
Anders Carlssond8f9cb02009-05-13 21:11:42 +00002855 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
John McCall58e6f342010-03-16 05:22:47 +00002856 unsigned InaccessibleBaseID,
Anders Carlssond8f9cb02009-05-13 21:11:42 +00002857 unsigned AmbigiousBaseConvID,
2858 SourceLocation Loc, SourceRange Range,
Anders Carlssone25a96c2010-04-24 17:11:09 +00002859 DeclarationName Name,
John McCallf871d0c2010-08-07 06:22:56 +00002860 CXXCastPath *BasePath);
Mike Stump1eb44332009-09-09 15:08:12 +00002861
Douglas Gregora8f32e02009-10-06 17:59:45 +00002862 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
Mike Stump1eb44332009-09-09 15:08:12 +00002863
Sebastian Redl23c7d062009-07-07 20:29:57 +00002864 /// CheckOverridingFunctionReturnType - Checks whether the return types are
2865 /// covariant, according to C++ [class.virtual]p5.
2866 bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
Anders Carlssond7ba27d2009-05-14 01:09:04 +00002867 const CXXMethodDecl *Old);
Sebastian Redl23c7d062009-07-07 20:29:57 +00002868
2869 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
2870 /// spec is a subset of base spec.
2871 bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
2872 const CXXMethodDecl *Old);
Douglas Gregore37ac4f2008-04-13 21:30:24 +00002873
Sean Huntbbd37c62009-11-21 08:43:09 +00002874 /// CheckOverridingFunctionAttributes - Checks whether attributes are
2875 /// incompatible or prevent overriding.
2876 bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
2877 const CXXMethodDecl *Old);
2878
Douglas Gregor4ba31362009-12-01 17:24:26 +00002879 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
Nick Lewycky03d98c52010-07-06 19:51:49 +00002880
Anders Carlsson29f006b2009-03-27 05:05:05 +00002881 //===--------------------------------------------------------------------===//
2882 // C++ Access Control
2883 //
Sebastian Redl726212f2009-07-18 14:32:15 +00002884
John McCall6b2accb2010-02-10 09:31:12 +00002885 enum AccessResult {
2886 AR_accessible,
2887 AR_inaccessible,
2888 AR_dependent,
2889 AR_delayed
2890 };
2891
Mike Stump1eb44332009-09-09 15:08:12 +00002892 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
Anders Carlsson29f006b2009-03-27 05:05:05 +00002893 NamedDecl *PrevMemberDecl,
2894 AccessSpecifier LexicalAS);
Sebastian Redl726212f2009-07-18 14:32:15 +00002895
John McCall6b2accb2010-02-10 09:31:12 +00002896 AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
John McCall9aa472c2010-03-19 07:35:19 +00002897 DeclAccessPair FoundDecl);
John McCall6b2accb2010-02-10 09:31:12 +00002898 AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
John McCall9aa472c2010-03-19 07:35:19 +00002899 DeclAccessPair FoundDecl);
John McCall90c8c572010-03-18 08:19:33 +00002900 AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
2901 SourceRange PlacementRange,
2902 CXXRecordDecl *NamingClass,
John McCall9aa472c2010-03-19 07:35:19 +00002903 DeclAccessPair FoundDecl);
John McCall6b2accb2010-02-10 09:31:12 +00002904 AccessResult CheckConstructorAccess(SourceLocation Loc,
2905 CXXConstructorDecl *D,
Anders Carlsson9a68a672010-04-21 18:47:17 +00002906 const InitializedEntity &Entity,
Jeffrey Yasskin57d12fd2010-06-07 15:58:05 +00002907 AccessSpecifier Access,
2908 bool IsCopyBindingRefToTemp = false);
John McCall6b2accb2010-02-10 09:31:12 +00002909 AccessResult CheckDestructorAccess(SourceLocation Loc,
John McCall58e6f342010-03-16 05:22:47 +00002910 CXXDestructorDecl *Dtor,
2911 const PartialDiagnostic &PDiag);
John McCallb0207482010-03-16 06:11:48 +00002912 AccessResult CheckDirectMemberAccess(SourceLocation Loc,
2913 NamedDecl *D,
2914 const PartialDiagnostic &PDiag);
John McCall6b2accb2010-02-10 09:31:12 +00002915 AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
2916 Expr *ObjectExpr,
John McCall58e6f342010-03-16 05:22:47 +00002917 Expr *ArgExpr,
John McCall9aa472c2010-03-19 07:35:19 +00002918 DeclAccessPair FoundDecl);
John McCall6bb80172010-03-30 21:47:33 +00002919 AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
2920 DeclAccessPair FoundDecl);
John McCall6b2accb2010-02-10 09:31:12 +00002921 AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
John McCall6b2accb2010-02-10 09:31:12 +00002922 QualType Base, QualType Derived,
2923 const CXXBasePath &Path,
John McCall58e6f342010-03-16 05:22:47 +00002924 unsigned DiagID,
John McCall6b2accb2010-02-10 09:31:12 +00002925 bool ForceCheck = false,
John McCall58e6f342010-03-16 05:22:47 +00002926 bool ForceUnprivileged = false);
John McCall6b2accb2010-02-10 09:31:12 +00002927 void CheckLookupAccess(const LookupResult &R);
John McCall92f88312010-01-23 00:46:32 +00002928
John McCall0c01d182010-03-24 05:22:00 +00002929 void HandleDependentAccessCheck(const DependentDiagnostic &DD,
2930 const MultiLevelTemplateArgumentList &TemplateArgs);
2931 void PerformDependentDiagnostics(const DeclContext *Pattern,
2932 const MultiLevelTemplateArgumentList &TemplateArgs);
2933
John McCall2f514482010-01-27 03:50:35 +00002934 void HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *Ctx);
Sebastian Redl726212f2009-07-18 14:32:15 +00002935
Chandler Carruth926c4b42010-06-28 08:39:25 +00002936 /// A flag to suppress access checking.
2937 bool SuppressAccessChecking;
2938
2939 void ActOnStartSuppressingAccessChecks();
2940 void ActOnStopSuppressingAccessChecks();
2941
Anders Carlsson8211eff2009-03-24 01:19:16 +00002942 enum AbstractDiagSelID {
2943 AbstractNone = -1,
2944 AbstractReturnType,
2945 AbstractParamType,
2946 AbstractVariableType,
2947 AbstractFieldType
2948 };
Mike Stump1eb44332009-09-09 15:08:12 +00002949
Anders Carlssona6ec7ad2009-08-27 00:13:57 +00002950 bool RequireNonAbstractType(SourceLocation Loc, QualType T,
2951 const PartialDiagnostic &PD,
2952 const CXXRecordDecl *CurrentRD = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00002953
2954 bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
Anders Carlssone65a3c82009-03-24 17:23:42 +00002955 AbstractDiagSelID SelID = AbstractNone,
2956 const CXXRecordDecl *CurrentRD = 0);
Anders Carlsson4681ebd2009-03-22 20:18:17 +00002957
Douglas Gregor1cd1b1e2008-11-06 22:13:31 +00002958 //===--------------------------------------------------------------------===//
2959 // C++ Overloaded Operators [C++ 13.5]
2960 //
2961
2962 bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
2963
Sean Hunta6c058d2010-01-13 09:01:02 +00002964 bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
2965
Douglas Gregor72c3f312008-12-05 18:15:24 +00002966 //===--------------------------------------------------------------------===//
2967 // C++ Templates [C++ 14]
2968 //
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002969 void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
Douglas Gregor1fd6d442010-05-21 23:18:07 +00002970 QualType ObjectType, bool EnteringContext,
2971 bool &MemberOfUnknownSpecialization);
John McCallf7a1a742009-11-24 19:00:30 +00002972
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002973 virtual TemplateNameKind isTemplateName(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002974 CXXScopeSpec &SS,
Abramo Bagnara7c153532010-08-06 12:11:11 +00002975 bool hasTemplateKeyword,
Douglas Gregor014e88d2009-11-03 23:16:33 +00002976 UnqualifiedId &Name,
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002977 TypeTy *ObjectType,
Douglas Gregor495c35d2009-08-25 22:51:20 +00002978 bool EnteringContext,
Douglas Gregor1fd6d442010-05-21 23:18:07 +00002979 TemplateTy &Template,
2980 bool &MemberOfUnknownSpecialization);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002981
2982 virtual bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
Douglas Gregor84d0a192010-01-12 21:28:44 +00002983 SourceLocation IILoc,
2984 Scope *S,
2985 const CXXScopeSpec *SS,
2986 TemplateTy &SuggestedTemplate,
2987 TemplateNameKind &SuggestedKind);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002988
Douglas Gregor72c3f312008-12-05 18:15:24 +00002989 bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002990 TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl);
Douglas Gregoraaba5e32009-02-04 19:02:06 +00002991
Mike Stump1eb44332009-09-09 15:08:12 +00002992 virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
Anders Carlsson941df7d2009-06-12 19:58:00 +00002993 SourceLocation EllipsisLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002994 SourceLocation KeyLoc,
2995 IdentifierInfo *ParamName,
2996 SourceLocation ParamNameLoc,
Douglas Gregorbb3310a2010-07-01 00:00:45 +00002997 unsigned Depth, unsigned Position,
2998 SourceLocation EqualLoc,
2999 TypeTy *DefaultArg);
Douglas Gregord684b002009-02-10 19:49:53 +00003000
Douglas Gregor2943aed2009-03-03 04:44:36 +00003001 QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
Chris Lattnerb28317a2009-03-28 19:18:32 +00003002 virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
3003 unsigned Depth,
Douglas Gregorbb3310a2010-07-01 00:00:45 +00003004 unsigned Position,
3005 SourceLocation EqualLoc,
3006 ExprArg DefaultArg);
Chris Lattnerb28317a2009-03-28 19:18:32 +00003007 virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S,
3008 SourceLocation TmpLoc,
3009 TemplateParamsTy *Params,
3010 IdentifierInfo *ParamName,
3011 SourceLocation ParamNameLoc,
3012 unsigned Depth,
Douglas Gregorbb3310a2010-07-01 00:00:45 +00003013 unsigned Position,
3014 SourceLocation EqualLoc,
3015 const ParsedTemplateArgument &DefaultArg);
Douglas Gregord684b002009-02-10 19:49:53 +00003016
Douglas Gregorc4b4e7b2008-12-24 02:52:09 +00003017 virtual TemplateParamsTy *
3018 ActOnTemplateParameterList(unsigned Depth,
3019 SourceLocation ExportLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00003020 SourceLocation TemplateLoc,
Douglas Gregorc4b4e7b2008-12-24 02:52:09 +00003021 SourceLocation LAngleLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00003022 DeclPtrTy *Params, unsigned NumParams,
Douglas Gregorc4b4e7b2008-12-24 02:52:09 +00003023 SourceLocation RAngleLoc);
Douglas Gregor5b6d70e2009-11-25 17:50:39 +00003024
3025 /// \brief The context in which we are checking a template parameter
3026 /// list.
3027 enum TemplateParamListContext {
3028 TPC_ClassTemplate,
3029 TPC_FunctionTemplate,
3030 TPC_ClassTemplateMember,
3031 TPC_FriendFunctionTemplate
3032 };
3033
Douglas Gregord684b002009-02-10 19:49:53 +00003034 bool CheckTemplateParameterList(TemplateParameterList *NewParams,
Douglas Gregor5b6d70e2009-11-25 17:50:39 +00003035 TemplateParameterList *OldParams,
3036 TemplateParamListContext TPC);
Douglas Gregorf59a56e2009-07-21 23:53:31 +00003037 TemplateParameterList *
3038 MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
3039 const CXXScopeSpec &SS,
3040 TemplateParameterList **ParamLists,
Douglas Gregor1fef4e62009-10-07 22:35:40 +00003041 unsigned NumParamLists,
John McCall77e8b112010-04-13 20:37:33 +00003042 bool IsFriend,
Douglas Gregor0167f3c2010-07-14 23:14:12 +00003043 bool &IsExplicitSpecialization,
3044 bool &Invalid);
Mike Stump1eb44332009-09-09 15:08:12 +00003045
John McCall0f434ec2009-07-31 02:45:11 +00003046 DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003047 SourceLocation KWLoc, CXXScopeSpec &SS,
Douglas Gregorbd1099e2009-07-23 16:36:45 +00003048 IdentifierInfo *Name, SourceLocation NameLoc,
3049 AttributeList *Attr,
Douglas Gregor05396e22009-08-25 17:23:04 +00003050 TemplateParameterList *TemplateParams,
Douglas Gregorbd1099e2009-07-23 16:36:45 +00003051 AccessSpecifier AS);
Douglas Gregorddc29e12009-02-06 22:42:48 +00003052
John McCalld5532b62009-11-23 01:53:49 +00003053 void translateTemplateArguments(const ASTTemplateArgsPtr &In,
3054 TemplateArgumentListInfo &Out);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003055
Douglas Gregor7532dc62009-03-30 22:58:21 +00003056 QualType CheckTemplateIdType(TemplateName Template,
3057 SourceLocation TemplateLoc,
John McCalld5532b62009-11-23 01:53:49 +00003058 const TemplateArgumentListInfo &TemplateArgs);
Douglas Gregor40808ce2009-03-09 23:48:35 +00003059
Douglas Gregorcc636682009-02-17 23:15:12 +00003060 virtual TypeResult
Douglas Gregor7532dc62009-03-30 22:58:21 +00003061 ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc,
3062 SourceLocation LAngleLoc,
3063 ASTTemplateArgsPtr TemplateArgs,
John McCall6b2becf2009-09-08 17:47:29 +00003064 SourceLocation RAngleLoc);
3065
3066 virtual TypeResult ActOnTagTemplateIdType(TypeResult Type,
3067 TagUseKind TUK,
3068 DeclSpec::TST TagSpec,
3069 SourceLocation TagLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00003070
John McCallf7a1a742009-11-24 19:00:30 +00003071 OwningExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
3072 LookupResult &R,
3073 bool RequiresADL,
John McCalld5532b62009-11-23 01:53:49 +00003074 const TemplateArgumentListInfo &TemplateArgs);
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003075 OwningExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
John McCallf7a1a742009-11-24 19:00:30 +00003076 DeclarationName Name,
3077 SourceLocation NameLoc,
3078 const TemplateArgumentListInfo &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003079
Douglas Gregord6ab2322010-06-16 23:00:59 +00003080 virtual TemplateNameKind ActOnDependentTemplateName(Scope *S,
3081 SourceLocation TemplateKWLoc,
3082 CXXScopeSpec &SS,
3083 UnqualifiedId &Name,
3084 TypeTy *ObjectType,
3085 bool EnteringContext,
3086 TemplateTy &Template);
Douglas Gregorc45c2322009-03-31 00:43:58 +00003087
Douglas Gregore94866f2009-06-12 21:21:02 +00003088 bool CheckClassTemplatePartialSpecializationArgs(
3089 TemplateParameterList *TemplateParams,
Anders Carlsson6360be72009-06-13 18:20:51 +00003090 const TemplateArgumentListBuilder &TemplateArgs,
Douglas Gregor6aa75cf2009-06-12 22:08:06 +00003091 bool &MirrorsPrimaryTemplate);
Douglas Gregore94866f2009-06-12 21:21:02 +00003092
Douglas Gregor212e81c2009-03-25 00:13:59 +00003093 virtual DeclResult
John McCall0f434ec2009-07-31 02:45:11 +00003094 ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
Mike Stump1eb44332009-09-09 15:08:12 +00003095 SourceLocation KWLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003096 CXXScopeSpec &SS,
Douglas Gregor7532dc62009-03-30 22:58:21 +00003097 TemplateTy Template,
Douglas Gregorcc636682009-02-17 23:15:12 +00003098 SourceLocation TemplateNameLoc,
Douglas Gregor55f6b142009-02-09 18:46:07 +00003099 SourceLocation LAngleLoc,
Douglas Gregor5908e9f2009-02-09 19:34:22 +00003100 ASTTemplateArgsPtr TemplateArgs,
Douglas Gregor55f6b142009-02-09 18:46:07 +00003101 SourceLocation RAngleLoc,
Douglas Gregorcc636682009-02-17 23:15:12 +00003102 AttributeList *Attr,
3103 MultiTemplateParamsArg TemplateParameterLists);
Douglas Gregor55f6b142009-02-09 18:46:07 +00003104
Mike Stump1eb44332009-09-09 15:08:12 +00003105 virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
Douglas Gregore542c862009-06-23 23:11:28 +00003106 MultiTemplateParamsArg TemplateParameterLists,
3107 Declarator &D);
Mike Stump1eb44332009-09-09 15:08:12 +00003108
3109 virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
Chris Lattner3d4b4822010-07-13 19:22:31 +00003110 MultiTemplateParamsArg TemplateParameterLists,
Douglas Gregor52591bf2009-06-24 00:54:41 +00003111 Declarator &D);
Mike Stump1eb44332009-09-09 15:08:12 +00003112
Douglas Gregor0d035142009-10-27 18:42:08 +00003113 bool
3114 CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
3115 TemplateSpecializationKind NewTSK,
3116 NamedDecl *PrevDecl,
3117 TemplateSpecializationKind PrevTSK,
Chris Lattner3d4b4822010-07-13 19:22:31 +00003118 SourceLocation PrevPtOfInstantiation,
Douglas Gregor0d035142009-10-27 18:42:08 +00003119 bool &SuppressNew);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003120
John McCallaf2094e2010-04-08 09:05:18 +00003121 bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
3122 const TemplateArgumentListInfo &ExplicitTemplateArgs,
3123 LookupResult &Previous);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003124
Douglas Gregorb9aa6b22009-09-24 23:14:47 +00003125 bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
John McCalld5532b62009-11-23 01:53:49 +00003126 const TemplateArgumentListInfo *ExplicitTemplateArgs,
John McCall68263142009-11-18 22:49:29 +00003127 LookupResult &Previous);
3128 bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003129
Douglas Gregor93dfdb12009-05-13 00:25:59 +00003130 virtual DeclResult
Mike Stump1eb44332009-09-09 15:08:12 +00003131 ActOnExplicitInstantiation(Scope *S,
Douglas Gregor45f96552009-09-04 06:33:52 +00003132 SourceLocation ExternLoc,
3133 SourceLocation TemplateLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00003134 unsigned TagSpec,
Douglas Gregor93dfdb12009-05-13 00:25:59 +00003135 SourceLocation KWLoc,
3136 const CXXScopeSpec &SS,
3137 TemplateTy Template,
3138 SourceLocation TemplateNameLoc,
3139 SourceLocation LAngleLoc,
3140 ASTTemplateArgsPtr TemplateArgs,
Douglas Gregor93dfdb12009-05-13 00:25:59 +00003141 SourceLocation RAngleLoc,
3142 AttributeList *Attr);
3143
Douglas Gregor3f5b61c2009-05-14 00:28:11 +00003144 virtual DeclResult
Mike Stump1eb44332009-09-09 15:08:12 +00003145 ActOnExplicitInstantiation(Scope *S,
Douglas Gregor45f96552009-09-04 06:33:52 +00003146 SourceLocation ExternLoc,
3147 SourceLocation TemplateLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00003148 unsigned TagSpec,
Douglas Gregor3f5b61c2009-05-14 00:28:11 +00003149 SourceLocation KWLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003150 CXXScopeSpec &SS,
Douglas Gregor3f5b61c2009-05-14 00:28:11 +00003151 IdentifierInfo *Name,
3152 SourceLocation NameLoc,
3153 AttributeList *Attr);
3154
Douglas Gregord5a423b2009-09-25 18:43:00 +00003155 virtual DeclResult ActOnExplicitInstantiation(Scope *S,
3156 SourceLocation ExternLoc,
3157 SourceLocation TemplateLoc,
3158 Declarator &D);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003159
3160 TemplateArgumentLoc
Douglas Gregor51ffb0c2009-11-25 18:55:14 +00003161 SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
3162 SourceLocation TemplateLoc,
3163 SourceLocation RAngleLoc,
3164 Decl *Param,
3165 TemplateArgumentListBuilder &Converted);
3166
Douglas Gregor02024a92010-03-28 02:42:43 +00003167 /// \brief Specifies the context in which a particular template
3168 /// argument is being checked.
3169 enum CheckTemplateArgumentKind {
3170 /// \brief The template argument was specified in the code or was
3171 /// instantiated with some deduced template arguments.
3172 CTAK_Specified,
3173
3174 /// \brief The template argument was deduced via template argument
3175 /// deduction.
3176 CTAK_Deduced,
3177
3178 /// \brief The template argument was deduced from an array bound
3179 /// via template argument deduction.
3180 CTAK_DeducedFromArrayBound
3181 };
3182
Douglas Gregore7526412009-11-11 19:31:23 +00003183 bool CheckTemplateArgument(NamedDecl *Param,
3184 const TemplateArgumentLoc &Arg,
Douglas Gregore7526412009-11-11 19:31:23 +00003185 TemplateDecl *Template,
3186 SourceLocation TemplateLoc,
Douglas Gregore7526412009-11-11 19:31:23 +00003187 SourceLocation RAngleLoc,
Douglas Gregor02024a92010-03-28 02:42:43 +00003188 TemplateArgumentListBuilder &Converted,
3189 CheckTemplateArgumentKind CTAK = CTAK_Specified);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003190
Douglas Gregorc15cb382009-02-09 23:23:08 +00003191 bool CheckTemplateArgumentList(TemplateDecl *Template,
3192 SourceLocation TemplateLoc,
John McCalld5532b62009-11-23 01:53:49 +00003193 const TemplateArgumentListInfo &TemplateArgs,
Douglas Gregor16134c62009-07-01 00:28:38 +00003194 bool PartialTemplateArgs,
Anders Carlsson1c5976e2009-06-05 03:43:12 +00003195 TemplateArgumentListBuilder &Converted);
Douglas Gregorc15cb382009-02-09 23:23:08 +00003196
Mike Stump1eb44332009-09-09 15:08:12 +00003197 bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
John McCall833ca992009-10-29 08:12:44 +00003198 const TemplateArgumentLoc &Arg,
Anders Carlsson436b1562009-06-13 00:33:33 +00003199 TemplateArgumentListBuilder &Converted);
3200
John McCall833ca992009-10-29 08:12:44 +00003201 bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
John McCalla93c9342009-12-07 02:54:59 +00003202 TypeSourceInfo *Arg);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003203 bool CheckTemplateArgumentPointerToMember(Expr *Arg,
Douglas Gregorcaddba02009-11-12 18:38:13 +00003204 TemplateArgument &Converted);
Mike Stump1eb44332009-09-09 15:08:12 +00003205 bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
Douglas Gregor2943aed2009-03-03 04:44:36 +00003206 QualType InstantiatedParamType, Expr *&Arg,
Douglas Gregor02024a92010-03-28 02:42:43 +00003207 TemplateArgument &Converted,
3208 CheckTemplateArgumentKind CTAK = CTAK_Specified);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003209 bool CheckTemplateArgument(TemplateTemplateParmDecl *Param,
Douglas Gregor788cd062009-11-11 01:00:40 +00003210 const TemplateArgumentLoc &Arg);
Douglas Gregor02024a92010-03-28 02:42:43 +00003211
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003212 OwningExprResult
Douglas Gregor02024a92010-03-28 02:42:43 +00003213 BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
3214 QualType ParamType,
3215 SourceLocation Loc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003216 OwningExprResult
Douglas Gregor02024a92010-03-28 02:42:43 +00003217 BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
3218 SourceLocation Loc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003219
Douglas Gregorfb898e12009-11-12 16:20:59 +00003220 /// \brief Enumeration describing how template parameter lists are compared
3221 /// for equality.
3222 enum TemplateParameterListEqualKind {
3223 /// \brief We are matching the template parameter lists of two templates
3224 /// that might be redeclarations.
3225 ///
3226 /// \code
3227 /// template<typename T> struct X;
3228 /// template<typename T> struct X;
3229 /// \endcode
3230 TPL_TemplateMatch,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003231
Douglas Gregorfb898e12009-11-12 16:20:59 +00003232 /// \brief We are matching the template parameter lists of two template
3233 /// template parameters as part of matching the template parameter lists
3234 /// of two templates that might be redeclarations.
3235 ///
3236 /// \code
3237 /// template<template<int I> class TT> struct X;
3238 /// template<template<int Value> class Other> struct X;
3239 /// \endcode
3240 TPL_TemplateTemplateParmMatch,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003241
Douglas Gregorfb898e12009-11-12 16:20:59 +00003242 /// \brief We are matching the template parameter lists of a template
3243 /// template argument against the template parameter lists of a template
3244 /// template parameter.
3245 ///
3246 /// \code
3247 /// template<template<int Value> class Metafun> struct X;
3248 /// template<int Value> struct integer_c;
3249 /// X<integer_c> xic;
3250 /// \endcode
3251 TPL_TemplateTemplateArgumentMatch
3252 };
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003253
Douglas Gregorddc29e12009-02-06 22:42:48 +00003254 bool TemplateParameterListsAreEqual(TemplateParameterList *New,
3255 TemplateParameterList *Old,
3256 bool Complain,
Douglas Gregorfb898e12009-11-12 16:20:59 +00003257 TemplateParameterListEqualKind Kind,
Douglas Gregordd0574e2009-02-10 00:24:35 +00003258 SourceLocation TemplateArgLoc
Douglas Gregor788cd062009-11-11 01:00:40 +00003259 = SourceLocation());
Mike Stump1eb44332009-09-09 15:08:12 +00003260
Douglas Gregor05396e22009-08-25 17:23:04 +00003261 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
Douglas Gregoraaba5e32009-02-04 19:02:06 +00003262
Douglas Gregord57959a2009-03-27 23:10:48 +00003263 /// \brief Called when the parser has parsed a C++ typename
3264 /// specifier, e.g., "typename T::type".
3265 ///
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003266 /// \param S The scope in which this typename type occurs.
Douglas Gregord57959a2009-03-27 23:10:48 +00003267 /// \param TypenameLoc the location of the 'typename' keyword
3268 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3269 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
3270 /// \param IdLoc the location of the identifier.
3271 virtual TypeResult
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003272 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
3273 const CXXScopeSpec &SS, const IdentifierInfo &II,
3274 SourceLocation IdLoc);
Douglas Gregor17343172009-04-01 00:28:59 +00003275
3276 /// \brief Called when the parser has parsed a C++ typename
Mike Stump1eb44332009-09-09 15:08:12 +00003277 /// specifier that ends in a template-id, e.g.,
Douglas Gregor17343172009-04-01 00:28:59 +00003278 /// "typename MetaFun::template apply<T1, T2>".
3279 ///
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003280 /// \param S The scope in which this typename type occurs.
Douglas Gregor17343172009-04-01 00:28:59 +00003281 /// \param TypenameLoc the location of the 'typename' keyword
3282 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3283 /// \param TemplateLoc the location of the 'template' keyword, if any.
3284 /// \param Ty the type that the typename specifier refers to.
3285 virtual TypeResult
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003286 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
3287 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
3288 TypeTy *Ty);
Douglas Gregor17343172009-04-01 00:28:59 +00003289
Douglas Gregor107de902010-04-24 15:35:55 +00003290 QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
3291 NestedNameSpecifier *NNS,
Douglas Gregord57959a2009-03-27 23:10:48 +00003292 const IdentifierInfo &II,
Abramo Bagnarae4da7a02010-05-19 21:37:53 +00003293 SourceLocation KeywordLoc,
3294 SourceRange NNSRange,
3295 SourceLocation IILoc);
Douglas Gregorc8ab2562009-05-31 09:31:02 +00003296
John McCall63b43852010-04-29 23:50:39 +00003297 TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
3298 SourceLocation Loc,
3299 DeclarationName Name);
3300 bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
Douglas Gregor4a959d82009-08-06 16:20:37 +00003301
Douglas Gregorbf4ea562009-09-15 16:23:51 +00003302 std::string
3303 getTemplateArgumentBindingsText(const TemplateParameterList *Params,
3304 const TemplateArgumentList &Args);
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003305
3306 std::string
3307 getTemplateArgumentBindingsText(const TemplateParameterList *Params,
3308 const TemplateArgument *Args,
3309 unsigned NumArgs);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003310
Douglas Gregorf67875d2009-06-12 18:26:56 +00003311 /// \brief Describes the result of template argument deduction.
3312 ///
3313 /// The TemplateDeductionResult enumeration describes the result of
3314 /// template argument deduction, as returned from
3315 /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
3316 /// structure provides additional information about the results of
3317 /// template argument deduction, e.g., the deduced template argument
3318 /// list (if successful) or the specific template parameters or
3319 /// deduced arguments that were involved in the failure.
3320 enum TemplateDeductionResult {
3321 /// \brief Template argument deduction was successful.
3322 TDK_Success = 0,
3323 /// \brief Template argument deduction exceeded the maximum template
3324 /// instantiation depth (which has already been diagnosed).
3325 TDK_InstantiationDepth,
3326 /// \brief Template argument deduction did not deduce a value
3327 /// for every template parameter.
3328 TDK_Incomplete,
3329 /// \brief Template argument deduction produced inconsistent
3330 /// deduced values for the given template parameter.
3331 TDK_Inconsistent,
3332 /// \brief Template argument deduction failed due to inconsistent
3333 /// cv-qualifiers on a template parameter type that would
3334 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
3335 /// but were given a non-const "X".
John McCall57e97782010-08-05 09:05:08 +00003336 TDK_Underqualified,
Douglas Gregorf67875d2009-06-12 18:26:56 +00003337 /// \brief Substitution of the deduced template argument values
3338 /// resulted in an error.
3339 TDK_SubstitutionFailure,
3340 /// \brief Substitution of the deduced template argument values
3341 /// into a non-deduced context produced a type or value that
3342 /// produces a type that does not match the original template
3343 /// arguments provided.
Douglas Gregore53060f2009-06-25 22:08:12 +00003344 TDK_NonDeducedMismatch,
Mike Stump1eb44332009-09-09 15:08:12 +00003345 /// \brief When performing template argument deduction for a function
Douglas Gregore53060f2009-06-25 22:08:12 +00003346 /// template, there were too many call arguments.
3347 TDK_TooManyArguments,
Mike Stump1eb44332009-09-09 15:08:12 +00003348 /// \brief When performing template argument deduction for a function
Douglas Gregore53060f2009-06-25 22:08:12 +00003349 /// template, there were too few call arguments.
Douglas Gregor6db8ed42009-06-30 23:57:56 +00003350 TDK_TooFewArguments,
3351 /// \brief The explicitly-specified template arguments were not valid
3352 /// template arguments for the given template.
Douglas Gregor4b52e252009-12-21 23:17:24 +00003353 TDK_InvalidExplicitArguments,
3354 /// \brief The arguments included an overloaded function name that could
3355 /// not be resolved to a suitable function.
3356 TDK_FailedOverloadResolution
Douglas Gregorf67875d2009-06-12 18:26:56 +00003357 };
3358
3359 /// \brief Provides information about an attempted template argument
3360 /// deduction, whose success or failure was described by a
3361 /// TemplateDeductionResult value.
3362 class TemplateDeductionInfo {
3363 /// \brief The context in which the template arguments are stored.
3364 ASTContext &Context;
3365
3366 /// \brief The deduced template argument list.
3367 ///
3368 TemplateArgumentList *Deduced;
3369
John McCall5769d612010-02-08 23:07:23 +00003370 /// \brief The source location at which template argument
3371 /// deduction is occurring.
3372 SourceLocation Loc;
3373
Douglas Gregorf67875d2009-06-12 18:26:56 +00003374 // do not implement these
3375 TemplateDeductionInfo(const TemplateDeductionInfo&);
3376 TemplateDeductionInfo &operator=(const TemplateDeductionInfo&);
3377
3378 public:
John McCall5769d612010-02-08 23:07:23 +00003379 TemplateDeductionInfo(ASTContext &Context, SourceLocation Loc)
3380 : Context(Context), Deduced(0), Loc(Loc) { }
Douglas Gregorf67875d2009-06-12 18:26:56 +00003381
3382 ~TemplateDeductionInfo() {
3383 // FIXME: if (Deduced) Deduced->Destroy(Context);
3384 }
3385
John McCall5769d612010-02-08 23:07:23 +00003386 /// \brief Returns the location at which template argument is
3387 /// occuring.
3388 SourceLocation getLocation() const {
3389 return Loc;
3390 }
3391
Douglas Gregorf67875d2009-06-12 18:26:56 +00003392 /// \brief Take ownership of the deduced template argument list.
Mike Stump1eb44332009-09-09 15:08:12 +00003393 TemplateArgumentList *take() {
Douglas Gregorf67875d2009-06-12 18:26:56 +00003394 TemplateArgumentList *Result = Deduced;
3395 Deduced = 0;
3396 return Result;
3397 }
3398
3399 /// \brief Provide a new template argument list that contains the
3400 /// results of template argument deduction.
3401 void reset(TemplateArgumentList *NewDeduced) {
3402 // FIXME: if (Deduced) Deduced->Destroy(Context);
3403 Deduced = NewDeduced;
3404 }
3405
3406 /// \brief The template parameter to which a template argument
3407 /// deduction failure refers.
3408 ///
3409 /// Depending on the result of template argument deduction, this
3410 /// template parameter may have different meanings:
3411 ///
3412 /// TDK_Incomplete: this is the first template parameter whose
3413 /// corresponding template argument was not deduced.
3414 ///
3415 /// TDK_Inconsistent: this is the template parameter for which
3416 /// two different template argument values were deduced.
3417 TemplateParameter Param;
3418
3419 /// \brief The first template argument to which the template
3420 /// argument deduction failure refers.
3421 ///
3422 /// Depending on the result of the template argument deduction,
3423 /// this template argument may have different meanings:
3424 ///
3425 /// TDK_Inconsistent: this argument is the first value deduced
3426 /// for the corresponding template parameter.
3427 ///
3428 /// TDK_SubstitutionFailure: this argument is the template
3429 /// argument we were instantiating when we encountered an error.
3430 ///
3431 /// TDK_NonDeducedMismatch: this is the template argument
3432 /// provided in the source code.
3433 TemplateArgument FirstArg;
3434
3435 /// \brief The second template argument to which the template
3436 /// argument deduction failure refers.
3437 ///
3438 /// FIXME: Finish documenting this.
3439 TemplateArgument SecondArg;
3440 };
3441
3442 TemplateDeductionResult
Douglas Gregor199d9912009-06-05 00:53:49 +00003443 DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
Douglas Gregorf67875d2009-06-12 18:26:56 +00003444 const TemplateArgumentList &TemplateArgs,
3445 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003446
Douglas Gregor83314aa2009-07-08 20:55:45 +00003447 TemplateDeductionResult
3448 SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
John McCalld5532b62009-11-23 01:53:49 +00003449 const TemplateArgumentListInfo &ExplicitTemplateArgs,
Douglas Gregor02024a92010-03-28 02:42:43 +00003450 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
Douglas Gregor83314aa2009-07-08 20:55:45 +00003451 llvm::SmallVectorImpl<QualType> &ParamTypes,
3452 QualType *FunctionType,
3453 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003454
3455 TemplateDeductionResult
Douglas Gregor83314aa2009-07-08 20:55:45 +00003456 FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
Douglas Gregor02024a92010-03-28 02:42:43 +00003457 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3458 unsigned NumExplicitlySpecified,
Douglas Gregor83314aa2009-07-08 20:55:45 +00003459 FunctionDecl *&Specialization,
3460 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003461
Douglas Gregore53060f2009-06-25 22:08:12 +00003462 TemplateDeductionResult
3463 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
John McCalld5532b62009-11-23 01:53:49 +00003464 const TemplateArgumentListInfo *ExplicitTemplateArgs,
Douglas Gregore53060f2009-06-25 22:08:12 +00003465 Expr **Args, unsigned NumArgs,
3466 FunctionDecl *&Specialization,
3467 TemplateDeductionInfo &Info);
Douglas Gregor83314aa2009-07-08 20:55:45 +00003468
3469 TemplateDeductionResult
3470 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
John McCalld5532b62009-11-23 01:53:49 +00003471 const TemplateArgumentListInfo *ExplicitTemplateArgs,
Douglas Gregor83314aa2009-07-08 20:55:45 +00003472 QualType ArgFunctionType,
3473 FunctionDecl *&Specialization,
3474 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003475
Douglas Gregor65ec1fd2009-08-21 23:19:43 +00003476 TemplateDeductionResult
3477 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3478 QualType ToType,
3479 CXXConversionDecl *&Specialization,
3480 TemplateDeductionInfo &Info);
3481
Douglas Gregor4b52e252009-12-21 23:17:24 +00003482 TemplateDeductionResult
3483 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3484 const TemplateArgumentListInfo *ExplicitTemplateArgs,
3485 FunctionDecl *&Specialization,
3486 TemplateDeductionInfo &Info);
3487
Douglas Gregor65ec1fd2009-08-21 23:19:43 +00003488 FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
3489 FunctionTemplateDecl *FT2,
John McCall5769d612010-02-08 23:07:23 +00003490 SourceLocation Loc,
Douglas Gregor8a514912009-09-14 18:39:43 +00003491 TemplatePartialOrderingContext TPOC);
John McCallc373d482010-01-27 01:50:18 +00003492 UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin,
3493 UnresolvedSetIterator SEnd,
3494 TemplatePartialOrderingContext TPOC,
3495 SourceLocation Loc,
3496 const PartialDiagnostic &NoneDiag,
3497 const PartialDiagnostic &AmbigDiag,
3498 const PartialDiagnostic &CandidateDiag);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003499
Douglas Gregorbf4ea562009-09-15 16:23:51 +00003500 ClassTemplatePartialSpecializationDecl *
3501 getMoreSpecializedPartialSpecialization(
3502 ClassTemplatePartialSpecializationDecl *PS1,
John McCall5769d612010-02-08 23:07:23 +00003503 ClassTemplatePartialSpecializationDecl *PS2,
3504 SourceLocation Loc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003505
Douglas Gregore73bb602009-09-14 21:25:05 +00003506 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
3507 bool OnlyDeduced,
Douglas Gregored9c0f92009-10-29 00:04:11 +00003508 unsigned Depth,
Douglas Gregor63f07c52009-09-18 23:21:38 +00003509 llvm::SmallVectorImpl<bool> &Used);
3510 void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate,
3511 llvm::SmallVectorImpl<bool> &Deduced);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003512
Douglas Gregor99ebf652009-02-27 19:31:52 +00003513 //===--------------------------------------------------------------------===//
3514 // C++ Template Instantiation
3515 //
Douglas Gregor26dce442009-03-10 00:06:19 +00003516
Douglas Gregor0f8716b2009-11-09 19:17:50 +00003517 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D,
Douglas Gregor525f96c2010-02-05 07:33:43 +00003518 const TemplateArgumentList *Innermost = 0,
Douglas Gregore7089b02010-05-03 23:29:10 +00003519 bool RelativeToPrimary = false,
3520 const FunctionDecl *Pattern = 0);
Douglas Gregor54dabfc2009-05-14 23:26:13 +00003521
Douglas Gregor26dce442009-03-10 00:06:19 +00003522 /// \brief A template instantiation that is currently in progress.
3523 struct ActiveTemplateInstantiation {
Douglas Gregordf667e72009-03-10 20:44:00 +00003524 /// \brief The kind of template instantiation we are performing
Douglas Gregorcca9e962009-07-01 22:01:06 +00003525 enum InstantiationKind {
Douglas Gregordf667e72009-03-10 20:44:00 +00003526 /// We are instantiating a template declaration. The entity is
Douglas Gregorb9f1b8d2009-05-15 00:01:03 +00003527 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
Douglas Gregordf667e72009-03-10 20:44:00 +00003528 TemplateInstantiation,
3529
3530 /// We are instantiating a default argument for a template
3531 /// parameter. The Entity is the template, and
3532 /// TemplateArgs/NumTemplateArguments provides the template
3533 /// arguments as specified.
Douglas Gregor637a4092009-06-10 23:47:09 +00003534 /// FIXME: Use a TemplateArgumentList
3535 DefaultTemplateArgumentInstantiation,
3536
Anders Carlsson25cae7f2009-09-05 05:14:19 +00003537 /// We are instantiating a default argument for a function.
3538 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
3539 /// provides the template arguments as specified.
3540 DefaultFunctionArgumentInstantiation,
3541
Mike Stump1eb44332009-09-09 15:08:12 +00003542 /// We are substituting explicit template arguments provided for
Douglas Gregorcca9e962009-07-01 22:01:06 +00003543 /// a function template. The entity is a FunctionTemplateDecl.
3544 ExplicitTemplateArgumentSubstitution,
Mike Stump1eb44332009-09-09 15:08:12 +00003545
Douglas Gregorcca9e962009-07-01 22:01:06 +00003546 /// We are substituting template argument determined as part of
3547 /// template argument deduction for either a class template
3548 /// partial specialization or a function template. The
3549 /// Entity is either a ClassTemplatePartialSpecializationDecl or
3550 /// a FunctionTemplateDecl.
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003551 DeducedTemplateArgumentSubstitution,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003552
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003553 /// We are substituting prior template arguments into a new
3554 /// template parameter. The template parameter itself is either a
3555 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
Douglas Gregorf35f8282009-11-11 21:54:23 +00003556 PriorTemplateArgumentSubstitution,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003557
Douglas Gregorf35f8282009-11-11 21:54:23 +00003558 /// We are checking the validity of a default template argument that
3559 /// has been used when naming a template-id.
3560 DefaultTemplateArgumentChecking
Douglas Gregordf667e72009-03-10 20:44:00 +00003561 } Kind;
3562
Douglas Gregor26dce442009-03-10 00:06:19 +00003563 /// \brief The point of instantiation within the source code.
3564 SourceLocation PointOfInstantiation;
3565
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003566 /// \brief The template in which we are performing the instantiation,
3567 /// for substitutions of prior template arguments.
3568 TemplateDecl *Template;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003569
Douglas Gregor26dce442009-03-10 00:06:19 +00003570 /// \brief The entity that is being instantiated.
Douglas Gregordf667e72009-03-10 20:44:00 +00003571 uintptr_t Entity;
3572
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003573 /// \brief The list of template arguments we are substituting, if they
3574 /// are not part of the entity.
Douglas Gregordf667e72009-03-10 20:44:00 +00003575 const TemplateArgument *TemplateArgs;
3576
3577 /// \brief The number of template arguments in TemplateArgs.
3578 unsigned NumTemplateArgs;
Douglas Gregor26dce442009-03-10 00:06:19 +00003579
3580 /// \brief The source range that covers the construct that cause
3581 /// the instantiation, e.g., the template-id that causes a class
3582 /// template instantiation.
3583 SourceRange InstantiationRange;
Douglas Gregordf667e72009-03-10 20:44:00 +00003584
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003585 ActiveTemplateInstantiation()
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003586 : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0),
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003587 NumTemplateArgs(0) {}
Eli Friedman2ebcc6b2009-08-15 22:50:33 +00003588
Douglas Gregorf35f8282009-11-11 21:54:23 +00003589 /// \brief Determines whether this template is an actual instantiation
3590 /// that should be counted toward the maximum instantiation depth.
3591 bool isInstantiationRecord() const;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003592
Douglas Gregordf667e72009-03-10 20:44:00 +00003593 friend bool operator==(const ActiveTemplateInstantiation &X,
3594 const ActiveTemplateInstantiation &Y) {
3595 if (X.Kind != Y.Kind)
3596 return false;
3597
3598 if (X.Entity != Y.Entity)
3599 return false;
3600
3601 switch (X.Kind) {
3602 case TemplateInstantiation:
3603 return true;
3604
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003605 case PriorTemplateArgumentSubstitution:
Douglas Gregorf35f8282009-11-11 21:54:23 +00003606 case DefaultTemplateArgumentChecking:
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003607 if (X.Template != Y.Template)
3608 return false;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003609
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003610 // Fall through
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003611
Douglas Gregordf667e72009-03-10 20:44:00 +00003612 case DefaultTemplateArgumentInstantiation:
Douglas Gregorcca9e962009-07-01 22:01:06 +00003613 case ExplicitTemplateArgumentSubstitution:
3614 case DeducedTemplateArgumentSubstitution:
Anders Carlsson25cae7f2009-09-05 05:14:19 +00003615 case DefaultFunctionArgumentInstantiation:
Douglas Gregordf667e72009-03-10 20:44:00 +00003616 return X.TemplateArgs == Y.TemplateArgs;
Mike Stump1eb44332009-09-09 15:08:12 +00003617
Douglas Gregordf667e72009-03-10 20:44:00 +00003618 }
3619
3620 return true;
3621 }
3622
3623 friend bool operator!=(const ActiveTemplateInstantiation &X,
3624 const ActiveTemplateInstantiation &Y) {
3625 return !(X == Y);
3626 }
Douglas Gregor26dce442009-03-10 00:06:19 +00003627 };
3628
3629 /// \brief List of active template instantiations.
3630 ///
3631 /// This vector is treated as a stack. As one template instantiation
3632 /// requires another template instantiation, additional
3633 /// instantiations are pushed onto the stack up to a
3634 /// user-configurable limit LangOptions::InstantiationDepth.
Mike Stump1eb44332009-09-09 15:08:12 +00003635 llvm::SmallVector<ActiveTemplateInstantiation, 16>
Douglas Gregor26dce442009-03-10 00:06:19 +00003636 ActiveTemplateInstantiations;
3637
Douglas Gregorf35f8282009-11-11 21:54:23 +00003638 /// \brief The number of ActiveTemplateInstantiation entries in
3639 /// \c ActiveTemplateInstantiations that are not actual instantiations and,
3640 /// therefore, should not be counted as part of the instantiation depth.
3641 unsigned NonInstantiationEntries;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003642
Douglas Gregor27b152f2009-03-10 18:52:44 +00003643 /// \brief The last template from which a template instantiation
3644 /// error or warning was produced.
3645 ///
3646 /// This value is used to suppress printing of redundant template
3647 /// instantiation backtraces when there are multiple errors in the
3648 /// same instantiation. FIXME: Does this belong in Sema? It's tough
3649 /// to implement it anywhere else.
Douglas Gregordf667e72009-03-10 20:44:00 +00003650 ActiveTemplateInstantiation LastTemplateInstantiationErrorContext;
Douglas Gregor27b152f2009-03-10 18:52:44 +00003651
Nick Lewycky03d98c52010-07-06 19:51:49 +00003652 /// \brief The stack of calls expression undergoing template instantiation.
3653 ///
3654 /// The top of this stack is used by a fixit instantiating unresolved
3655 /// function calls to fix the AST to match the textual change it prints.
3656 llvm::SmallVector<CallExpr *, 8> CallsUndergoingInstantiation;
3657
Douglas Gregor26dce442009-03-10 00:06:19 +00003658 /// \brief A stack object to be created when performing template
3659 /// instantiation.
3660 ///
3661 /// Construction of an object of type \c InstantiatingTemplate
3662 /// pushes the current instantiation onto the stack of active
3663 /// instantiations. If the size of this stack exceeds the maximum
3664 /// number of recursive template instantiations, construction
3665 /// produces an error and evaluates true.
3666 ///
3667 /// Destruction of this object will pop the named instantiation off
3668 /// the stack.
3669 struct InstantiatingTemplate {
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003670 /// \brief Note that we are instantiating a class template,
3671 /// function template, or a member thereof.
Douglas Gregor26dce442009-03-10 00:06:19 +00003672 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003673 Decl *Entity,
Douglas Gregor26dce442009-03-10 00:06:19 +00003674 SourceRange InstantiationRange = SourceRange());
Douglas Gregordf667e72009-03-10 20:44:00 +00003675
3676 /// \brief Note that we are instantiating a default argument in a
3677 /// template-id.
3678 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3679 TemplateDecl *Template,
3680 const TemplateArgument *TemplateArgs,
3681 unsigned NumTemplateArgs,
3682 SourceRange InstantiationRange = SourceRange());
3683
Douglas Gregorcca9e962009-07-01 22:01:06 +00003684 /// \brief Note that we are instantiating a default argument in a
3685 /// template-id.
3686 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3687 FunctionTemplateDecl *FunctionTemplate,
3688 const TemplateArgument *TemplateArgs,
3689 unsigned NumTemplateArgs,
3690 ActiveTemplateInstantiation::InstantiationKind Kind,
3691 SourceRange InstantiationRange = SourceRange());
Mike Stump1eb44332009-09-09 15:08:12 +00003692
Douglas Gregor637a4092009-06-10 23:47:09 +00003693 /// \brief Note that we are instantiating as part of template
3694 /// argument deduction for a class template partial
3695 /// specialization.
3696 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3697 ClassTemplatePartialSpecializationDecl *PartialSpec,
3698 const TemplateArgument *TemplateArgs,
3699 unsigned NumTemplateArgs,
3700 SourceRange InstantiationRange = SourceRange());
3701
Anders Carlsson25cae7f2009-09-05 05:14:19 +00003702 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3703 ParmVarDecl *Param,
3704 const TemplateArgument *TemplateArgs,
3705 unsigned NumTemplateArgs,
3706 SourceRange InstantiationRange = SourceRange());
3707
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003708 /// \brief Note that we are substituting prior template arguments into a
3709 /// non-type or template template parameter.
3710 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3711 TemplateDecl *Template,
3712 NonTypeTemplateParmDecl *Param,
3713 const TemplateArgument *TemplateArgs,
3714 unsigned NumTemplateArgs,
3715 SourceRange InstantiationRange);
3716
3717 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3718 TemplateDecl *Template,
3719 TemplateTemplateParmDecl *Param,
3720 const TemplateArgument *TemplateArgs,
3721 unsigned NumTemplateArgs,
3722 SourceRange InstantiationRange);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003723
Douglas Gregorf35f8282009-11-11 21:54:23 +00003724 /// \brief Note that we are checking the default template argument
3725 /// against the template parameter for a given template-id.
3726 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3727 TemplateDecl *Template,
3728 NamedDecl *Param,
3729 const TemplateArgument *TemplateArgs,
3730 unsigned NumTemplateArgs,
3731 SourceRange InstantiationRange);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003732
3733
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003734 /// \brief Note that we have finished instantiating this template.
3735 void Clear();
3736
3737 ~InstantiatingTemplate() { Clear(); }
Douglas Gregor26dce442009-03-10 00:06:19 +00003738
3739 /// \brief Determines whether we have exceeded the maximum
3740 /// recursive template instantiations.
3741 operator bool() const { return Invalid; }
3742
3743 private:
3744 Sema &SemaRef;
3745 bool Invalid;
3746
Douglas Gregordf667e72009-03-10 20:44:00 +00003747 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
3748 SourceRange InstantiationRange);
3749
Douglas Gregor26dce442009-03-10 00:06:19 +00003750 InstantiatingTemplate(const InstantiatingTemplate&); // not implemented
3751
Mike Stump1eb44332009-09-09 15:08:12 +00003752 InstantiatingTemplate&
Douglas Gregor26dce442009-03-10 00:06:19 +00003753 operator=(const InstantiatingTemplate&); // not implemented
3754 };
3755
Douglas Gregoree1828a2009-03-10 18:03:33 +00003756 void PrintInstantiationStack();
3757
Douglas Gregor5e9f35c2009-06-14 07:33:30 +00003758 /// \brief Determines whether we are currently in a context where
3759 /// template argument substitution failures are not considered
3760 /// errors.
3761 ///
3762 /// When this routine returns true, the emission of most diagnostics
3763 /// will be suppressed and there will be no local error recovery.
3764 bool isSFINAEContext() const;
3765
Douglas Gregorbb260412009-06-14 08:02:22 +00003766 /// \brief RAII class used to determine whether SFINAE has
3767 /// trapped any errors that occur during template argument
3768 /// deduction.
3769 class SFINAETrap {
3770 Sema &SemaRef;
3771 unsigned PrevSFINAEErrors;
3772 public:
3773 explicit SFINAETrap(Sema &SemaRef)
3774 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors) { }
3775
3776 ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; }
3777
3778 /// \brief Determine whether any SFINAE errors have been trapped.
Mike Stump1eb44332009-09-09 15:08:12 +00003779 bool hasErrorOccurred() const {
3780 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
Douglas Gregorbb260412009-06-14 08:02:22 +00003781 }
3782 };
3783
Douglas Gregorc63d2c82010-05-12 16:39:35 +00003784 /// \brief RAII class that determines when any errors have occurred
3785 /// between the time the instance was created and the time it was
3786 /// queried.
3787 class ErrorTrap {
3788 Sema &SemaRef;
3789 unsigned PrevErrors;
3790
3791 public:
3792 explicit ErrorTrap(Sema &SemaRef)
3793 : SemaRef(SemaRef), PrevErrors(SemaRef.getDiagnostics().getNumErrors()) {}
3794
3795 /// \brief Determine whether any errors have occurred since this
3796 /// object instance was created.
3797 bool hasErrorOccurred() const {
3798 return SemaRef.getDiagnostics().getNumErrors() > PrevErrors;
3799 }
3800 };
3801
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003802 /// \brief A stack-allocated class that identifies which local
3803 /// variable declaration instantiations are present in this scope.
3804 ///
3805 /// A new instance of this class type will be created whenever we
3806 /// instantiate a new function declaration, which will have its own
3807 /// set of parameter declarations.
3808 class LocalInstantiationScope {
3809 /// \brief Reference to the semantic analysis that is performing
3810 /// this template instantiation.
3811 Sema &SemaRef;
3812
Douglas Gregor815215d2009-05-27 05:35:12 +00003813 /// \brief A mapping from local declarations that occur
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003814 /// within a template to their instantiations.
3815 ///
3816 /// This mapping is used during instantiation to keep track of,
3817 /// e.g., function parameter and variable declarations. For example,
3818 /// given:
3819 ///
3820 /// \code
3821 /// template<typename T> T add(T x, T y) { return x + y; }
3822 /// \endcode
3823 ///
3824 /// when we instantiate add<int>, we will introduce a mapping from
3825 /// the ParmVarDecl for 'x' that occurs in the template to the
3826 /// instantiated ParmVarDecl for 'x'.
Douglas Gregor815215d2009-05-27 05:35:12 +00003827 llvm::DenseMap<const Decl *, Decl *> LocalDecls;
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003828
Douglas Gregor895162d2010-04-30 18:55:50 +00003829 /// \brief The outer scope, which contains local variable
Douglas Gregor550d9b22009-10-31 17:21:17 +00003830 /// definitions from some other instantiation (that may not be
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003831 /// relevant to this particular scope).
3832 LocalInstantiationScope *Outer;
3833
Douglas Gregor60406be2010-01-16 22:29:39 +00003834 /// \brief Whether we have already exited this scope.
3835 bool Exited;
3836
Douglas Gregor895162d2010-04-30 18:55:50 +00003837 /// \brief Whether to combine this scope with the outer scope, such that
3838 /// lookup will search our outer scope.
3839 bool CombineWithOuterScope;
3840
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003841 // This class is non-copyable
3842 LocalInstantiationScope(const LocalInstantiationScope &);
3843 LocalInstantiationScope &operator=(const LocalInstantiationScope &);
3844
3845 public:
Douglas Gregor895162d2010-04-30 18:55:50 +00003846 LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false)
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003847 : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
Douglas Gregor895162d2010-04-30 18:55:50 +00003848 Exited(false), CombineWithOuterScope(CombineWithOuterScope)
3849 {
3850 SemaRef.CurrentInstantiationScope = this;
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003851 }
3852
3853 ~LocalInstantiationScope() {
Douglas Gregor895162d2010-04-30 18:55:50 +00003854 Exit();
Douglas Gregor60406be2010-01-16 22:29:39 +00003855 }
3856
3857 /// \brief Exit this local instantiation scope early.
3858 void Exit() {
Douglas Gregor895162d2010-04-30 18:55:50 +00003859 if (Exited)
3860 return;
3861
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003862 SemaRef.CurrentInstantiationScope = Outer;
Douglas Gregor60406be2010-01-16 22:29:39 +00003863 Exited = true;
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003864 }
3865
Douglas Gregor895162d2010-04-30 18:55:50 +00003866 Decl *getInstantiationOf(const Decl *D);
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003867
Douglas Gregor815215d2009-05-27 05:35:12 +00003868 VarDecl *getInstantiationOf(const VarDecl *Var) {
3869 return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var)));
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003870 }
3871
Douglas Gregor815215d2009-05-27 05:35:12 +00003872 ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) {
3873 return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var)));
3874 }
3875
Douglas Gregor550d9b22009-10-31 17:21:17 +00003876 NonTypeTemplateParmDecl *getInstantiationOf(
3877 const NonTypeTemplateParmDecl *Var) {
3878 return cast<NonTypeTemplateParmDecl>(getInstantiationOf(cast<Decl>(Var)));
3879 }
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003880
Douglas Gregor895162d2010-04-30 18:55:50 +00003881 void InstantiatedLocal(const Decl *D, Decl *Inst);
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003882 };
3883
3884 /// \brief The current instantiation scope used to store local
3885 /// variables.
3886 LocalInstantiationScope *CurrentInstantiationScope;
3887
Ted Kremenekd0ed4482010-02-02 02:07:01 +00003888 /// \brief The number of typos corrected by CorrectTypo.
3889 unsigned TyposCorrected;
3890
Ted Kremenekd064fdc2010-03-23 00:13:23 +00003891 /// \brief Worker object for performing CFG-based warnings.
3892 sema::AnalysisBasedWarnings AnalysisWarnings;
3893
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003894 /// \brief An entity for which implicit template instantiation is required.
3895 ///
Mike Stump1eb44332009-09-09 15:08:12 +00003896 /// The source location associated with the declaration is the first place in
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003897 /// the source code where the declaration was "used". It is not necessarily
Mike Stump1eb44332009-09-09 15:08:12 +00003898 /// the point of instantiation (which will be either before or after the
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003899 /// namespace-scope declaration that triggered this implicit instantiation),
3900 /// However, it is the location that diagnostics should generally refer to,
3901 /// because users will need to know what code triggered the instantiation.
3902 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
Mike Stump1eb44332009-09-09 15:08:12 +00003903
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003904 /// \brief The queue of implicit template instantiations that are required
3905 /// but have not yet been performed.
Douglas Gregorb33fe2f2009-06-30 17:20:14 +00003906 std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations;
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003907
Douglas Gregor60406be2010-01-16 22:29:39 +00003908 /// \brief The queue of implicit template instantiations that are required
3909 /// and must be performed within the current local scope.
3910 ///
3911 /// This queue is only used for member functions of local classes in
3912 /// templates, which must be instantiated in the same scope as their
3913 /// enclosing function, so that they can reference function-local
3914 /// types, static variables, enumerators, etc.
3915 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
3916
3917 void PerformPendingImplicitInstantiations(bool LocalOnly = false);
Mike Stump1eb44332009-09-09 15:08:12 +00003918
John McCalla93c9342009-12-07 02:54:59 +00003919 TypeSourceInfo *SubstType(TypeSourceInfo *T,
John McCallcd7ba1c2009-10-21 00:58:09 +00003920 const MultiLevelTemplateArgumentList &TemplateArgs,
3921 SourceLocation Loc, DeclarationName Entity);
3922
Mike Stump1eb44332009-09-09 15:08:12 +00003923 QualType SubstType(QualType T,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003924 const MultiLevelTemplateArgumentList &TemplateArgs,
John McCallce3ff2b2009-08-25 22:02:44 +00003925 SourceLocation Loc, DeclarationName Entity);
Mike Stump1eb44332009-09-09 15:08:12 +00003926
John McCall6cd3b9f2010-04-09 17:38:44 +00003927 TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
3928 const MultiLevelTemplateArgumentList &TemplateArgs,
3929 SourceLocation Loc,
3930 DeclarationName Entity);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003931 ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
Douglas Gregorcb27b0f2010-04-12 07:48:19 +00003932 const MultiLevelTemplateArgumentList &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003933 OwningExprResult SubstExpr(Expr *E,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003934 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregora0e500d2009-03-12 16:53:44 +00003935
Mike Stump1eb44332009-09-09 15:08:12 +00003936 OwningStmtResult SubstStmt(Stmt *S,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003937 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor54dabfc2009-05-14 23:26:13 +00003938
John McCallce3ff2b2009-08-25 22:02:44 +00003939 Decl *SubstDecl(Decl *D, DeclContext *Owner,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003940 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor8dbc2692009-03-17 21:15:40 +00003941
Mike Stump1eb44332009-09-09 15:08:12 +00003942 bool
John McCallce3ff2b2009-08-25 22:02:44 +00003943 SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
3944 CXXRecordDecl *Pattern,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003945 const MultiLevelTemplateArgumentList &TemplateArgs);
John McCalle29ba202009-08-20 01:44:21 +00003946
3947 bool
Douglas Gregord475b8d2009-03-25 21:17:03 +00003948 InstantiateClass(SourceLocation PointOfInstantiation,
3949 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003950 const MultiLevelTemplateArgumentList &TemplateArgs,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003951 TemplateSpecializationKind TSK,
Douglas Gregor5842ba92009-08-24 15:23:48 +00003952 bool Complain = true);
Douglas Gregord475b8d2009-03-25 21:17:03 +00003953
John McCall1d8d1cc2010-08-01 02:01:53 +00003954 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
3955 Decl *Pattern, Decl *Inst);
3956
Mike Stump1eb44332009-09-09 15:08:12 +00003957 bool
Douglas Gregor972e6ce2009-10-27 06:26:26 +00003958 InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
Douglas Gregor2943aed2009-03-03 04:44:36 +00003959 ClassTemplateSpecializationDecl *ClassTemplateSpec,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003960 TemplateSpecializationKind TSK,
3961 bool Complain = true);
Douglas Gregor99ebf652009-02-27 19:31:52 +00003962
Douglas Gregora58861f2009-05-13 20:28:22 +00003963 void InstantiateClassMembers(SourceLocation PointOfInstantiation,
3964 CXXRecordDecl *Instantiation,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003965 const MultiLevelTemplateArgumentList &TemplateArgs,
3966 TemplateSpecializationKind TSK);
Douglas Gregora58861f2009-05-13 20:28:22 +00003967
3968 void InstantiateClassTemplateSpecializationMembers(
3969 SourceLocation PointOfInstantiation,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003970 ClassTemplateSpecializationDecl *ClassTemplateSpec,
3971 TemplateSpecializationKind TSK);
Douglas Gregora58861f2009-05-13 20:28:22 +00003972
Douglas Gregorab452ba2009-03-26 23:50:42 +00003973 NestedNameSpecifier *
John McCallce3ff2b2009-08-25 22:02:44 +00003974 SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
3975 SourceRange Range,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003976 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor5953d8b2009-03-19 17:26:29 +00003977
Douglas Gregorde650ae2009-03-31 18:38:02 +00003978 TemplateName
John McCallce3ff2b2009-08-25 22:02:44 +00003979 SubstTemplateName(TemplateName Name, SourceLocation Loc,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003980 const MultiLevelTemplateArgumentList &TemplateArgs);
John McCall833ca992009-10-29 08:12:44 +00003981 bool Subst(const TemplateArgumentLoc &Arg, TemplateArgumentLoc &Result,
3982 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregorde650ae2009-03-31 18:38:02 +00003983
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003984 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
Douglas Gregorb33fe2f2009-06-30 17:20:14 +00003985 FunctionDecl *Function,
Douglas Gregore2d3a3d2009-10-15 14:05:49 +00003986 bool Recursive = false,
3987 bool DefinitionRequired = false);
Douglas Gregor7caa6822009-07-24 20:34:43 +00003988 void InstantiateStaticDataMemberDefinition(
John McCallce3ff2b2009-08-25 22:02:44 +00003989 SourceLocation PointOfInstantiation,
3990 VarDecl *Var,
Douglas Gregore2d3a3d2009-10-15 14:05:49 +00003991 bool Recursive = false,
3992 bool DefinitionRequired = false);
Douglas Gregora58861f2009-05-13 20:28:22 +00003993
Anders Carlsson09025312009-08-29 05:16:22 +00003994 void InstantiateMemInitializers(CXXConstructorDecl *New,
3995 const CXXConstructorDecl *Tmpl,
3996 const MultiLevelTemplateArgumentList &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003997
Douglas Gregor7c1e98f2010-03-01 15:56:25 +00003998 NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
Douglas Gregore95b4092009-09-16 18:34:49 +00003999 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor7c1e98f2010-03-01 15:56:25 +00004000 DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
Douglas Gregore95b4092009-09-16 18:34:49 +00004001 const MultiLevelTemplateArgumentList &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00004002
Steve Naroff3536b442007-09-06 21:24:23 +00004003 // Objective-C declarations.
Chris Lattnerb28317a2009-03-28 19:18:32 +00004004 virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
4005 IdentifierInfo *ClassName,
4006 SourceLocation ClassLoc,
4007 IdentifierInfo *SuperName,
4008 SourceLocation SuperLoc,
4009 const DeclPtrTy *ProtoRefs,
4010 unsigned NumProtoRefs,
Douglas Gregor18df52b2010-01-16 15:02:53 +00004011 const SourceLocation *ProtoLocs,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004012 SourceLocation EndProtoLoc,
4013 AttributeList *AttrList);
Mike Stump1eb44332009-09-09 15:08:12 +00004014
Chris Lattnerb28317a2009-03-28 19:18:32 +00004015 virtual DeclPtrTy ActOnCompatiblityAlias(
Fariborz Jahanian243b64b2007-10-11 23:42:27 +00004016 SourceLocation AtCompatibilityAliasLoc,
4017 IdentifierInfo *AliasName, SourceLocation AliasLocation,
4018 IdentifierInfo *ClassName, SourceLocation ClassLocation);
Steve Naroff61d68522009-03-05 15:22:01 +00004019
4020 void CheckForwardProtocolDeclarationForCircularDependency(
4021 IdentifierInfo *PName,
4022 SourceLocation &PLoc, SourceLocation PrevLoc,
4023 const ObjCList<ObjCProtocolDecl> &PList);
Mike Stump1eb44332009-09-09 15:08:12 +00004024
Chris Lattnerb28317a2009-03-28 19:18:32 +00004025 virtual DeclPtrTy ActOnStartProtocolInterface(
Nate Begeman1abc7f62008-02-20 22:57:40 +00004026 SourceLocation AtProtoInterfaceLoc,
Fariborz Jahanian25e077d2007-09-17 21:07:36 +00004027 IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004028 const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs,
Douglas Gregor18df52b2010-01-16 15:02:53 +00004029 const SourceLocation *ProtoLocs,
Daniel Dunbar246e70f2008-09-26 04:48:09 +00004030 SourceLocation EndProtoLoc,
4031 AttributeList *AttrList);
Mike Stump1eb44332009-09-09 15:08:12 +00004032
Chris Lattnerb28317a2009-03-28 19:18:32 +00004033 virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
4034 IdentifierInfo *ClassName,
4035 SourceLocation ClassLoc,
4036 IdentifierInfo *CategoryName,
4037 SourceLocation CategoryLoc,
4038 const DeclPtrTy *ProtoRefs,
4039 unsigned NumProtoRefs,
Douglas Gregor18df52b2010-01-16 15:02:53 +00004040 const SourceLocation *ProtoLocs,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004041 SourceLocation EndProtoLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004042
Chris Lattnerb28317a2009-03-28 19:18:32 +00004043 virtual DeclPtrTy ActOnStartClassImplementation(
Nate Begeman1abc7f62008-02-20 22:57:40 +00004044 SourceLocation AtClassImplLoc,
Fariborz Jahanianccb4f312007-09-25 18:38:09 +00004045 IdentifierInfo *ClassName, SourceLocation ClassLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00004046 IdentifierInfo *SuperClassname,
Fariborz Jahanianccb4f312007-09-25 18:38:09 +00004047 SourceLocation SuperClassLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004048
Chris Lattnerb28317a2009-03-28 19:18:32 +00004049 virtual DeclPtrTy ActOnStartCategoryImplementation(
Fariborz Jahanian8f3fde02007-10-02 16:38:50 +00004050 SourceLocation AtCatImplLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00004051 IdentifierInfo *ClassName,
Fariborz Jahanian8f3fde02007-10-02 16:38:50 +00004052 SourceLocation ClassLoc,
4053 IdentifierInfo *CatName,
4054 SourceLocation CatLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004055
Chris Lattnerb28317a2009-03-28 19:18:32 +00004056 virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
Ted Kremenekc09cba62009-11-17 23:12:20 +00004057 IdentifierInfo **IdentList,
4058 SourceLocation *IdentLocs,
4059 unsigned NumElts);
Mike Stump1eb44332009-09-09 15:08:12 +00004060
Chris Lattner3d4b4822010-07-13 19:22:31 +00004061 virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
Chris Lattner7caeabd2008-07-21 22:17:28 +00004062 const IdentifierLocPair *IdentList,
Fariborz Jahanianbc1c8772008-12-17 01:07:27 +00004063 unsigned NumElts,
4064 AttributeList *attrList);
Mike Stump1eb44332009-09-09 15:08:12 +00004065
Chris Lattnere13b9592008-07-26 04:03:38 +00004066 virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
Chris Lattner7caeabd2008-07-21 22:17:28 +00004067 const IdentifierLocPair *ProtocolId,
Fariborz Jahanian4b6c9052007-10-11 00:55:41 +00004068 unsigned NumProtocols,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004069 llvm::SmallVectorImpl<DeclPtrTy> &Protocols);
Mike Stump1eb44332009-09-09 15:08:12 +00004070
4071 /// Ensure attributes are consistent with type.
Daniel Dunbar95e61fb2008-09-23 21:53:23 +00004072 /// \param [in, out] Attributes The attributes to check; they will
4073 /// be modified to be consistent with \arg PropertyTy.
Fariborz Jahanian842f07b2010-03-30 22:40:11 +00004074 void CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
Daniel Dunbar95e61fb2008-09-23 21:53:23 +00004075 SourceLocation Loc,
4076 unsigned &Attributes);
Steve Naroff0701bbb2009-01-08 17:28:14 +00004077 void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
Mike Stump1eb44332009-09-09 15:08:12 +00004078 void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
Fariborz Jahanian02edb982008-05-01 00:03:38 +00004079 ObjCPropertyDecl *SuperProperty,
Chris Lattner8ec03f52008-11-24 03:54:41 +00004080 const IdentifierInfo *Name);
Fariborz Jahanian02edb982008-05-01 00:03:38 +00004081 void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004082
4083 void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
Fariborz Jahaniandbdec8b2009-08-04 01:07:16 +00004084 ObjCMethodDecl *MethodDecl,
4085 bool IsInstance);
Mike Stump1eb44332009-09-09 15:08:12 +00004086
Fariborz Jahanian107089f2010-01-18 18:41:16 +00004087 void CompareProperties(Decl *CDecl, DeclPtrTy MergeProtocols);
Mike Stump1eb44332009-09-09 15:08:12 +00004088
4089 void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
Fariborz Jahanianb7f95f52009-03-02 19:05:07 +00004090 ObjCInterfaceDecl *ID);
Mike Stump1eb44332009-09-09 15:08:12 +00004091
Fariborz Jahanian107089f2010-01-18 18:41:16 +00004092 void MatchOneProtocolPropertiesInClass(Decl *CDecl,
4093 ObjCProtocolDecl *PDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004094
Fariborz Jahanian17cb3262010-05-05 21:52:17 +00004095 virtual void ActOnAtEnd(Scope *S, SourceRange AtEnd,
Ted Kremenek782f2f52010-01-07 01:20:12 +00004096 DeclPtrTy classDecl,
4097 DeclPtrTy *allMethods = 0, unsigned allNum = 0,
4098 DeclPtrTy *allProperties = 0, unsigned pNum = 0,
4099 DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00004100
Chris Lattnerb28317a2009-03-28 19:18:32 +00004101 virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
4102 FieldDeclarator &FD, ObjCDeclSpec &ODS,
4103 Selector GetterSel, Selector SetterSel,
4104 DeclPtrTy ClassCategory,
4105 bool *OverridingProperty,
4106 tok::ObjCKeywordKind MethodImplKind);
Mike Stump1eb44332009-09-09 15:08:12 +00004107
Fariborz Jahanian17cb3262010-05-05 21:52:17 +00004108 virtual DeclPtrTy ActOnPropertyImplDecl(Scope *S,
4109 SourceLocation AtLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004110 SourceLocation PropertyLoc,
4111 bool ImplKind,DeclPtrTy ClassImplDecl,
4112 IdentifierInfo *PropertyId,
4113 IdentifierInfo *PropertyIvar);
Mike Stump1eb44332009-09-09 15:08:12 +00004114
Chris Lattnerb28317a2009-03-28 19:18:32 +00004115 virtual DeclPtrTy ActOnMethodDeclaration(
Steve Naroffbef11852007-10-26 20:53:56 +00004116 SourceLocation BeginLoc, // location of the + or -.
4117 SourceLocation EndLoc, // location of the ; or {.
Mike Stump1eb44332009-09-09 15:08:12 +00004118 tok::TokenKind MethodType,
4119 DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
Fariborz Jahanianf1de0ca2007-10-31 23:53:01 +00004120 Selector Sel,
Steve Naroff68d331a2007-09-27 14:38:14 +00004121 // optional arguments. The number of types/arguments is obtained
4122 // from the Sel.getNumArgs().
Chris Lattnere294d3f2009-04-11 18:57:04 +00004123 ObjCArgInfo *ArgInfo,
Fariborz Jahanian4f4fd922010-04-08 00:30:06 +00004124 DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args
Steve Naroff335eafa2007-11-15 12:35:21 +00004125 AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
4126 bool isVariadic = false);
Steve Naroff81bfde92007-10-16 23:12:48 +00004127
Steve Narofff1afaf62009-02-26 15:55:06 +00004128 // Helper method for ActOnClassMethod/ActOnInstanceMethod.
4129 // Will search "local" class/category implementations for a method decl.
Fariborz Jahanian175ba1e2009-03-04 18:15:57 +00004130 // Will also search in class's root looking for instance method.
Steve Narofff1afaf62009-02-26 15:55:06 +00004131 // Returns 0 if no method is found.
Mike Stump1eb44332009-09-09 15:08:12 +00004132 ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
Steve Naroff5609ec02009-03-08 18:56:13 +00004133 ObjCInterfaceDecl *CDecl);
4134 ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
4135 ObjCInterfaceDecl *ClassDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004136
Chris Lattnereb483eb2010-04-11 08:28:14 +00004137 OwningExprResult
Chris Lattner7f816522010-04-11 07:45:24 +00004138 HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
Chris Lattnerb9d4fc12010-04-11 07:51:10 +00004139 Expr *BaseExpr,
Chris Lattner7f816522010-04-11 07:45:24 +00004140 DeclarationName MemberName,
Chris Lattnerb9d4fc12010-04-11 07:51:10 +00004141 SourceLocation MemberLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004142
Chris Lattnereb483eb2010-04-11 08:28:14 +00004143 virtual OwningExprResult
4144 ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
4145 IdentifierInfo &propertyName,
4146 SourceLocation receiverNameLoc,
4147 SourceLocation propertyNameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004148
Douglas Gregor47bd5432010-04-14 02:46:37 +00004149 virtual ObjCMessageKind getObjCMessageKind(Scope *S,
Douglas Gregor1569f952010-04-21 20:38:13 +00004150 IdentifierInfo *Name,
Douglas Gregor47bd5432010-04-14 02:46:37 +00004151 SourceLocation NameLoc,
4152 bool IsSuper,
Douglas Gregor1569f952010-04-21 20:38:13 +00004153 bool HasTrailingDot,
4154 TypeTy *&ReceiverType);
Douglas Gregor47bd5432010-04-14 02:46:37 +00004155
Douglas Gregor2725ca82010-04-21 19:57:20 +00004156 virtual OwningExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
4157 Selector Sel,
4158 SourceLocation LBracLoc,
4159 SourceLocation SelectorLoc,
4160 SourceLocation RBracLoc,
4161 MultiExprArg Args);
Steve Naroff68d331a2007-09-27 14:38:14 +00004162
Douglas Gregor2725ca82010-04-21 19:57:20 +00004163 OwningExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
4164 QualType ReceiverType,
4165 SourceLocation SuperLoc,
4166 Selector Sel,
Douglas Gregorf49bb082010-04-22 17:01:48 +00004167 ObjCMethodDecl *Method,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004168 SourceLocation LBracLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004169 SourceLocation RBracLoc,
4170 MultiExprArg Args);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004171
Douglas Gregor2725ca82010-04-21 19:57:20 +00004172 virtual OwningExprResult ActOnClassMessage(Scope *S,
4173 TypeTy *Receiver,
4174 Selector Sel,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004175 SourceLocation LBracLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004176 SourceLocation SelectorLoc,
4177 SourceLocation RBracLoc,
4178 MultiExprArg Args);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004179
Douglas Gregor2725ca82010-04-21 19:57:20 +00004180 OwningExprResult BuildInstanceMessage(ExprArg Receiver,
4181 QualType ReceiverType,
4182 SourceLocation SuperLoc,
4183 Selector Sel,
Douglas Gregorf49bb082010-04-22 17:01:48 +00004184 ObjCMethodDecl *Method,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004185 SourceLocation LBracLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004186 SourceLocation RBracLoc,
4187 MultiExprArg Args);
4188
4189 virtual OwningExprResult ActOnInstanceMessage(Scope *S,
4190 ExprArg Receiver,
4191 Selector Sel,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004192 SourceLocation LBracLoc,
4193 SourceLocation SelectorLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004194 SourceLocation RBracLoc,
4195 MultiExprArg Args);
4196
Mike Stump1eb44332009-09-09 15:08:12 +00004197
Daniel Dunbarea75a822010-05-27 00:04:40 +00004198 /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
4199 virtual void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
4200 SourceLocation PragmaLoc,
4201 SourceLocation KindLoc);
4202
Daniel Dunbar4cde9272008-10-14 05:35:18 +00004203 /// ActOnPragmaPack - Called on well formed #pragma pack(...).
4204 virtual void ActOnPragmaPack(PragmaPackKind Kind,
4205 IdentifierInfo *Name,
4206 ExprTy *Alignment,
Mike Stump1eb44332009-09-09 15:08:12 +00004207 SourceLocation PragmaLoc,
Daniel Dunbar4cde9272008-10-14 05:35:18 +00004208 SourceLocation LParenLoc,
4209 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004210
Ted Kremenek4726d032009-03-23 22:28:25 +00004211 /// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Ted Kremenek7a02a372009-08-03 23:24:57 +00004212 virtual void ActOnPragmaUnused(const Token *Identifiers,
4213 unsigned NumIdentifiers, Scope *curScope,
Mike Stump1eb44332009-09-09 15:08:12 +00004214 SourceLocation PragmaLoc,
Ted Kremenek4726d032009-03-23 22:28:25 +00004215 SourceLocation LParenLoc,
4216 SourceLocation RParenLoc);
Eli Friedmanc49f19b2009-06-05 02:44:36 +00004217
Eli Friedmanaa8b0d12010-08-05 06:57:20 +00004218 /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
4219 virtual void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
4220 SourceLocation PragmaLoc);
4221
Ryan Flynn7b1fdbd2009-07-31 02:52:19 +00004222 NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II);
4223 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
Ryan Flynne25ff832009-07-30 03:15:39 +00004224
Eli Friedmandec7c762009-06-05 06:28:29 +00004225 /// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Eli Friedmanc49f19b2009-06-05 02:44:36 +00004226 virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName,
4227 SourceLocation PragmaLoc,
4228 SourceLocation WeakNameLoc);
4229
Eli Friedmandec7c762009-06-05 06:28:29 +00004230 /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Eli Friedmanc49f19b2009-06-05 02:44:36 +00004231 virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
4232 IdentifierInfo* AliasName,
4233 SourceLocation PragmaLoc,
4234 SourceLocation WeakNameLoc,
4235 SourceLocation AliasNameLoc);
4236
Daniel Dunbar9f21f892010-05-27 01:53:40 +00004237 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
4238 /// a the record decl, to handle '#pragma pack' and '#pragma options align'.
4239 void AddAlignmentAttributesForRecord(RecordDecl *RD);
Mike Stump1eb44332009-09-09 15:08:12 +00004240
Chris Lattner574aa402009-02-17 01:09:29 +00004241 /// FreePackedContext - Deallocate and null out PackContext.
4242 void FreePackedContext();
Daniel Dunbar4cde9272008-10-14 05:35:18 +00004243
Eli Friedmanaa8b0d12010-08-05 06:57:20 +00004244 /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
4245 /// add an appropriate visibility attribute.
4246 void AddPushedVisibilityAttribute(Decl *RD);
4247
4248 /// PushPragmaVisibility - Push the top element of the visibility stack; used
4249 /// for '#pragma GCC visibility' and visibility attributes on namespaces.
4250 void PushPragmaVisibility(VisibilityAttr::VisibilityTypes type);
4251
4252 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
4253 /// for '#pragma GCC visibility' and visibility attributes on namespaces.
4254 void PopPragmaVisibility();
4255
4256 /// FreeVisContext - Deallocate and null out VisContext.
4257 void FreeVisContext();
4258
Chandler Carruth4ced79f2010-06-25 03:22:07 +00004259 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4260 void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, Expr *E);
4261
Sebastian Redl906082e2010-07-20 04:20:21 +00004262 /// CastCategory - Get the correct forwarded implicit cast result category
4263 /// from the inner expression.
4264 ImplicitCastExpr::ResultCategory CastCategory(Expr *E);
4265
Chris Lattner1e0a3902008-01-16 19:17:22 +00004266 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
4267 /// cast. If there is already an implicit cast, merge into the existing one.
Douglas Gregoreb8f3062008-11-12 17:17:38 +00004268 /// If isLvalue, the result of the cast is an lvalue.
Eli Friedman73c39ab2009-10-20 08:27:19 +00004269 void ImpCastExprToType(Expr *&Expr, QualType Type, CastExpr::CastKind Kind,
Sebastian Redl906082e2010-07-20 04:20:21 +00004270 ImplicitCastExpr::ResultCategory Category =
4271 ImplicitCastExpr::RValue,
John McCallf871d0c2010-08-07 06:22:56 +00004272 const CXXCastPath *BasePath = 0);
Chris Lattner1e0a3902008-01-16 19:17:22 +00004273
Reid Spencer5f016e22007-07-11 17:01:13 +00004274 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
Chris Lattner925e60d2007-12-28 05:29:59 +00004275 // functions and arrays to their respective pointers (C99 6.3.2.1).
Mike Stump1eb44332009-09-09 15:08:12 +00004276 Expr *UsualUnaryConversions(Expr *&expr);
Eli Friedman3c0eb162008-05-27 03:33:27 +00004277
Steve Naroffc80b4ee2007-07-16 21:54:35 +00004278 // DefaultFunctionArrayConversion - converts functions and arrays
Mike Stump1eb44332009-09-09 15:08:12 +00004279 // to their respective pointers (C99 6.3.2.1).
Steve Naroffc80b4ee2007-07-16 21:54:35 +00004280 void DefaultFunctionArrayConversion(Expr *&expr);
Mike Stump1eb44332009-09-09 15:08:12 +00004281
Douglas Gregora873dfc2010-02-03 00:27:59 +00004282 // DefaultFunctionArrayLvalueConversion - converts functions and
4283 // arrays to their respective pointers and performs the
4284 // lvalue-to-rvalue conversion.
4285 void DefaultFunctionArrayLvalueConversion(Expr *&expr);
4286
Steve Naroffb291ab62007-08-28 23:30:39 +00004287 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
Mike Stump1eb44332009-09-09 15:08:12 +00004288 // do not have a prototype. Integer promotions are performed on each
Steve Naroffb291ab62007-08-28 23:30:39 +00004289 // argument, and arguments that have type float are promoted to double.
Chris Lattner925e60d2007-12-28 05:29:59 +00004290 void DefaultArgumentPromotion(Expr *&Expr);
Anders Carlssondce5e2c2009-01-16 16:48:51 +00004291
4292 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
4293 enum VariadicCallType {
4294 VariadicFunction,
4295 VariadicBlock,
Anders Carlssond74d4142009-09-08 01:48:42 +00004296 VariadicMethod,
Fariborz Jahanian4cd1c702009-11-24 19:27:49 +00004297 VariadicConstructor,
4298 VariadicDoesNotApply
Anders Carlssondce5e2c2009-01-16 16:48:51 +00004299 };
Mike Stump1eb44332009-09-09 15:08:12 +00004300
Fariborz Jahanian4cd1c702009-11-24 19:27:49 +00004301 /// GatherArgumentsForCall - Collector argument expressions for various
4302 /// form of call prototypes.
4303 bool GatherArgumentsForCall(SourceLocation CallLoc,
4304 FunctionDecl *FDecl,
4305 const FunctionProtoType *Proto,
4306 unsigned FirstProtoArg,
4307 Expr **Args, unsigned NumArgs,
4308 llvm::SmallVector<Expr *, 8> &AllArgs,
Fariborz Jahanian4cd1c702009-11-24 19:27:49 +00004309 VariadicCallType CallType = VariadicDoesNotApply);
4310
Anders Carlssondce5e2c2009-01-16 16:48:51 +00004311 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
4312 // will warn if the resulting type is not a POD type.
Chris Lattner40378332010-05-16 04:01:30 +00004313 bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT,
4314 FunctionDecl *FDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004315
Reid Spencer5f016e22007-07-11 17:01:13 +00004316 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
4317 // operands and then handles various conversions that are common to binary
4318 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
Mike Stump1eb44332009-09-09 15:08:12 +00004319 // routine returns the first non-arithmetic type found. The client is
Reid Spencer5f016e22007-07-11 17:01:13 +00004320 // responsible for emitting appropriate error diagnostics.
Steve Naroff9f5fa9b2007-08-24 19:07:16 +00004321 QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
4322 bool isCompAssign = false);
Mike Stump1eb44332009-09-09 15:08:12 +00004323
Chris Lattnerb7b61152008-01-04 18:22:42 +00004324 /// AssignConvertType - All of the 'assignment' semantic checks return this
4325 /// enum to indicate whether the assignment was allowed. These checks are
4326 /// done for simple assignments, as well as initialization, return from
4327 /// function, argument passing, etc. The query is phrased in terms of a
4328 /// source and destination type.
Chris Lattner5cf216b2008-01-04 18:04:52 +00004329 enum AssignConvertType {
Chris Lattnerb7b61152008-01-04 18:22:42 +00004330 /// Compatible - the types are compatible according to the standard.
Reid Spencer5f016e22007-07-11 17:01:13 +00004331 Compatible,
Mike Stump1eb44332009-09-09 15:08:12 +00004332
Chris Lattnerb7b61152008-01-04 18:22:42 +00004333 /// PointerToInt - The assignment converts a pointer to an int, which we
4334 /// accept as an extension.
4335 PointerToInt,
Mike Stump1eb44332009-09-09 15:08:12 +00004336
Chris Lattnerb7b61152008-01-04 18:22:42 +00004337 /// IntToPointer - The assignment converts an int to a pointer, which we
4338 /// accept as an extension.
4339 IntToPointer,
Mike Stump1eb44332009-09-09 15:08:12 +00004340
Chris Lattnerb7b61152008-01-04 18:22:42 +00004341 /// FunctionVoidPointer - The assignment is between a function pointer and
4342 /// void*, which the standard doesn't allow, but we accept as an extension.
Chris Lattnerbfe639e2008-01-03 22:56:36 +00004343 FunctionVoidPointer,
Chris Lattnerb7b61152008-01-04 18:22:42 +00004344
4345 /// IncompatiblePointer - The assignment is between two pointers types that
4346 /// are not compatible, but we accept them as an extension.
Reid Spencer5f016e22007-07-11 17:01:13 +00004347 IncompatiblePointer,
Eli Friedmanf05c05d2009-03-22 23:59:44 +00004348
4349 /// IncompatiblePointer - The assignment is between two pointers types which
4350 /// point to integers which have a different sign, but are otherwise identical.
4351 /// This is a subset of the above, but broken out because it's by far the most
4352 /// common case of incompatible pointers.
4353 IncompatiblePointerSign,
4354
Chris Lattnerb7b61152008-01-04 18:22:42 +00004355 /// CompatiblePointerDiscardsQualifiers - The assignment discards
4356 /// c/v/r qualifiers, which we accept as an extension.
4357 CompatiblePointerDiscardsQualifiers,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004358
Sean Huntc9132b62009-11-08 07:46:34 +00004359 /// IncompatibleNestedPointerQualifiers - The assignment is between two
4360 /// nested pointer types, and the qualifiers other than the first two
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004361 /// levels differ e.g. char ** -> const char **, but we accept them as an
4362 /// extension.
Sean Huntc9132b62009-11-08 07:46:34 +00004363 IncompatibleNestedPointerQualifiers,
Steve Naroff1c7d0672008-09-04 15:10:53 +00004364
Anders Carlssonb0f90cc2009-01-30 23:17:46 +00004365 /// IncompatibleVectors - The assignment is between two vector types that
4366 /// have the same size, which we accept as an extension.
4367 IncompatibleVectors,
Mike Stump1eb44332009-09-09 15:08:12 +00004368
4369 /// IntToBlockPointer - The assignment converts an int to a block
Steve Naroff1c7d0672008-09-04 15:10:53 +00004370 /// pointer. We disallow this.
4371 IntToBlockPointer,
4372
Mike Stump1eb44332009-09-09 15:08:12 +00004373 /// IncompatibleBlockPointer - The assignment is between two block
Steve Naroff1c7d0672008-09-04 15:10:53 +00004374 /// pointers types that are not compatible.
4375 IncompatibleBlockPointer,
Mike Stump1eb44332009-09-09 15:08:12 +00004376
Steve Naroff39579072008-10-14 22:18:38 +00004377 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
4378 /// id type and something else (that is incompatible with it). For example,
4379 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
4380 IncompatibleObjCQualifiedId,
Mike Stump1eb44332009-09-09 15:08:12 +00004381
Chris Lattnerb7b61152008-01-04 18:22:42 +00004382 /// Incompatible - We reject this conversion outright, it is invalid to
4383 /// represent it in the AST.
4384 Incompatible
Reid Spencer5f016e22007-07-11 17:01:13 +00004385 };
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004386
Chris Lattner5cf216b2008-01-04 18:04:52 +00004387 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
4388 /// assignment conversion type specified by ConvTy. This returns true if the
4389 /// conversion was invalid or false if the conversion was accepted.
4390 bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
4391 SourceLocation Loc,
4392 QualType DstType, QualType SrcType,
Douglas Gregora41a8c52010-04-22 00:20:18 +00004393 Expr *SrcExpr, AssignmentAction Action,
4394 bool *Complained = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00004395
4396 /// CheckAssignmentConstraints - Perform type checking for assignment,
4397 /// argument passing, variable initialization, and function return values.
Chris Lattner5cf216b2008-01-04 18:04:52 +00004398 /// This routine is only used by the following two methods. C99 6.5.16.
4399 AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
Mike Stump1eb44332009-09-09 15:08:12 +00004400
4401 // CheckSingleAssignmentConstraints - Currently used by
4402 // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
Steve Naroff90045e82007-07-13 23:32:42 +00004403 // this routine performs the default function/array converions.
Mike Stump1eb44332009-09-09 15:08:12 +00004404 AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
Chris Lattner5cf216b2008-01-04 18:04:52 +00004405 Expr *&rExpr);
Douglas Gregor0c74e8a2009-04-29 22:16:16 +00004406
4407 // \brief If the lhs type is a transparent union, check whether we
4408 // can initialize the transparent union with the given expression.
Mike Stump1eb44332009-09-09 15:08:12 +00004409 AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
Douglas Gregor0c74e8a2009-04-29 22:16:16 +00004410 Expr *&rExpr);
Mike Stump1eb44332009-09-09 15:08:12 +00004411
Reid Spencer5f016e22007-07-11 17:01:13 +00004412 // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
Mike Stump1eb44332009-09-09 15:08:12 +00004413 AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
Chris Lattner5cf216b2008-01-04 18:04:52 +00004414 QualType rhsType);
Mike Stump1eb44332009-09-09 15:08:12 +00004415
Fariborz Jahanian52efc3f2009-12-08 18:24:49 +00004416 AssignConvertType CheckObjCPointerTypesForAssignment(QualType lhsType,
4417 QualType rhsType);
4418
Steve Naroff1c7d0672008-09-04 15:10:53 +00004419 // Helper function for CheckAssignmentConstraints involving two
Sebastian Redld1bd7fc2009-04-19 19:26:31 +00004420 // block pointer types.
Mike Stump1eb44332009-09-09 15:08:12 +00004421 AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
Steve Naroff1c7d0672008-09-04 15:10:53 +00004422 QualType rhsType);
Douglas Gregor77a52232008-09-12 00:47:35 +00004423
4424 bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
Douglas Gregor94b1dd22008-10-24 04:54:22 +00004425
Sebastian Redl2c7588f2009-10-10 12:04:10 +00004426 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
4427
Mike Stump1eb44332009-09-09 15:08:12 +00004428 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor68647482009-12-16 03:45:30 +00004429 AssignmentAction Action,
Douglas Gregor871f4392010-04-16 17:16:43 +00004430 bool AllowExplicit = false);
Mike Stump1eb44332009-09-09 15:08:12 +00004431 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor68647482009-12-16 03:45:30 +00004432 AssignmentAction Action,
Fariborz Jahanian51bebc82009-09-23 20:55:32 +00004433 bool AllowExplicit,
Fariborz Jahanian51bebc82009-09-23 20:55:32 +00004434 ImplicitConversionSequence& ICS);
4435 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor09f41cf2009-01-14 15:45:31 +00004436 const ImplicitConversionSequence& ICS,
Douglas Gregor68647482009-12-16 03:45:30 +00004437 AssignmentAction Action,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00004438 bool IgnoreBaseAccess = false);
Douglas Gregor94b1dd22008-10-24 04:54:22 +00004439 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor45920e82008-12-19 17:40:08 +00004440 const StandardConversionSequence& SCS,
Chris Lattner3d4b4822010-07-13 19:22:31 +00004441 AssignmentAction Action,bool IgnoreBaseAccess);
Sebastian Redl22460502009-02-07 00:15:38 +00004442
Reid Spencer5f016e22007-07-11 17:01:13 +00004443 /// the following "Check" methods will return a valid/converted QualType
4444 /// or a null QualType (indicating an error diagnostic was issued).
Sebastian Redl22460502009-02-07 00:15:38 +00004445
4446 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
Douglas Gregordf032512009-03-12 22:46:12 +00004447 QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
Sebastian Redl7c8bd602009-02-07 20:10:22 +00004448 QualType CheckPointerToMemberOperands( // C++ 5.5
Sebastian Redl22460502009-02-07 00:15:38 +00004449 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect);
Douglas Gregordf032512009-03-12 22:46:12 +00004450 QualType CheckMultiplyDivideOperands( // C99 6.5.5
Chris Lattner7ef655a2010-01-12 21:23:57 +00004451 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign,
4452 bool isDivide);
Douglas Gregordf032512009-03-12 22:46:12 +00004453 QualType CheckRemainderOperands( // C99 6.5.5
Sebastian Redl22460502009-02-07 00:15:38 +00004454 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Douglas Gregordf032512009-03-12 22:46:12 +00004455 QualType CheckAdditionOperands( // C99 6.5.6
Eli Friedmanab3a8522009-03-28 01:22:36 +00004456 Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
Douglas Gregordf032512009-03-12 22:46:12 +00004457 QualType CheckSubtractionOperands( // C99 6.5.6
Eli Friedmanab3a8522009-03-28 01:22:36 +00004458 Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
Douglas Gregordf032512009-03-12 22:46:12 +00004459 QualType CheckShiftOperands( // C99 6.5.7
Steve Naroff9f5fa9b2007-08-24 19:07:16 +00004460 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Douglas Gregordf032512009-03-12 22:46:12 +00004461 QualType CheckCompareOperands( // C99 6.5.8/9
Chris Lattner3d4b4822010-07-13 19:22:31 +00004462 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc,
4463 bool isRelational);
Douglas Gregordf032512009-03-12 22:46:12 +00004464 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
Sebastian Redl22460502009-02-07 00:15:38 +00004465 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Douglas Gregordf032512009-03-12 22:46:12 +00004466 QualType CheckLogicalOperands( // C99 6.5.[13,14]
Chris Lattner90a8f272010-07-13 19:41:32 +00004467 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc);
Reid Spencer5f016e22007-07-11 17:01:13 +00004468 // CheckAssignmentOperands is used for both simple and compound assignment.
4469 // For simple assignment, pass both expressions and a null converted type.
4470 // For compound assignment, pass both expressions and the converted type.
Douglas Gregordf032512009-03-12 22:46:12 +00004471 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
Steve Narofff1120de2007-08-24 22:33:52 +00004472 Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
Douglas Gregordf032512009-03-12 22:46:12 +00004473 QualType CheckCommaOperands( // C99 6.5.17
Chris Lattner29a1cfb2008-11-18 01:30:42 +00004474 Expr *lex, Expr *&rex, SourceLocation OpLoc);
Douglas Gregordf032512009-03-12 22:46:12 +00004475 QualType CheckConditionalOperands( // C99 6.5.15
Steve Naroff49b45262007-07-13 16:58:59 +00004476 Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
Sebastian Redl3201f6b2009-04-16 17:51:27 +00004477 QualType CXXCheckConditionalOperands( // C++ 5.16
4478 Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
Douglas Gregor8f00dcf2010-04-16 23:20:25 +00004479 QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
Douglas Gregorb2cb1cb2010-02-25 22:29:57 +00004480 bool *NonStandardCompositeType = 0);
Nate Begemanbe2341d2008-07-14 18:02:46 +00004481
Fariborz Jahanianeebc4752009-12-10 19:47:41 +00004482 QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS,
4483 SourceLocation questionLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004484
Nate Begemanbe2341d2008-07-14 18:02:46 +00004485 /// type checking for vector binary operators.
Chandler Carruth8069a732010-05-19 02:12:56 +00004486 QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
4487 QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx,
4488 SourceLocation l, bool isRel);
Mike Stump1eb44332009-09-09 15:08:12 +00004489
Steve Narofff69936d2007-09-16 03:34:24 +00004490 /// type checking unary operators (subroutines of ActOnUnaryOp).
Reid Spencer5f016e22007-07-11 17:01:13 +00004491 /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
Sebastian Redle6d5a4a2008-12-20 09:35:34 +00004492 QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004493 bool isInc, bool isPrefix);
Reid Spencer5f016e22007-07-11 17:01:13 +00004494 QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
4495 QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
Chris Lattnerba27e2a2009-02-17 08:12:06 +00004496 QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal);
Mike Stump1eb44332009-09-09 15:08:12 +00004497
Steve Naroffe1b31fe2007-07-27 22:15:19 +00004498 /// type checking primary expressions.
Nate Begeman213541a2008-04-18 23:10:10 +00004499 QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00004500 const IdentifierInfo *Comp,
Anders Carlsson8f28f992009-08-26 18:25:21 +00004501 SourceLocation CmpLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004502
Steve Narofff0090632007-09-02 02:04:30 +00004503 /// type checking declaration initializers (C99 6.7.8)
Douglas Gregorcb57fb92009-12-16 06:35:08 +00004504 bool CheckInitList(const InitializedEntity &Entity,
4505 InitListExpr *&InitList, QualType &DeclType);
Steve Naroffd0091aa2008-01-10 22:15:12 +00004506 bool CheckForConstantInitializer(Expr *e, QualType t);
Mike Stump1eb44332009-09-09 15:08:12 +00004507
Douglas Gregor27c8dc02008-10-29 00:13:59 +00004508 // type checking C++ declaration initializers (C++ [dcl.init]).
4509
4510 /// ReferenceCompareResult - Expresses the result of comparing two
4511 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
4512 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
4513 enum ReferenceCompareResult {
4514 /// Ref_Incompatible - The two types are incompatible, so direct
4515 /// reference binding is not possible.
4516 Ref_Incompatible = 0,
4517 /// Ref_Related - The two types are reference-related, which means
4518 /// that their unqualified forms (T1 and T2) are either the same
4519 /// or T1 is a base class of T2.
4520 Ref_Related,
4521 /// Ref_Compatible_With_Added_Qualification - The two types are
4522 /// reference-compatible with added qualification, meaning that
4523 /// they are reference-compatible and the qualifiers on T1 (cv1)
4524 /// are greater than the qualifiers on T2 (cv2).
4525 Ref_Compatible_With_Added_Qualification,
4526 /// Ref_Compatible - The two types are reference-compatible and
4527 /// have equivalent qualifiers (cv1 == cv2).
4528 Ref_Compatible
4529 };
4530
Douglas Gregor393896f2009-11-05 13:06:35 +00004531 ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
4532 QualType T1, QualType T2,
Douglas Gregor569c3162010-08-07 11:51:51 +00004533 bool &DerivedToBase,
4534 bool &ObjCConversion);
Douglas Gregor27c8dc02008-10-29 00:13:59 +00004535
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004536 /// CheckCastTypes - Check type constraints for casting between types under
Sebastian Redlef0cb8e2009-07-29 13:50:23 +00004537 /// C semantics, or forward to CXXCheckCStyleCast in C++.
4538 bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr,
John McCallf871d0c2010-08-07 06:22:56 +00004539 CastExpr::CastKind &Kind, CXXCastPath &BasePath,
Fariborz Jahaniane9f42082009-08-26 18:55:36 +00004540 bool FunctionalStyle = false);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004541
Mike Stump1eb44332009-09-09 15:08:12 +00004542 // CheckVectorCast - check type constraints for vectors.
Anders Carlsson584b2472007-11-27 07:16:40 +00004543 // Since vectors are an extension, there are no C standard reference for this.
4544 // We allow casting between vectors and integer datatypes of the same size.
Anders Carlssona64db8f2007-11-27 05:51:55 +00004545 // returns true if the cast is invalid
Anders Carlssonc3516322009-10-16 02:48:28 +00004546 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
4547 CastExpr::CastKind &Kind);
Mike Stump1eb44332009-09-09 15:08:12 +00004548
4549 // CheckExtVectorCast - check type constraints for extended vectors.
Nate Begeman58d29a42009-06-26 00:50:28 +00004550 // Since vectors are an extension, there are no C standard reference for this.
4551 // We allow casting between vectors and integer datatypes of the same size,
4552 // or vectors and the element type of that vector.
4553 // returns true if the cast is invalid
Anders Carlsson16a89042009-10-16 05:23:41 +00004554 bool CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *&CastExpr,
4555 CastExpr::CastKind &Kind);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004556
4557 /// CXXCheckCStyleCast - Check constraints of a C-style or function-style
4558 /// cast under C++ semantics.
Sebastian Redlef0cb8e2009-07-29 13:50:23 +00004559 bool CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
John McCallf871d0c2010-08-07 06:22:56 +00004560 CastExpr::CastKind &Kind, CXXCastPath &BasePath,
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00004561 bool FunctionalStyle);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004562
Mike Stump1eb44332009-09-09 15:08:12 +00004563 /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
Daniel Dunbar637cebb2008-09-11 00:01:56 +00004564 /// \param Method - May be null.
4565 /// \param [out] ReturnType - The return type of the send.
4566 /// \return true iff there were any incompatible types.
Daniel Dunbar91e19b22008-09-11 00:50:25 +00004567 bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel,
Chris Lattner077bf5e2008-11-24 03:33:13 +00004568 ObjCMethodDecl *Method, bool isClassMessage,
Daniel Dunbar637cebb2008-09-11 00:01:56 +00004569 SourceLocation lbrac, SourceLocation rbrac,
Mike Stump1eb44332009-09-09 15:08:12 +00004570 QualType &ReturnType);
Argyrios Kyrtzidis59210932008-09-10 02:17:11 +00004571
John McCall5a881bb2009-10-12 21:59:07 +00004572 /// CheckBooleanCondition - Diagnose problems involving the use of
4573 /// the given expression as a boolean condition (e.g. in an if
4574 /// statement). Also performs the standard function and array
4575 /// decays, possibly changing the input variable.
4576 ///
4577 /// \param Loc - A location associated with the condition, e.g. the
4578 /// 'if' keyword.
4579 /// \return true iff there were any errors
4580 bool CheckBooleanCondition(Expr *&CondExpr, SourceLocation Loc);
4581
Douglas Gregor586596f2010-05-06 17:25:47 +00004582 virtual OwningExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc,
4583 ExprArg SubExpr);
4584
John McCall5a881bb2009-10-12 21:59:07 +00004585 /// DiagnoseAssignmentAsCondition - Given that an expression is
4586 /// being used as a boolean condition, warn if it's an assignment.
4587 void DiagnoseAssignmentAsCondition(Expr *E);
4588
Argyrios Kyrtzidis59210932008-09-10 02:17:11 +00004589 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
4590 bool CheckCXXBooleanCondition(Expr *&CondExpr);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004591
Chris Lattnerf4021e72007-08-23 05:46:52 +00004592 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
4593 /// the specified width and sign. If an overflow occurs, detect it and emit
4594 /// the specified diagnostic.
Mike Stump1eb44332009-09-09 15:08:12 +00004595 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
Chris Lattnerf4021e72007-08-23 05:46:52 +00004596 unsigned NewWidth, bool NewSign,
4597 SourceLocation Loc, unsigned DiagID);
Mike Stump1eb44332009-09-09 15:08:12 +00004598
Anders Carlsson15281452008-11-04 16:57:32 +00004599 /// Checks that the Objective-C declaration is declared in the global scope.
4600 /// Emits an error and marks the declaration as invalid if it's not declared
4601 /// in the global scope.
4602 bool CheckObjCDeclScope(Decl *D);
4603
Anders Carlsson7c50aca2007-10-15 20:28:48 +00004604 void InitBuiltinVaListType();
Eli Friedman1b76ada2008-06-03 21:01:11 +00004605
Anders Carlssone21555e2008-11-30 19:50:32 +00004606 /// VerifyIntegerConstantExpression - verifies that an expression is an ICE,
4607 /// and reports the appropriate diagnostics. Returns false on success.
4608 /// Can optionally return the value of the expression.
Anders Carlsson9f1e5722008-12-06 20:33:04 +00004609 bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0);
Anders Carlsson4000ea62008-12-01 02:17:22 +00004610
Anders Carlsson9f1e5722008-12-06 20:33:04 +00004611 /// VerifyBitField - verifies that a bit field expression is an ICE and has
Mike Stump1eb44332009-09-09 15:08:12 +00004612 /// the correct width, and that the field type is valid.
Anders Carlsson9f1e5722008-12-06 20:33:04 +00004613 /// Returns false on success.
Eli Friedman1d954f62009-08-15 21:55:26 +00004614 /// Can optionally return whether the bit-field is of width 0
Mike Stump1eb44332009-09-09 15:08:12 +00004615 bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
4616 QualType FieldTy, const Expr *BitWidth,
Eli Friedman1d954f62009-08-15 21:55:26 +00004617 bool *ZeroWidth = 0);
Sebastian Redl0eb23302009-01-19 00:08:26 +00004618
Douglas Gregor81b747b2009-09-17 21:32:03 +00004619 /// \name Code completion
4620 //@{
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004621 virtual void CodeCompleteOrdinaryName(Scope *S,
Douglas Gregor01dfea02010-01-10 23:08:15 +00004622 CodeCompletionContext CompletionContext);
Douglas Gregorf9578432010-07-28 21:50:18 +00004623 virtual void CodeCompleteExpression(Scope *S, QualType T,
4624 bool IntegralConstantExpression = false);
Douglas Gregor81b747b2009-09-17 21:32:03 +00004625 virtual void CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *Base,
4626 SourceLocation OpLoc,
4627 bool IsArrow);
Douglas Gregor374929f2009-09-18 15:37:17 +00004628 virtual void CodeCompleteTag(Scope *S, unsigned TagSpec);
Douglas Gregor3e1005f2009-09-21 18:10:23 +00004629 virtual void CodeCompleteCase(Scope *S);
Douglas Gregor9c6a0e92009-09-22 15:41:20 +00004630 virtual void CodeCompleteCall(Scope *S, ExprTy *Fn,
4631 ExprTy **Args, unsigned NumArgs);
Douglas Gregor5ac3bdb2010-05-30 01:49:25 +00004632 virtual void CodeCompleteInitializer(Scope *S, DeclPtrTy D);
4633 virtual void CodeCompleteReturn(Scope *S);
4634 virtual void CodeCompleteAssignmentRHS(Scope *S, ExprTy *LHS);
4635
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00004636 virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
Douglas Gregor81b747b2009-09-17 21:32:03 +00004637 bool EnteringContext);
Douglas Gregor49f40bd2009-09-18 19:03:04 +00004638 virtual void CodeCompleteUsing(Scope *S);
4639 virtual void CodeCompleteUsingDirective(Scope *S);
4640 virtual void CodeCompleteNamespaceDecl(Scope *S);
4641 virtual void CodeCompleteNamespaceAliasDecl(Scope *S);
Douglas Gregored8d3222009-09-18 20:05:18 +00004642 virtual void CodeCompleteOperatorName(Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004643
Douglas Gregorc464ae82009-12-07 09:27:33 +00004644 virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
4645 bool InInterface);
Douglas Gregorc38c3e12010-01-13 21:54:15 +00004646 virtual void CodeCompleteObjCAtVisibility(Scope *S);
Douglas Gregor9a0c85e2009-12-07 09:51:25 +00004647 virtual void CodeCompleteObjCAtStatement(Scope *S);
4648 virtual void CodeCompleteObjCAtExpression(Scope *S);
Douglas Gregora93b1082009-11-18 23:08:07 +00004649 virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
Douglas Gregor4ad96852009-11-19 07:41:15 +00004650 virtual void CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl,
4651 DeclPtrTy *Methods,
4652 unsigned NumMethods);
4653 virtual void CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ClassDecl,
4654 DeclPtrTy *Methods,
4655 unsigned NumMethods);
Douglas Gregor8e254cf2010-05-27 23:06:34 +00004656 virtual void CodeCompleteObjCMessageReceiver(Scope *S);
Douglas Gregor2725ca82010-04-21 19:57:20 +00004657 virtual void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
4658 IdentifierInfo **SelIdents,
4659 unsigned NumSelIdents);
4660 virtual void CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004661 IdentifierInfo **SelIdents,
Douglas Gregord3c68542009-11-19 01:08:35 +00004662 unsigned NumSelIdents);
4663 virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
4664 IdentifierInfo **SelIdents,
4665 unsigned NumSelIdents);
Douglas Gregor55385fe2009-11-18 04:19:12 +00004666 virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
4667 unsigned NumProtocols);
Douglas Gregor083128f2009-11-18 04:49:41 +00004668 virtual void CodeCompleteObjCProtocolDecl(Scope *S);
Douglas Gregor3b49aca2009-11-18 16:26:39 +00004669 virtual void CodeCompleteObjCInterfaceDecl(Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004670 virtual void CodeCompleteObjCSuperclass(Scope *S,
Douglas Gregorc83c6872010-04-15 22:33:43 +00004671 IdentifierInfo *ClassName,
4672 SourceLocation ClassNameLoc);
Douglas Gregor3b49aca2009-11-18 16:26:39 +00004673 virtual void CodeCompleteObjCImplementationDecl(Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004674 virtual void CodeCompleteObjCInterfaceCategory(Scope *S,
Douglas Gregorc83c6872010-04-15 22:33:43 +00004675 IdentifierInfo *ClassName,
4676 SourceLocation ClassNameLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004677 virtual void CodeCompleteObjCImplementationCategory(Scope *S,
Douglas Gregorc83c6872010-04-15 22:33:43 +00004678 IdentifierInfo *ClassName,
4679 SourceLocation ClassNameLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004680 virtual void CodeCompleteObjCPropertyDefinition(Scope *S,
Douglas Gregor322328b2009-11-18 22:32:06 +00004681 DeclPtrTy ObjCImpDecl);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004682 virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
Douglas Gregor322328b2009-11-18 22:32:06 +00004683 IdentifierInfo *PropertyName,
4684 DeclPtrTy ObjCImpDecl);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004685 virtual void CodeCompleteObjCMethodDecl(Scope *S,
Douglas Gregore8f5a172010-04-07 00:21:17 +00004686 bool IsInstanceMethod,
4687 TypeTy *ReturnType,
4688 DeclPtrTy IDecl);
Douglas Gregor1f5537a2010-07-08 23:20:03 +00004689 virtual void CodeCompleteObjCMethodDeclSelector(Scope *S,
4690 bool IsInstanceMethod,
Douglas Gregor40ed9a12010-07-08 23:37:41 +00004691 bool AtParameterName,
Douglas Gregor1f5537a2010-07-08 23:20:03 +00004692 TypeTy *ReturnType,
4693 IdentifierInfo **SelIdents,
4694 unsigned NumSelIdents);
4695
Douglas Gregor3b49aca2009-11-18 16:26:39 +00004696 //@}
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004697
Chris Lattner59907c42007-08-10 20:18:51 +00004698 //===--------------------------------------------------------------------===//
4699 // Extra semantic analysis beyond the C type system
Ted Kremeneke0e53132010-01-28 23:39:18 +00004700
4701public:
4702 SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
4703 unsigned ByteNo) const;
4704
Chris Lattner925e60d2007-12-28 05:29:59 +00004705private:
Anders Carlssond406bf02009-08-16 01:56:34 +00004706 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
4707 bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
Mike Stump1eb44332009-09-09 15:08:12 +00004708
Ryan Flynn4403a5e2009-08-06 03:00:50 +00004709 bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall);
Chris Lattner69039812009-02-18 06:01:06 +00004710 bool CheckObjCString(Expr *Arg);
Anders Carlssond406bf02009-08-16 01:56:34 +00004711
4712 Action::OwningExprResult CheckBuiltinFunctionCall(unsigned BuiltinID,
4713 CallExpr *TheCall);
Nate Begeman26a31422010-06-08 02:47:44 +00004714 bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
4715 bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
4716
Chris Lattner925e60d2007-12-28 05:29:59 +00004717 bool SemaBuiltinVAStart(CallExpr *TheCall);
4718 bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
Benjamin Kramer3b1e26b2010-02-16 10:07:31 +00004719 bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
Douglas Gregorcde01732009-05-19 22:10:17 +00004720
4721public:
4722 // Used by C++ template instantiation.
Sebastian Redl0eb23302009-01-19 00:08:26 +00004723 Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
Douglas Gregorcde01732009-05-19 22:10:17 +00004724
4725private:
Mike Stump1eb44332009-09-09 15:08:12 +00004726 bool SemaBuiltinPrefetch(CallExpr *TheCall);
Eli Friedmand875fed2009-05-03 04:46:36 +00004727 bool SemaBuiltinObjectSize(CallExpr *TheCall);
4728 bool SemaBuiltinLongjmp(CallExpr *TheCall);
Chandler Carruthd2014572010-07-09 18:59:35 +00004729 OwningExprResult SemaBuiltinAtomicOverloaded(OwningExprResult TheCallResult);
Eric Christopher691ebc32010-04-17 02:26:23 +00004730 bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
4731 llvm::APSInt &Result);
Ted Kremenek826a3452010-07-16 02:11:22 +00004732
Ted Kremenek082d9362009-03-20 21:35:28 +00004733 bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
4734 bool HasVAListArg, unsigned format_idx,
Ted Kremenek826a3452010-07-16 02:11:22 +00004735 unsigned firstDataArg, bool isPrintf);
4736
4737 void CheckFormatString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
Ted Kremenek082d9362009-03-20 21:35:28 +00004738 const CallExpr *TheCall, bool HasVAListArg,
Ted Kremenek826a3452010-07-16 02:11:22 +00004739 unsigned format_idx, unsigned firstDataArg,
4740 bool isPrintf);
4741
Mike Stump1eb44332009-09-09 15:08:12 +00004742 void CheckNonNullArguments(const NonNullAttr *NonNull,
Fariborz Jahaniane898f8a2009-05-21 18:48:51 +00004743 const CallExpr *TheCall);
Ted Kremenek826a3452010-07-16 02:11:22 +00004744
4745 void CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg,
4746 unsigned format_idx, unsigned firstDataArg,
4747 bool isPrintf);
4748
Ted Kremenek06de2762007-08-17 16:46:58 +00004749 void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
4750 SourceLocation ReturnLoc);
Ted Kremenek588e5eb2007-11-25 00:58:00 +00004751 void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
John McCall323ed742010-05-06 08:58:33 +00004752 void CheckImplicitConversions(Expr *E);
Reid Spencer5f016e22007-07-11 17:01:13 +00004753};
4754
Ted Kremenek8189cde2009-02-07 01:47:29 +00004755//===--------------------------------------------------------------------===//
4756// Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers).
4757template <typename T>
4758class ExprOwningPtr : public Action::ExprArg {
4759public:
Douglas Gregora0e500d2009-03-12 16:53:44 +00004760 ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}
Mike Stump1eb44332009-09-09 15:08:12 +00004761
Ted Kremenek8189cde2009-02-07 01:47:29 +00004762 void reset(T* p) { Action::ExprArg::operator=(p); }
4763 T* get() const { return static_cast<T*>(Action::ExprArg::get()); }
4764 T* take() { return static_cast<T*>(Action::ExprArg::take()); }
4765 T* release() { return take(); }
Mike Stump1eb44332009-09-09 15:08:12 +00004766
Ted Kremenek8189cde2009-02-07 01:47:29 +00004767 T& operator*() const { return *get(); }
4768 T* operator->() const { return get(); }
4769};
Douglas Gregord7e27052009-05-20 22:33:37 +00004770
Reid Spencer5f016e22007-07-11 17:01:13 +00004771} // end namespace clang
4772
4773#endif