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