blob: eb84417c33af0a34e4df4b9eff1fe4c1c4c1dc53 [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,
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00001182 CXXBaseSpecifierArray& 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,
Anders Carlssonf9d68e12010-04-24 19:36:51 +00001189 CXXBaseSpecifierArray &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,
Mike Stump1eb44332009-09-09 15:08:12 +00001680 bool matchBasedOnSizeAndAlignment = false);
Steve Naroff3b950172007-10-10 21:53:07 +00001681
Fariborz Jahanianb33f3ad2009-05-01 20:07:12 +00001682 /// MatchAllMethodDeclarations - Check methods declaraed in interface or
1683 /// or protocol against those declared in their implementations.
1684 void MatchAllMethodDeclarations(const llvm::DenseSet<Selector> &InsMap,
1685 const llvm::DenseSet<Selector> &ClsMap,
1686 llvm::DenseSet<Selector> &InsMapSeen,
1687 llvm::DenseSet<Selector> &ClsMapSeen,
1688 ObjCImplDecl* IMPDecl,
1689 ObjCContainerDecl* IDecl,
1690 bool &IncompleteImpl,
1691 bool ImmediateClass);
1692
Sebastian Redldb9d2142010-08-02 23:18:59 +00001693private:
1694 /// AddMethodToGlobalPool - Add an instance or factory method to the global
1695 /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
1696 void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
1697
1698 /// LookupMethodInGlobalPool - Returns the instance or factory method and
1699 /// optionally warns if there are multiple signatures.
1700 ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
1701 bool warn, bool instance);
1702
1703public:
Steve Naroff58ff9e82007-10-14 00:58:41 +00001704 /// AddInstanceMethodToGlobalPool - All instance methods in a translation
1705 /// unit are added to a global pool. This allows us to efficiently associate
1706 /// a selector with a method declaraation for purposes of typechecking
1707 /// messages sent to "id" (where the class of the object is unknown).
Sebastian Redldb9d2142010-08-02 23:18:59 +00001708 void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
1709 AddMethodToGlobalPool(Method, impl, /*instance*/true);
1710 }
1711
1712 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
1713 void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
1714 AddMethodToGlobalPool(Method, impl, /*instance*/false);
1715 }
Mike Stump1eb44332009-09-09 15:08:12 +00001716
Steve Naroff037cda52008-09-30 14:38:43 +00001717 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
1718 /// there are multiple signatures.
Fariborz Jahanian835ed7f2009-08-22 21:13:55 +00001719 ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
Sebastian Redldb9d2142010-08-02 23:18:59 +00001720 bool warn=true) {
1721 return LookupMethodInGlobalPool(Sel, R, warn, /*instance*/true);
1722 }
Douglas Gregorf0aaf7a2009-04-24 21:10:55 +00001723
1724 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
1725 /// there are multiple signatures.
Fariborz Jahanian3fe10412010-07-22 18:24:20 +00001726 ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R,
Sebastian Redldb9d2142010-08-02 23:18:59 +00001727 bool warn=true) {
1728 return LookupMethodInGlobalPool(Sel, R, warn, /*instance*/false);
1729 }
Fariborz Jahanian3fe10412010-07-22 18:24:20 +00001730
1731 /// LookupImplementedMethodInGlobalPool - Returns the method which has an
1732 /// implementation.
1733 ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
Mike Stump1eb44332009-09-09 15:08:12 +00001734
Fariborz Jahanian786cd152010-04-27 17:18:58 +00001735 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
Fariborz Jahaniane4498c62010-04-28 16:11:27 +00001736 /// initialization.
Fariborz Jahanian786cd152010-04-27 17:18:58 +00001737 void CollectIvarsToConstructOrDestruct(const ObjCInterfaceDecl *OI,
Fariborz Jahaniane4498c62010-04-28 16:11:27 +00001738 llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars);
Reid Spencer5f016e22007-07-11 17:01:13 +00001739 //===--------------------------------------------------------------------===//
1740 // Statement Parsing Callbacks: SemaStmt.cpp.
1741public:
Anders Carlsson6b1d2832009-05-17 21:11:30 +00001742 virtual OwningStmtResult ActOnExprStmt(FullExprArg Expr);
Sebastian Redla60528c2008-12-21 12:04:03 +00001743
1744 virtual OwningStmtResult ActOnNullStmt(SourceLocation SemiLoc);
1745 virtual OwningStmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
1746 MultiStmtArg Elts,
1747 bool isStmtExpr);
Chris Lattner682bf922009-03-29 16:50:03 +00001748 virtual OwningStmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
Chris Lattnerb28317a2009-03-28 19:18:32 +00001749 SourceLocation StartLoc,
Sebastian Redla60528c2008-12-21 12:04:03 +00001750 SourceLocation EndLoc);
Fariborz Jahaniana7cf23a2009-11-19 22:12:37 +00001751 virtual void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
Sebastian Redl117054a2008-12-28 16:13:43 +00001752 virtual OwningStmtResult ActOnCaseStmt(SourceLocation CaseLoc, ExprArg LHSVal,
1753 SourceLocation DotDotDotLoc, ExprArg RHSVal,
Chris Lattner24e1e702009-03-04 04:23:07 +00001754 SourceLocation ColonLoc);
1755 virtual void ActOnCaseStmtBody(StmtTy *CaseStmt, StmtArg SubStmt);
Mike Stump1eb44332009-09-09 15:08:12 +00001756
Sebastian Redl117054a2008-12-28 16:13:43 +00001757 virtual OwningStmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
1758 SourceLocation ColonLoc,
1759 StmtArg SubStmt, Scope *CurScope);
Sebastian Redlde307472009-01-11 00:38:46 +00001760 virtual OwningStmtResult ActOnLabelStmt(SourceLocation IdentLoc,
1761 IdentifierInfo *II,
1762 SourceLocation ColonLoc,
1763 StmtArg SubStmt);
Mike Stump1eb44332009-09-09 15:08:12 +00001764 virtual OwningStmtResult ActOnIfStmt(SourceLocation IfLoc,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001765 FullExprArg CondVal, DeclPtrTy CondVar,
1766 StmtArg ThenVal,
Anders Carlssona99fad82009-05-17 18:26:53 +00001767 SourceLocation ElseLoc, StmtArg ElseVal);
Douglas Gregor586596f2010-05-06 17:25:47 +00001768 virtual OwningStmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
1769 ExprArg Cond,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001770 DeclPtrTy CondVar);
Sebastian Redlde307472009-01-11 00:38:46 +00001771 virtual OwningStmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
1772 StmtArg Switch, StmtArg Body);
Mike Stump1eb44332009-09-09 15:08:12 +00001773 virtual OwningStmtResult ActOnWhileStmt(SourceLocation WhileLoc,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001774 FullExprArg Cond,
1775 DeclPtrTy CondVar, StmtArg Body);
Sebastian Redlf05b1522009-01-16 23:28:06 +00001776 virtual OwningStmtResult ActOnDoStmt(SourceLocation DoLoc, StmtArg Body,
Chris Lattner98913592009-06-12 23:04:47 +00001777 SourceLocation WhileLoc,
1778 SourceLocation CondLParen, ExprArg Cond,
1779 SourceLocation CondRParen);
Sebastian Redlf05b1522009-01-16 23:28:06 +00001780
1781 virtual OwningStmtResult ActOnForStmt(SourceLocation ForLoc,
1782 SourceLocation LParenLoc,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001783 StmtArg First, FullExprArg Second,
1784 DeclPtrTy SecondVar,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001785 FullExprArg Third,
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00001786 SourceLocation RParenLoc,
Sebastian Redlf05b1522009-01-16 23:28:06 +00001787 StmtArg Body);
1788 virtual OwningStmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
1789 SourceLocation LParenLoc,
1790 StmtArg First, ExprArg Second,
1791 SourceLocation RParenLoc, StmtArg Body);
Sebastian Redl4cffe2f2009-01-18 13:19:59 +00001792
1793 virtual OwningStmtResult ActOnGotoStmt(SourceLocation GotoLoc,
1794 SourceLocation LabelLoc,
1795 IdentifierInfo *LabelII);
1796 virtual OwningStmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
1797 SourceLocation StarLoc,
1798 ExprArg DestExp);
1799 virtual OwningStmtResult ActOnContinueStmt(SourceLocation ContinueLoc,
1800 Scope *CurScope);
1801 virtual OwningStmtResult ActOnBreakStmt(SourceLocation GotoLoc,
1802 Scope *CurScope);
1803
1804 virtual OwningStmtResult ActOnReturnStmt(SourceLocation ReturnLoc,
Anders Carlssonf53b4432009-08-18 16:11:00 +00001805 ExprArg RetValExp);
Sebastian Redl4cffe2f2009-01-18 13:19:59 +00001806 OwningStmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc,
1807 Expr *RetValExp);
1808
Sebastian Redl3037ed02009-01-18 16:53:17 +00001809 virtual OwningStmtResult ActOnAsmStmt(SourceLocation AsmLoc,
1810 bool IsSimple,
1811 bool IsVolatile,
1812 unsigned NumOutputs,
1813 unsigned NumInputs,
Anders Carlssonff93dbd2010-01-30 22:25:16 +00001814 IdentifierInfo **Names,
Sebastian Redl3037ed02009-01-18 16:53:17 +00001815 MultiExprArg Constraints,
1816 MultiExprArg Exprs,
1817 ExprArg AsmString,
1818 MultiExprArg Clobbers,
Mike Stump3b11fd32010-01-04 22:37:17 +00001819 SourceLocation RParenLoc,
1820 bool MSAsm = false);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001821
Douglas Gregor160b5632010-04-26 17:32:49 +00001822
1823 VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
1824 IdentifierInfo *Name, SourceLocation NameLoc,
1825 bool Invalid = false);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001826
Douglas Gregor160b5632010-04-26 17:32:49 +00001827 virtual DeclPtrTy ActOnObjCExceptionDecl(Scope *S, Declarator &D);
1828
Sebastian Redl431e90e2009-01-18 17:43:11 +00001829 virtual OwningStmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc,
1830 SourceLocation RParen,
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001831 DeclPtrTy Parm, StmtArg Body);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001832
1833 virtual OwningStmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc,
1834 StmtArg Body);
1835
1836 virtual OwningStmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc,
1837 StmtArg Try,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001838 MultiStmtArg Catch,
Douglas Gregor8f5e3dd2010-04-23 22:50:49 +00001839 StmtArg Finally);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001840
Douglas Gregord1377b22010-04-22 21:44:01 +00001841 virtual OwningStmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc,
1842 ExprArg Throw);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001843 virtual OwningStmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00001844 ExprArg Throw,
Steve Naroffe21dd6f2009-02-11 20:05:44 +00001845 Scope *CurScope);
Sebastian Redl431e90e2009-01-18 17:43:11 +00001846 virtual OwningStmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
1847 ExprArg SynchExpr,
1848 StmtArg SynchBody);
Sebastian Redla0fd8652008-12-21 16:41:36 +00001849
Douglas Gregord308e622009-05-18 20:51:54 +00001850 VarDecl *BuildExceptionDeclaration(Scope *S, QualType ExDeclType,
John McCalla93c9342009-12-07 02:54:59 +00001851 TypeSourceInfo *TInfo,
Douglas Gregord308e622009-05-18 20:51:54 +00001852 IdentifierInfo *Name,
1853 SourceLocation Loc,
1854 SourceRange Range);
Chris Lattnerb28317a2009-03-28 19:18:32 +00001855 virtual DeclPtrTy ActOnExceptionDeclarator(Scope *S, Declarator &D);
Douglas Gregord308e622009-05-18 20:51:54 +00001856
Sebastian Redl4b07b292008-12-22 19:15:10 +00001857 virtual OwningStmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00001858 DeclPtrTy ExDecl,
Sebastian Redl4b07b292008-12-22 19:15:10 +00001859 StmtArg HandlerBlock);
Sebastian Redl8351da02008-12-22 21:35:02 +00001860 virtual OwningStmtResult ActOnCXXTryBlock(SourceLocation TryLoc,
1861 StmtArg TryBlock,
1862 MultiStmtArg Handlers);
Sebastian Redl13e88542009-04-27 21:33:24 +00001863 void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
Sebastian Redla0fd8652008-12-21 16:41:36 +00001864
Anders Carlsson636463e2009-07-30 22:17:18 +00001865 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
1866 /// whose result is unused, warn.
1867 void DiagnoseUnusedExprResult(const Stmt *S);
Douglas Gregor5764f612010-05-08 23:05:03 +00001868 void DiagnoseUnusedDecl(const NamedDecl *ND);
1869
John McCall54abf7d2009-11-04 02:18:39 +00001870 ParsingDeclStackState PushParsingDeclaration();
1871 void PopParsingDeclaration(ParsingDeclStackState S, DeclPtrTy D);
1872 void EmitDeprecationWarning(NamedDecl *D, SourceLocation Loc);
1873
John McCall2f514482010-01-27 03:50:35 +00001874 void HandleDelayedDeprecationCheck(DelayedDiagnostic &DD, Decl *Ctx);
1875
Reid Spencer5f016e22007-07-11 17:01:13 +00001876 //===--------------------------------------------------------------------===//
1877 // Expression Parsing Callbacks: SemaExpr.cpp.
1878
John McCall54abf7d2009-11-04 02:18:39 +00001879 bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc);
Mike Stump1eb44332009-09-09 15:08:12 +00001880 bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
Fariborz Jahanianc001e892009-05-08 20:20:55 +00001881 ObjCMethodDecl *Getter,
1882 SourceLocation Loc);
Fariborz Jahanian5b530052009-05-13 18:09:35 +00001883 void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
1884 Expr **Args, unsigned NumArgs);
Chris Lattner76a642f2009-02-15 22:43:40 +00001885
Douglas Gregor2afce722009-11-26 00:44:06 +00001886 virtual void
Douglas Gregorac7610d2009-06-22 20:57:11 +00001887 PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
Mike Stump1eb44332009-09-09 15:08:12 +00001888
Douglas Gregor2afce722009-11-26 00:44:06 +00001889 virtual void PopExpressionEvaluationContext();
Mike Stump1eb44332009-09-09 15:08:12 +00001890
Douglas Gregore0762c92009-06-19 23:52:42 +00001891 void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
Douglas Gregorb4eeaff2010-05-07 23:12:07 +00001892 void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
Douglas Gregor1c7c3fb2009-12-22 01:01:55 +00001893 bool DiagRuntimeBehavior(SourceLocation Loc, const PartialDiagnostic &PD);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001894
Reid Spencer5f016e22007-07-11 17:01:13 +00001895 // Primary Expressions.
Douglas Gregor4b2d3f72009-02-26 21:00:50 +00001896 virtual SourceRange getExprRange(ExprTy *E) const;
1897
Douglas Gregor02a24ee2009-11-03 16:56:39 +00001898 virtual OwningExprResult ActOnIdExpression(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00001899 CXXScopeSpec &SS,
Douglas Gregor02a24ee2009-11-03 16:56:39 +00001900 UnqualifiedId &Name,
1901 bool HasTrailingLParen,
1902 bool IsAddressOfOperand);
John McCallf7a1a742009-11-24 19:00:30 +00001903
Douglas Gregor91f7ac72010-05-18 16:14:23 +00001904 bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
1905 CorrectTypoContext CTC = CTC_Unknown);
John McCall578b69b2009-12-16 08:11:27 +00001906
John McCallf7a1a742009-11-24 19:00:30 +00001907 OwningExprResult LookupInObjCMethod(LookupResult &R,
1908 Scope *S,
Fariborz Jahanian48c2d562010-01-12 23:58:59 +00001909 IdentifierInfo *II,
1910 bool AllowBuiltinCreation=false);
John McCallf7a1a742009-11-24 19:00:30 +00001911
1912 OwningExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
1913 DeclarationName Name,
1914 SourceLocation NameLoc,
John McCall2f841ba2009-12-02 03:53:29 +00001915 bool isAddressOfOperand,
John McCallf7a1a742009-11-24 19:00:30 +00001916 const TemplateArgumentListInfo *TemplateArgs);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00001917
John McCalldbd872f2009-12-08 09:08:17 +00001918 OwningExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
Douglas Gregor0da76df2009-11-23 11:41:28 +00001919 SourceLocation Loc,
Anders Carlssone41590d2009-06-24 00:10:43 +00001920 const CXXScopeSpec *SS = 0);
Douglas Gregorffb4b6e2009-04-15 06:41:24 +00001921 VarDecl *BuildAnonymousStructUnionMemberPath(FieldDecl *Field,
1922 llvm::SmallVectorImpl<FieldDecl *> &Path);
Sebastian Redlcd965b92009-01-18 18:53:16 +00001923 OwningExprResult
Douglas Gregorbcbffc42009-01-07 00:43:41 +00001924 BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
1925 FieldDecl *Field,
1926 Expr *BaseObjectExpr = 0,
1927 SourceLocation OpLoc = SourceLocation());
John McCall3b4294e2009-12-16 12:17:52 +00001928 OwningExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
1929 LookupResult &R,
1930 const TemplateArgumentListInfo *TemplateArgs);
John McCallaa81e162009-12-01 22:10:20 +00001931 OwningExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
1932 LookupResult &R,
1933 const TemplateArgumentListInfo *TemplateArgs,
1934 bool IsDefiniteInstance);
John McCallf7a1a742009-11-24 19:00:30 +00001935 bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
John McCall5b3f9132009-11-22 01:44:31 +00001936 const LookupResult &R,
1937 bool HasTrailingLParen);
John McCallf7a1a742009-11-24 19:00:30 +00001938
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00001939 OwningExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
John McCallf7a1a742009-11-24 19:00:30 +00001940 DeclarationName Name,
1941 SourceLocation NameLoc);
1942 OwningExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
1943 DeclarationName Name,
1944 SourceLocation NameLoc,
1945 const TemplateArgumentListInfo *TemplateArgs);
1946
1947 OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
1948 LookupResult &R,
1949 bool ADL);
1950 OwningExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
John McCallba135432009-11-21 08:51:07 +00001951 SourceLocation Loc,
1952 NamedDecl *D);
Mike Stump1eb44332009-09-09 15:08:12 +00001953
Sebastian Redlcd965b92009-01-18 18:53:16 +00001954 virtual OwningExprResult ActOnPredefinedExpr(SourceLocation Loc,
1955 tok::TokenKind Kind);
1956 virtual OwningExprResult ActOnNumericConstant(const Token &);
1957 virtual OwningExprResult ActOnCharacterConstant(const Token &);
1958 virtual OwningExprResult ActOnParenExpr(SourceLocation L, SourceLocation R,
1959 ExprArg Val);
Fariborz Jahanianf88f7ab2009-11-25 01:26:41 +00001960 virtual OwningExprResult ActOnParenOrParenListExpr(SourceLocation L,
Nate Begeman2ef13e52009-08-10 23:49:36 +00001961 SourceLocation R,
Fariborz Jahanianf88f7ab2009-11-25 01:26:41 +00001962 MultiExprArg Val,
1963 TypeTy *TypeOfCast=0);
Mike Stump1eb44332009-09-09 15:08:12 +00001964
Steve Narofff69936d2007-09-16 03:34:24 +00001965 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
Reid Spencer5f016e22007-07-11 17:01:13 +00001966 /// fragments (e.g. "foo" "bar" L"baz").
Sebastian Redl0eb23302009-01-19 00:08:26 +00001967 virtual OwningExprResult ActOnStringLiteral(const Token *Toks,
1968 unsigned NumToks);
Sebastian Redlcd965b92009-01-18 18:53:16 +00001969
Reid Spencer5f016e22007-07-11 17:01:13 +00001970 // Binary/Unary Operators. 'Tok' is the token for the operator.
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001971 OwningExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00001972 unsigned OpcIn,
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001973 ExprArg InputArg);
Douglas Gregor6ca7cfb2009-11-05 00:51:44 +00001974 OwningExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
1975 UnaryOperator::Opcode Opc, ExprArg input);
Sebastian Redl0eb23302009-01-19 00:08:26 +00001976 virtual OwningExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
1977 tok::TokenKind Op, ExprArg Input);
Sebastian Redl05189992008-11-11 17:56:53 +00001978
John McCalla93c9342009-12-07 02:54:59 +00001979 OwningExprResult CreateSizeOfAlignOfExpr(TypeSourceInfo *T,
John McCall5ab75172009-11-04 07:28:41 +00001980 SourceLocation OpLoc,
Douglas Gregorba498172009-03-13 21:01:28 +00001981 bool isSizeOf, SourceRange R);
Mike Stump1eb44332009-09-09 15:08:12 +00001982 OwningExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
Douglas Gregorba498172009-03-13 21:01:28 +00001983 bool isSizeOf, SourceRange R);
Douglas Gregorbc736fc2009-03-13 23:49:33 +00001984 virtual OwningExprResult
1985 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
1986 void *TyOrEx, const SourceRange &ArgRange);
Mike Stump1eb44332009-09-09 15:08:12 +00001987
Chris Lattner31e21e02009-01-24 20:17:12 +00001988 bool CheckAlignOfExpr(Expr *E, SourceLocation OpLoc, const SourceRange &R);
Sebastian Redl05189992008-11-11 17:56:53 +00001989 bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc,
1990 const SourceRange &R, bool isSizeof);
Sebastian Redl0eb23302009-01-19 00:08:26 +00001991
1992 virtual OwningExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
1993 tok::TokenKind Kind,
1994 ExprArg Input);
1995
1996 virtual OwningExprResult ActOnArraySubscriptExpr(Scope *S, ExprArg Base,
1997 SourceLocation LLoc,
1998 ExprArg Idx,
1999 SourceLocation RLoc);
Sebastian Redlf322ed62009-10-29 20:17:01 +00002000 OwningExprResult CreateBuiltinArraySubscriptExpr(ExprArg Base,
2001 SourceLocation LLoc,
2002 ExprArg Idx,
2003 SourceLocation RLoc);
Douglas Gregorc4bf26f2009-09-01 00:37:14 +00002004
John McCall129e2df2009-11-30 22:42:35 +00002005 OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
John McCallaa81e162009-12-01 22:10:20 +00002006 QualType BaseType,
Douglas Gregorc4bf26f2009-09-01 00:37:14 +00002007 SourceLocation OpLoc,
John McCall129e2df2009-11-30 22:42:35 +00002008 bool IsArrow,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002009 CXXScopeSpec &SS,
John McCall129e2df2009-11-30 22:42:35 +00002010 NamedDecl *FirstQualifierInScope,
2011 DeclarationName Name,
2012 SourceLocation NameLoc,
2013 const TemplateArgumentListInfo *TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00002014
John McCall129e2df2009-11-30 22:42:35 +00002015 OwningExprResult BuildMemberReferenceExpr(ExprArg Base,
John McCallaa81e162009-12-01 22:10:20 +00002016 QualType BaseType,
John McCall129e2df2009-11-30 22:42:35 +00002017 SourceLocation OpLoc, bool IsArrow,
2018 const CXXScopeSpec &SS,
John McCallc2233c52010-01-15 08:34:02 +00002019 NamedDecl *FirstQualifierInScope,
John McCall129e2df2009-11-30 22:42:35 +00002020 LookupResult &R,
Douglas Gregor06a9f362010-05-01 20:49:11 +00002021 const TemplateArgumentListInfo *TemplateArgs,
2022 bool SuppressQualifierCheck = false);
John McCall129e2df2009-11-30 22:42:35 +00002023
2024 OwningExprResult LookupMemberExpr(LookupResult &R, Expr *&Base,
John McCall812c1542009-12-07 22:46:59 +00002025 bool &IsArrow, SourceLocation OpLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002026 CXXScopeSpec &SS,
John McCallad00b772010-06-16 08:42:20 +00002027 DeclPtrTy ObjCImpDecl,
2028 bool HasTemplateArgs);
John McCall129e2df2009-11-30 22:42:35 +00002029
2030 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
John McCall2f841ba2009-12-02 03:53:29 +00002031 const CXXScopeSpec &SS,
John McCall129e2df2009-11-30 22:42:35 +00002032 const LookupResult &R);
2033
2034 OwningExprResult ActOnDependentMemberExpr(ExprArg Base,
John McCallaa81e162009-12-01 22:10:20 +00002035 QualType BaseType,
John McCall129e2df2009-11-30 22:42:35 +00002036 bool IsArrow,
Anders Carlsson8f28f992009-08-26 18:25:21 +00002037 SourceLocation OpLoc,
John McCall129e2df2009-11-30 22:42:35 +00002038 const CXXScopeSpec &SS,
2039 NamedDecl *FirstQualifierInScope,
2040 DeclarationName Name,
2041 SourceLocation NameLoc,
2042 const TemplateArgumentListInfo *TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00002043
Douglas Gregor2d1c2142009-11-03 19:44:04 +00002044 virtual OwningExprResult ActOnMemberAccessExpr(Scope *S, ExprArg Base,
2045 SourceLocation OpLoc,
2046 tok::TokenKind OpKind,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002047 CXXScopeSpec &SS,
Douglas Gregor2d1c2142009-11-03 19:44:04 +00002048 UnqualifiedId &Member,
2049 DeclPtrTy ObjCImpDecl,
2050 bool HasTrailingLParen);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002051
Fariborz Jahanian393612e2009-07-21 22:36:06 +00002052 virtual void ActOnDefaultCtorInitializers(DeclPtrTy CDtorDecl);
Sebastian Redl0eb23302009-01-19 00:08:26 +00002053 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
Douglas Gregor88a35142008-12-22 05:46:06 +00002054 FunctionDecl *FDecl,
Douglas Gregor72564e72009-02-26 23:50:07 +00002055 const FunctionProtoType *Proto,
Douglas Gregor88a35142008-12-22 05:46:06 +00002056 Expr **Args, unsigned NumArgs,
2057 SourceLocation RParenLoc);
Sebastian Redl0eb23302009-01-19 00:08:26 +00002058
Steve Narofff69936d2007-09-16 03:34:24 +00002059 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
Reid Spencer5f016e22007-07-11 17:01:13 +00002060 /// This provides the location of the left/right parens and a list of comma
2061 /// locations.
Sebastian Redl0eb23302009-01-19 00:08:26 +00002062 virtual OwningExprResult ActOnCallExpr(Scope *S, ExprArg Fn,
2063 SourceLocation LParenLoc,
2064 MultiExprArg Args,
2065 SourceLocation *CommaLocs,
2066 SourceLocation RParenLoc);
John McCallaa81e162009-12-01 22:10:20 +00002067 OwningExprResult BuildResolvedCallExpr(Expr *Fn,
2068 NamedDecl *NDecl,
2069 SourceLocation LParenLoc,
2070 Expr **Args, unsigned NumArgs,
2071 SourceLocation RParenLoc);
Sebastian Redl0eb23302009-01-19 00:08:26 +00002072
Nate Begeman2ef13e52009-08-10 23:49:36 +00002073 virtual OwningExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
2074 TypeTy *Ty, SourceLocation RParenLoc,
2075 ExprArg Op);
John McCallb042fdf2010-01-15 18:56:44 +00002076 OwningExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
2077 TypeSourceInfo *Ty,
2078 SourceLocation RParenLoc,
2079 ExprArg Op);
2080
Fariborz Jahaniana79f8b32009-11-23 19:51:43 +00002081 virtual bool TypeIsVectorType(TypeTy *Ty) {
2082 return GetTypeFromParser(Ty)->isVectorType();
2083 }
Mike Stump1eb44332009-09-09 15:08:12 +00002084
Nate Begeman2ef13e52009-08-10 23:49:36 +00002085 OwningExprResult MaybeConvertParenListExprToParenExpr(Scope *S, ExprArg ME);
2086 OwningExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
2087 SourceLocation RParenLoc, ExprArg E,
John McCall42f56b52010-01-18 19:35:47 +00002088 TypeSourceInfo *TInfo);
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002089
2090 virtual OwningExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
2091 TypeTy *Ty,
2092 SourceLocation RParenLoc,
2093 ExprArg Op);
2094
John McCall42f56b52010-01-18 19:35:47 +00002095 OwningExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
2096 TypeSourceInfo *TInfo,
2097 SourceLocation RParenLoc,
2098 ExprArg InitExpr);
2099
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002100 virtual OwningExprResult ActOnInitList(SourceLocation LParenLoc,
2101 MultiExprArg InitList,
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002102 SourceLocation RParenLoc);
2103
Douglas Gregor05c13a32009-01-22 00:58:24 +00002104 virtual OwningExprResult ActOnDesignatedInitializer(Designation &Desig,
2105 SourceLocation Loc,
Douglas Gregoreeae8f02009-03-28 00:41:23 +00002106 bool GNUSyntax,
Douglas Gregor05c13a32009-01-22 00:58:24 +00002107 OwningExprResult Init);
2108
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002109 virtual OwningExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
2110 tok::TokenKind Kind,
2111 ExprArg LHS, ExprArg RHS);
Douglas Gregor6ca7cfb2009-11-05 00:51:44 +00002112 OwningExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
2113 BinaryOperator::Opcode Opc,
2114 Expr *lhs, Expr *rhs);
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002115 OwningExprResult CreateBuiltinBinOp(SourceLocation TokLoc,
2116 unsigned Opc, Expr *lhs, Expr *rhs);
Douglas Gregoreaebc752008-11-06 23:29:22 +00002117
Steve Narofff69936d2007-09-16 03:34:24 +00002118 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
Reid Spencer5f016e22007-07-11 17:01:13 +00002119 /// in the case of a the GNU conditional expr extension.
Sebastian Redlb8a6aca2009-01-19 22:31:54 +00002120 virtual OwningExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
2121 SourceLocation ColonLoc,
2122 ExprArg Cond, ExprArg LHS,
2123 ExprArg RHS);
Reid Spencer5f016e22007-07-11 17:01:13 +00002124
Steve Naroff1b273c42007-09-16 14:56:35 +00002125 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
Sebastian Redlf53597f2009-03-15 17:47:39 +00002126 virtual OwningExprResult ActOnAddrLabel(SourceLocation OpLoc,
2127 SourceLocation LabLoc,
2128 IdentifierInfo *LabelII);
2129
2130 virtual OwningExprResult ActOnStmtExpr(SourceLocation LPLoc, StmtArg SubStmt,
2131 SourceLocation RPLoc); // "({..})"
Chris Lattner73d0d4f2007-08-30 17:45:32 +00002132
2133 /// __builtin_offsetof(type, a.b[123][456].c)
Douglas Gregor8ecdb652010-04-28 22:16:22 +00002134 OwningExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
2135 TypeSourceInfo *TInfo,
2136 OffsetOfComponent *CompPtr,
2137 unsigned NumComponents,
2138 SourceLocation RParenLoc);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002139 virtual OwningExprResult ActOnBuiltinOffsetOf(Scope *S,
2140 SourceLocation BuiltinLoc,
2141 SourceLocation TypeLoc,
2142 TypeTy *Arg1,
2143 OffsetOfComponent *CompPtr,
2144 unsigned NumComponents,
2145 SourceLocation RParenLoc);
2146
Steve Naroffd34e9152007-08-01 22:05:33 +00002147 // __builtin_types_compatible_p(type1, type2)
Sebastian Redlf53597f2009-03-15 17:47:39 +00002148 virtual OwningExprResult ActOnTypesCompatibleExpr(SourceLocation BuiltinLoc,
2149 TypeTy *arg1, TypeTy *arg2,
2150 SourceLocation RPLoc);
2151
Steve Naroffd04fdd52007-08-03 21:21:27 +00002152 // __builtin_choose_expr(constExpr, expr1, expr2)
Sebastian Redlf53597f2009-03-15 17:47:39 +00002153 virtual OwningExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
2154 ExprArg cond, ExprArg expr1,
2155 ExprArg expr2, SourceLocation RPLoc);
2156
Anders Carlsson7c50aca2007-10-15 20:28:48 +00002157 // __builtin_va_arg(expr, type)
Sebastian Redlf53597f2009-03-15 17:47:39 +00002158 virtual OwningExprResult ActOnVAArg(SourceLocation BuiltinLoc,
2159 ExprArg expr, TypeTy *type,
2160 SourceLocation RPLoc);
Steve Naroff4eb206b2008-09-03 18:15:37 +00002161
Douglas Gregor2d8b2732008-11-29 04:51:27 +00002162 // __null
Sebastian Redlf53597f2009-03-15 17:47:39 +00002163 virtual OwningExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
Douglas Gregor2d8b2732008-11-29 04:51:27 +00002164
Steve Naroff4eb206b2008-09-03 18:15:37 +00002165 //===------------------------- "Block" Extension ------------------------===//
2166
2167 /// ActOnBlockStart - This callback is invoked when a block literal is
2168 /// started.
Steve Naroff090276f2008-10-10 01:28:17 +00002169 virtual void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002170
Steve Naroff090276f2008-10-10 01:28:17 +00002171 /// ActOnBlockArguments - This callback allows processing of block arguments.
2172 /// If there are no arguments, this is still invoked.
Mike Stump98eb8a72009-02-04 22:31:32 +00002173 virtual void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002174
Steve Naroff4eb206b2008-09-03 18:15:37 +00002175 /// ActOnBlockError - If there is an error parsing a block, this callback
2176 /// is invoked to pop the information about the block from the action impl.
2177 virtual void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
Sebastian Redlf53597f2009-03-15 17:47:39 +00002178
Steve Naroff4eb206b2008-09-03 18:15:37 +00002179 /// ActOnBlockStmtExpr - This is called when the body of a block statement
2180 /// literal was successfully completed. ^(int x){...}
Sebastian Redlf53597f2009-03-15 17:47:39 +00002181 virtual OwningExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc,
2182 StmtArg Body, Scope *CurScope);
Steve Naroff4eb206b2008-09-03 18:15:37 +00002183
Chris Lattner76a642f2009-02-15 22:43:40 +00002184 //===---------------------------- C++ Features --------------------------===//
2185
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +00002186 // Act on C++ namespaces
Chris Lattnerb28317a2009-03-28 19:18:32 +00002187 virtual DeclPtrTy ActOnStartNamespaceDef(Scope *S, SourceLocation IdentLoc,
2188 IdentifierInfo *Ident,
Anders Carlsson2a3503d2010-02-07 01:09:23 +00002189 SourceLocation LBrace,
2190 AttributeList *AttrList);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002191 virtual void ActOnFinishNamespaceDef(DeclPtrTy Dcl, SourceLocation RBrace);
Argyrios Kyrtzidis2d1c5d32008-04-27 13:50:30 +00002192
Argyrios Kyrtzidis76c38d32010-08-02 07:14:54 +00002193 NamespaceDecl *getStdNamespace() const {
2194 return cast_or_null<NamespaceDecl>(
2195 StdNamespace.get(Context.getExternalSource()));
2196 }
Argyrios Kyrtzidis26faaac2010-08-02 07:14:39 +00002197 NamespaceDecl *getOrCreateStdNamespace();
Argyrios Kyrtzidis76c38d32010-08-02 07:14:54 +00002198
2199 CXXRecordDecl *getStdBadAlloc() const {
2200 return cast_or_null<CXXRecordDecl>(
2201 StdBadAlloc.get(Context.getExternalSource()));
2202 }
2203
Chris Lattnerb28317a2009-03-28 19:18:32 +00002204 virtual DeclPtrTy ActOnUsingDirective(Scope *CurScope,
2205 SourceLocation UsingLoc,
2206 SourceLocation NamespcLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002207 CXXScopeSpec &SS,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002208 SourceLocation IdentLoc,
2209 IdentifierInfo *NamespcName,
2210 AttributeList *AttrList);
Mike Stump1eb44332009-09-09 15:08:12 +00002211
Douglas Gregor2a3009a2009-02-03 19:21:40 +00002212 void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
2213
Chris Lattnerb28317a2009-03-28 19:18:32 +00002214 virtual DeclPtrTy ActOnNamespaceAliasDef(Scope *CurScope,
Anders Carlsson03bd5a12009-03-28 22:53:22 +00002215 SourceLocation NamespaceLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002216 SourceLocation AliasLoc,
2217 IdentifierInfo *Alias,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002218 CXXScopeSpec &SS,
Anders Carlsson03bd5a12009-03-28 22:53:22 +00002219 SourceLocation IdentLoc,
2220 IdentifierInfo *Ident);
Douglas Gregor9cfbe482009-06-20 00:51:54 +00002221
John McCall9f54ad42009-12-10 09:41:52 +00002222 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
2223 bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
2224 const LookupResult &PreviousDecls);
2225 UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
2226 NamedDecl *Target);
John McCall604e7f12009-12-08 07:46:18 +00002227
John McCall9f54ad42009-12-10 09:41:52 +00002228 bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
2229 bool isTypeName,
2230 const CXXScopeSpec &SS,
2231 SourceLocation NameLoc,
2232 const LookupResult &Previous);
John McCalled976492009-12-04 22:46:56 +00002233 bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
2234 const CXXScopeSpec &SS,
2235 SourceLocation NameLoc);
2236
John McCall9488ea12009-11-17 05:59:44 +00002237 NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
2238 SourceLocation UsingLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002239 CXXScopeSpec &SS,
Anders Carlssonc72160b2009-08-28 05:40:36 +00002240 SourceLocation IdentLoc,
2241 DeclarationName Name,
2242 AttributeList *AttrList,
John McCall7ba107a2009-11-18 02:36:19 +00002243 bool IsInstantiation,
2244 bool IsTypeName,
2245 SourceLocation TypenameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002246
Douglas Gregor9cfbe482009-06-20 00:51:54 +00002247 virtual DeclPtrTy ActOnUsingDeclaration(Scope *CurScope,
Anders Carlsson595adc12009-08-29 19:54:19 +00002248 AccessSpecifier AS,
John McCall60fa3cf2009-12-11 02:10:03 +00002249 bool HasUsingKeyword,
Anders Carlssonc72160b2009-08-28 05:40:36 +00002250 SourceLocation UsingLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002251 CXXScopeSpec &SS,
Douglas Gregor12c118a2009-11-04 16:30:06 +00002252 UnqualifiedId &Name,
Anders Carlssonc72160b2009-08-28 05:40:36 +00002253 AttributeList *AttrList,
John McCall7ba107a2009-11-18 02:36:19 +00002254 bool IsTypeName,
2255 SourceLocation TypenameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002256
2257 /// AddCXXDirectInitializerToDecl - This action is called immediately after
Argyrios Kyrtzidis73a0d882008-10-06 17:10:33 +00002258 /// ActOnDeclarator, when a C++ direct initializer is present.
2259 /// e.g: "int x(1);"
Chris Lattnerb28317a2009-03-28 19:18:32 +00002260 virtual void AddCXXDirectInitializerToDecl(DeclPtrTy Dcl,
Argyrios Kyrtzidis73a0d882008-10-06 17:10:33 +00002261 SourceLocation LParenLoc,
Sebastian Redlf53597f2009-03-15 17:47:39 +00002262 MultiExprArg Exprs,
Argyrios Kyrtzidis73a0d882008-10-06 17:10:33 +00002263 SourceLocation *CommaLocs,
2264 SourceLocation RParenLoc);
2265
Anders Carlsson49d44012009-04-24 05:16:06 +00002266 /// InitializeVarWithConstructor - Creates an CXXConstructExpr
2267 /// and sets it as the initializer for the the passed in VarDecl.
Mike Stump1eb44332009-09-09 15:08:12 +00002268 bool InitializeVarWithConstructor(VarDecl *VD,
Anders Carlsson930e8d02009-04-16 23:50:50 +00002269 CXXConstructorDecl *Constructor,
Anders Carlssonf47511a2009-09-07 22:23:31 +00002270 MultiExprArg Exprs);
Anders Carlsson9abf2ae2009-08-16 05:13:48 +00002271
Anders Carlssonec8e5ea2009-09-05 07:40:38 +00002272 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
2273 /// including handling of its default argument expressions.
Anders Carlsson72e96fd2010-05-02 22:54:08 +00002274 OwningExprResult
2275 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
2276 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
2277 bool RequiresZeroInit = false,
2278 CXXConstructExpr::ConstructionKind ConstructKind =
2279 CXXConstructExpr::CK_Complete);
Anders Carlsson9abf2ae2009-08-16 05:13:48 +00002280
Anders Carlssonec8e5ea2009-09-05 07:40:38 +00002281 // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
2282 // the constructor can be elidable?
Anders Carlsson72e96fd2010-05-02 22:54:08 +00002283 OwningExprResult
2284 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
2285 CXXConstructorDecl *Constructor, bool Elidable,
2286 MultiExprArg Exprs, bool RequiresZeroInit = false,
2287 CXXConstructExpr::ConstructionKind ConstructKind =
2288 CXXConstructExpr::CK_Complete);
Mike Stump1eb44332009-09-09 15:08:12 +00002289
Anders Carlsson56c5e332009-08-25 03:49:14 +00002290 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
2291 /// the default expr if needed.
2292 OwningExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
2293 FunctionDecl *FD,
2294 ParmVarDecl *Param);
Mike Stump1eb44332009-09-09 15:08:12 +00002295
Fariborz Jahaniana83f7ed2009-08-03 19:13:25 +00002296 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
2297 /// constructed variable.
John McCall68c6c9a2010-02-02 09:10:11 +00002298 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
Mike Stump1eb44332009-09-09 15:08:12 +00002299
Douglas Gregor32df23e2010-07-01 22:02:46 +00002300 /// \brief Declare the implicit default constructor for the given class.
2301 ///
Douglas Gregor32df23e2010-07-01 22:02:46 +00002302 /// \param ClassDecl The class declaration into which the implicit
2303 /// default constructor will be added.
2304 ///
2305 /// \returns The implicitly-declared default constructor.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002306 CXXConstructorDecl *DeclareImplicitDefaultConstructor(
Douglas Gregor32df23e2010-07-01 22:02:46 +00002307 CXXRecordDecl *ClassDecl);
2308
Mike Stump1eb44332009-09-09 15:08:12 +00002309 /// DefineImplicitDefaultConstructor - Checks for feasibility of
Fariborz Jahanianf8dcb862009-06-19 19:55:27 +00002310 /// defining this constructor as the default constructor.
2311 void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
2312 CXXConstructorDecl *Constructor);
Mike Stump1eb44332009-09-09 15:08:12 +00002313
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002314 /// \brief Declare the implicit destructor for the given class.
2315 ///
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002316 /// \param ClassDecl The class declaration into which the implicit
2317 /// destructor will be added.
2318 ///
2319 /// \returns The implicitly-declared destructor.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002320 CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002321
Mike Stump1eb44332009-09-09 15:08:12 +00002322 /// DefineImplicitDestructor - Checks for feasibility of
Fariborz Jahanian8d2b3562009-06-26 23:49:16 +00002323 /// defining this destructor as the default destructor.
2324 void DefineImplicitDestructor(SourceLocation CurrentLocation,
Douglas Gregorfabd43a2010-07-01 19:09:28 +00002325 CXXDestructorDecl *Destructor);
Mike Stump1eb44332009-09-09 15:08:12 +00002326
Douglas Gregor4a0c26f2010-07-01 17:57:27 +00002327 /// \brief Declare the implicit copy constructor for the given class.
2328 ///
2329 /// \param S The scope of the class, which may be NULL if this is a
2330 /// template instantiation.
2331 ///
2332 /// \param ClassDecl The class declaration into which the implicit
2333 /// copy constructor will be added.
2334 ///
2335 /// \returns The implicitly-declared copy constructor.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002336 CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
Douglas Gregor4a0c26f2010-07-01 17:57:27 +00002337
Mike Stump1eb44332009-09-09 15:08:12 +00002338 /// DefineImplicitCopyConstructor - Checks for feasibility of
Fariborz Jahanian485f0872009-06-22 23:34:40 +00002339 /// defining this constructor as the copy constructor.
2340 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
2341 CXXConstructorDecl *Constructor,
2342 unsigned TypeQuals);
Mike Stump1eb44332009-09-09 15:08:12 +00002343
Douglas Gregord3c35902010-07-01 16:36:15 +00002344 /// \brief Declare the implicit copy assignment operator for the given class.
2345 ///
2346 /// \param S The scope of the class, which may be NULL if this is a
2347 /// template instantiation.
2348 ///
2349 /// \param ClassDecl The class declaration into which the implicit
2350 /// copy-assignment operator will be added.
2351 ///
2352 /// \returns The implicitly-declared copy assignment operator.
Douglas Gregor23c94db2010-07-02 17:43:08 +00002353 CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
Douglas Gregord3c35902010-07-01 16:36:15 +00002354
2355 /// \brief Defined an implicitly-declared copy assignment operator.
Douglas Gregor39957dc2010-05-01 15:04:51 +00002356 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
2357 CXXMethodDecl *MethodDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00002358
Douglas Gregor4923aa22010-07-02 20:37:36 +00002359 /// \brief Force the declaration of any implicitly-declared members of this
2360 /// class.
2361 void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
2362
Anders Carlssondef11992009-05-30 20:36:53 +00002363 /// MaybeBindToTemporary - If the passed in expression has a record type with
2364 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
2365 /// it simply returns the passed in expression.
2366 OwningExprResult MaybeBindToTemporary(Expr *E);
Mike Stump1eb44332009-09-09 15:08:12 +00002367
Douglas Gregor39da0b82009-09-09 23:08:42 +00002368 bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
2369 MultiExprArg ArgsPtr,
Douglas Gregor523d46a2010-04-18 07:40:54 +00002370 SourceLocation Loc,
Douglas Gregor39da0b82009-09-09 23:08:42 +00002371 ASTOwningVector<&ActionBase::DeleteExpr> &ConvertedArgs);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002372
Douglas Gregor124b8782010-02-16 19:09:40 +00002373 virtual TypeTy *getDestructorName(SourceLocation TildeLoc,
2374 IdentifierInfo &II, SourceLocation NameLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002375 Scope *S, CXXScopeSpec &SS,
Douglas Gregor124b8782010-02-16 19:09:40 +00002376 TypeTy *ObjectType,
2377 bool EnteringContext);
2378
Douglas Gregor49badde2008-10-27 19:41:14 +00002379 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002380 virtual OwningExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
2381 tok::TokenKind Kind,
2382 SourceLocation LAngleBracketLoc,
2383 TypeTy *Ty,
2384 SourceLocation RAngleBracketLoc,
2385 SourceLocation LParenLoc,
2386 ExprArg E,
2387 SourceLocation RParenLoc);
Reid Spencer5f016e22007-07-11 17:01:13 +00002388
John McCallc89724c2010-01-15 19:13:16 +00002389 OwningExprResult BuildCXXNamedCast(SourceLocation OpLoc,
2390 tok::TokenKind Kind,
2391 TypeSourceInfo *Ty,
2392 ExprArg E,
2393 SourceRange AngleBrackets,
2394 SourceRange Parens);
2395
Douglas Gregor57fdc8a2010-04-26 22:37:10 +00002396 OwningExprResult BuildCXXTypeId(QualType TypeInfoType,
2397 SourceLocation TypeidLoc,
2398 TypeSourceInfo *Operand,
2399 SourceLocation RParenLoc);
2400 OwningExprResult BuildCXXTypeId(QualType TypeInfoType,
2401 SourceLocation TypeidLoc,
2402 ExprArg Operand,
2403 SourceLocation RParenLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002404
Sebastian Redlf53597f2009-03-15 17:47:39 +00002405 /// ActOnCXXTypeid - Parse typeid( something ).
2406 virtual OwningExprResult ActOnCXXTypeid(SourceLocation OpLoc,
2407 SourceLocation LParenLoc, bool isType,
2408 void *TyOrExpr,
2409 SourceLocation RParenLoc);
Sebastian Redlc42e1182008-11-11 11:37:55 +00002410
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002411 //// ActOnCXXThis - Parse 'this' pointer.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002412 virtual OwningExprResult ActOnCXXThis(SourceLocation ThisLoc);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002413
Steve Naroff1b273c42007-09-16 14:56:35 +00002414 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002415 virtual OwningExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc,
2416 tok::TokenKind Kind);
2417
Sebastian Redl6e8ed162009-05-10 18:38:11 +00002418 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
2419 virtual OwningExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
2420
Chris Lattner50dd2892008-02-26 00:51:44 +00002421 //// ActOnCXXThrow - Parse throw expressions.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002422 virtual OwningExprResult ActOnCXXThrow(SourceLocation OpLoc,
2423 ExprArg expr);
Sebastian Redl972041f2009-04-27 20:27:31 +00002424 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E);
Chris Lattner50dd2892008-02-26 00:51:44 +00002425
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +00002426 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
2427 /// Can be interpreted either as function-style casting ("int(x)")
2428 /// or class type construction ("ClassType(x,y,z)")
2429 /// or creation of a value-initialized type ("int()").
Sebastian Redlf53597f2009-03-15 17:47:39 +00002430 virtual OwningExprResult ActOnCXXTypeConstructExpr(SourceRange TypeRange,
2431 TypeTy *TypeRep,
2432 SourceLocation LParenLoc,
2433 MultiExprArg Exprs,
2434 SourceLocation *CommaLocs,
2435 SourceLocation RParenLoc);
Argyrios Kyrtzidis987a14b2008-08-22 15:38:55 +00002436
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002437 /// ActOnCXXNew - Parsed a C++ 'new' expression.
Sebastian Redlf53597f2009-03-15 17:47:39 +00002438 virtual OwningExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
2439 SourceLocation PlacementLParen,
2440 MultiExprArg PlacementArgs,
2441 SourceLocation PlacementRParen,
Douglas Gregor4bd40312010-07-13 15:54:32 +00002442 SourceRange TypeIdParens, Declarator &D,
Sebastian Redlf53597f2009-03-15 17:47:39 +00002443 SourceLocation ConstructorLParen,
2444 MultiExprArg ConstructorArgs,
2445 SourceLocation ConstructorRParen);
Douglas Gregor3433cf72009-05-21 00:00:09 +00002446 OwningExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
2447 SourceLocation PlacementLParen,
2448 MultiExprArg PlacementArgs,
2449 SourceLocation PlacementRParen,
Douglas Gregor4bd40312010-07-13 15:54:32 +00002450 SourceRange TypeIdParens,
Douglas Gregor3433cf72009-05-21 00:00:09 +00002451 QualType AllocType,
2452 SourceLocation TypeLoc,
2453 SourceRange TypeRange,
2454 ExprArg ArraySize,
2455 SourceLocation ConstructorLParen,
2456 MultiExprArg ConstructorArgs,
2457 SourceLocation ConstructorRParen);
Mike Stump1eb44332009-09-09 15:08:12 +00002458
Douglas Gregor3433cf72009-05-21 00:00:09 +00002459 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
2460 SourceRange R);
Sebastian Redl00e68e22009-02-09 18:24:27 +00002461 bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
2462 bool UseGlobal, QualType AllocType, bool IsArray,
Sebastian Redlb5a57a62008-12-03 20:26:15 +00002463 Expr **PlaceArgs, unsigned NumPlaceArgs,
2464 FunctionDecl *&OperatorNew,
2465 FunctionDecl *&OperatorDelete);
Sebastian Redl00e68e22009-02-09 18:24:27 +00002466 bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
2467 DeclarationName Name, Expr** Args,
2468 unsigned NumArgs, DeclContext *Ctx,
Sebastian Redl7f662392008-12-04 22:20:51 +00002469 bool AllowMissing, FunctionDecl *&Operator);
Sebastian Redlb5a57a62008-12-03 20:26:15 +00002470 void DeclareGlobalNewDelete();
2471 void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
Nuno Lopesfc284482009-12-16 16:59:22 +00002472 QualType Argument,
2473 bool addMallocAttr = false);
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002474
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002475 bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
Anders Carlsson5ec02ae2009-12-02 17:15:43 +00002476 DeclarationName Name, FunctionDecl* &Operator);
Anders Carlsson78f74552009-11-15 18:45:20 +00002477
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002478 /// ActOnCXXDelete - Parsed a C++ 'delete' expression
Sebastian Redlf53597f2009-03-15 17:47:39 +00002479 virtual OwningExprResult ActOnCXXDelete(SourceLocation StartLoc,
2480 bool UseGlobal, bool ArrayForm,
2481 ExprArg Operand);
Sebastian Redl4c5d3202008-11-21 19:14:01 +00002482
Douglas Gregor99e9b4d2009-11-25 00:27:52 +00002483 virtual DeclResult ActOnCXXConditionDeclaration(Scope *S,
2484 Declarator &D);
Douglas Gregor586596f2010-05-06 17:25:47 +00002485 OwningExprResult CheckConditionVariable(VarDecl *ConditionVar,
2486 SourceLocation StmtLoc,
2487 bool ConvertToBoolean);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002488
Sebastian Redl64b45f72009-01-05 20:52:13 +00002489 /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
2490 /// pseudo-functions.
2491 virtual OwningExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
2492 SourceLocation KWLoc,
2493 SourceLocation LParen,
2494 TypeTy *Ty,
2495 SourceLocation RParen);
Mike Stump1eb44332009-09-09 15:08:12 +00002496
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002497 virtual OwningExprResult ActOnStartCXXMemberReference(Scope *S,
2498 ExprArg Base,
2499 SourceLocation OpLoc,
2500 tok::TokenKind OpKind,
Douglas Gregord4dca082010-02-24 18:44:31 +00002501 TypeTy *&ObjectType,
2502 bool &MayBePseudoDestructor);
2503
Douglas Gregor77549082010-02-24 21:29:12 +00002504 OwningExprResult DiagnoseDtorReference(SourceLocation NameLoc,
2505 ExprArg MemExpr);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002506
Douglas Gregorb57fb492010-02-24 22:38:50 +00002507 OwningExprResult BuildPseudoDestructorExpr(ExprArg Base,
2508 SourceLocation OpLoc,
2509 tok::TokenKind OpKind,
2510 const CXXScopeSpec &SS,
2511 TypeSourceInfo *ScopeType,
2512 SourceLocation CCLoc,
Douglas Gregorfce46ee2010-02-24 23:50:37 +00002513 SourceLocation TildeLoc,
Douglas Gregora2e7dd22010-02-25 01:56:36 +00002514 PseudoDestructorTypeStorage DestroyedType,
Douglas Gregorb57fb492010-02-24 22:38:50 +00002515 bool HasTrailingLParen);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002516
Douglas Gregord4dca082010-02-24 18:44:31 +00002517 virtual OwningExprResult ActOnPseudoDestructorExpr(Scope *S, ExprArg Base,
2518 SourceLocation OpLoc,
2519 tok::TokenKind OpKind,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002520 CXXScopeSpec &SS,
Douglas Gregord4dca082010-02-24 18:44:31 +00002521 UnqualifiedId &FirstTypeName,
2522 SourceLocation CCLoc,
2523 SourceLocation TildeLoc,
2524 UnqualifiedId &SecondTypeName,
2525 bool HasTrailingLParen);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002526
Mike Stump1eb44332009-09-09 15:08:12 +00002527 /// MaybeCreateCXXExprWithTemporaries - If the list of temporaries is
Anders Carlsson99ba36d2009-06-05 15:38:08 +00002528 /// non-empty, will create a new CXXExprWithTemporaries expression.
2529 /// Otherwise, just returs the passed in expression.
Anders Carlsson0ece4912009-12-15 20:51:39 +00002530 Expr *MaybeCreateCXXExprWithTemporaries(Expr *SubExpr);
Douglas Gregor90f93822009-12-22 22:17:25 +00002531 OwningExprResult MaybeCreateCXXExprWithTemporaries(OwningExprResult SubExpr);
Anders Carlsson5ee56e92009-12-16 02:09:40 +00002532 FullExpr CreateFullExpr(Expr *SubExpr);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002533
Anders Carlsson165a0a02009-05-17 18:41:29 +00002534 virtual OwningExprResult ActOnFinishFullExpr(ExprArg Expr);
2535
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002536 // Marks SS invalid if it represents an incomplete type.
John McCall77bb1aa2010-05-01 00:40:08 +00002537 bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
Mike Stump1eb44332009-09-09 15:08:12 +00002538
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002539 DeclContext *computeDeclContext(QualType T);
Mike Stump1eb44332009-09-09 15:08:12 +00002540 DeclContext *computeDeclContext(const CXXScopeSpec &SS,
Douglas Gregorf59a56e2009-07-21 23:53:31 +00002541 bool EnteringContext = false);
Douglas Gregor5953d8b2009-03-19 17:26:29 +00002542 bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
Douglas Gregor42af25f2009-05-11 19:58:34 +00002543 CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
2544 bool isUnknownSpecialization(const CXXScopeSpec &SS);
Douglas Gregorca5e77f2009-03-18 00:36:05 +00002545
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002546 /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the
2547 /// global scope ('::').
2548 virtual CXXScopeTy *ActOnCXXGlobalScopeSpecifier(Scope *S,
2549 SourceLocation CCLoc);
2550
Douglas Gregoredc90502010-02-25 04:46:04 +00002551 bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
Douglas Gregorc68afe22009-09-03 21:38:09 +00002552 NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
Mike Stump1eb44332009-09-09 15:08:12 +00002553
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002554 virtual bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
Douglas Gregor77549082010-02-24 21:29:12 +00002555 SourceLocation IdLoc,
2556 IdentifierInfo &II,
2557 TypeTy *ObjectType);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002558
Douglas Gregorc68afe22009-09-03 21:38:09 +00002559 CXXScopeTy *BuildCXXNestedNameSpecifier(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002560 CXXScopeSpec &SS,
Douglas Gregorc68afe22009-09-03 21:38:09 +00002561 SourceLocation IdLoc,
2562 SourceLocation CCLoc,
2563 IdentifierInfo &II,
2564 QualType ObjectType,
2565 NamedDecl *ScopeLookupResult,
Chris Lattner46646492009-12-07 01:36:53 +00002566 bool EnteringContext,
2567 bool ErrorRecoveryLookup);
Mike Stump1eb44332009-09-09 15:08:12 +00002568
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002569 virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002570 CXXScopeSpec &SS,
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002571 SourceLocation IdLoc,
2572 SourceLocation CCLoc,
Douglas Gregor495c35d2009-08-25 22:51:20 +00002573 IdentifierInfo &II,
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002574 TypeTy *ObjectType,
Douglas Gregor495c35d2009-08-25 22:51:20 +00002575 bool EnteringContext);
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002576
Chris Lattner46646492009-12-07 01:36:53 +00002577 virtual bool IsInvalidUnlessNestedName(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002578 CXXScopeSpec &SS,
Chris Lattner46646492009-12-07 01:36:53 +00002579 IdentifierInfo &II,
2580 TypeTy *ObjectType,
2581 bool EnteringContext);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002582
Douglas Gregor39a8de12009-02-25 19:37:18 +00002583 /// ActOnCXXNestedNameSpecifier - Called during parsing of a
2584 /// nested-name-specifier that involves a template-id, e.g.,
2585 /// "foo::bar<int, float>::", and now we need to build a scope
2586 /// specifier. \p SS is empty or the previously parsed nested-name
2587 /// part ("foo::"), \p Type is the already-parsed class template
2588 /// specialization (or other template-id that names a type), \p
2589 /// TypeRange is the source range where the type is located, and \p
2590 /// CCLoc is the location of the trailing '::'.
2591 virtual CXXScopeTy *ActOnCXXNestedNameSpecifier(Scope *S,
2592 const CXXScopeSpec &SS,
2593 TypeTy *Type,
2594 SourceRange TypeRange,
Douglas Gregoredc90502010-02-25 04:46:04 +00002595 SourceLocation CCLoc);
Douglas Gregor39a8de12009-02-25 19:37:18 +00002596
John McCalle7e278b2009-12-11 20:04:54 +00002597 virtual bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2598
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002599 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2600 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2601 /// After this method is called, according to [C++ 3.4.3p3], names should be
2602 /// looked up in the declarator-id's scope, until the declarator is parsed and
2603 /// ActOnCXXExitDeclaratorScope is called.
2604 /// The 'SS' should be a non-empty valid CXXScopeSpec.
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002605 virtual bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002606
2607 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2608 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2609 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2610 /// Used to indicate that names should revert to being looked up in the
2611 /// defining scope.
Douglas Gregor0a59acb2008-12-16 00:38:16 +00002612 virtual void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
Argyrios Kyrtzidisef6e6472008-11-08 17:17:31 +00002613
Argyrios Kyrtzidis0ffd9ff2009-06-17 22:50:06 +00002614 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
2615 /// initializer for the declaration 'Dcl'.
2616 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
2617 /// static data member of class X, names should be looked up in the scope of
2618 /// class X.
2619 virtual void ActOnCXXEnterDeclInitializer(Scope *S, DeclPtrTy Dcl);
2620
2621 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
2622 /// initializer for the declaration 'Dcl'.
2623 virtual void ActOnCXXExitDeclInitializer(Scope *S, DeclPtrTy Dcl);
2624
Anders Carlsson55085182007-08-21 17:43:55 +00002625 // ParseObjCStringLiteral - Parse Objective-C string literals.
Mike Stump1eb44332009-09-09 15:08:12 +00002626 virtual ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
Chris Lattnerb3a99cd2007-12-12 01:04:12 +00002627 ExprTy **Strings,
2628 unsigned NumStrings);
Mike Stump1eb44332009-09-09 15:08:12 +00002629
2630 Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
Douglas Gregor81d34662010-04-20 15:39:42 +00002631 TypeSourceInfo *EncodedTypeInfo,
Mike Stump1eb44332009-09-09 15:08:12 +00002632 SourceLocation RParenLoc);
John McCall6bb80172010-03-30 21:47:33 +00002633 CXXMemberCallExpr *BuildCXXMemberCallExpr(Expr *Exp,
2634 NamedDecl *FoundDecl,
2635 CXXMethodDecl *Method);
Fariborz Jahanianb7400232009-09-28 23:23:40 +00002636
Anders Carlssonf9bcf012007-08-22 15:14:15 +00002637 virtual ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
Chris Lattner674af952007-10-16 22:51:17 +00002638 SourceLocation EncodeLoc,
Anders Carlssonf9bcf012007-08-22 15:14:15 +00002639 SourceLocation LParenLoc,
2640 TypeTy *Ty,
2641 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002642
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00002643 // ParseObjCSelectorExpression - Build selector expression for @selector
2644 virtual ExprResult ParseObjCSelectorExpression(Selector Sel,
2645 SourceLocation AtLoc,
Fariborz Jahanian2a35fa92007-10-16 23:21:02 +00002646 SourceLocation SelLoc,
Fariborz Jahanianb62f6812007-10-16 20:40:23 +00002647 SourceLocation LParenLoc,
2648 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00002649
Fariborz Jahanian390d50a2007-10-17 16:58:11 +00002650 // ParseObjCProtocolExpression - Build protocol expression for @protocol
2651 virtual ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
2652 SourceLocation AtLoc,
2653 SourceLocation ProtoLoc,
2654 SourceLocation LParenLoc,
2655 SourceLocation RParenLoc);
Douglas Gregore37ac4f2008-04-13 21:30:24 +00002656
2657 //===--------------------------------------------------------------------===//
Douglas Gregor074149e2009-01-05 19:45:36 +00002658 // C++ Declarations
2659 //
Chris Lattnerb28317a2009-03-28 19:18:32 +00002660 virtual DeclPtrTy ActOnStartLinkageSpecification(Scope *S,
2661 SourceLocation ExternLoc,
2662 SourceLocation LangLoc,
Benjamin Kramerd5663812010-05-03 13:08:54 +00002663 llvm::StringRef Lang,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002664 SourceLocation LBraceLoc);
2665 virtual DeclPtrTy ActOnFinishLinkageSpecification(Scope *S,
2666 DeclPtrTy LinkageSpec,
2667 SourceLocation RBraceLoc);
Douglas Gregor074149e2009-01-05 19:45:36 +00002668
2669
2670 //===--------------------------------------------------------------------===//
Douglas Gregore37ac4f2008-04-13 21:30:24 +00002671 // C++ Classes
2672 //
Argyrios Kyrtzidiseb83ecd2008-11-08 16:45:02 +00002673 virtual bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
2674 const CXXScopeSpec *SS);
Sebastian Redle2b68332009-04-12 17:16:29 +00002675
Abramo Bagnara6206d532010-06-05 05:09:32 +00002676 virtual DeclPtrTy ActOnAccessSpecifier(AccessSpecifier Access,
2677 SourceLocation ASLoc,
2678 SourceLocation ColonLoc);
2679
Chris Lattnerb28317a2009-03-28 19:18:32 +00002680 virtual DeclPtrTy ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
2681 Declarator &D,
Douglas Gregor37b372b2009-08-20 22:52:58 +00002682 MultiTemplateParamsArg TemplateParameterLists,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002683 ExprTy *BitfieldWidth,
Sebastian Redld1a78462009-11-24 23:38:44 +00002684 ExprTy *Init, bool IsDefinition,
Sebastian Redle2b68332009-04-12 17:16:29 +00002685 bool Deleted = false);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002686
Chris Lattnerb28317a2009-03-28 19:18:32 +00002687 virtual MemInitResult ActOnMemInitializer(DeclPtrTy ConstructorD,
Douglas Gregor7ad83902008-11-05 04:29:56 +00002688 Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002689 CXXScopeSpec &SS,
Douglas Gregor7ad83902008-11-05 04:29:56 +00002690 IdentifierInfo *MemberOrBase,
Fariborz Jahanian96174332009-07-01 19:21:19 +00002691 TypeTy *TemplateTypeTy,
Douglas Gregor7ad83902008-11-05 04:29:56 +00002692 SourceLocation IdLoc,
2693 SourceLocation LParenLoc,
2694 ExprTy **Args, unsigned NumArgs,
2695 SourceLocation *CommaLocs,
2696 SourceLocation RParenLoc);
2697
Eli Friedman59c04372009-07-29 19:44:27 +00002698 MemInitResult BuildMemberInitializer(FieldDecl *Member, Expr **Args,
2699 unsigned NumArgs, SourceLocation IdLoc,
Douglas Gregor802ab452009-12-02 22:36:29 +00002700 SourceLocation LParenLoc,
Eli Friedman59c04372009-07-29 19:44:27 +00002701 SourceLocation RParenLoc);
2702
Douglas Gregor802ab452009-12-02 22:36:29 +00002703 MemInitResult BuildBaseInitializer(QualType BaseType,
John McCalla93c9342009-12-07 02:54:59 +00002704 TypeSourceInfo *BaseTInfo,
Douglas Gregor802ab452009-12-02 22:36:29 +00002705 Expr **Args, unsigned NumArgs,
2706 SourceLocation LParenLoc,
Eli Friedman59c04372009-07-29 19:44:27 +00002707 SourceLocation RParenLoc,
2708 CXXRecordDecl *ClassDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00002709
Benjamin Kramer3f17a372009-11-09 20:14:44 +00002710 bool SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor,
Douglas Gregor9db7dbb2010-01-31 09:12:51 +00002711 CXXBaseOrMemberInitializer **Initializers,
Anders Carlssonec3332b2010-04-02 03:43:34 +00002712 unsigned NumInitializers, bool AnyErrors);
Fariborz Jahaniane4498c62010-04-28 16:11:27 +00002713
2714 void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
2715
Mike Stump1eb44332009-09-09 15:08:12 +00002716
John McCallef027fe2010-03-16 21:39:52 +00002717 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
2718 /// mark all the non-trivial destructors of its members and bases as
2719 /// referenced.
2720 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
2721 CXXRecordDecl *Record);
Mike Stump1eb44332009-09-09 15:08:12 +00002722
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002723 /// \brief The list of classes whose vtables have been used within
2724 /// this translation unit, and the source locations at which the
2725 /// first use occurred.
2726 llvm::SmallVector<std::pair<CXXRecordDecl *, SourceLocation>, 16>
2727 VTableUses;
Anders Carlssond6a637f2009-12-07 08:24:59 +00002728
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002729 /// \brief The set of classes whose vtables have been used within
2730 /// this translation unit, and a bit that will be true if the vtable is
2731 /// required to be emitted (otherwise, it should be emitted only if needed
2732 /// by code generation).
2733 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
2734
2735 /// \brief A list of all of the dynamic classes in this translation
2736 /// unit.
2737 llvm::SmallVector<CXXRecordDecl *, 16> DynamicClasses;
2738
2739 /// \brief Note that the vtable for the given class was used at the
2740 /// given location.
2741 void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
2742 bool DefinitionRequired = false);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002743
Anders Carlssond6a637f2009-12-07 08:24:59 +00002744 /// MarkVirtualMembersReferenced - Will mark all virtual members of the given
2745 /// CXXRecordDecl referenced.
Rafael Espindola3e1ae932010-03-26 00:36:59 +00002746 void MarkVirtualMembersReferenced(SourceLocation Loc,
2747 const CXXRecordDecl *RD);
Anders Carlssond6a637f2009-12-07 08:24:59 +00002748
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002749 /// \brief Define all of the vtables that have been used in this
2750 /// translation unit and reference any virtual members used by those
2751 /// vtables.
2752 ///
2753 /// \returns true if any work was done, false otherwise.
2754 bool DefineUsedVTables();
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002755
Douglas Gregor23c94db2010-07-02 17:43:08 +00002756 void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
Douglas Gregor396b7cd2008-11-03 17:51:48 +00002757
Mike Stump1eb44332009-09-09 15:08:12 +00002758 virtual void ActOnMemInitializers(DeclPtrTy ConstructorDecl,
Anders Carlssona7b35212009-03-25 02:58:17 +00002759 SourceLocation ColonLoc,
Douglas Gregor9db7dbb2010-01-31 09:12:51 +00002760 MemInitTy **MemInits, unsigned NumMemInits,
2761 bool AnyErrors);
Mike Stump1eb44332009-09-09 15:08:12 +00002762
Douglas Gregor23c94db2010-07-02 17:43:08 +00002763 void CheckCompletedCXXClass(CXXRecordDecl *Record);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002764 virtual void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002765 DeclPtrTy TagDecl,
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002766 SourceLocation LBrac,
Douglas Gregor0b4c9b52010-03-29 14:42:08 +00002767 SourceLocation RBrac,
2768 AttributeList *AttrList);
Argyrios Kyrtzidis07952322008-07-01 10:37:29 +00002769
Douglas Gregor6569d682009-05-27 23:11:45 +00002770 virtual void ActOnReenterTemplateScope(Scope *S, DeclPtrTy Template);
John McCall7a1dc562009-12-19 10:49:29 +00002771 virtual void ActOnStartDelayedMemberDeclarations(Scope *S,
2772 DeclPtrTy Record);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002773 virtual void ActOnStartDelayedCXXMethodDeclaration(Scope *S,
2774 DeclPtrTy Method);
2775 virtual void ActOnDelayedCXXMethodParameter(Scope *S, DeclPtrTy Param);
2776 virtual void ActOnFinishDelayedCXXMethodDeclaration(Scope *S,
2777 DeclPtrTy Method);
John McCall7a1dc562009-12-19 10:49:29 +00002778 virtual void ActOnFinishDelayedMemberDeclarations(Scope *S,
2779 DeclPtrTy Record);
Douglas Gregor72b505b2008-12-16 21:30:33 +00002780
Mike Stump1eb44332009-09-09 15:08:12 +00002781 virtual DeclPtrTy ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002782 ExprArg AssertExpr,
2783 ExprArg AssertMessageExpr);
Mike Stump1eb44332009-09-09 15:08:12 +00002784
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002785 FriendDecl *CheckFriendTypeDecl(SourceLocation FriendLoc,
Douglas Gregor1d869352010-04-07 16:53:43 +00002786 TypeSourceInfo *TSInfo);
John McCalldd4a3b02009-09-16 22:47:08 +00002787 DeclPtrTy ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
2788 MultiTemplateParamsArg TemplateParams);
John McCallbbbcdd92009-09-11 21:02:39 +00002789 DeclPtrTy ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition,
2790 MultiTemplateParamsArg TemplateParams);
Anders Carlsson00338362009-05-11 22:55:49 +00002791
Chris Lattner65401802009-04-25 08:28:21 +00002792 QualType CheckConstructorDeclarator(Declarator &D, QualType R,
2793 FunctionDecl::StorageClass& SC);
Chris Lattner6e475012009-04-25 08:35:12 +00002794 void CheckConstructor(CXXConstructorDecl *Constructor);
Douglas Gregord92ec472010-07-01 05:10:53 +00002795 QualType CheckDestructorDeclarator(Declarator &D, QualType R,
Chris Lattner65401802009-04-25 08:28:21 +00002796 FunctionDecl::StorageClass& SC);
Anders Carlsson5ec02ae2009-12-02 17:15:43 +00002797 bool CheckDestructor(CXXDestructorDecl *Destructor);
Chris Lattner6e475012009-04-25 08:35:12 +00002798 void CheckConversionDeclarator(Declarator &D, QualType &R,
Douglas Gregor2f1bc522008-11-07 20:08:42 +00002799 FunctionDecl::StorageClass& SC);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002800 DeclPtrTy ActOnConversionDeclarator(CXXConversionDecl *Conversion);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002801
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002802 //===--------------------------------------------------------------------===//
2803 // C++ Derived Classes
2804 //
2805
2806 /// ActOnBaseSpecifier - Parsed a base specifier
Douglas Gregor2943aed2009-03-03 04:44:36 +00002807 CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
2808 SourceRange SpecifierRange,
2809 bool Virtual, AccessSpecifier Access,
Nick Lewycky56062202010-07-26 16:56:01 +00002810 TypeSourceInfo *TInfo);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002811
2812 /// SetClassDeclAttributesFromBase - Copies class decl traits
2813 /// (such as whether the class has a trivial constructor,
Anders Carlsson51f94042009-12-03 17:49:57 +00002814 /// trivial destructor etc) from the given base class.
2815 void SetClassDeclAttributesFromBase(CXXRecordDecl *Class,
2816 const CXXRecordDecl *BaseClass,
2817 bool BaseIsVirtual);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002818
Mike Stump1eb44332009-09-09 15:08:12 +00002819 virtual BaseResult ActOnBaseSpecifier(DeclPtrTy classdecl,
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002820 SourceRange SpecifierRange,
2821 bool Virtual, AccessSpecifier Access,
Mike Stump1eb44332009-09-09 15:08:12 +00002822 TypeTy *basetype, SourceLocation
Douglas Gregor2943aed2009-03-03 04:44:36 +00002823 BaseLoc);
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002824
Douglas Gregor2943aed2009-03-03 04:44:36 +00002825 bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
2826 unsigned NumBases);
Mike Stump1eb44332009-09-09 15:08:12 +00002827 virtual void ActOnBaseSpecifiers(DeclPtrTy ClassDecl, BaseTy **Bases,
Douglas Gregorbc0805a2008-10-23 00:40:37 +00002828 unsigned NumBases);
2829
2830 bool IsDerivedFrom(QualType Derived, QualType Base);
Douglas Gregora8f32e02009-10-06 17:59:45 +00002831 bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths);
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00002832
2833 // FIXME: I don't like this name.
2834 void BuildBasePathArray(const CXXBasePaths &Paths,
2835 CXXBaseSpecifierArray &BasePath);
2836
Douglas Gregor6fb745b2010-05-13 16:44:06 +00002837 bool BasePathInvolvesVirtualBase(const CXXBaseSpecifierArray &BasePath);
2838
Douglas Gregor0575d4a2008-10-24 16:17:19 +00002839 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00002840 SourceLocation Loc, SourceRange Range,
Anders Carlssone25a96c2010-04-24 17:11:09 +00002841 CXXBaseSpecifierArray *BasePath = 0,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00002842 bool IgnoreAccess = false);
Anders Carlssond8f9cb02009-05-13 21:11:42 +00002843 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
John McCall58e6f342010-03-16 05:22:47 +00002844 unsigned InaccessibleBaseID,
Anders Carlssond8f9cb02009-05-13 21:11:42 +00002845 unsigned AmbigiousBaseConvID,
2846 SourceLocation Loc, SourceRange Range,
Anders Carlssone25a96c2010-04-24 17:11:09 +00002847 DeclarationName Name,
2848 CXXBaseSpecifierArray *BasePath);
Mike Stump1eb44332009-09-09 15:08:12 +00002849
Douglas Gregora8f32e02009-10-06 17:59:45 +00002850 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
Mike Stump1eb44332009-09-09 15:08:12 +00002851
Sebastian Redl23c7d062009-07-07 20:29:57 +00002852 /// CheckOverridingFunctionReturnType - Checks whether the return types are
2853 /// covariant, according to C++ [class.virtual]p5.
2854 bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
Anders Carlssond7ba27d2009-05-14 01:09:04 +00002855 const CXXMethodDecl *Old);
Sebastian Redl23c7d062009-07-07 20:29:57 +00002856
2857 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
2858 /// spec is a subset of base spec.
2859 bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
2860 const CXXMethodDecl *Old);
Douglas Gregore37ac4f2008-04-13 21:30:24 +00002861
Sean Huntbbd37c62009-11-21 08:43:09 +00002862 /// CheckOverridingFunctionAttributes - Checks whether attributes are
2863 /// incompatible or prevent overriding.
2864 bool CheckOverridingFunctionAttributes(const CXXMethodDecl *New,
2865 const CXXMethodDecl *Old);
2866
Douglas Gregor4ba31362009-12-01 17:24:26 +00002867 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
Nick Lewycky03d98c52010-07-06 19:51:49 +00002868
Anders Carlsson29f006b2009-03-27 05:05:05 +00002869 //===--------------------------------------------------------------------===//
2870 // C++ Access Control
2871 //
Sebastian Redl726212f2009-07-18 14:32:15 +00002872
John McCall6b2accb2010-02-10 09:31:12 +00002873 enum AccessResult {
2874 AR_accessible,
2875 AR_inaccessible,
2876 AR_dependent,
2877 AR_delayed
2878 };
2879
Mike Stump1eb44332009-09-09 15:08:12 +00002880 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
Anders Carlsson29f006b2009-03-27 05:05:05 +00002881 NamedDecl *PrevMemberDecl,
2882 AccessSpecifier LexicalAS);
Sebastian Redl726212f2009-07-18 14:32:15 +00002883
John McCall6b2accb2010-02-10 09:31:12 +00002884 AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
John McCall9aa472c2010-03-19 07:35:19 +00002885 DeclAccessPair FoundDecl);
John McCall6b2accb2010-02-10 09:31:12 +00002886 AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
John McCall9aa472c2010-03-19 07:35:19 +00002887 DeclAccessPair FoundDecl);
John McCall90c8c572010-03-18 08:19:33 +00002888 AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
2889 SourceRange PlacementRange,
2890 CXXRecordDecl *NamingClass,
John McCall9aa472c2010-03-19 07:35:19 +00002891 DeclAccessPair FoundDecl);
John McCall6b2accb2010-02-10 09:31:12 +00002892 AccessResult CheckConstructorAccess(SourceLocation Loc,
2893 CXXConstructorDecl *D,
Anders Carlsson9a68a672010-04-21 18:47:17 +00002894 const InitializedEntity &Entity,
Jeffrey Yasskin57d12fd2010-06-07 15:58:05 +00002895 AccessSpecifier Access,
2896 bool IsCopyBindingRefToTemp = false);
John McCall6b2accb2010-02-10 09:31:12 +00002897 AccessResult CheckDestructorAccess(SourceLocation Loc,
John McCall58e6f342010-03-16 05:22:47 +00002898 CXXDestructorDecl *Dtor,
2899 const PartialDiagnostic &PDiag);
John McCallb0207482010-03-16 06:11:48 +00002900 AccessResult CheckDirectMemberAccess(SourceLocation Loc,
2901 NamedDecl *D,
2902 const PartialDiagnostic &PDiag);
John McCall6b2accb2010-02-10 09:31:12 +00002903 AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
2904 Expr *ObjectExpr,
John McCall58e6f342010-03-16 05:22:47 +00002905 Expr *ArgExpr,
John McCall9aa472c2010-03-19 07:35:19 +00002906 DeclAccessPair FoundDecl);
John McCall6bb80172010-03-30 21:47:33 +00002907 AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
2908 DeclAccessPair FoundDecl);
John McCall6b2accb2010-02-10 09:31:12 +00002909 AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
John McCall6b2accb2010-02-10 09:31:12 +00002910 QualType Base, QualType Derived,
2911 const CXXBasePath &Path,
John McCall58e6f342010-03-16 05:22:47 +00002912 unsigned DiagID,
John McCall6b2accb2010-02-10 09:31:12 +00002913 bool ForceCheck = false,
John McCall58e6f342010-03-16 05:22:47 +00002914 bool ForceUnprivileged = false);
John McCall6b2accb2010-02-10 09:31:12 +00002915 void CheckLookupAccess(const LookupResult &R);
John McCall92f88312010-01-23 00:46:32 +00002916
John McCall0c01d182010-03-24 05:22:00 +00002917 void HandleDependentAccessCheck(const DependentDiagnostic &DD,
2918 const MultiLevelTemplateArgumentList &TemplateArgs);
2919 void PerformDependentDiagnostics(const DeclContext *Pattern,
2920 const MultiLevelTemplateArgumentList &TemplateArgs);
2921
John McCall2f514482010-01-27 03:50:35 +00002922 void HandleDelayedAccessCheck(DelayedDiagnostic &DD, Decl *Ctx);
Sebastian Redl726212f2009-07-18 14:32:15 +00002923
Chandler Carruth926c4b42010-06-28 08:39:25 +00002924 /// A flag to suppress access checking.
2925 bool SuppressAccessChecking;
2926
2927 void ActOnStartSuppressingAccessChecks();
2928 void ActOnStopSuppressingAccessChecks();
2929
Anders Carlsson8211eff2009-03-24 01:19:16 +00002930 enum AbstractDiagSelID {
2931 AbstractNone = -1,
2932 AbstractReturnType,
2933 AbstractParamType,
2934 AbstractVariableType,
2935 AbstractFieldType
2936 };
Mike Stump1eb44332009-09-09 15:08:12 +00002937
Anders Carlssona6ec7ad2009-08-27 00:13:57 +00002938 bool RequireNonAbstractType(SourceLocation Loc, QualType T,
2939 const PartialDiagnostic &PD,
2940 const CXXRecordDecl *CurrentRD = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00002941
2942 bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
Anders Carlssone65a3c82009-03-24 17:23:42 +00002943 AbstractDiagSelID SelID = AbstractNone,
2944 const CXXRecordDecl *CurrentRD = 0);
Anders Carlsson4681ebd2009-03-22 20:18:17 +00002945
Douglas Gregor1cd1b1e2008-11-06 22:13:31 +00002946 //===--------------------------------------------------------------------===//
2947 // C++ Overloaded Operators [C++ 13.5]
2948 //
2949
2950 bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
2951
Sean Hunta6c058d2010-01-13 09:01:02 +00002952 bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
2953
Douglas Gregor72c3f312008-12-05 18:15:24 +00002954 //===--------------------------------------------------------------------===//
2955 // C++ Templates [C++ 14]
2956 //
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002957 void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
Douglas Gregor1fd6d442010-05-21 23:18:07 +00002958 QualType ObjectType, bool EnteringContext,
2959 bool &MemberOfUnknownSpecialization);
John McCallf7a1a742009-11-24 19:00:30 +00002960
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002961 virtual TemplateNameKind isTemplateName(Scope *S,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00002962 CXXScopeSpec &SS,
Abramo Bagnara7c153532010-08-06 12:11:11 +00002963 bool hasTemplateKeyword,
Douglas Gregor014e88d2009-11-03 23:16:33 +00002964 UnqualifiedId &Name,
Douglas Gregor2dd078a2009-09-02 22:59:36 +00002965 TypeTy *ObjectType,
Douglas Gregor495c35d2009-08-25 22:51:20 +00002966 bool EnteringContext,
Douglas Gregor1fd6d442010-05-21 23:18:07 +00002967 TemplateTy &Template,
2968 bool &MemberOfUnknownSpecialization);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002969
2970 virtual bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
Douglas Gregor84d0a192010-01-12 21:28:44 +00002971 SourceLocation IILoc,
2972 Scope *S,
2973 const CXXScopeSpec *SS,
2974 TemplateTy &SuggestedTemplate,
2975 TemplateNameKind &SuggestedKind);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00002976
Douglas Gregor72c3f312008-12-05 18:15:24 +00002977 bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002978 TemplateDecl *AdjustDeclIfTemplate(DeclPtrTy &Decl);
Douglas Gregoraaba5e32009-02-04 19:02:06 +00002979
Mike Stump1eb44332009-09-09 15:08:12 +00002980 virtual DeclPtrTy ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
Anders Carlsson941df7d2009-06-12 19:58:00 +00002981 SourceLocation EllipsisLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00002982 SourceLocation KeyLoc,
2983 IdentifierInfo *ParamName,
2984 SourceLocation ParamNameLoc,
Douglas Gregorbb3310a2010-07-01 00:00:45 +00002985 unsigned Depth, unsigned Position,
2986 SourceLocation EqualLoc,
2987 TypeTy *DefaultArg);
Douglas Gregord684b002009-02-10 19:49:53 +00002988
Douglas Gregor2943aed2009-03-03 04:44:36 +00002989 QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002990 virtual DeclPtrTy ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
2991 unsigned Depth,
Douglas Gregorbb3310a2010-07-01 00:00:45 +00002992 unsigned Position,
2993 SourceLocation EqualLoc,
2994 ExprArg DefaultArg);
Chris Lattnerb28317a2009-03-28 19:18:32 +00002995 virtual DeclPtrTy ActOnTemplateTemplateParameter(Scope *S,
2996 SourceLocation TmpLoc,
2997 TemplateParamsTy *Params,
2998 IdentifierInfo *ParamName,
2999 SourceLocation ParamNameLoc,
3000 unsigned Depth,
Douglas Gregorbb3310a2010-07-01 00:00:45 +00003001 unsigned Position,
3002 SourceLocation EqualLoc,
3003 const ParsedTemplateArgument &DefaultArg);
Douglas Gregord684b002009-02-10 19:49:53 +00003004
Douglas Gregorc4b4e7b2008-12-24 02:52:09 +00003005 virtual TemplateParamsTy *
3006 ActOnTemplateParameterList(unsigned Depth,
3007 SourceLocation ExportLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00003008 SourceLocation TemplateLoc,
Douglas Gregorc4b4e7b2008-12-24 02:52:09 +00003009 SourceLocation LAngleLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00003010 DeclPtrTy *Params, unsigned NumParams,
Douglas Gregorc4b4e7b2008-12-24 02:52:09 +00003011 SourceLocation RAngleLoc);
Douglas Gregor5b6d70e2009-11-25 17:50:39 +00003012
3013 /// \brief The context in which we are checking a template parameter
3014 /// list.
3015 enum TemplateParamListContext {
3016 TPC_ClassTemplate,
3017 TPC_FunctionTemplate,
3018 TPC_ClassTemplateMember,
3019 TPC_FriendFunctionTemplate
3020 };
3021
Douglas Gregord684b002009-02-10 19:49:53 +00003022 bool CheckTemplateParameterList(TemplateParameterList *NewParams,
Douglas Gregor5b6d70e2009-11-25 17:50:39 +00003023 TemplateParameterList *OldParams,
3024 TemplateParamListContext TPC);
Douglas Gregorf59a56e2009-07-21 23:53:31 +00003025 TemplateParameterList *
3026 MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
3027 const CXXScopeSpec &SS,
3028 TemplateParameterList **ParamLists,
Douglas Gregor1fef4e62009-10-07 22:35:40 +00003029 unsigned NumParamLists,
John McCall77e8b112010-04-13 20:37:33 +00003030 bool IsFriend,
Douglas Gregor0167f3c2010-07-14 23:14:12 +00003031 bool &IsExplicitSpecialization,
3032 bool &Invalid);
Mike Stump1eb44332009-09-09 15:08:12 +00003033
John McCall0f434ec2009-07-31 02:45:11 +00003034 DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003035 SourceLocation KWLoc, CXXScopeSpec &SS,
Douglas Gregorbd1099e2009-07-23 16:36:45 +00003036 IdentifierInfo *Name, SourceLocation NameLoc,
3037 AttributeList *Attr,
Douglas Gregor05396e22009-08-25 17:23:04 +00003038 TemplateParameterList *TemplateParams,
Douglas Gregorbd1099e2009-07-23 16:36:45 +00003039 AccessSpecifier AS);
Douglas Gregorddc29e12009-02-06 22:42:48 +00003040
John McCalld5532b62009-11-23 01:53:49 +00003041 void translateTemplateArguments(const ASTTemplateArgsPtr &In,
3042 TemplateArgumentListInfo &Out);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003043
Douglas Gregor7532dc62009-03-30 22:58:21 +00003044 QualType CheckTemplateIdType(TemplateName Template,
3045 SourceLocation TemplateLoc,
John McCalld5532b62009-11-23 01:53:49 +00003046 const TemplateArgumentListInfo &TemplateArgs);
Douglas Gregor40808ce2009-03-09 23:48:35 +00003047
Douglas Gregorcc636682009-02-17 23:15:12 +00003048 virtual TypeResult
Douglas Gregor7532dc62009-03-30 22:58:21 +00003049 ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc,
3050 SourceLocation LAngleLoc,
3051 ASTTemplateArgsPtr TemplateArgs,
John McCall6b2becf2009-09-08 17:47:29 +00003052 SourceLocation RAngleLoc);
3053
3054 virtual TypeResult ActOnTagTemplateIdType(TypeResult Type,
3055 TagUseKind TUK,
3056 DeclSpec::TST TagSpec,
3057 SourceLocation TagLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00003058
John McCallf7a1a742009-11-24 19:00:30 +00003059 OwningExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
3060 LookupResult &R,
3061 bool RequiresADL,
John McCalld5532b62009-11-23 01:53:49 +00003062 const TemplateArgumentListInfo &TemplateArgs);
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003063 OwningExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
John McCallf7a1a742009-11-24 19:00:30 +00003064 DeclarationName Name,
3065 SourceLocation NameLoc,
3066 const TemplateArgumentListInfo &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003067
Douglas Gregord6ab2322010-06-16 23:00:59 +00003068 virtual TemplateNameKind ActOnDependentTemplateName(Scope *S,
3069 SourceLocation TemplateKWLoc,
3070 CXXScopeSpec &SS,
3071 UnqualifiedId &Name,
3072 TypeTy *ObjectType,
3073 bool EnteringContext,
3074 TemplateTy &Template);
Douglas Gregorc45c2322009-03-31 00:43:58 +00003075
Douglas Gregore94866f2009-06-12 21:21:02 +00003076 bool CheckClassTemplatePartialSpecializationArgs(
3077 TemplateParameterList *TemplateParams,
Anders Carlsson6360be72009-06-13 18:20:51 +00003078 const TemplateArgumentListBuilder &TemplateArgs,
Douglas Gregor6aa75cf2009-06-12 22:08:06 +00003079 bool &MirrorsPrimaryTemplate);
Douglas Gregore94866f2009-06-12 21:21:02 +00003080
Douglas Gregor212e81c2009-03-25 00:13:59 +00003081 virtual DeclResult
John McCall0f434ec2009-07-31 02:45:11 +00003082 ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
Mike Stump1eb44332009-09-09 15:08:12 +00003083 SourceLocation KWLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003084 CXXScopeSpec &SS,
Douglas Gregor7532dc62009-03-30 22:58:21 +00003085 TemplateTy Template,
Douglas Gregorcc636682009-02-17 23:15:12 +00003086 SourceLocation TemplateNameLoc,
Douglas Gregor55f6b142009-02-09 18:46:07 +00003087 SourceLocation LAngleLoc,
Douglas Gregor5908e9f2009-02-09 19:34:22 +00003088 ASTTemplateArgsPtr TemplateArgs,
Douglas Gregor55f6b142009-02-09 18:46:07 +00003089 SourceLocation RAngleLoc,
Douglas Gregorcc636682009-02-17 23:15:12 +00003090 AttributeList *Attr,
3091 MultiTemplateParamsArg TemplateParameterLists);
Douglas Gregor55f6b142009-02-09 18:46:07 +00003092
Mike Stump1eb44332009-09-09 15:08:12 +00003093 virtual DeclPtrTy ActOnTemplateDeclarator(Scope *S,
Douglas Gregore542c862009-06-23 23:11:28 +00003094 MultiTemplateParamsArg TemplateParameterLists,
3095 Declarator &D);
Mike Stump1eb44332009-09-09 15:08:12 +00003096
3097 virtual DeclPtrTy ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
Chris Lattner3d4b4822010-07-13 19:22:31 +00003098 MultiTemplateParamsArg TemplateParameterLists,
Douglas Gregor52591bf2009-06-24 00:54:41 +00003099 Declarator &D);
Mike Stump1eb44332009-09-09 15:08:12 +00003100
Douglas Gregor0d035142009-10-27 18:42:08 +00003101 bool
3102 CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
3103 TemplateSpecializationKind NewTSK,
3104 NamedDecl *PrevDecl,
3105 TemplateSpecializationKind PrevTSK,
Chris Lattner3d4b4822010-07-13 19:22:31 +00003106 SourceLocation PrevPtOfInstantiation,
Douglas Gregor0d035142009-10-27 18:42:08 +00003107 bool &SuppressNew);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003108
John McCallaf2094e2010-04-08 09:05:18 +00003109 bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
3110 const TemplateArgumentListInfo &ExplicitTemplateArgs,
3111 LookupResult &Previous);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003112
Douglas Gregorb9aa6b22009-09-24 23:14:47 +00003113 bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
John McCalld5532b62009-11-23 01:53:49 +00003114 const TemplateArgumentListInfo *ExplicitTemplateArgs,
John McCall68263142009-11-18 22:49:29 +00003115 LookupResult &Previous);
3116 bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003117
Douglas Gregor93dfdb12009-05-13 00:25:59 +00003118 virtual DeclResult
Mike Stump1eb44332009-09-09 15:08:12 +00003119 ActOnExplicitInstantiation(Scope *S,
Douglas Gregor45f96552009-09-04 06:33:52 +00003120 SourceLocation ExternLoc,
3121 SourceLocation TemplateLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00003122 unsigned TagSpec,
Douglas Gregor93dfdb12009-05-13 00:25:59 +00003123 SourceLocation KWLoc,
3124 const CXXScopeSpec &SS,
3125 TemplateTy Template,
3126 SourceLocation TemplateNameLoc,
3127 SourceLocation LAngleLoc,
3128 ASTTemplateArgsPtr TemplateArgs,
Douglas Gregor93dfdb12009-05-13 00:25:59 +00003129 SourceLocation RAngleLoc,
3130 AttributeList *Attr);
3131
Douglas Gregor3f5b61c2009-05-14 00:28:11 +00003132 virtual DeclResult
Mike Stump1eb44332009-09-09 15:08:12 +00003133 ActOnExplicitInstantiation(Scope *S,
Douglas Gregor45f96552009-09-04 06:33:52 +00003134 SourceLocation ExternLoc,
3135 SourceLocation TemplateLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00003136 unsigned TagSpec,
Douglas Gregor3f5b61c2009-05-14 00:28:11 +00003137 SourceLocation KWLoc,
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00003138 CXXScopeSpec &SS,
Douglas Gregor3f5b61c2009-05-14 00:28:11 +00003139 IdentifierInfo *Name,
3140 SourceLocation NameLoc,
3141 AttributeList *Attr);
3142
Douglas Gregord5a423b2009-09-25 18:43:00 +00003143 virtual DeclResult ActOnExplicitInstantiation(Scope *S,
3144 SourceLocation ExternLoc,
3145 SourceLocation TemplateLoc,
3146 Declarator &D);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003147
3148 TemplateArgumentLoc
Douglas Gregor51ffb0c2009-11-25 18:55:14 +00003149 SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
3150 SourceLocation TemplateLoc,
3151 SourceLocation RAngleLoc,
3152 Decl *Param,
3153 TemplateArgumentListBuilder &Converted);
3154
Douglas Gregor02024a92010-03-28 02:42:43 +00003155 /// \brief Specifies the context in which a particular template
3156 /// argument is being checked.
3157 enum CheckTemplateArgumentKind {
3158 /// \brief The template argument was specified in the code or was
3159 /// instantiated with some deduced template arguments.
3160 CTAK_Specified,
3161
3162 /// \brief The template argument was deduced via template argument
3163 /// deduction.
3164 CTAK_Deduced,
3165
3166 /// \brief The template argument was deduced from an array bound
3167 /// via template argument deduction.
3168 CTAK_DeducedFromArrayBound
3169 };
3170
Douglas Gregore7526412009-11-11 19:31:23 +00003171 bool CheckTemplateArgument(NamedDecl *Param,
3172 const TemplateArgumentLoc &Arg,
Douglas Gregore7526412009-11-11 19:31:23 +00003173 TemplateDecl *Template,
3174 SourceLocation TemplateLoc,
Douglas Gregore7526412009-11-11 19:31:23 +00003175 SourceLocation RAngleLoc,
Douglas Gregor02024a92010-03-28 02:42:43 +00003176 TemplateArgumentListBuilder &Converted,
3177 CheckTemplateArgumentKind CTAK = CTAK_Specified);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003178
Douglas Gregorc15cb382009-02-09 23:23:08 +00003179 bool CheckTemplateArgumentList(TemplateDecl *Template,
3180 SourceLocation TemplateLoc,
John McCalld5532b62009-11-23 01:53:49 +00003181 const TemplateArgumentListInfo &TemplateArgs,
Douglas Gregor16134c62009-07-01 00:28:38 +00003182 bool PartialTemplateArgs,
Anders Carlsson1c5976e2009-06-05 03:43:12 +00003183 TemplateArgumentListBuilder &Converted);
Douglas Gregorc15cb382009-02-09 23:23:08 +00003184
Mike Stump1eb44332009-09-09 15:08:12 +00003185 bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
John McCall833ca992009-10-29 08:12:44 +00003186 const TemplateArgumentLoc &Arg,
Anders Carlsson436b1562009-06-13 00:33:33 +00003187 TemplateArgumentListBuilder &Converted);
3188
John McCall833ca992009-10-29 08:12:44 +00003189 bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
John McCalla93c9342009-12-07 02:54:59 +00003190 TypeSourceInfo *Arg);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003191 bool CheckTemplateArgumentPointerToMember(Expr *Arg,
Douglas Gregorcaddba02009-11-12 18:38:13 +00003192 TemplateArgument &Converted);
Mike Stump1eb44332009-09-09 15:08:12 +00003193 bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
Douglas Gregor2943aed2009-03-03 04:44:36 +00003194 QualType InstantiatedParamType, Expr *&Arg,
Douglas Gregor02024a92010-03-28 02:42:43 +00003195 TemplateArgument &Converted,
3196 CheckTemplateArgumentKind CTAK = CTAK_Specified);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003197 bool CheckTemplateArgument(TemplateTemplateParmDecl *Param,
Douglas Gregor788cd062009-11-11 01:00:40 +00003198 const TemplateArgumentLoc &Arg);
Douglas Gregor02024a92010-03-28 02:42:43 +00003199
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003200 OwningExprResult
Douglas Gregor02024a92010-03-28 02:42:43 +00003201 BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
3202 QualType ParamType,
3203 SourceLocation Loc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003204 OwningExprResult
Douglas Gregor02024a92010-03-28 02:42:43 +00003205 BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
3206 SourceLocation Loc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003207
Douglas Gregorfb898e12009-11-12 16:20:59 +00003208 /// \brief Enumeration describing how template parameter lists are compared
3209 /// for equality.
3210 enum TemplateParameterListEqualKind {
3211 /// \brief We are matching the template parameter lists of two templates
3212 /// that might be redeclarations.
3213 ///
3214 /// \code
3215 /// template<typename T> struct X;
3216 /// template<typename T> struct X;
3217 /// \endcode
3218 TPL_TemplateMatch,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003219
Douglas Gregorfb898e12009-11-12 16:20:59 +00003220 /// \brief We are matching the template parameter lists of two template
3221 /// template parameters as part of matching the template parameter lists
3222 /// of two templates that might be redeclarations.
3223 ///
3224 /// \code
3225 /// template<template<int I> class TT> struct X;
3226 /// template<template<int Value> class Other> struct X;
3227 /// \endcode
3228 TPL_TemplateTemplateParmMatch,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003229
Douglas Gregorfb898e12009-11-12 16:20:59 +00003230 /// \brief We are matching the template parameter lists of a template
3231 /// template argument against the template parameter lists of a template
3232 /// template parameter.
3233 ///
3234 /// \code
3235 /// template<template<int Value> class Metafun> struct X;
3236 /// template<int Value> struct integer_c;
3237 /// X<integer_c> xic;
3238 /// \endcode
3239 TPL_TemplateTemplateArgumentMatch
3240 };
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003241
Douglas Gregorddc29e12009-02-06 22:42:48 +00003242 bool TemplateParameterListsAreEqual(TemplateParameterList *New,
3243 TemplateParameterList *Old,
3244 bool Complain,
Douglas Gregorfb898e12009-11-12 16:20:59 +00003245 TemplateParameterListEqualKind Kind,
Douglas Gregordd0574e2009-02-10 00:24:35 +00003246 SourceLocation TemplateArgLoc
Douglas Gregor788cd062009-11-11 01:00:40 +00003247 = SourceLocation());
Mike Stump1eb44332009-09-09 15:08:12 +00003248
Douglas Gregor05396e22009-08-25 17:23:04 +00003249 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
Douglas Gregoraaba5e32009-02-04 19:02:06 +00003250
Douglas Gregord57959a2009-03-27 23:10:48 +00003251 /// \brief Called when the parser has parsed a C++ typename
3252 /// specifier, e.g., "typename T::type".
3253 ///
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003254 /// \param S The scope in which this typename type occurs.
Douglas Gregord57959a2009-03-27 23:10:48 +00003255 /// \param TypenameLoc the location of the 'typename' keyword
3256 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3257 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
3258 /// \param IdLoc the location of the identifier.
3259 virtual TypeResult
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003260 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
3261 const CXXScopeSpec &SS, const IdentifierInfo &II,
3262 SourceLocation IdLoc);
Douglas Gregor17343172009-04-01 00:28:59 +00003263
3264 /// \brief Called when the parser has parsed a C++ typename
Mike Stump1eb44332009-09-09 15:08:12 +00003265 /// specifier that ends in a template-id, e.g.,
Douglas Gregor17343172009-04-01 00:28:59 +00003266 /// "typename MetaFun::template apply<T1, T2>".
3267 ///
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003268 /// \param S The scope in which this typename type occurs.
Douglas Gregor17343172009-04-01 00:28:59 +00003269 /// \param TypenameLoc the location of the 'typename' keyword
3270 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3271 /// \param TemplateLoc the location of the 'template' keyword, if any.
3272 /// \param Ty the type that the typename specifier refers to.
3273 virtual TypeResult
Douglas Gregor1a15dae2010-06-16 22:31:08 +00003274 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
3275 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
3276 TypeTy *Ty);
Douglas Gregor17343172009-04-01 00:28:59 +00003277
Douglas Gregor107de902010-04-24 15:35:55 +00003278 QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
3279 NestedNameSpecifier *NNS,
Douglas Gregord57959a2009-03-27 23:10:48 +00003280 const IdentifierInfo &II,
Abramo Bagnarae4da7a02010-05-19 21:37:53 +00003281 SourceLocation KeywordLoc,
3282 SourceRange NNSRange,
3283 SourceLocation IILoc);
Douglas Gregorc8ab2562009-05-31 09:31:02 +00003284
John McCall63b43852010-04-29 23:50:39 +00003285 TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
3286 SourceLocation Loc,
3287 DeclarationName Name);
3288 bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
Douglas Gregor4a959d82009-08-06 16:20:37 +00003289
Douglas Gregorbf4ea562009-09-15 16:23:51 +00003290 std::string
3291 getTemplateArgumentBindingsText(const TemplateParameterList *Params,
3292 const TemplateArgumentList &Args);
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003293
3294 std::string
3295 getTemplateArgumentBindingsText(const TemplateParameterList *Params,
3296 const TemplateArgument *Args,
3297 unsigned NumArgs);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003298
Douglas Gregorf67875d2009-06-12 18:26:56 +00003299 /// \brief Describes the result of template argument deduction.
3300 ///
3301 /// The TemplateDeductionResult enumeration describes the result of
3302 /// template argument deduction, as returned from
3303 /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
3304 /// structure provides additional information about the results of
3305 /// template argument deduction, e.g., the deduced template argument
3306 /// list (if successful) or the specific template parameters or
3307 /// deduced arguments that were involved in the failure.
3308 enum TemplateDeductionResult {
3309 /// \brief Template argument deduction was successful.
3310 TDK_Success = 0,
3311 /// \brief Template argument deduction exceeded the maximum template
3312 /// instantiation depth (which has already been diagnosed).
3313 TDK_InstantiationDepth,
3314 /// \brief Template argument deduction did not deduce a value
3315 /// for every template parameter.
3316 TDK_Incomplete,
3317 /// \brief Template argument deduction produced inconsistent
3318 /// deduced values for the given template parameter.
3319 TDK_Inconsistent,
3320 /// \brief Template argument deduction failed due to inconsistent
3321 /// cv-qualifiers on a template parameter type that would
3322 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
3323 /// but were given a non-const "X".
John McCall57e97782010-08-05 09:05:08 +00003324 TDK_Underqualified,
Douglas Gregorf67875d2009-06-12 18:26:56 +00003325 /// \brief Substitution of the deduced template argument values
3326 /// resulted in an error.
3327 TDK_SubstitutionFailure,
3328 /// \brief Substitution of the deduced template argument values
3329 /// into a non-deduced context produced a type or value that
3330 /// produces a type that does not match the original template
3331 /// arguments provided.
Douglas Gregore53060f2009-06-25 22:08:12 +00003332 TDK_NonDeducedMismatch,
Mike Stump1eb44332009-09-09 15:08:12 +00003333 /// \brief When performing template argument deduction for a function
Douglas Gregore53060f2009-06-25 22:08:12 +00003334 /// template, there were too many call arguments.
3335 TDK_TooManyArguments,
Mike Stump1eb44332009-09-09 15:08:12 +00003336 /// \brief When performing template argument deduction for a function
Douglas Gregore53060f2009-06-25 22:08:12 +00003337 /// template, there were too few call arguments.
Douglas Gregor6db8ed42009-06-30 23:57:56 +00003338 TDK_TooFewArguments,
3339 /// \brief The explicitly-specified template arguments were not valid
3340 /// template arguments for the given template.
Douglas Gregor4b52e252009-12-21 23:17:24 +00003341 TDK_InvalidExplicitArguments,
3342 /// \brief The arguments included an overloaded function name that could
3343 /// not be resolved to a suitable function.
3344 TDK_FailedOverloadResolution
Douglas Gregorf67875d2009-06-12 18:26:56 +00003345 };
3346
3347 /// \brief Provides information about an attempted template argument
3348 /// deduction, whose success or failure was described by a
3349 /// TemplateDeductionResult value.
3350 class TemplateDeductionInfo {
3351 /// \brief The context in which the template arguments are stored.
3352 ASTContext &Context;
3353
3354 /// \brief The deduced template argument list.
3355 ///
3356 TemplateArgumentList *Deduced;
3357
John McCall5769d612010-02-08 23:07:23 +00003358 /// \brief The source location at which template argument
3359 /// deduction is occurring.
3360 SourceLocation Loc;
3361
Douglas Gregorf67875d2009-06-12 18:26:56 +00003362 // do not implement these
3363 TemplateDeductionInfo(const TemplateDeductionInfo&);
3364 TemplateDeductionInfo &operator=(const TemplateDeductionInfo&);
3365
3366 public:
John McCall5769d612010-02-08 23:07:23 +00003367 TemplateDeductionInfo(ASTContext &Context, SourceLocation Loc)
3368 : Context(Context), Deduced(0), Loc(Loc) { }
Douglas Gregorf67875d2009-06-12 18:26:56 +00003369
3370 ~TemplateDeductionInfo() {
3371 // FIXME: if (Deduced) Deduced->Destroy(Context);
3372 }
3373
John McCall5769d612010-02-08 23:07:23 +00003374 /// \brief Returns the location at which template argument is
3375 /// occuring.
3376 SourceLocation getLocation() const {
3377 return Loc;
3378 }
3379
Douglas Gregorf67875d2009-06-12 18:26:56 +00003380 /// \brief Take ownership of the deduced template argument list.
Mike Stump1eb44332009-09-09 15:08:12 +00003381 TemplateArgumentList *take() {
Douglas Gregorf67875d2009-06-12 18:26:56 +00003382 TemplateArgumentList *Result = Deduced;
3383 Deduced = 0;
3384 return Result;
3385 }
3386
3387 /// \brief Provide a new template argument list that contains the
3388 /// results of template argument deduction.
3389 void reset(TemplateArgumentList *NewDeduced) {
3390 // FIXME: if (Deduced) Deduced->Destroy(Context);
3391 Deduced = NewDeduced;
3392 }
3393
3394 /// \brief The template parameter to which a template argument
3395 /// deduction failure refers.
3396 ///
3397 /// Depending on the result of template argument deduction, this
3398 /// template parameter may have different meanings:
3399 ///
3400 /// TDK_Incomplete: this is the first template parameter whose
3401 /// corresponding template argument was not deduced.
3402 ///
3403 /// TDK_Inconsistent: this is the template parameter for which
3404 /// two different template argument values were deduced.
3405 TemplateParameter Param;
3406
3407 /// \brief The first template argument to which the template
3408 /// argument deduction failure refers.
3409 ///
3410 /// Depending on the result of the template argument deduction,
3411 /// this template argument may have different meanings:
3412 ///
3413 /// TDK_Inconsistent: this argument is the first value deduced
3414 /// for the corresponding template parameter.
3415 ///
3416 /// TDK_SubstitutionFailure: this argument is the template
3417 /// argument we were instantiating when we encountered an error.
3418 ///
3419 /// TDK_NonDeducedMismatch: this is the template argument
3420 /// provided in the source code.
3421 TemplateArgument FirstArg;
3422
3423 /// \brief The second template argument to which the template
3424 /// argument deduction failure refers.
3425 ///
3426 /// FIXME: Finish documenting this.
3427 TemplateArgument SecondArg;
3428 };
3429
3430 TemplateDeductionResult
Douglas Gregor199d9912009-06-05 00:53:49 +00003431 DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
Douglas Gregorf67875d2009-06-12 18:26:56 +00003432 const TemplateArgumentList &TemplateArgs,
3433 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003434
Douglas Gregor83314aa2009-07-08 20:55:45 +00003435 TemplateDeductionResult
3436 SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
John McCalld5532b62009-11-23 01:53:49 +00003437 const TemplateArgumentListInfo &ExplicitTemplateArgs,
Douglas Gregor02024a92010-03-28 02:42:43 +00003438 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
Douglas Gregor83314aa2009-07-08 20:55:45 +00003439 llvm::SmallVectorImpl<QualType> &ParamTypes,
3440 QualType *FunctionType,
3441 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003442
3443 TemplateDeductionResult
Douglas Gregor83314aa2009-07-08 20:55:45 +00003444 FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
Douglas Gregor02024a92010-03-28 02:42:43 +00003445 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3446 unsigned NumExplicitlySpecified,
Douglas Gregor83314aa2009-07-08 20:55:45 +00003447 FunctionDecl *&Specialization,
3448 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003449
Douglas Gregore53060f2009-06-25 22:08:12 +00003450 TemplateDeductionResult
3451 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
John McCalld5532b62009-11-23 01:53:49 +00003452 const TemplateArgumentListInfo *ExplicitTemplateArgs,
Douglas Gregore53060f2009-06-25 22:08:12 +00003453 Expr **Args, unsigned NumArgs,
3454 FunctionDecl *&Specialization,
3455 TemplateDeductionInfo &Info);
Douglas Gregor83314aa2009-07-08 20:55:45 +00003456
3457 TemplateDeductionResult
3458 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
John McCalld5532b62009-11-23 01:53:49 +00003459 const TemplateArgumentListInfo *ExplicitTemplateArgs,
Douglas Gregor83314aa2009-07-08 20:55:45 +00003460 QualType ArgFunctionType,
3461 FunctionDecl *&Specialization,
3462 TemplateDeductionInfo &Info);
Mike Stump1eb44332009-09-09 15:08:12 +00003463
Douglas Gregor65ec1fd2009-08-21 23:19:43 +00003464 TemplateDeductionResult
3465 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3466 QualType ToType,
3467 CXXConversionDecl *&Specialization,
3468 TemplateDeductionInfo &Info);
3469
Douglas Gregor4b52e252009-12-21 23:17:24 +00003470 TemplateDeductionResult
3471 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3472 const TemplateArgumentListInfo *ExplicitTemplateArgs,
3473 FunctionDecl *&Specialization,
3474 TemplateDeductionInfo &Info);
3475
Douglas Gregor65ec1fd2009-08-21 23:19:43 +00003476 FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
3477 FunctionTemplateDecl *FT2,
John McCall5769d612010-02-08 23:07:23 +00003478 SourceLocation Loc,
Douglas Gregor8a514912009-09-14 18:39:43 +00003479 TemplatePartialOrderingContext TPOC);
John McCallc373d482010-01-27 01:50:18 +00003480 UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin,
3481 UnresolvedSetIterator SEnd,
3482 TemplatePartialOrderingContext TPOC,
3483 SourceLocation Loc,
3484 const PartialDiagnostic &NoneDiag,
3485 const PartialDiagnostic &AmbigDiag,
3486 const PartialDiagnostic &CandidateDiag);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003487
Douglas Gregorbf4ea562009-09-15 16:23:51 +00003488 ClassTemplatePartialSpecializationDecl *
3489 getMoreSpecializedPartialSpecialization(
3490 ClassTemplatePartialSpecializationDecl *PS1,
John McCall5769d612010-02-08 23:07:23 +00003491 ClassTemplatePartialSpecializationDecl *PS2,
3492 SourceLocation Loc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003493
Douglas Gregore73bb602009-09-14 21:25:05 +00003494 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
3495 bool OnlyDeduced,
Douglas Gregored9c0f92009-10-29 00:04:11 +00003496 unsigned Depth,
Douglas Gregor63f07c52009-09-18 23:21:38 +00003497 llvm::SmallVectorImpl<bool> &Used);
3498 void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate,
3499 llvm::SmallVectorImpl<bool> &Deduced);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003500
Douglas Gregor99ebf652009-02-27 19:31:52 +00003501 //===--------------------------------------------------------------------===//
3502 // C++ Template Instantiation
3503 //
Douglas Gregor26dce442009-03-10 00:06:19 +00003504
Douglas Gregor0f8716b2009-11-09 19:17:50 +00003505 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D,
Douglas Gregor525f96c2010-02-05 07:33:43 +00003506 const TemplateArgumentList *Innermost = 0,
Douglas Gregore7089b02010-05-03 23:29:10 +00003507 bool RelativeToPrimary = false,
3508 const FunctionDecl *Pattern = 0);
Douglas Gregor54dabfc2009-05-14 23:26:13 +00003509
Douglas Gregor26dce442009-03-10 00:06:19 +00003510 /// \brief A template instantiation that is currently in progress.
3511 struct ActiveTemplateInstantiation {
Douglas Gregordf667e72009-03-10 20:44:00 +00003512 /// \brief The kind of template instantiation we are performing
Douglas Gregorcca9e962009-07-01 22:01:06 +00003513 enum InstantiationKind {
Douglas Gregordf667e72009-03-10 20:44:00 +00003514 /// We are instantiating a template declaration. The entity is
Douglas Gregorb9f1b8d2009-05-15 00:01:03 +00003515 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
Douglas Gregordf667e72009-03-10 20:44:00 +00003516 TemplateInstantiation,
3517
3518 /// We are instantiating a default argument for a template
3519 /// parameter. The Entity is the template, and
3520 /// TemplateArgs/NumTemplateArguments provides the template
3521 /// arguments as specified.
Douglas Gregor637a4092009-06-10 23:47:09 +00003522 /// FIXME: Use a TemplateArgumentList
3523 DefaultTemplateArgumentInstantiation,
3524
Anders Carlsson25cae7f2009-09-05 05:14:19 +00003525 /// We are instantiating a default argument for a function.
3526 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
3527 /// provides the template arguments as specified.
3528 DefaultFunctionArgumentInstantiation,
3529
Mike Stump1eb44332009-09-09 15:08:12 +00003530 /// We are substituting explicit template arguments provided for
Douglas Gregorcca9e962009-07-01 22:01:06 +00003531 /// a function template. The entity is a FunctionTemplateDecl.
3532 ExplicitTemplateArgumentSubstitution,
Mike Stump1eb44332009-09-09 15:08:12 +00003533
Douglas Gregorcca9e962009-07-01 22:01:06 +00003534 /// We are substituting template argument determined as part of
3535 /// template argument deduction for either a class template
3536 /// partial specialization or a function template. The
3537 /// Entity is either a ClassTemplatePartialSpecializationDecl or
3538 /// a FunctionTemplateDecl.
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003539 DeducedTemplateArgumentSubstitution,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003540
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003541 /// We are substituting prior template arguments into a new
3542 /// template parameter. The template parameter itself is either a
3543 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
Douglas Gregorf35f8282009-11-11 21:54:23 +00003544 PriorTemplateArgumentSubstitution,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003545
Douglas Gregorf35f8282009-11-11 21:54:23 +00003546 /// We are checking the validity of a default template argument that
3547 /// has been used when naming a template-id.
3548 DefaultTemplateArgumentChecking
Douglas Gregordf667e72009-03-10 20:44:00 +00003549 } Kind;
3550
Douglas Gregor26dce442009-03-10 00:06:19 +00003551 /// \brief The point of instantiation within the source code.
3552 SourceLocation PointOfInstantiation;
3553
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003554 /// \brief The template in which we are performing the instantiation,
3555 /// for substitutions of prior template arguments.
3556 TemplateDecl *Template;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003557
Douglas Gregor26dce442009-03-10 00:06:19 +00003558 /// \brief The entity that is being instantiated.
Douglas Gregordf667e72009-03-10 20:44:00 +00003559 uintptr_t Entity;
3560
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003561 /// \brief The list of template arguments we are substituting, if they
3562 /// are not part of the entity.
Douglas Gregordf667e72009-03-10 20:44:00 +00003563 const TemplateArgument *TemplateArgs;
3564
3565 /// \brief The number of template arguments in TemplateArgs.
3566 unsigned NumTemplateArgs;
Douglas Gregor26dce442009-03-10 00:06:19 +00003567
3568 /// \brief The source range that covers the construct that cause
3569 /// the instantiation, e.g., the template-id that causes a class
3570 /// template instantiation.
3571 SourceRange InstantiationRange;
Douglas Gregordf667e72009-03-10 20:44:00 +00003572
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003573 ActiveTemplateInstantiation()
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003574 : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0),
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003575 NumTemplateArgs(0) {}
Eli Friedman2ebcc6b2009-08-15 22:50:33 +00003576
Douglas Gregorf35f8282009-11-11 21:54:23 +00003577 /// \brief Determines whether this template is an actual instantiation
3578 /// that should be counted toward the maximum instantiation depth.
3579 bool isInstantiationRecord() const;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003580
Douglas Gregordf667e72009-03-10 20:44:00 +00003581 friend bool operator==(const ActiveTemplateInstantiation &X,
3582 const ActiveTemplateInstantiation &Y) {
3583 if (X.Kind != Y.Kind)
3584 return false;
3585
3586 if (X.Entity != Y.Entity)
3587 return false;
3588
3589 switch (X.Kind) {
3590 case TemplateInstantiation:
3591 return true;
3592
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003593 case PriorTemplateArgumentSubstitution:
Douglas Gregorf35f8282009-11-11 21:54:23 +00003594 case DefaultTemplateArgumentChecking:
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003595 if (X.Template != Y.Template)
3596 return false;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003597
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003598 // Fall through
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003599
Douglas Gregordf667e72009-03-10 20:44:00 +00003600 case DefaultTemplateArgumentInstantiation:
Douglas Gregorcca9e962009-07-01 22:01:06 +00003601 case ExplicitTemplateArgumentSubstitution:
3602 case DeducedTemplateArgumentSubstitution:
Anders Carlsson25cae7f2009-09-05 05:14:19 +00003603 case DefaultFunctionArgumentInstantiation:
Douglas Gregordf667e72009-03-10 20:44:00 +00003604 return X.TemplateArgs == Y.TemplateArgs;
Mike Stump1eb44332009-09-09 15:08:12 +00003605
Douglas Gregordf667e72009-03-10 20:44:00 +00003606 }
3607
3608 return true;
3609 }
3610
3611 friend bool operator!=(const ActiveTemplateInstantiation &X,
3612 const ActiveTemplateInstantiation &Y) {
3613 return !(X == Y);
3614 }
Douglas Gregor26dce442009-03-10 00:06:19 +00003615 };
3616
3617 /// \brief List of active template instantiations.
3618 ///
3619 /// This vector is treated as a stack. As one template instantiation
3620 /// requires another template instantiation, additional
3621 /// instantiations are pushed onto the stack up to a
3622 /// user-configurable limit LangOptions::InstantiationDepth.
Mike Stump1eb44332009-09-09 15:08:12 +00003623 llvm::SmallVector<ActiveTemplateInstantiation, 16>
Douglas Gregor26dce442009-03-10 00:06:19 +00003624 ActiveTemplateInstantiations;
3625
Douglas Gregorf35f8282009-11-11 21:54:23 +00003626 /// \brief The number of ActiveTemplateInstantiation entries in
3627 /// \c ActiveTemplateInstantiations that are not actual instantiations and,
3628 /// therefore, should not be counted as part of the instantiation depth.
3629 unsigned NonInstantiationEntries;
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003630
Douglas Gregor27b152f2009-03-10 18:52:44 +00003631 /// \brief The last template from which a template instantiation
3632 /// error or warning was produced.
3633 ///
3634 /// This value is used to suppress printing of redundant template
3635 /// instantiation backtraces when there are multiple errors in the
3636 /// same instantiation. FIXME: Does this belong in Sema? It's tough
3637 /// to implement it anywhere else.
Douglas Gregordf667e72009-03-10 20:44:00 +00003638 ActiveTemplateInstantiation LastTemplateInstantiationErrorContext;
Douglas Gregor27b152f2009-03-10 18:52:44 +00003639
Nick Lewycky03d98c52010-07-06 19:51:49 +00003640 /// \brief The stack of calls expression undergoing template instantiation.
3641 ///
3642 /// The top of this stack is used by a fixit instantiating unresolved
3643 /// function calls to fix the AST to match the textual change it prints.
3644 llvm::SmallVector<CallExpr *, 8> CallsUndergoingInstantiation;
3645
Douglas Gregor26dce442009-03-10 00:06:19 +00003646 /// \brief A stack object to be created when performing template
3647 /// instantiation.
3648 ///
3649 /// Construction of an object of type \c InstantiatingTemplate
3650 /// pushes the current instantiation onto the stack of active
3651 /// instantiations. If the size of this stack exceeds the maximum
3652 /// number of recursive template instantiations, construction
3653 /// produces an error and evaluates true.
3654 ///
3655 /// Destruction of this object will pop the named instantiation off
3656 /// the stack.
3657 struct InstantiatingTemplate {
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003658 /// \brief Note that we are instantiating a class template,
3659 /// function template, or a member thereof.
Douglas Gregor26dce442009-03-10 00:06:19 +00003660 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003661 Decl *Entity,
Douglas Gregor26dce442009-03-10 00:06:19 +00003662 SourceRange InstantiationRange = SourceRange());
Douglas Gregordf667e72009-03-10 20:44:00 +00003663
3664 /// \brief Note that we are instantiating a default argument in a
3665 /// template-id.
3666 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3667 TemplateDecl *Template,
3668 const TemplateArgument *TemplateArgs,
3669 unsigned NumTemplateArgs,
3670 SourceRange InstantiationRange = SourceRange());
3671
Douglas Gregorcca9e962009-07-01 22:01:06 +00003672 /// \brief Note that we are instantiating a default argument in a
3673 /// template-id.
3674 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3675 FunctionTemplateDecl *FunctionTemplate,
3676 const TemplateArgument *TemplateArgs,
3677 unsigned NumTemplateArgs,
3678 ActiveTemplateInstantiation::InstantiationKind Kind,
3679 SourceRange InstantiationRange = SourceRange());
Mike Stump1eb44332009-09-09 15:08:12 +00003680
Douglas Gregor637a4092009-06-10 23:47:09 +00003681 /// \brief Note that we are instantiating as part of template
3682 /// argument deduction for a class template partial
3683 /// specialization.
3684 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3685 ClassTemplatePartialSpecializationDecl *PartialSpec,
3686 const TemplateArgument *TemplateArgs,
3687 unsigned NumTemplateArgs,
3688 SourceRange InstantiationRange = SourceRange());
3689
Anders Carlsson25cae7f2009-09-05 05:14:19 +00003690 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3691 ParmVarDecl *Param,
3692 const TemplateArgument *TemplateArgs,
3693 unsigned NumTemplateArgs,
3694 SourceRange InstantiationRange = SourceRange());
3695
Douglas Gregor9148c3f2009-11-11 19:13:48 +00003696 /// \brief Note that we are substituting prior template arguments into a
3697 /// non-type or template template parameter.
3698 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3699 TemplateDecl *Template,
3700 NonTypeTemplateParmDecl *Param,
3701 const TemplateArgument *TemplateArgs,
3702 unsigned NumTemplateArgs,
3703 SourceRange InstantiationRange);
3704
3705 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3706 TemplateDecl *Template,
3707 TemplateTemplateParmDecl *Param,
3708 const TemplateArgument *TemplateArgs,
3709 unsigned NumTemplateArgs,
3710 SourceRange InstantiationRange);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003711
Douglas Gregorf35f8282009-11-11 21:54:23 +00003712 /// \brief Note that we are checking the default template argument
3713 /// against the template parameter for a given template-id.
3714 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
3715 TemplateDecl *Template,
3716 NamedDecl *Param,
3717 const TemplateArgument *TemplateArgs,
3718 unsigned NumTemplateArgs,
3719 SourceRange InstantiationRange);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003720
3721
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003722 /// \brief Note that we have finished instantiating this template.
3723 void Clear();
3724
3725 ~InstantiatingTemplate() { Clear(); }
Douglas Gregor26dce442009-03-10 00:06:19 +00003726
3727 /// \brief Determines whether we have exceeded the maximum
3728 /// recursive template instantiations.
3729 operator bool() const { return Invalid; }
3730
3731 private:
3732 Sema &SemaRef;
3733 bool Invalid;
3734
Douglas Gregordf667e72009-03-10 20:44:00 +00003735 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
3736 SourceRange InstantiationRange);
3737
Douglas Gregor26dce442009-03-10 00:06:19 +00003738 InstantiatingTemplate(const InstantiatingTemplate&); // not implemented
3739
Mike Stump1eb44332009-09-09 15:08:12 +00003740 InstantiatingTemplate&
Douglas Gregor26dce442009-03-10 00:06:19 +00003741 operator=(const InstantiatingTemplate&); // not implemented
3742 };
3743
Douglas Gregoree1828a2009-03-10 18:03:33 +00003744 void PrintInstantiationStack();
3745
Douglas Gregor5e9f35c2009-06-14 07:33:30 +00003746 /// \brief Determines whether we are currently in a context where
3747 /// template argument substitution failures are not considered
3748 /// errors.
3749 ///
3750 /// When this routine returns true, the emission of most diagnostics
3751 /// will be suppressed and there will be no local error recovery.
3752 bool isSFINAEContext() const;
3753
Douglas Gregorbb260412009-06-14 08:02:22 +00003754 /// \brief RAII class used to determine whether SFINAE has
3755 /// trapped any errors that occur during template argument
3756 /// deduction.
3757 class SFINAETrap {
3758 Sema &SemaRef;
3759 unsigned PrevSFINAEErrors;
3760 public:
3761 explicit SFINAETrap(Sema &SemaRef)
3762 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors) { }
3763
3764 ~SFINAETrap() { SemaRef.NumSFINAEErrors = PrevSFINAEErrors; }
3765
3766 /// \brief Determine whether any SFINAE errors have been trapped.
Mike Stump1eb44332009-09-09 15:08:12 +00003767 bool hasErrorOccurred() const {
3768 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
Douglas Gregorbb260412009-06-14 08:02:22 +00003769 }
3770 };
3771
Douglas Gregorc63d2c82010-05-12 16:39:35 +00003772 /// \brief RAII class that determines when any errors have occurred
3773 /// between the time the instance was created and the time it was
3774 /// queried.
3775 class ErrorTrap {
3776 Sema &SemaRef;
3777 unsigned PrevErrors;
3778
3779 public:
3780 explicit ErrorTrap(Sema &SemaRef)
3781 : SemaRef(SemaRef), PrevErrors(SemaRef.getDiagnostics().getNumErrors()) {}
3782
3783 /// \brief Determine whether any errors have occurred since this
3784 /// object instance was created.
3785 bool hasErrorOccurred() const {
3786 return SemaRef.getDiagnostics().getNumErrors() > PrevErrors;
3787 }
3788 };
3789
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003790 /// \brief A stack-allocated class that identifies which local
3791 /// variable declaration instantiations are present in this scope.
3792 ///
3793 /// A new instance of this class type will be created whenever we
3794 /// instantiate a new function declaration, which will have its own
3795 /// set of parameter declarations.
3796 class LocalInstantiationScope {
3797 /// \brief Reference to the semantic analysis that is performing
3798 /// this template instantiation.
3799 Sema &SemaRef;
3800
Douglas Gregor815215d2009-05-27 05:35:12 +00003801 /// \brief A mapping from local declarations that occur
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003802 /// within a template to their instantiations.
3803 ///
3804 /// This mapping is used during instantiation to keep track of,
3805 /// e.g., function parameter and variable declarations. For example,
3806 /// given:
3807 ///
3808 /// \code
3809 /// template<typename T> T add(T x, T y) { return x + y; }
3810 /// \endcode
3811 ///
3812 /// when we instantiate add<int>, we will introduce a mapping from
3813 /// the ParmVarDecl for 'x' that occurs in the template to the
3814 /// instantiated ParmVarDecl for 'x'.
Douglas Gregor815215d2009-05-27 05:35:12 +00003815 llvm::DenseMap<const Decl *, Decl *> LocalDecls;
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003816
Douglas Gregor895162d2010-04-30 18:55:50 +00003817 /// \brief The outer scope, which contains local variable
Douglas Gregor550d9b22009-10-31 17:21:17 +00003818 /// definitions from some other instantiation (that may not be
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003819 /// relevant to this particular scope).
3820 LocalInstantiationScope *Outer;
3821
Douglas Gregor60406be2010-01-16 22:29:39 +00003822 /// \brief Whether we have already exited this scope.
3823 bool Exited;
3824
Douglas Gregor895162d2010-04-30 18:55:50 +00003825 /// \brief Whether to combine this scope with the outer scope, such that
3826 /// lookup will search our outer scope.
3827 bool CombineWithOuterScope;
3828
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003829 // This class is non-copyable
3830 LocalInstantiationScope(const LocalInstantiationScope &);
3831 LocalInstantiationScope &operator=(const LocalInstantiationScope &);
3832
3833 public:
Douglas Gregor895162d2010-04-30 18:55:50 +00003834 LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false)
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003835 : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope),
Douglas Gregor895162d2010-04-30 18:55:50 +00003836 Exited(false), CombineWithOuterScope(CombineWithOuterScope)
3837 {
3838 SemaRef.CurrentInstantiationScope = this;
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003839 }
3840
3841 ~LocalInstantiationScope() {
Douglas Gregor895162d2010-04-30 18:55:50 +00003842 Exit();
Douglas Gregor60406be2010-01-16 22:29:39 +00003843 }
3844
3845 /// \brief Exit this local instantiation scope early.
3846 void Exit() {
Douglas Gregor895162d2010-04-30 18:55:50 +00003847 if (Exited)
3848 return;
3849
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003850 SemaRef.CurrentInstantiationScope = Outer;
Douglas Gregor60406be2010-01-16 22:29:39 +00003851 Exited = true;
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003852 }
3853
Douglas Gregor895162d2010-04-30 18:55:50 +00003854 Decl *getInstantiationOf(const Decl *D);
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003855
Douglas Gregor815215d2009-05-27 05:35:12 +00003856 VarDecl *getInstantiationOf(const VarDecl *Var) {
3857 return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var)));
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003858 }
3859
Douglas Gregor815215d2009-05-27 05:35:12 +00003860 ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) {
3861 return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var)));
3862 }
3863
Douglas Gregor550d9b22009-10-31 17:21:17 +00003864 NonTypeTemplateParmDecl *getInstantiationOf(
3865 const NonTypeTemplateParmDecl *Var) {
3866 return cast<NonTypeTemplateParmDecl>(getInstantiationOf(cast<Decl>(Var)));
3867 }
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003868
Douglas Gregor895162d2010-04-30 18:55:50 +00003869 void InstantiatedLocal(const Decl *D, Decl *Inst);
Douglas Gregor48dd19b2009-05-14 21:44:34 +00003870 };
3871
3872 /// \brief The current instantiation scope used to store local
3873 /// variables.
3874 LocalInstantiationScope *CurrentInstantiationScope;
3875
Ted Kremenekd0ed4482010-02-02 02:07:01 +00003876 /// \brief The number of typos corrected by CorrectTypo.
3877 unsigned TyposCorrected;
3878
Ted Kremenekd064fdc2010-03-23 00:13:23 +00003879 /// \brief Worker object for performing CFG-based warnings.
3880 sema::AnalysisBasedWarnings AnalysisWarnings;
3881
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003882 /// \brief An entity for which implicit template instantiation is required.
3883 ///
Mike Stump1eb44332009-09-09 15:08:12 +00003884 /// The source location associated with the declaration is the first place in
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003885 /// the source code where the declaration was "used". It is not necessarily
Mike Stump1eb44332009-09-09 15:08:12 +00003886 /// the point of instantiation (which will be either before or after the
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003887 /// namespace-scope declaration that triggered this implicit instantiation),
3888 /// However, it is the location that diagnostics should generally refer to,
3889 /// because users will need to know what code triggered the instantiation.
3890 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
Mike Stump1eb44332009-09-09 15:08:12 +00003891
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003892 /// \brief The queue of implicit template instantiations that are required
3893 /// but have not yet been performed.
Douglas Gregorb33fe2f2009-06-30 17:20:14 +00003894 std::deque<PendingImplicitInstantiation> PendingImplicitInstantiations;
Douglas Gregord7f37bf2009-06-22 23:06:13 +00003895
Douglas Gregor60406be2010-01-16 22:29:39 +00003896 /// \brief The queue of implicit template instantiations that are required
3897 /// and must be performed within the current local scope.
3898 ///
3899 /// This queue is only used for member functions of local classes in
3900 /// templates, which must be instantiated in the same scope as their
3901 /// enclosing function, so that they can reference function-local
3902 /// types, static variables, enumerators, etc.
3903 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
3904
3905 void PerformPendingImplicitInstantiations(bool LocalOnly = false);
Mike Stump1eb44332009-09-09 15:08:12 +00003906
John McCalla93c9342009-12-07 02:54:59 +00003907 TypeSourceInfo *SubstType(TypeSourceInfo *T,
John McCallcd7ba1c2009-10-21 00:58:09 +00003908 const MultiLevelTemplateArgumentList &TemplateArgs,
3909 SourceLocation Loc, DeclarationName Entity);
3910
Mike Stump1eb44332009-09-09 15:08:12 +00003911 QualType SubstType(QualType T,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003912 const MultiLevelTemplateArgumentList &TemplateArgs,
John McCallce3ff2b2009-08-25 22:02:44 +00003913 SourceLocation Loc, DeclarationName Entity);
Mike Stump1eb44332009-09-09 15:08:12 +00003914
John McCall6cd3b9f2010-04-09 17:38:44 +00003915 TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
3916 const MultiLevelTemplateArgumentList &TemplateArgs,
3917 SourceLocation Loc,
3918 DeclarationName Entity);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00003919 ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
Douglas Gregorcb27b0f2010-04-12 07:48:19 +00003920 const MultiLevelTemplateArgumentList &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003921 OwningExprResult SubstExpr(Expr *E,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003922 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregora0e500d2009-03-12 16:53:44 +00003923
Mike Stump1eb44332009-09-09 15:08:12 +00003924 OwningStmtResult SubstStmt(Stmt *S,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003925 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor54dabfc2009-05-14 23:26:13 +00003926
John McCallce3ff2b2009-08-25 22:02:44 +00003927 Decl *SubstDecl(Decl *D, DeclContext *Owner,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003928 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor8dbc2692009-03-17 21:15:40 +00003929
Mike Stump1eb44332009-09-09 15:08:12 +00003930 bool
John McCallce3ff2b2009-08-25 22:02:44 +00003931 SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
3932 CXXRecordDecl *Pattern,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003933 const MultiLevelTemplateArgumentList &TemplateArgs);
John McCalle29ba202009-08-20 01:44:21 +00003934
3935 bool
Douglas Gregord475b8d2009-03-25 21:17:03 +00003936 InstantiateClass(SourceLocation PointOfInstantiation,
3937 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003938 const MultiLevelTemplateArgumentList &TemplateArgs,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003939 TemplateSpecializationKind TSK,
Douglas Gregor5842ba92009-08-24 15:23:48 +00003940 bool Complain = true);
Douglas Gregord475b8d2009-03-25 21:17:03 +00003941
John McCall1d8d1cc2010-08-01 02:01:53 +00003942 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
3943 Decl *Pattern, Decl *Inst);
3944
Mike Stump1eb44332009-09-09 15:08:12 +00003945 bool
Douglas Gregor972e6ce2009-10-27 06:26:26 +00003946 InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
Douglas Gregor2943aed2009-03-03 04:44:36 +00003947 ClassTemplateSpecializationDecl *ClassTemplateSpec,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003948 TemplateSpecializationKind TSK,
3949 bool Complain = true);
Douglas Gregor99ebf652009-02-27 19:31:52 +00003950
Douglas Gregora58861f2009-05-13 20:28:22 +00003951 void InstantiateClassMembers(SourceLocation PointOfInstantiation,
3952 CXXRecordDecl *Instantiation,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003953 const MultiLevelTemplateArgumentList &TemplateArgs,
3954 TemplateSpecializationKind TSK);
Douglas Gregora58861f2009-05-13 20:28:22 +00003955
3956 void InstantiateClassTemplateSpecializationMembers(
3957 SourceLocation PointOfInstantiation,
Douglas Gregord0e3daf2009-09-04 22:48:11 +00003958 ClassTemplateSpecializationDecl *ClassTemplateSpec,
3959 TemplateSpecializationKind TSK);
Douglas Gregora58861f2009-05-13 20:28:22 +00003960
Douglas Gregorab452ba2009-03-26 23:50:42 +00003961 NestedNameSpecifier *
John McCallce3ff2b2009-08-25 22:02:44 +00003962 SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
3963 SourceRange Range,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003964 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor5953d8b2009-03-19 17:26:29 +00003965
Douglas Gregorde650ae2009-03-31 18:38:02 +00003966 TemplateName
John McCallce3ff2b2009-08-25 22:02:44 +00003967 SubstTemplateName(TemplateName Name, SourceLocation Loc,
Douglas Gregord6350ae2009-08-28 20:31:08 +00003968 const MultiLevelTemplateArgumentList &TemplateArgs);
John McCall833ca992009-10-29 08:12:44 +00003969 bool Subst(const TemplateArgumentLoc &Arg, TemplateArgumentLoc &Result,
3970 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregorde650ae2009-03-31 18:38:02 +00003971
Douglas Gregorf3e7ce42009-05-18 17:01:57 +00003972 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
Douglas Gregorb33fe2f2009-06-30 17:20:14 +00003973 FunctionDecl *Function,
Douglas Gregore2d3a3d2009-10-15 14:05:49 +00003974 bool Recursive = false,
3975 bool DefinitionRequired = false);
Douglas Gregor7caa6822009-07-24 20:34:43 +00003976 void InstantiateStaticDataMemberDefinition(
John McCallce3ff2b2009-08-25 22:02:44 +00003977 SourceLocation PointOfInstantiation,
3978 VarDecl *Var,
Douglas Gregore2d3a3d2009-10-15 14:05:49 +00003979 bool Recursive = false,
3980 bool DefinitionRequired = false);
Douglas Gregora58861f2009-05-13 20:28:22 +00003981
Anders Carlsson09025312009-08-29 05:16:22 +00003982 void InstantiateMemInitializers(CXXConstructorDecl *New,
3983 const CXXConstructorDecl *Tmpl,
3984 const MultiLevelTemplateArgumentList &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003985
Douglas Gregor7c1e98f2010-03-01 15:56:25 +00003986 NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
Douglas Gregore95b4092009-09-16 18:34:49 +00003987 const MultiLevelTemplateArgumentList &TemplateArgs);
Douglas Gregor7c1e98f2010-03-01 15:56:25 +00003988 DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
Douglas Gregore95b4092009-09-16 18:34:49 +00003989 const MultiLevelTemplateArgumentList &TemplateArgs);
Mike Stump1eb44332009-09-09 15:08:12 +00003990
Steve Naroff3536b442007-09-06 21:24:23 +00003991 // Objective-C declarations.
Chris Lattnerb28317a2009-03-28 19:18:32 +00003992 virtual DeclPtrTy ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
3993 IdentifierInfo *ClassName,
3994 SourceLocation ClassLoc,
3995 IdentifierInfo *SuperName,
3996 SourceLocation SuperLoc,
3997 const DeclPtrTy *ProtoRefs,
3998 unsigned NumProtoRefs,
Douglas Gregor18df52b2010-01-16 15:02:53 +00003999 const SourceLocation *ProtoLocs,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004000 SourceLocation EndProtoLoc,
4001 AttributeList *AttrList);
Mike Stump1eb44332009-09-09 15:08:12 +00004002
Chris Lattnerb28317a2009-03-28 19:18:32 +00004003 virtual DeclPtrTy ActOnCompatiblityAlias(
Fariborz Jahanian243b64b2007-10-11 23:42:27 +00004004 SourceLocation AtCompatibilityAliasLoc,
4005 IdentifierInfo *AliasName, SourceLocation AliasLocation,
4006 IdentifierInfo *ClassName, SourceLocation ClassLocation);
Steve Naroff61d68522009-03-05 15:22:01 +00004007
4008 void CheckForwardProtocolDeclarationForCircularDependency(
4009 IdentifierInfo *PName,
4010 SourceLocation &PLoc, SourceLocation PrevLoc,
4011 const ObjCList<ObjCProtocolDecl> &PList);
Mike Stump1eb44332009-09-09 15:08:12 +00004012
Chris Lattnerb28317a2009-03-28 19:18:32 +00004013 virtual DeclPtrTy ActOnStartProtocolInterface(
Nate Begeman1abc7f62008-02-20 22:57:40 +00004014 SourceLocation AtProtoInterfaceLoc,
Fariborz Jahanian25e077d2007-09-17 21:07:36 +00004015 IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004016 const DeclPtrTy *ProtoRefNames, unsigned NumProtoRefs,
Douglas Gregor18df52b2010-01-16 15:02:53 +00004017 const SourceLocation *ProtoLocs,
Daniel Dunbar246e70f2008-09-26 04:48:09 +00004018 SourceLocation EndProtoLoc,
4019 AttributeList *AttrList);
Mike Stump1eb44332009-09-09 15:08:12 +00004020
Chris Lattnerb28317a2009-03-28 19:18:32 +00004021 virtual DeclPtrTy ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
4022 IdentifierInfo *ClassName,
4023 SourceLocation ClassLoc,
4024 IdentifierInfo *CategoryName,
4025 SourceLocation CategoryLoc,
4026 const DeclPtrTy *ProtoRefs,
4027 unsigned NumProtoRefs,
Douglas Gregor18df52b2010-01-16 15:02:53 +00004028 const SourceLocation *ProtoLocs,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004029 SourceLocation EndProtoLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004030
Chris Lattnerb28317a2009-03-28 19:18:32 +00004031 virtual DeclPtrTy ActOnStartClassImplementation(
Nate Begeman1abc7f62008-02-20 22:57:40 +00004032 SourceLocation AtClassImplLoc,
Fariborz Jahanianccb4f312007-09-25 18:38:09 +00004033 IdentifierInfo *ClassName, SourceLocation ClassLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00004034 IdentifierInfo *SuperClassname,
Fariborz Jahanianccb4f312007-09-25 18:38:09 +00004035 SourceLocation SuperClassLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004036
Chris Lattnerb28317a2009-03-28 19:18:32 +00004037 virtual DeclPtrTy ActOnStartCategoryImplementation(
Fariborz Jahanian8f3fde02007-10-02 16:38:50 +00004038 SourceLocation AtCatImplLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00004039 IdentifierInfo *ClassName,
Fariborz Jahanian8f3fde02007-10-02 16:38:50 +00004040 SourceLocation ClassLoc,
4041 IdentifierInfo *CatName,
4042 SourceLocation CatLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004043
Chris Lattnerb28317a2009-03-28 19:18:32 +00004044 virtual DeclPtrTy ActOnForwardClassDeclaration(SourceLocation Loc,
Ted Kremenekc09cba62009-11-17 23:12:20 +00004045 IdentifierInfo **IdentList,
4046 SourceLocation *IdentLocs,
4047 unsigned NumElts);
Mike Stump1eb44332009-09-09 15:08:12 +00004048
Chris Lattner3d4b4822010-07-13 19:22:31 +00004049 virtual DeclPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
Chris Lattner7caeabd2008-07-21 22:17:28 +00004050 const IdentifierLocPair *IdentList,
Fariborz Jahanianbc1c8772008-12-17 01:07:27 +00004051 unsigned NumElts,
4052 AttributeList *attrList);
Mike Stump1eb44332009-09-09 15:08:12 +00004053
Chris Lattnere13b9592008-07-26 04:03:38 +00004054 virtual void FindProtocolDeclaration(bool WarnOnDeclarations,
Chris Lattner7caeabd2008-07-21 22:17:28 +00004055 const IdentifierLocPair *ProtocolId,
Fariborz Jahanian4b6c9052007-10-11 00:55:41 +00004056 unsigned NumProtocols,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004057 llvm::SmallVectorImpl<DeclPtrTy> &Protocols);
Mike Stump1eb44332009-09-09 15:08:12 +00004058
4059 /// Ensure attributes are consistent with type.
Daniel Dunbar95e61fb2008-09-23 21:53:23 +00004060 /// \param [in, out] Attributes The attributes to check; they will
4061 /// be modified to be consistent with \arg PropertyTy.
Fariborz Jahanian842f07b2010-03-30 22:40:11 +00004062 void CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
Daniel Dunbar95e61fb2008-09-23 21:53:23 +00004063 SourceLocation Loc,
4064 unsigned &Attributes);
Steve Naroff0701bbb2009-01-08 17:28:14 +00004065 void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
Mike Stump1eb44332009-09-09 15:08:12 +00004066 void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
Fariborz Jahanian02edb982008-05-01 00:03:38 +00004067 ObjCPropertyDecl *SuperProperty,
Chris Lattner8ec03f52008-11-24 03:54:41 +00004068 const IdentifierInfo *Name);
Fariborz Jahanian02edb982008-05-01 00:03:38 +00004069 void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004070
4071 void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
Fariborz Jahaniandbdec8b2009-08-04 01:07:16 +00004072 ObjCMethodDecl *MethodDecl,
4073 bool IsInstance);
Mike Stump1eb44332009-09-09 15:08:12 +00004074
Fariborz Jahanian107089f2010-01-18 18:41:16 +00004075 void CompareProperties(Decl *CDecl, DeclPtrTy MergeProtocols);
Mike Stump1eb44332009-09-09 15:08:12 +00004076
4077 void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
Fariborz Jahanianb7f95f52009-03-02 19:05:07 +00004078 ObjCInterfaceDecl *ID);
Mike Stump1eb44332009-09-09 15:08:12 +00004079
Fariborz Jahanian107089f2010-01-18 18:41:16 +00004080 void MatchOneProtocolPropertiesInClass(Decl *CDecl,
4081 ObjCProtocolDecl *PDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004082
Fariborz Jahanian17cb3262010-05-05 21:52:17 +00004083 virtual void ActOnAtEnd(Scope *S, SourceRange AtEnd,
Ted Kremenek782f2f52010-01-07 01:20:12 +00004084 DeclPtrTy classDecl,
4085 DeclPtrTy *allMethods = 0, unsigned allNum = 0,
4086 DeclPtrTy *allProperties = 0, unsigned pNum = 0,
4087 DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00004088
Chris Lattnerb28317a2009-03-28 19:18:32 +00004089 virtual DeclPtrTy ActOnProperty(Scope *S, SourceLocation AtLoc,
4090 FieldDeclarator &FD, ObjCDeclSpec &ODS,
4091 Selector GetterSel, Selector SetterSel,
4092 DeclPtrTy ClassCategory,
4093 bool *OverridingProperty,
4094 tok::ObjCKeywordKind MethodImplKind);
Mike Stump1eb44332009-09-09 15:08:12 +00004095
Fariborz Jahanian17cb3262010-05-05 21:52:17 +00004096 virtual DeclPtrTy ActOnPropertyImplDecl(Scope *S,
4097 SourceLocation AtLoc,
Chris Lattnerb28317a2009-03-28 19:18:32 +00004098 SourceLocation PropertyLoc,
4099 bool ImplKind,DeclPtrTy ClassImplDecl,
4100 IdentifierInfo *PropertyId,
4101 IdentifierInfo *PropertyIvar);
Mike Stump1eb44332009-09-09 15:08:12 +00004102
Chris Lattnerb28317a2009-03-28 19:18:32 +00004103 virtual DeclPtrTy ActOnMethodDeclaration(
Steve Naroffbef11852007-10-26 20:53:56 +00004104 SourceLocation BeginLoc, // location of the + or -.
4105 SourceLocation EndLoc, // location of the ; or {.
Mike Stump1eb44332009-09-09 15:08:12 +00004106 tok::TokenKind MethodType,
4107 DeclPtrTy ClassDecl, ObjCDeclSpec &ReturnQT, TypeTy *ReturnType,
Fariborz Jahanianf1de0ca2007-10-31 23:53:01 +00004108 Selector Sel,
Steve Naroff68d331a2007-09-27 14:38:14 +00004109 // optional arguments. The number of types/arguments is obtained
4110 // from the Sel.getNumArgs().
Chris Lattnere294d3f2009-04-11 18:57:04 +00004111 ObjCArgInfo *ArgInfo,
Fariborz Jahanian4f4fd922010-04-08 00:30:06 +00004112 DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args
Steve Naroff335eafa2007-11-15 12:35:21 +00004113 AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
4114 bool isVariadic = false);
Steve Naroff81bfde92007-10-16 23:12:48 +00004115
Steve Narofff1afaf62009-02-26 15:55:06 +00004116 // Helper method for ActOnClassMethod/ActOnInstanceMethod.
4117 // Will search "local" class/category implementations for a method decl.
Fariborz Jahanian175ba1e2009-03-04 18:15:57 +00004118 // Will also search in class's root looking for instance method.
Steve Narofff1afaf62009-02-26 15:55:06 +00004119 // Returns 0 if no method is found.
Mike Stump1eb44332009-09-09 15:08:12 +00004120 ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
Steve Naroff5609ec02009-03-08 18:56:13 +00004121 ObjCInterfaceDecl *CDecl);
4122 ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
4123 ObjCInterfaceDecl *ClassDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004124
Chris Lattnereb483eb2010-04-11 08:28:14 +00004125 OwningExprResult
Chris Lattner7f816522010-04-11 07:45:24 +00004126 HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
Chris Lattnerb9d4fc12010-04-11 07:51:10 +00004127 Expr *BaseExpr,
Chris Lattner7f816522010-04-11 07:45:24 +00004128 DeclarationName MemberName,
Chris Lattnerb9d4fc12010-04-11 07:51:10 +00004129 SourceLocation MemberLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004130
Chris Lattnereb483eb2010-04-11 08:28:14 +00004131 virtual OwningExprResult
4132 ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
4133 IdentifierInfo &propertyName,
4134 SourceLocation receiverNameLoc,
4135 SourceLocation propertyNameLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004136
Douglas Gregor47bd5432010-04-14 02:46:37 +00004137 virtual ObjCMessageKind getObjCMessageKind(Scope *S,
Douglas Gregor1569f952010-04-21 20:38:13 +00004138 IdentifierInfo *Name,
Douglas Gregor47bd5432010-04-14 02:46:37 +00004139 SourceLocation NameLoc,
4140 bool IsSuper,
Douglas Gregor1569f952010-04-21 20:38:13 +00004141 bool HasTrailingDot,
4142 TypeTy *&ReceiverType);
Douglas Gregor47bd5432010-04-14 02:46:37 +00004143
Douglas Gregor2725ca82010-04-21 19:57:20 +00004144 virtual OwningExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
4145 Selector Sel,
4146 SourceLocation LBracLoc,
4147 SourceLocation SelectorLoc,
4148 SourceLocation RBracLoc,
4149 MultiExprArg Args);
Steve Naroff68d331a2007-09-27 14:38:14 +00004150
Douglas Gregor2725ca82010-04-21 19:57:20 +00004151 OwningExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
4152 QualType ReceiverType,
4153 SourceLocation SuperLoc,
4154 Selector Sel,
Douglas Gregorf49bb082010-04-22 17:01:48 +00004155 ObjCMethodDecl *Method,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004156 SourceLocation LBracLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004157 SourceLocation RBracLoc,
4158 MultiExprArg Args);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004159
Douglas Gregor2725ca82010-04-21 19:57:20 +00004160 virtual OwningExprResult ActOnClassMessage(Scope *S,
4161 TypeTy *Receiver,
4162 Selector Sel,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004163 SourceLocation LBracLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004164 SourceLocation SelectorLoc,
4165 SourceLocation RBracLoc,
4166 MultiExprArg Args);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004167
Douglas Gregor2725ca82010-04-21 19:57:20 +00004168 OwningExprResult BuildInstanceMessage(ExprArg Receiver,
4169 QualType ReceiverType,
4170 SourceLocation SuperLoc,
4171 Selector Sel,
Douglas Gregorf49bb082010-04-22 17:01:48 +00004172 ObjCMethodDecl *Method,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004173 SourceLocation LBracLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004174 SourceLocation RBracLoc,
4175 MultiExprArg Args);
4176
4177 virtual OwningExprResult ActOnInstanceMessage(Scope *S,
4178 ExprArg Receiver,
4179 Selector Sel,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004180 SourceLocation LBracLoc,
4181 SourceLocation SelectorLoc,
Douglas Gregor2725ca82010-04-21 19:57:20 +00004182 SourceLocation RBracLoc,
4183 MultiExprArg Args);
4184
Mike Stump1eb44332009-09-09 15:08:12 +00004185
Daniel Dunbarea75a822010-05-27 00:04:40 +00004186 /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
4187 virtual void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
4188 SourceLocation PragmaLoc,
4189 SourceLocation KindLoc);
4190
Daniel Dunbar4cde9272008-10-14 05:35:18 +00004191 /// ActOnPragmaPack - Called on well formed #pragma pack(...).
4192 virtual void ActOnPragmaPack(PragmaPackKind Kind,
4193 IdentifierInfo *Name,
4194 ExprTy *Alignment,
Mike Stump1eb44332009-09-09 15:08:12 +00004195 SourceLocation PragmaLoc,
Daniel Dunbar4cde9272008-10-14 05:35:18 +00004196 SourceLocation LParenLoc,
4197 SourceLocation RParenLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004198
Ted Kremenek4726d032009-03-23 22:28:25 +00004199 /// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
Ted Kremenek7a02a372009-08-03 23:24:57 +00004200 virtual void ActOnPragmaUnused(const Token *Identifiers,
4201 unsigned NumIdentifiers, Scope *curScope,
Mike Stump1eb44332009-09-09 15:08:12 +00004202 SourceLocation PragmaLoc,
Ted Kremenek4726d032009-03-23 22:28:25 +00004203 SourceLocation LParenLoc,
4204 SourceLocation RParenLoc);
Eli Friedmanc49f19b2009-06-05 02:44:36 +00004205
Eli Friedmanaa8b0d12010-08-05 06:57:20 +00004206 /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
4207 virtual void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
4208 SourceLocation PragmaLoc);
4209
Ryan Flynn7b1fdbd2009-07-31 02:52:19 +00004210 NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II);
4211 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
Ryan Flynne25ff832009-07-30 03:15:39 +00004212
Eli Friedmandec7c762009-06-05 06:28:29 +00004213 /// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
Eli Friedmanc49f19b2009-06-05 02:44:36 +00004214 virtual void ActOnPragmaWeakID(IdentifierInfo* WeakName,
4215 SourceLocation PragmaLoc,
4216 SourceLocation WeakNameLoc);
4217
Eli Friedmandec7c762009-06-05 06:28:29 +00004218 /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
Eli Friedmanc49f19b2009-06-05 02:44:36 +00004219 virtual void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
4220 IdentifierInfo* AliasName,
4221 SourceLocation PragmaLoc,
4222 SourceLocation WeakNameLoc,
4223 SourceLocation AliasNameLoc);
4224
Daniel Dunbar9f21f892010-05-27 01:53:40 +00004225 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
4226 /// a the record decl, to handle '#pragma pack' and '#pragma options align'.
4227 void AddAlignmentAttributesForRecord(RecordDecl *RD);
Mike Stump1eb44332009-09-09 15:08:12 +00004228
Chris Lattner574aa402009-02-17 01:09:29 +00004229 /// FreePackedContext - Deallocate and null out PackContext.
4230 void FreePackedContext();
Daniel Dunbar4cde9272008-10-14 05:35:18 +00004231
Eli Friedmanaa8b0d12010-08-05 06:57:20 +00004232 /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
4233 /// add an appropriate visibility attribute.
4234 void AddPushedVisibilityAttribute(Decl *RD);
4235
4236 /// PushPragmaVisibility - Push the top element of the visibility stack; used
4237 /// for '#pragma GCC visibility' and visibility attributes on namespaces.
4238 void PushPragmaVisibility(VisibilityAttr::VisibilityTypes type);
4239
4240 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
4241 /// for '#pragma GCC visibility' and visibility attributes on namespaces.
4242 void PopPragmaVisibility();
4243
4244 /// FreeVisContext - Deallocate and null out VisContext.
4245 void FreeVisContext();
4246
Chandler Carruth4ced79f2010-06-25 03:22:07 +00004247 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4248 void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, Expr *E);
4249
Sebastian Redl906082e2010-07-20 04:20:21 +00004250 /// CastCategory - Get the correct forwarded implicit cast result category
4251 /// from the inner expression.
4252 ImplicitCastExpr::ResultCategory CastCategory(Expr *E);
4253
Chris Lattner1e0a3902008-01-16 19:17:22 +00004254 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
4255 /// cast. If there is already an implicit cast, merge into the existing one.
Douglas Gregoreb8f3062008-11-12 17:17:38 +00004256 /// If isLvalue, the result of the cast is an lvalue.
Eli Friedman73c39ab2009-10-20 08:27:19 +00004257 void ImpCastExprToType(Expr *&Expr, QualType Type, CastExpr::CastKind Kind,
Sebastian Redl906082e2010-07-20 04:20:21 +00004258 ImplicitCastExpr::ResultCategory Category =
4259 ImplicitCastExpr::RValue,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004260 CXXBaseSpecifierArray BasePath =
Anders Carlssonf1b48b72010-04-24 16:57:13 +00004261 CXXBaseSpecifierArray());
Chris Lattner1e0a3902008-01-16 19:17:22 +00004262
Reid Spencer5f016e22007-07-11 17:01:13 +00004263 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
Chris Lattner925e60d2007-12-28 05:29:59 +00004264 // functions and arrays to their respective pointers (C99 6.3.2.1).
Mike Stump1eb44332009-09-09 15:08:12 +00004265 Expr *UsualUnaryConversions(Expr *&expr);
Eli Friedman3c0eb162008-05-27 03:33:27 +00004266
Steve Naroffc80b4ee2007-07-16 21:54:35 +00004267 // DefaultFunctionArrayConversion - converts functions and arrays
Mike Stump1eb44332009-09-09 15:08:12 +00004268 // to their respective pointers (C99 6.3.2.1).
Steve Naroffc80b4ee2007-07-16 21:54:35 +00004269 void DefaultFunctionArrayConversion(Expr *&expr);
Mike Stump1eb44332009-09-09 15:08:12 +00004270
Douglas Gregora873dfc2010-02-03 00:27:59 +00004271 // DefaultFunctionArrayLvalueConversion - converts functions and
4272 // arrays to their respective pointers and performs the
4273 // lvalue-to-rvalue conversion.
4274 void DefaultFunctionArrayLvalueConversion(Expr *&expr);
4275
Steve Naroffb291ab62007-08-28 23:30:39 +00004276 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
Mike Stump1eb44332009-09-09 15:08:12 +00004277 // do not have a prototype. Integer promotions are performed on each
Steve Naroffb291ab62007-08-28 23:30:39 +00004278 // argument, and arguments that have type float are promoted to double.
Chris Lattner925e60d2007-12-28 05:29:59 +00004279 void DefaultArgumentPromotion(Expr *&Expr);
Anders Carlssondce5e2c2009-01-16 16:48:51 +00004280
4281 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
4282 enum VariadicCallType {
4283 VariadicFunction,
4284 VariadicBlock,
Anders Carlssond74d4142009-09-08 01:48:42 +00004285 VariadicMethod,
Fariborz Jahanian4cd1c702009-11-24 19:27:49 +00004286 VariadicConstructor,
4287 VariadicDoesNotApply
Anders Carlssondce5e2c2009-01-16 16:48:51 +00004288 };
Mike Stump1eb44332009-09-09 15:08:12 +00004289
Fariborz Jahanian4cd1c702009-11-24 19:27:49 +00004290 /// GatherArgumentsForCall - Collector argument expressions for various
4291 /// form of call prototypes.
4292 bool GatherArgumentsForCall(SourceLocation CallLoc,
4293 FunctionDecl *FDecl,
4294 const FunctionProtoType *Proto,
4295 unsigned FirstProtoArg,
4296 Expr **Args, unsigned NumArgs,
4297 llvm::SmallVector<Expr *, 8> &AllArgs,
Fariborz Jahanian4cd1c702009-11-24 19:27:49 +00004298 VariadicCallType CallType = VariadicDoesNotApply);
4299
Anders Carlssondce5e2c2009-01-16 16:48:51 +00004300 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
4301 // will warn if the resulting type is not a POD type.
Chris Lattner40378332010-05-16 04:01:30 +00004302 bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT,
4303 FunctionDecl *FDecl);
Mike Stump1eb44332009-09-09 15:08:12 +00004304
Reid Spencer5f016e22007-07-11 17:01:13 +00004305 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
4306 // operands and then handles various conversions that are common to binary
4307 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
Mike Stump1eb44332009-09-09 15:08:12 +00004308 // routine returns the first non-arithmetic type found. The client is
Reid Spencer5f016e22007-07-11 17:01:13 +00004309 // responsible for emitting appropriate error diagnostics.
Steve Naroff9f5fa9b2007-08-24 19:07:16 +00004310 QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
4311 bool isCompAssign = false);
Mike Stump1eb44332009-09-09 15:08:12 +00004312
Chris Lattnerb7b61152008-01-04 18:22:42 +00004313 /// AssignConvertType - All of the 'assignment' semantic checks return this
4314 /// enum to indicate whether the assignment was allowed. These checks are
4315 /// done for simple assignments, as well as initialization, return from
4316 /// function, argument passing, etc. The query is phrased in terms of a
4317 /// source and destination type.
Chris Lattner5cf216b2008-01-04 18:04:52 +00004318 enum AssignConvertType {
Chris Lattnerb7b61152008-01-04 18:22:42 +00004319 /// Compatible - the types are compatible according to the standard.
Reid Spencer5f016e22007-07-11 17:01:13 +00004320 Compatible,
Mike Stump1eb44332009-09-09 15:08:12 +00004321
Chris Lattnerb7b61152008-01-04 18:22:42 +00004322 /// PointerToInt - The assignment converts a pointer to an int, which we
4323 /// accept as an extension.
4324 PointerToInt,
Mike Stump1eb44332009-09-09 15:08:12 +00004325
Chris Lattnerb7b61152008-01-04 18:22:42 +00004326 /// IntToPointer - The assignment converts an int to a pointer, which we
4327 /// accept as an extension.
4328 IntToPointer,
Mike Stump1eb44332009-09-09 15:08:12 +00004329
Chris Lattnerb7b61152008-01-04 18:22:42 +00004330 /// FunctionVoidPointer - The assignment is between a function pointer and
4331 /// void*, which the standard doesn't allow, but we accept as an extension.
Chris Lattnerbfe639e2008-01-03 22:56:36 +00004332 FunctionVoidPointer,
Chris Lattnerb7b61152008-01-04 18:22:42 +00004333
4334 /// IncompatiblePointer - The assignment is between two pointers types that
4335 /// are not compatible, but we accept them as an extension.
Reid Spencer5f016e22007-07-11 17:01:13 +00004336 IncompatiblePointer,
Eli Friedmanf05c05d2009-03-22 23:59:44 +00004337
4338 /// IncompatiblePointer - The assignment is between two pointers types which
4339 /// point to integers which have a different sign, but are otherwise identical.
4340 /// This is a subset of the above, but broken out because it's by far the most
4341 /// common case of incompatible pointers.
4342 IncompatiblePointerSign,
4343
Chris Lattnerb7b61152008-01-04 18:22:42 +00004344 /// CompatiblePointerDiscardsQualifiers - The assignment discards
4345 /// c/v/r qualifiers, which we accept as an extension.
4346 CompatiblePointerDiscardsQualifiers,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004347
Sean Huntc9132b62009-11-08 07:46:34 +00004348 /// IncompatibleNestedPointerQualifiers - The assignment is between two
4349 /// nested pointer types, and the qualifiers other than the first two
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004350 /// levels differ e.g. char ** -> const char **, but we accept them as an
4351 /// extension.
Sean Huntc9132b62009-11-08 07:46:34 +00004352 IncompatibleNestedPointerQualifiers,
Steve Naroff1c7d0672008-09-04 15:10:53 +00004353
Anders Carlssonb0f90cc2009-01-30 23:17:46 +00004354 /// IncompatibleVectors - The assignment is between two vector types that
4355 /// have the same size, which we accept as an extension.
4356 IncompatibleVectors,
Mike Stump1eb44332009-09-09 15:08:12 +00004357
4358 /// IntToBlockPointer - The assignment converts an int to a block
Steve Naroff1c7d0672008-09-04 15:10:53 +00004359 /// pointer. We disallow this.
4360 IntToBlockPointer,
4361
Mike Stump1eb44332009-09-09 15:08:12 +00004362 /// IncompatibleBlockPointer - The assignment is between two block
Steve Naroff1c7d0672008-09-04 15:10:53 +00004363 /// pointers types that are not compatible.
4364 IncompatibleBlockPointer,
Mike Stump1eb44332009-09-09 15:08:12 +00004365
Steve Naroff39579072008-10-14 22:18:38 +00004366 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
4367 /// id type and something else (that is incompatible with it). For example,
4368 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
4369 IncompatibleObjCQualifiedId,
Mike Stump1eb44332009-09-09 15:08:12 +00004370
Chris Lattnerb7b61152008-01-04 18:22:42 +00004371 /// Incompatible - We reject this conversion outright, it is invalid to
4372 /// represent it in the AST.
4373 Incompatible
Reid Spencer5f016e22007-07-11 17:01:13 +00004374 };
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004375
Chris Lattner5cf216b2008-01-04 18:04:52 +00004376 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
4377 /// assignment conversion type specified by ConvTy. This returns true if the
4378 /// conversion was invalid or false if the conversion was accepted.
4379 bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
4380 SourceLocation Loc,
4381 QualType DstType, QualType SrcType,
Douglas Gregora41a8c52010-04-22 00:20:18 +00004382 Expr *SrcExpr, AssignmentAction Action,
4383 bool *Complained = 0);
Mike Stump1eb44332009-09-09 15:08:12 +00004384
4385 /// CheckAssignmentConstraints - Perform type checking for assignment,
4386 /// argument passing, variable initialization, and function return values.
Chris Lattner5cf216b2008-01-04 18:04:52 +00004387 /// This routine is only used by the following two methods. C99 6.5.16.
4388 AssignConvertType CheckAssignmentConstraints(QualType lhs, QualType rhs);
Mike Stump1eb44332009-09-09 15:08:12 +00004389
4390 // CheckSingleAssignmentConstraints - Currently used by
4391 // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
Steve Naroff90045e82007-07-13 23:32:42 +00004392 // this routine performs the default function/array converions.
Mike Stump1eb44332009-09-09 15:08:12 +00004393 AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
Chris Lattner5cf216b2008-01-04 18:04:52 +00004394 Expr *&rExpr);
Douglas Gregor0c74e8a2009-04-29 22:16:16 +00004395
4396 // \brief If the lhs type is a transparent union, check whether we
4397 // can initialize the transparent union with the given expression.
Mike Stump1eb44332009-09-09 15:08:12 +00004398 AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
Douglas Gregor0c74e8a2009-04-29 22:16:16 +00004399 Expr *&rExpr);
Mike Stump1eb44332009-09-09 15:08:12 +00004400
Reid Spencer5f016e22007-07-11 17:01:13 +00004401 // Helper function for CheckAssignmentConstraints (C99 6.5.16.1p1)
Mike Stump1eb44332009-09-09 15:08:12 +00004402 AssignConvertType CheckPointerTypesForAssignment(QualType lhsType,
Chris Lattner5cf216b2008-01-04 18:04:52 +00004403 QualType rhsType);
Mike Stump1eb44332009-09-09 15:08:12 +00004404
Fariborz Jahanian52efc3f2009-12-08 18:24:49 +00004405 AssignConvertType CheckObjCPointerTypesForAssignment(QualType lhsType,
4406 QualType rhsType);
4407
Steve Naroff1c7d0672008-09-04 15:10:53 +00004408 // Helper function for CheckAssignmentConstraints involving two
Sebastian Redld1bd7fc2009-04-19 19:26:31 +00004409 // block pointer types.
Mike Stump1eb44332009-09-09 15:08:12 +00004410 AssignConvertType CheckBlockPointerTypesForAssignment(QualType lhsType,
Steve Naroff1c7d0672008-09-04 15:10:53 +00004411 QualType rhsType);
Douglas Gregor77a52232008-09-12 00:47:35 +00004412
4413 bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
Douglas Gregor94b1dd22008-10-24 04:54:22 +00004414
Sebastian Redl2c7588f2009-10-10 12:04:10 +00004415 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
4416
Mike Stump1eb44332009-09-09 15:08:12 +00004417 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor68647482009-12-16 03:45:30 +00004418 AssignmentAction Action,
Douglas Gregor871f4392010-04-16 17:16:43 +00004419 bool AllowExplicit = false);
Mike Stump1eb44332009-09-09 15:08:12 +00004420 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor68647482009-12-16 03:45:30 +00004421 AssignmentAction Action,
Fariborz Jahanian51bebc82009-09-23 20:55:32 +00004422 bool AllowExplicit,
Fariborz Jahanian51bebc82009-09-23 20:55:32 +00004423 ImplicitConversionSequence& ICS);
4424 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor09f41cf2009-01-14 15:45:31 +00004425 const ImplicitConversionSequence& ICS,
Douglas Gregor68647482009-12-16 03:45:30 +00004426 AssignmentAction Action,
Sebastian Redla82e4ae2009-11-14 21:15:49 +00004427 bool IgnoreBaseAccess = false);
Douglas Gregor94b1dd22008-10-24 04:54:22 +00004428 bool PerformImplicitConversion(Expr *&From, QualType ToType,
Douglas Gregor45920e82008-12-19 17:40:08 +00004429 const StandardConversionSequence& SCS,
Chris Lattner3d4b4822010-07-13 19:22:31 +00004430 AssignmentAction Action,bool IgnoreBaseAccess);
Sebastian Redl22460502009-02-07 00:15:38 +00004431
Reid Spencer5f016e22007-07-11 17:01:13 +00004432 /// the following "Check" methods will return a valid/converted QualType
4433 /// or a null QualType (indicating an error diagnostic was issued).
Sebastian Redl22460502009-02-07 00:15:38 +00004434
4435 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
Douglas Gregordf032512009-03-12 22:46:12 +00004436 QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
Sebastian Redl7c8bd602009-02-07 20:10:22 +00004437 QualType CheckPointerToMemberOperands( // C++ 5.5
Sebastian Redl22460502009-02-07 00:15:38 +00004438 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isIndirect);
Douglas Gregordf032512009-03-12 22:46:12 +00004439 QualType CheckMultiplyDivideOperands( // C99 6.5.5
Chris Lattner7ef655a2010-01-12 21:23:57 +00004440 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign,
4441 bool isDivide);
Douglas Gregordf032512009-03-12 22:46:12 +00004442 QualType CheckRemainderOperands( // C99 6.5.5
Sebastian Redl22460502009-02-07 00:15:38 +00004443 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Douglas Gregordf032512009-03-12 22:46:12 +00004444 QualType CheckAdditionOperands( // C99 6.5.6
Eli Friedmanab3a8522009-03-28 01:22:36 +00004445 Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
Douglas Gregordf032512009-03-12 22:46:12 +00004446 QualType CheckSubtractionOperands( // C99 6.5.6
Eli Friedmanab3a8522009-03-28 01:22:36 +00004447 Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
Douglas Gregordf032512009-03-12 22:46:12 +00004448 QualType CheckShiftOperands( // C99 6.5.7
Steve Naroff9f5fa9b2007-08-24 19:07:16 +00004449 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
Douglas Gregordf032512009-03-12 22:46:12 +00004450 QualType CheckCompareOperands( // C99 6.5.8/9
Chris Lattner3d4b4822010-07-13 19:22:31 +00004451 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc,
4452 bool isRelational);
Douglas Gregordf032512009-03-12 22:46:12 +00004453 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
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 CheckLogicalOperands( // C99 6.5.[13,14]
Chris Lattner90a8f272010-07-13 19:41:32 +00004456 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc);
Reid Spencer5f016e22007-07-11 17:01:13 +00004457 // CheckAssignmentOperands is used for both simple and compound assignment.
4458 // For simple assignment, pass both expressions and a null converted type.
4459 // For compound assignment, pass both expressions and the converted type.
Douglas Gregordf032512009-03-12 22:46:12 +00004460 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
Steve Narofff1120de2007-08-24 22:33:52 +00004461 Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
Douglas Gregordf032512009-03-12 22:46:12 +00004462 QualType CheckCommaOperands( // C99 6.5.17
Chris Lattner29a1cfb2008-11-18 01:30:42 +00004463 Expr *lex, Expr *&rex, SourceLocation OpLoc);
Douglas Gregordf032512009-03-12 22:46:12 +00004464 QualType CheckConditionalOperands( // C99 6.5.15
Steve Naroff49b45262007-07-13 16:58:59 +00004465 Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
Sebastian Redl3201f6b2009-04-16 17:51:27 +00004466 QualType CXXCheckConditionalOperands( // C++ 5.16
4467 Expr *&cond, Expr *&lhs, Expr *&rhs, SourceLocation questionLoc);
Douglas Gregor8f00dcf2010-04-16 23:20:25 +00004468 QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
Douglas Gregorb2cb1cb2010-02-25 22:29:57 +00004469 bool *NonStandardCompositeType = 0);
Nate Begemanbe2341d2008-07-14 18:02:46 +00004470
Fariborz Jahanianeebc4752009-12-10 19:47:41 +00004471 QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS,
4472 SourceLocation questionLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004473
Nate Begemanbe2341d2008-07-14 18:02:46 +00004474 /// type checking for vector binary operators.
Chandler Carruth8069a732010-05-19 02:12:56 +00004475 QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
4476 QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx,
4477 SourceLocation l, bool isRel);
Mike Stump1eb44332009-09-09 15:08:12 +00004478
Steve Narofff69936d2007-09-16 03:34:24 +00004479 /// type checking unary operators (subroutines of ActOnUnaryOp).
Reid Spencer5f016e22007-07-11 17:01:13 +00004480 /// C99 6.5.3.1, 6.5.3.2, 6.5.3.4
Sebastian Redle6d5a4a2008-12-20 09:35:34 +00004481 QualType CheckIncrementDecrementOperand(Expr *op, SourceLocation OpLoc,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004482 bool isInc, bool isPrefix);
Reid Spencer5f016e22007-07-11 17:01:13 +00004483 QualType CheckAddressOfOperand(Expr *op, SourceLocation OpLoc);
4484 QualType CheckIndirectionOperand(Expr *op, SourceLocation OpLoc);
Chris Lattnerba27e2a2009-02-17 08:12:06 +00004485 QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc, bool isReal);
Mike Stump1eb44332009-09-09 15:08:12 +00004486
Steve Naroffe1b31fe2007-07-27 22:15:19 +00004487 /// type checking primary expressions.
Nate Begeman213541a2008-04-18 23:10:10 +00004488 QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc,
Mike Stump1eb44332009-09-09 15:08:12 +00004489 const IdentifierInfo *Comp,
Anders Carlsson8f28f992009-08-26 18:25:21 +00004490 SourceLocation CmpLoc);
Mike Stump1eb44332009-09-09 15:08:12 +00004491
Steve Narofff0090632007-09-02 02:04:30 +00004492 /// type checking declaration initializers (C99 6.7.8)
Douglas Gregorcb57fb92009-12-16 06:35:08 +00004493 bool CheckInitList(const InitializedEntity &Entity,
4494 InitListExpr *&InitList, QualType &DeclType);
Steve Naroffd0091aa2008-01-10 22:15:12 +00004495 bool CheckForConstantInitializer(Expr *e, QualType t);
Mike Stump1eb44332009-09-09 15:08:12 +00004496
Douglas Gregor27c8dc02008-10-29 00:13:59 +00004497 // type checking C++ declaration initializers (C++ [dcl.init]).
4498
4499 /// ReferenceCompareResult - Expresses the result of comparing two
4500 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
4501 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
4502 enum ReferenceCompareResult {
4503 /// Ref_Incompatible - The two types are incompatible, so direct
4504 /// reference binding is not possible.
4505 Ref_Incompatible = 0,
4506 /// Ref_Related - The two types are reference-related, which means
4507 /// that their unqualified forms (T1 and T2) are either the same
4508 /// or T1 is a base class of T2.
4509 Ref_Related,
4510 /// Ref_Compatible_With_Added_Qualification - The two types are
4511 /// reference-compatible with added qualification, meaning that
4512 /// they are reference-compatible and the qualifiers on T1 (cv1)
4513 /// are greater than the qualifiers on T2 (cv2).
4514 Ref_Compatible_With_Added_Qualification,
4515 /// Ref_Compatible - The two types are reference-compatible and
4516 /// have equivalent qualifiers (cv1 == cv2).
4517 Ref_Compatible
4518 };
4519
Douglas Gregor393896f2009-11-05 13:06:35 +00004520 ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
4521 QualType T1, QualType T2,
Douglas Gregor15da57e2008-10-29 02:00:59 +00004522 bool& DerivedToBase);
Douglas Gregor27c8dc02008-10-29 00:13:59 +00004523
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004524 /// CheckCastTypes - Check type constraints for casting between types under
Sebastian Redlef0cb8e2009-07-29 13:50:23 +00004525 /// C semantics, or forward to CXXCheckCStyleCast in C++.
4526 bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr,
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00004527 CastExpr::CastKind &Kind, CXXBaseSpecifierArray &BasePath,
Fariborz Jahaniane9f42082009-08-26 18:55:36 +00004528 bool FunctionalStyle = false);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004529
Mike Stump1eb44332009-09-09 15:08:12 +00004530 // CheckVectorCast - check type constraints for vectors.
Anders Carlsson584b2472007-11-27 07:16:40 +00004531 // Since vectors are an extension, there are no C standard reference for this.
4532 // We allow casting between vectors and integer datatypes of the same size.
Anders Carlssona64db8f2007-11-27 05:51:55 +00004533 // returns true if the cast is invalid
Anders Carlssonc3516322009-10-16 02:48:28 +00004534 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
4535 CastExpr::CastKind &Kind);
Mike Stump1eb44332009-09-09 15:08:12 +00004536
4537 // CheckExtVectorCast - check type constraints for extended vectors.
Nate Begeman58d29a42009-06-26 00:50:28 +00004538 // Since vectors are an extension, there are no C standard reference for this.
4539 // We allow casting between vectors and integer datatypes of the same size,
4540 // or vectors and the element type of that vector.
4541 // returns true if the cast is invalid
Anders Carlsson16a89042009-10-16 05:23:41 +00004542 bool CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *&CastExpr,
4543 CastExpr::CastKind &Kind);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004544
4545 /// CXXCheckCStyleCast - Check constraints of a C-style or function-style
4546 /// cast under C++ semantics.
Sebastian Redlef0cb8e2009-07-29 13:50:23 +00004547 bool CXXCheckCStyleCast(SourceRange R, QualType CastTy, Expr *&CastExpr,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004548 CastExpr::CastKind &Kind,
Anders Carlsson5cf86ba2010-04-24 19:06:50 +00004549 CXXBaseSpecifierArray &BasePath,
4550 bool FunctionalStyle);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004551
Mike Stump1eb44332009-09-09 15:08:12 +00004552 /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
Daniel Dunbar637cebb2008-09-11 00:01:56 +00004553 /// \param Method - May be null.
4554 /// \param [out] ReturnType - The return type of the send.
4555 /// \return true iff there were any incompatible types.
Daniel Dunbar91e19b22008-09-11 00:50:25 +00004556 bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel,
Chris Lattner077bf5e2008-11-24 03:33:13 +00004557 ObjCMethodDecl *Method, bool isClassMessage,
Daniel Dunbar637cebb2008-09-11 00:01:56 +00004558 SourceLocation lbrac, SourceLocation rbrac,
Mike Stump1eb44332009-09-09 15:08:12 +00004559 QualType &ReturnType);
Argyrios Kyrtzidis59210932008-09-10 02:17:11 +00004560
John McCall5a881bb2009-10-12 21:59:07 +00004561 /// CheckBooleanCondition - Diagnose problems involving the use of
4562 /// the given expression as a boolean condition (e.g. in an if
4563 /// statement). Also performs the standard function and array
4564 /// decays, possibly changing the input variable.
4565 ///
4566 /// \param Loc - A location associated with the condition, e.g. the
4567 /// 'if' keyword.
4568 /// \return true iff there were any errors
4569 bool CheckBooleanCondition(Expr *&CondExpr, SourceLocation Loc);
4570
Douglas Gregor586596f2010-05-06 17:25:47 +00004571 virtual OwningExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc,
4572 ExprArg SubExpr);
4573
John McCall5a881bb2009-10-12 21:59:07 +00004574 /// DiagnoseAssignmentAsCondition - Given that an expression is
4575 /// being used as a boolean condition, warn if it's an assignment.
4576 void DiagnoseAssignmentAsCondition(Expr *E);
4577
Argyrios Kyrtzidis59210932008-09-10 02:17:11 +00004578 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
4579 bool CheckCXXBooleanCondition(Expr *&CondExpr);
Sebastian Redl9cc11e72009-07-25 15:41:38 +00004580
Chris Lattnerf4021e72007-08-23 05:46:52 +00004581 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
4582 /// the specified width and sign. If an overflow occurs, detect it and emit
4583 /// the specified diagnostic.
Mike Stump1eb44332009-09-09 15:08:12 +00004584 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
Chris Lattnerf4021e72007-08-23 05:46:52 +00004585 unsigned NewWidth, bool NewSign,
4586 SourceLocation Loc, unsigned DiagID);
Mike Stump1eb44332009-09-09 15:08:12 +00004587
Anders Carlsson15281452008-11-04 16:57:32 +00004588 /// Checks that the Objective-C declaration is declared in the global scope.
4589 /// Emits an error and marks the declaration as invalid if it's not declared
4590 /// in the global scope.
4591 bool CheckObjCDeclScope(Decl *D);
4592
Anders Carlsson7c50aca2007-10-15 20:28:48 +00004593 void InitBuiltinVaListType();
Eli Friedman1b76ada2008-06-03 21:01:11 +00004594
Anders Carlssone21555e2008-11-30 19:50:32 +00004595 /// VerifyIntegerConstantExpression - verifies that an expression is an ICE,
4596 /// and reports the appropriate diagnostics. Returns false on success.
4597 /// Can optionally return the value of the expression.
Anders Carlsson9f1e5722008-12-06 20:33:04 +00004598 bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0);
Anders Carlsson4000ea62008-12-01 02:17:22 +00004599
Anders Carlsson9f1e5722008-12-06 20:33:04 +00004600 /// VerifyBitField - verifies that a bit field expression is an ICE and has
Mike Stump1eb44332009-09-09 15:08:12 +00004601 /// the correct width, and that the field type is valid.
Anders Carlsson9f1e5722008-12-06 20:33:04 +00004602 /// Returns false on success.
Eli Friedman1d954f62009-08-15 21:55:26 +00004603 /// Can optionally return whether the bit-field is of width 0
Mike Stump1eb44332009-09-09 15:08:12 +00004604 bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
4605 QualType FieldTy, const Expr *BitWidth,
Eli Friedman1d954f62009-08-15 21:55:26 +00004606 bool *ZeroWidth = 0);
Sebastian Redl0eb23302009-01-19 00:08:26 +00004607
Douglas Gregor81b747b2009-09-17 21:32:03 +00004608 /// \name Code completion
4609 //@{
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004610 virtual void CodeCompleteOrdinaryName(Scope *S,
Douglas Gregor01dfea02010-01-10 23:08:15 +00004611 CodeCompletionContext CompletionContext);
Douglas Gregorf9578432010-07-28 21:50:18 +00004612 virtual void CodeCompleteExpression(Scope *S, QualType T,
4613 bool IntegralConstantExpression = false);
Douglas Gregor81b747b2009-09-17 21:32:03 +00004614 virtual void CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *Base,
4615 SourceLocation OpLoc,
4616 bool IsArrow);
Douglas Gregor374929f2009-09-18 15:37:17 +00004617 virtual void CodeCompleteTag(Scope *S, unsigned TagSpec);
Douglas Gregor3e1005f2009-09-21 18:10:23 +00004618 virtual void CodeCompleteCase(Scope *S);
Douglas Gregor9c6a0e92009-09-22 15:41:20 +00004619 virtual void CodeCompleteCall(Scope *S, ExprTy *Fn,
4620 ExprTy **Args, unsigned NumArgs);
Douglas Gregor5ac3bdb2010-05-30 01:49:25 +00004621 virtual void CodeCompleteInitializer(Scope *S, DeclPtrTy D);
4622 virtual void CodeCompleteReturn(Scope *S);
4623 virtual void CodeCompleteAssignmentRHS(Scope *S, ExprTy *LHS);
4624
Jeffrey Yasskin9ab14542010-04-08 16:38:48 +00004625 virtual void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
Douglas Gregor81b747b2009-09-17 21:32:03 +00004626 bool EnteringContext);
Douglas Gregor49f40bd2009-09-18 19:03:04 +00004627 virtual void CodeCompleteUsing(Scope *S);
4628 virtual void CodeCompleteUsingDirective(Scope *S);
4629 virtual void CodeCompleteNamespaceDecl(Scope *S);
4630 virtual void CodeCompleteNamespaceAliasDecl(Scope *S);
Douglas Gregored8d3222009-09-18 20:05:18 +00004631 virtual void CodeCompleteOperatorName(Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004632
Douglas Gregorc464ae82009-12-07 09:27:33 +00004633 virtual void CodeCompleteObjCAtDirective(Scope *S, DeclPtrTy ObjCImpDecl,
4634 bool InInterface);
Douglas Gregorc38c3e12010-01-13 21:54:15 +00004635 virtual void CodeCompleteObjCAtVisibility(Scope *S);
Douglas Gregor9a0c85e2009-12-07 09:51:25 +00004636 virtual void CodeCompleteObjCAtStatement(Scope *S);
4637 virtual void CodeCompleteObjCAtExpression(Scope *S);
Douglas Gregora93b1082009-11-18 23:08:07 +00004638 virtual void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
Douglas Gregor4ad96852009-11-19 07:41:15 +00004639 virtual void CodeCompleteObjCPropertyGetter(Scope *S, DeclPtrTy ClassDecl,
4640 DeclPtrTy *Methods,
4641 unsigned NumMethods);
4642 virtual void CodeCompleteObjCPropertySetter(Scope *S, DeclPtrTy ClassDecl,
4643 DeclPtrTy *Methods,
4644 unsigned NumMethods);
Douglas Gregor8e254cf2010-05-27 23:06:34 +00004645 virtual void CodeCompleteObjCMessageReceiver(Scope *S);
Douglas Gregor2725ca82010-04-21 19:57:20 +00004646 virtual void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
4647 IdentifierInfo **SelIdents,
4648 unsigned NumSelIdents);
4649 virtual void CodeCompleteObjCClassMessage(Scope *S, TypeTy *Receiver,
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004650 IdentifierInfo **SelIdents,
Douglas Gregord3c68542009-11-19 01:08:35 +00004651 unsigned NumSelIdents);
4652 virtual void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
4653 IdentifierInfo **SelIdents,
4654 unsigned NumSelIdents);
Douglas Gregor55385fe2009-11-18 04:19:12 +00004655 virtual void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
4656 unsigned NumProtocols);
Douglas Gregor083128f2009-11-18 04:49:41 +00004657 virtual void CodeCompleteObjCProtocolDecl(Scope *S);
Douglas Gregor3b49aca2009-11-18 16:26:39 +00004658 virtual void CodeCompleteObjCInterfaceDecl(Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004659 virtual void CodeCompleteObjCSuperclass(Scope *S,
Douglas Gregorc83c6872010-04-15 22:33:43 +00004660 IdentifierInfo *ClassName,
4661 SourceLocation ClassNameLoc);
Douglas Gregor3b49aca2009-11-18 16:26:39 +00004662 virtual void CodeCompleteObjCImplementationDecl(Scope *S);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004663 virtual void CodeCompleteObjCInterfaceCategory(Scope *S,
Douglas Gregorc83c6872010-04-15 22:33:43 +00004664 IdentifierInfo *ClassName,
4665 SourceLocation ClassNameLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004666 virtual void CodeCompleteObjCImplementationCategory(Scope *S,
Douglas Gregorc83c6872010-04-15 22:33:43 +00004667 IdentifierInfo *ClassName,
4668 SourceLocation ClassNameLoc);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004669 virtual void CodeCompleteObjCPropertyDefinition(Scope *S,
Douglas Gregor322328b2009-11-18 22:32:06 +00004670 DeclPtrTy ObjCImpDecl);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004671 virtual void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
Douglas Gregor322328b2009-11-18 22:32:06 +00004672 IdentifierInfo *PropertyName,
4673 DeclPtrTy ObjCImpDecl);
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004674 virtual void CodeCompleteObjCMethodDecl(Scope *S,
Douglas Gregore8f5a172010-04-07 00:21:17 +00004675 bool IsInstanceMethod,
4676 TypeTy *ReturnType,
4677 DeclPtrTy IDecl);
Douglas Gregor1f5537a2010-07-08 23:20:03 +00004678 virtual void CodeCompleteObjCMethodDeclSelector(Scope *S,
4679 bool IsInstanceMethod,
Douglas Gregor40ed9a12010-07-08 23:37:41 +00004680 bool AtParameterName,
Douglas Gregor1f5537a2010-07-08 23:20:03 +00004681 TypeTy *ReturnType,
4682 IdentifierInfo **SelIdents,
4683 unsigned NumSelIdents);
4684
Douglas Gregor3b49aca2009-11-18 16:26:39 +00004685 //@}
Sean Hunt1e3f5ba2010-04-28 23:02:27 +00004686
Chris Lattner59907c42007-08-10 20:18:51 +00004687 //===--------------------------------------------------------------------===//
4688 // Extra semantic analysis beyond the C type system
Ted Kremeneke0e53132010-01-28 23:39:18 +00004689
4690public:
4691 SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
4692 unsigned ByteNo) const;
4693
Chris Lattner925e60d2007-12-28 05:29:59 +00004694private:
Anders Carlssond406bf02009-08-16 01:56:34 +00004695 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
4696 bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
Mike Stump1eb44332009-09-09 15:08:12 +00004697
Ryan Flynn4403a5e2009-08-06 03:00:50 +00004698 bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall);
Chris Lattner69039812009-02-18 06:01:06 +00004699 bool CheckObjCString(Expr *Arg);
Anders Carlssond406bf02009-08-16 01:56:34 +00004700
4701 Action::OwningExprResult CheckBuiltinFunctionCall(unsigned BuiltinID,
4702 CallExpr *TheCall);
Nate Begeman26a31422010-06-08 02:47:44 +00004703 bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
4704 bool CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
4705
Chris Lattner925e60d2007-12-28 05:29:59 +00004706 bool SemaBuiltinVAStart(CallExpr *TheCall);
4707 bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
Benjamin Kramer3b1e26b2010-02-16 10:07:31 +00004708 bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
Douglas Gregorcde01732009-05-19 22:10:17 +00004709
4710public:
4711 // Used by C++ template instantiation.
Sebastian Redl0eb23302009-01-19 00:08:26 +00004712 Action::OwningExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
Douglas Gregorcde01732009-05-19 22:10:17 +00004713
4714private:
Mike Stump1eb44332009-09-09 15:08:12 +00004715 bool SemaBuiltinPrefetch(CallExpr *TheCall);
Eli Friedmand875fed2009-05-03 04:46:36 +00004716 bool SemaBuiltinObjectSize(CallExpr *TheCall);
4717 bool SemaBuiltinLongjmp(CallExpr *TheCall);
Chandler Carruthd2014572010-07-09 18:59:35 +00004718 OwningExprResult SemaBuiltinAtomicOverloaded(OwningExprResult TheCallResult);
Eric Christopher691ebc32010-04-17 02:26:23 +00004719 bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
4720 llvm::APSInt &Result);
Ted Kremenek826a3452010-07-16 02:11:22 +00004721
Ted Kremenek082d9362009-03-20 21:35:28 +00004722 bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
4723 bool HasVAListArg, unsigned format_idx,
Ted Kremenek826a3452010-07-16 02:11:22 +00004724 unsigned firstDataArg, bool isPrintf);
4725
4726 void CheckFormatString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
Ted Kremenek082d9362009-03-20 21:35:28 +00004727 const CallExpr *TheCall, bool HasVAListArg,
Ted Kremenek826a3452010-07-16 02:11:22 +00004728 unsigned format_idx, unsigned firstDataArg,
4729 bool isPrintf);
4730
Mike Stump1eb44332009-09-09 15:08:12 +00004731 void CheckNonNullArguments(const NonNullAttr *NonNull,
Fariborz Jahaniane898f8a2009-05-21 18:48:51 +00004732 const CallExpr *TheCall);
Ted Kremenek826a3452010-07-16 02:11:22 +00004733
4734 void CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg,
4735 unsigned format_idx, unsigned firstDataArg,
4736 bool isPrintf);
4737
Ted Kremenek06de2762007-08-17 16:46:58 +00004738 void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
4739 SourceLocation ReturnLoc);
Ted Kremenek588e5eb2007-11-25 00:58:00 +00004740 void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
John McCall323ed742010-05-06 08:58:33 +00004741 void CheckImplicitConversions(Expr *E);
Reid Spencer5f016e22007-07-11 17:01:13 +00004742};
4743
Ted Kremenek8189cde2009-02-07 01:47:29 +00004744//===--------------------------------------------------------------------===//
4745// Typed version of Parser::ExprArg (smart pointer for wrapping Expr pointers).
4746template <typename T>
4747class ExprOwningPtr : public Action::ExprArg {
4748public:
Douglas Gregora0e500d2009-03-12 16:53:44 +00004749 ExprOwningPtr(Sema *S, T *expr) : Action::ExprArg(*S, expr) {}
Mike Stump1eb44332009-09-09 15:08:12 +00004750
Ted Kremenek8189cde2009-02-07 01:47:29 +00004751 void reset(T* p) { Action::ExprArg::operator=(p); }
4752 T* get() const { return static_cast<T*>(Action::ExprArg::get()); }
4753 T* take() { return static_cast<T*>(Action::ExprArg::take()); }
4754 T* release() { return take(); }
Mike Stump1eb44332009-09-09 15:08:12 +00004755
Ted Kremenek8189cde2009-02-07 01:47:29 +00004756 T& operator*() const { return *get(); }
4757 T* operator->() const { return get(); }
4758};
Douglas Gregord7e27052009-05-20 22:33:37 +00004759
Reid Spencer5f016e22007-07-11 17:01:13 +00004760} // end namespace clang
4761
4762#endif