1 //===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the Sema class, which performs semantic analysis and
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CLANG_SEMA_SEMA_H
16 #define LLVM_CLANG_SEMA_SEMA_H
18 #include "clang/Sema/Ownership.h"
19 #include "clang/Sema/AnalysisBasedWarnings.h"
20 #include "clang/Sema/IdentifierResolver.h"
21 #include "clang/Sema/ObjCMethodList.h"
22 #include "clang/Sema/DeclSpec.h"
23 #include "clang/AST/Expr.h"
24 #include "clang/AST/DeclarationName.h"
25 #include "clang/AST/ExternalASTSource.h"
26 #include "clang/AST/TypeLoc.h"
27 #include "clang/Basic/Specifiers.h"
28 #include "clang/Basic/TemplateKinds.h"
29 #include "clang/Basic/TypeTraits.h"
30 #include "llvm/ADT/OwningPtr.h"
31 #include "llvm/ADT/SmallPtrSet.h"
32 #include "llvm/ADT/SmallVector.h"
38 template <typename ValueT> struct DenseMapInfo;
39 template <typename ValueT, typename ValueInfoT> class DenseSet;
51 typedef llvm::SmallVector<CXXBaseSpecifier*, 4> CXXCastPath;
52 class CXXConstructorDecl;
53 class CXXConversionDecl;
54 class CXXDestructorDecl;
55 class CXXFieldCollector;
56 class CXXMemberCallExpr;
62 class ClassTemplateDecl;
63 class ClassTemplatePartialSpecializationDecl;
64 class ClassTemplateSpecializationDecl;
65 class CodeCompleteConsumer;
66 class CodeCompletionAllocator;
67 class CodeCompletionResult;
73 class DeducedTemplateArgument;
74 class DependentDiagnostic;
75 class DesignatedInitExpr;
77 class EnumConstantDecl;
80 class ExternalSemaSource;
84 class FunctionProtoType;
85 class FunctionTemplateDecl;
86 class ImplicitConversionSequence;
88 class InitializationKind;
89 class InitializationSequence;
90 class InitializedEntity;
94 class LocalInstantiationScope;
97 class MultiLevelTemplateArgumentList;
100 class ObjCCategoryDecl;
101 class ObjCCategoryImplDecl;
102 class ObjCCompatibleAliasDecl;
103 class ObjCContainerDecl;
105 class ObjCImplementationDecl;
106 class ObjCInterfaceDecl;
108 template <class T> class ObjCList;
109 class ObjCMethodDecl;
110 class ObjCPropertyDecl;
111 class ObjCProtocolDecl;
112 class OverloadCandidateSet;
116 class PseudoDestructorTypeStorage;
118 class StandardConversionSequence;
122 class TargetAttributesSema;
123 class TemplateArgument;
124 class TemplateArgumentList;
125 class TemplateArgumentLoc;
127 class TemplateParameterList;
128 class TemplatePartialOrderingContext;
129 class TemplateTemplateParmDecl;
134 class UnresolvedLookupExpr;
135 class UnresolvedMemberExpr;
136 class UnresolvedSetImpl;
137 class UnresolvedSetIterator;
139 class UsingShadowDecl;
142 class VisibilityAttr;
143 class VisibleDeclConsumer;
144 class IndirectFieldDecl;
147 class AccessedEntity;
148 class BlockScopeInfo;
149 class DelayedDiagnostic;
150 class FunctionScopeInfo;
151 class TemplateDeductionInfo;
154 /// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator
157 /// LocInfoType is a "transient" type, only needed for passing to/from Parser
158 /// and Sema, when we want to preserve type source info for a parsed type.
159 /// It will not participate in the type system semantics in any way.
160 class LocInfoType : public Type {
162 // The last number that can fit in Type's TC.
163 // Avoids conflict with an existing Type class.
164 LocInfo = Type::TypeLast + 1
167 TypeSourceInfo *DeclInfo;
169 LocInfoType(QualType ty, TypeSourceInfo *TInfo)
170 : Type((TypeClass)LocInfo, ty, ty->isDependentType(),
171 ty->isVariablyModifiedType(),
172 ty->containsUnexpandedParameterPack()),
174 assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?");
179 QualType getType() const { return getCanonicalTypeInternal(); }
180 TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; }
182 void getAsStringInternal(std::string &Str,
183 const PrintingPolicy &Policy) const;
185 static bool classof(const Type *T) {
186 return T->getTypeClass() == (TypeClass)LocInfo;
188 static bool classof(const LocInfoType *) { return true; }
191 // FIXME: No way to easily map from TemplateTypeParmTypes to
192 // TemplateTypeParmDecls, so we have this horrible PointerUnion.
193 typedef std::pair<llvm::PointerUnion<const TemplateTypeParmType*, NamedDecl*>,
194 SourceLocation> UnexpandedParameterPack;
196 /// Sema - This implements semantic analysis and AST building for C.
198 Sema(const Sema&); // DO NOT IMPLEMENT
199 void operator=(const Sema&); // DO NOT IMPLEMENT
200 mutable const TargetAttributesSema* TheTargetAttributesSema;
202 typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy;
203 typedef OpaquePtr<TemplateName> TemplateTy;
204 typedef OpaquePtr<QualType> TypeTy;
206 typedef CXXBaseSpecifier BaseTy;
207 typedef CXXCtorInitializer MemInitTy;
210 typedef TemplateParameterList TemplateParamsTy;
211 typedef NestedNameSpecifier CXXScopeTy;
213 OpenCLOptions OpenCLFeatures;
214 FPOptions FPFeatures;
216 const LangOptions &LangOpts;
219 ASTConsumer &Consumer;
221 SourceManager &SourceMgr;
223 /// \brief Source of additional semantic information.
224 ExternalSemaSource *ExternalSource;
226 /// \brief Code-completion consumer.
227 CodeCompleteConsumer *CodeCompleter;
229 /// CurContext - This is the current declaration context of parsing.
230 DeclContext *CurContext;
232 /// VAListTagName - The declaration name corresponding to __va_list_tag.
233 /// This is used as part of a hack to omit that class from ADL results.
234 DeclarationName VAListTagName;
236 /// PackContext - Manages the stack for #pragma pack. An alignment
237 /// of 0 indicates default alignment.
238 void *PackContext; // Really a "PragmaPackStack*"
240 /// VisContext - Manages the stack for #pragma GCC visibility.
241 void *VisContext; // Really a "PragmaVisStack*"
243 /// \brief Stack containing information about each of the nested
244 /// function, block, and method scopes that are currently active.
246 /// This array is never empty. Clients should ignore the first
247 /// element, which is used to cache a single FunctionScopeInfo
248 /// that's used to parse every top-level function.
249 llvm::SmallVector<sema::FunctionScopeInfo *, 4> FunctionScopes;
251 /// ExprTemporaries - This is the stack of temporaries that are created by
252 /// the current full expression.
253 llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries;
255 /// ExtVectorDecls - This is a list all the extended vector types. This allows
256 /// us to associate a raw vector type with one of the ext_vector type names.
257 /// This is only necessary for issuing pretty diagnostics.
258 llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
260 /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
261 llvm::OwningPtr<CXXFieldCollector> FieldCollector;
263 typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy;
265 /// PureVirtualClassDiagSet - a set of class declarations which we have
266 /// emitted a list of pure virtual functions. Used to prevent emitting the
267 /// same list more than once.
268 llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet;
270 /// ParsingInitForAutoVars - a set of declarations with auto types for which
271 /// we are currently parsing the initializer.
272 llvm::SmallPtrSet<const Decl*, 4> ParsingInitForAutoVars;
274 /// \brief A mapping from external names to the most recent
275 /// locally-scoped external declaration with that name.
277 /// This map contains external declarations introduced in local
282 /// void foo(int, int);
286 /// Here, the name "foo" will be associated with the declaration on
287 /// "foo" within f. This name is not visible outside of
288 /// "f". However, we still find it in two cases:
290 /// - If we are declaring another external with the name "foo", we
291 /// can find "foo" as a previous declaration, so that the types
292 /// of this external declaration can be checked for
295 /// - If we would implicitly declare "foo" (e.g., due to a call to
296 /// "foo" in C when no prototype or definition is visible), then
297 /// we find this declaration of "foo" and complain that it is
299 llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls;
301 /// \brief All the tentative definitions encountered in the TU.
302 llvm::SmallVector<VarDecl *, 2> TentativeDefinitions;
304 /// \brief The set of file scoped decls seen so far that have not been used
305 /// and must warn if not used. Only contains the first declaration.
306 llvm::SmallVector<const DeclaratorDecl*, 4> UnusedFileScopedDecls;
308 class DelayedDiagnostics;
310 class ParsingDeclState {
311 unsigned SavedStackSize;
312 friend class Sema::DelayedDiagnostics;
315 class ProcessingContextState {
316 unsigned SavedParsingDepth;
317 unsigned SavedActiveStackBase;
318 friend class Sema::DelayedDiagnostics;
321 /// A class which encapsulates the logic for delaying diagnostics
322 /// during parsing and other processing.
323 class DelayedDiagnostics {
324 /// \brief The stack of diagnostics that were delayed due to being
325 /// produced during the parsing of a declaration.
326 sema::DelayedDiagnostic *Stack;
328 /// \brief The number of objects on the delayed-diagnostics stack.
331 /// \brief The current capacity of the delayed-diagnostics stack.
332 unsigned StackCapacity;
334 /// \brief The index of the first "active" delayed diagnostic in
335 /// the stack. When parsing class definitions, we ignore active
336 /// delayed diagnostics from the surrounding context.
337 unsigned ActiveStackBase;
339 /// \brief The depth of the declarations we're currently parsing.
340 /// This gets saved and reset whenever we enter a class definition.
341 unsigned ParsingDepth;
344 DelayedDiagnostics() : Stack(0), StackSize(0), StackCapacity(0),
345 ActiveStackBase(0), ParsingDepth(0) {}
347 ~DelayedDiagnostics() {
348 delete[] reinterpret_cast<char*>(Stack);
351 /// Adds a delayed diagnostic.
352 void add(const sema::DelayedDiagnostic &diag);
354 /// Determines whether diagnostics should be delayed.
355 bool shouldDelayDiagnostics() { return ParsingDepth > 0; }
357 /// Observe that we've started parsing a declaration. Access and
358 /// deprecation diagnostics will be delayed; when the declaration
359 /// is completed, all active delayed diagnostics will be evaluated
360 /// in its context, and then active diagnostics stack will be
361 /// popped down to the saved depth.
362 ParsingDeclState pushParsingDecl() {
365 ParsingDeclState state;
366 state.SavedStackSize = StackSize;
370 /// Observe that we're completed parsing a declaration.
371 static void popParsingDecl(Sema &S, ParsingDeclState state, Decl *decl);
373 /// Observe that we've started processing a different context, the
374 /// contents of which are semantically separate from the
375 /// declarations it may lexically appear in. This sets aside the
376 /// current stack of active diagnostics and starts afresh.
377 ProcessingContextState pushContext() {
378 assert(StackSize >= ActiveStackBase);
380 ProcessingContextState state;
381 state.SavedParsingDepth = ParsingDepth;
382 state.SavedActiveStackBase = ActiveStackBase;
384 ActiveStackBase = StackSize;
390 /// Observe that we've stopped processing a context. This
391 /// restores the previous stack of active diagnostics.
392 void popContext(ProcessingContextState state) {
393 assert(ActiveStackBase == StackSize);
394 assert(ParsingDepth == 0);
395 ActiveStackBase = state.SavedActiveStackBase;
396 ParsingDepth = state.SavedParsingDepth;
398 } DelayedDiagnostics;
400 /// A RAII object to temporarily push a declaration context.
404 DeclContext *SavedContext;
405 ProcessingContextState SavedContextState;
408 ContextRAII(Sema &S, DeclContext *ContextToPush)
409 : S(S), SavedContext(S.CurContext),
410 SavedContextState(S.DelayedDiagnostics.pushContext())
412 assert(ContextToPush && "pushing null context");
413 S.CurContext = ContextToPush;
417 if (!SavedContext) return;
418 S.CurContext = SavedContext;
419 S.DelayedDiagnostics.popContext(SavedContextState);
428 /// WeakUndeclaredIdentifiers - Identifiers contained in
429 /// #pragma weak before declared. rare. may alias another
430 /// identifier, declared or undeclared
432 IdentifierInfo *alias; // alias (optional)
433 SourceLocation loc; // for diagnostics
434 bool used; // identifier later declared?
437 : alias(0), loc(SourceLocation()), used(false) {}
438 WeakInfo(IdentifierInfo *Alias, SourceLocation Loc)
439 : alias(Alias), loc(Loc), used(false) {}
440 inline IdentifierInfo * getAlias() const { return alias; }
441 inline SourceLocation getLocation() const { return loc; }
442 void setUsed(bool Used=true) { used = Used; }
443 inline bool getUsed() { return used; }
444 bool operator==(WeakInfo RHS) const {
445 return alias == RHS.getAlias() && loc == RHS.getLocation();
447 bool operator!=(WeakInfo RHS) const { return !(*this == RHS); }
449 llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers;
451 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
452 /// #pragma weak during processing of other Decls.
453 /// I couldn't figure out a clean way to generate these in-line, so
454 /// we store them here and handle separately -- which is a hack.
455 /// It would be best to refactor this.
456 llvm::SmallVector<Decl*,2> WeakTopLevelDecl;
458 IdentifierResolver IdResolver;
460 /// Translation Unit Scope - useful to Objective-C actions that need
461 /// to lookup file scope declarations in the "ordinary" C decl namespace.
462 /// For example, user-defined classes, built-in "id" type, etc.
465 /// \brief The C++ "std" namespace, where the standard library resides.
466 LazyDeclPtr StdNamespace;
468 /// \brief The C++ "std::bad_alloc" class, which is defined by the C++
469 /// standard library.
470 LazyDeclPtr StdBadAlloc;
472 /// \brief The C++ "type_info" declaration, which is defined in <typeinfo>.
473 RecordDecl *CXXTypeInfoDecl;
475 /// \brief The MSVC "_GUID" struct, which is defined in MSVC header files.
476 RecordDecl *MSVCGuidDecl;
478 /// A flag to remember whether the implicit forms of operator new and delete
479 /// have been declared.
480 bool GlobalNewDeleteDeclared;
482 /// \brief The set of declarations that have been referenced within
483 /// a potentially evaluated expression.
484 typedef llvm::SmallVector<std::pair<SourceLocation, Decl *>, 10>
485 PotentiallyReferencedDecls;
487 /// \brief A set of diagnostics that may be emitted.
488 typedef llvm::SmallVector<std::pair<SourceLocation, PartialDiagnostic>, 10>
489 PotentiallyEmittedDiagnostics;
491 /// \brief Describes how the expressions currently being parsed are
492 /// evaluated at run-time, if at all.
493 enum ExpressionEvaluationContext {
494 /// \brief The current expression and its subexpressions occur within an
495 /// unevaluated operand (C++0x [expr]p8), such as a constant expression
496 /// or the subexpression of \c sizeof, where the type or the value of the
497 /// expression may be significant but no code will be generated to evaluate
498 /// the value of the expression at run time.
501 /// \brief The current expression is potentially evaluated at run time,
502 /// which means that code may be generated to evaluate the value of the
503 /// expression at run time.
504 PotentiallyEvaluated,
506 /// \brief The current expression may be potentially evaluated or it may
507 /// be unevaluated, but it is impossible to tell from the lexical context.
508 /// This evaluation context is used primary for the operand of the C++
509 /// \c typeid expression, whose argument is potentially evaluated only when
510 /// it is an lvalue of polymorphic class type (C++ [basic.def.odr]p2).
511 PotentiallyPotentiallyEvaluated,
513 /// \brief The current expression is potentially evaluated, but any
514 /// declarations referenced inside that expression are only used if
515 /// in fact the current expression is used.
517 /// This value is used when parsing default function arguments, for which
518 /// we would like to provide diagnostics (e.g., passing non-POD arguments
519 /// through varargs) but do not want to mark declarations as "referenced"
520 /// until the default argument is used.
521 PotentiallyEvaluatedIfUsed
524 /// \brief Data structure used to record current or nested
525 /// expression evaluation contexts.
526 struct ExpressionEvaluationContextRecord {
527 /// \brief The expression evaluation context.
528 ExpressionEvaluationContext Context;
530 /// \brief The number of temporaries that were active when we
531 /// entered this expression evaluation context.
532 unsigned NumTemporaries;
534 /// \brief The set of declarations referenced within a
535 /// potentially potentially-evaluated context.
537 /// When leaving a potentially potentially-evaluated context, each
538 /// of these elements will be as referenced if the corresponding
539 /// potentially potentially evaluated expression is potentially
541 PotentiallyReferencedDecls *PotentiallyReferenced;
543 /// \brief The set of diagnostics to emit should this potentially
544 /// potentially-evaluated context become evaluated.
545 PotentiallyEmittedDiagnostics *PotentiallyDiagnosed;
547 ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context,
548 unsigned NumTemporaries)
549 : Context(Context), NumTemporaries(NumTemporaries),
550 PotentiallyReferenced(0), PotentiallyDiagnosed(0) { }
552 void addReferencedDecl(SourceLocation Loc, Decl *Decl) {
553 if (!PotentiallyReferenced)
554 PotentiallyReferenced = new PotentiallyReferencedDecls;
555 PotentiallyReferenced->push_back(std::make_pair(Loc, Decl));
558 void addDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) {
559 if (!PotentiallyDiagnosed)
560 PotentiallyDiagnosed = new PotentiallyEmittedDiagnostics;
561 PotentiallyDiagnosed->push_back(std::make_pair(Loc, PD));
565 delete PotentiallyReferenced;
566 delete PotentiallyDiagnosed;
567 PotentiallyReferenced = 0;
568 PotentiallyDiagnosed = 0;
572 /// A stack of expression evaluation contexts.
573 llvm::SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts;
575 /// \brief Whether the code handled by Sema should be considered a
576 /// complete translation unit or not.
578 /// When true (which is generally the case), Sema will perform
579 /// end-of-translation-unit semantic tasks (such as creating
580 /// initializers for tentative definitions in C) once parsing has
581 /// completed. This flag will be false when building PCH files,
582 /// since a PCH file is by definition not a complete translation
584 bool CompleteTranslationUnit;
586 llvm::BumpPtrAllocator BumpAlloc;
588 /// \brief The number of SFINAE diagnostics that have been trapped.
589 unsigned NumSFINAEErrors;
591 typedef llvm::DenseMap<ParmVarDecl *, llvm::SmallVector<ParmVarDecl *, 1> >
592 UnparsedDefaultArgInstantiationsMap;
594 /// \brief A mapping from parameters with unparsed default arguments to the
595 /// set of instantiations of each parameter.
597 /// This mapping is a temporary data structure used when parsing
598 /// nested class templates or nested classes of class templates,
599 /// where we might end up instantiating an inner class before the
600 /// default arguments of its methods have been parsed.
601 UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations;
603 // Contains the locations of the beginning of unparsed default
604 // argument locations.
605 llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs;
607 /// UndefinedInternals - all the used, undefined objects with
608 /// internal linkage in this translation unit.
609 llvm::DenseMap<NamedDecl*, SourceLocation> UndefinedInternals;
611 typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods;
612 typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool;
614 /// Method Pool - allows efficient lookup when typechecking messages to "id".
615 /// We need to maintain a list, since selectors can have differing signatures
616 /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
617 /// of selectors are "overloaded").
618 GlobalMethodPool MethodPool;
620 /// Method selectors used in a @selector expression. Used for implementation
622 llvm::DenseMap<Selector, SourceLocation> ReferencedSelectors;
624 GlobalMethodPool::iterator ReadMethodPool(Selector Sel);
626 /// Private Helper predicate to check for 'self'.
627 bool isSelfExpr(Expr *RExpr);
629 Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
630 bool CompleteTranslationUnit = true,
631 CodeCompleteConsumer *CompletionConsumer = 0);
634 /// \brief Perform initialization that occurs after the parser has been
635 /// initialized but before it parses anything.
638 const LangOptions &getLangOptions() const { return LangOpts; }
639 OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; }
640 FPOptions &getFPOptions() { return FPFeatures; }
642 Diagnostic &getDiagnostics() const { return Diags; }
643 SourceManager &getSourceManager() const { return SourceMgr; }
644 const TargetAttributesSema &getTargetAttributesSema() const;
645 Preprocessor &getPreprocessor() const { return PP; }
646 ASTContext &getASTContext() const { return Context; }
647 ASTConsumer &getASTConsumer() const { return Consumer; }
649 /// \brief Helper class that creates diagnostics with optional
650 /// template instantiation stacks.
652 /// This class provides a wrapper around the basic DiagnosticBuilder
653 /// class that emits diagnostics. SemaDiagnosticBuilder is
654 /// responsible for emitting the diagnostic (as DiagnosticBuilder
655 /// does) and, if the diagnostic comes from inside a template
656 /// instantiation, printing the template instantiation stack as
658 class SemaDiagnosticBuilder : public DiagnosticBuilder {
663 SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID)
664 : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { }
666 explicit SemaDiagnosticBuilder(Sema &SemaRef)
667 : DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { }
669 ~SemaDiagnosticBuilder();
672 /// \brief Emit a diagnostic.
673 SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID);
675 /// \brief Emit a partial diagnostic.
676 SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD);
678 /// \brief Build a partial diagnostic.
679 PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h
681 ExprResult Owned(Expr* E) { return E; }
682 ExprResult Owned(ExprResult R) { return R; }
683 StmtResult Owned(Stmt* S) { return S; }
685 void ActOnEndOfTranslationUnit();
687 Scope *getScopeForContext(DeclContext *Ctx);
689 void PushFunctionScope();
690 void PushBlockScope(Scope *BlockScope, BlockDecl *Block);
691 void PopFunctionOrBlockScope(const sema::AnalysisBasedWarnings::Policy *WP =0,
692 const Decl *D = 0, const BlockExpr *blkExpr = 0);
694 sema::FunctionScopeInfo *getCurFunction() const {
695 return FunctionScopes.back();
698 bool hasAnyErrorsInThisFunction() const;
700 /// \brief Retrieve the current block, if any.
701 sema::BlockScopeInfo *getCurBlock();
703 /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
704 llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; }
706 //===--------------------------------------------------------------------===//
707 // Type Analysis / Processing: SemaType.cpp.
710 QualType adjustParameterType(QualType T);
711 QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs);
712 QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVR) {
713 return BuildQualifiedType(T, Loc, Qualifiers::fromCVRMask(CVR));
715 QualType BuildPointerType(QualType T,
716 SourceLocation Loc, DeclarationName Entity);
717 QualType BuildReferenceType(QualType T, bool LValueRef,
718 SourceLocation Loc, DeclarationName Entity);
719 QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM,
720 Expr *ArraySize, unsigned Quals,
721 SourceRange Brackets, DeclarationName Entity);
722 QualType BuildExtVectorType(QualType T, Expr *ArraySize,
723 SourceLocation AttrLoc);
724 QualType BuildFunctionType(QualType T,
725 QualType *ParamTypes, unsigned NumParamTypes,
726 bool Variadic, unsigned Quals,
727 RefQualifierKind RefQualifier,
728 SourceLocation Loc, DeclarationName Entity,
729 FunctionType::ExtInfo Info);
730 QualType BuildMemberPointerType(QualType T, QualType Class,
732 DeclarationName Entity);
733 QualType BuildBlockPointerType(QualType T,
734 SourceLocation Loc, DeclarationName Entity);
735 QualType BuildParenType(QualType T);
737 TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S,
738 TagDecl **OwnedDecl = 0,
739 bool AllowAutoInTypeName = false);
740 TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T,
741 TypeSourceInfo *ReturnTypeInfo);
742 /// \brief Package the given type and TSI into a ParsedType.
743 ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo);
744 DeclarationNameInfo GetNameForDeclarator(Declarator &D);
745 DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name);
746 static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo = 0);
747 bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range);
748 bool CheckDistantExceptionSpec(QualType T);
749 bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New);
750 bool CheckEquivalentExceptionSpec(
751 const FunctionProtoType *Old, SourceLocation OldLoc,
752 const FunctionProtoType *New, SourceLocation NewLoc);
753 bool CheckEquivalentExceptionSpec(
754 const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
755 const FunctionProtoType *Old, SourceLocation OldLoc,
756 const FunctionProtoType *New, SourceLocation NewLoc,
757 bool *MissingExceptionSpecification = 0,
758 bool *MissingEmptyExceptionSpecification = 0);
759 bool CheckExceptionSpecSubset(
760 const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID,
761 const FunctionProtoType *Superset, SourceLocation SuperLoc,
762 const FunctionProtoType *Subset, SourceLocation SubLoc);
763 bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID,
764 const FunctionProtoType *Target, SourceLocation TargetLoc,
765 const FunctionProtoType *Source, SourceLocation SourceLoc);
767 TypeResult ActOnTypeName(Scope *S, Declarator &D);
769 bool RequireCompleteType(SourceLocation Loc, QualType T,
770 const PartialDiagnostic &PD,
771 std::pair<SourceLocation, PartialDiagnostic> Note);
772 bool RequireCompleteType(SourceLocation Loc, QualType T,
773 const PartialDiagnostic &PD);
774 bool RequireCompleteType(SourceLocation Loc, QualType T,
777 QualType getElaboratedType(ElaboratedTypeKeyword Keyword,
778 const CXXScopeSpec &SS, QualType T);
780 QualType BuildTypeofExprType(Expr *E, SourceLocation Loc);
781 QualType BuildDecltypeType(Expr *E, SourceLocation Loc);
783 //===--------------------------------------------------------------------===//
784 // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
787 DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr);
789 void DiagnoseUseOfUnimplementedSelectors();
791 ParsedType getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
792 Scope *S, CXXScopeSpec *SS = 0,
793 bool isClassName = false,
794 bool HasTrailingDot = false,
795 ParsedType ObjectType = ParsedType());
796 TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S);
797 bool DiagnoseUnknownTypeName(const IdentifierInfo &II,
798 SourceLocation IILoc,
801 ParsedType &SuggestedType);
803 Decl *ActOnDeclarator(Scope *S, Declarator &D);
805 Decl *HandleDeclarator(Scope *S, Declarator &D,
806 MultiTemplateParamsArg TemplateParameterLists,
807 bool IsFunctionDefinition);
808 void RegisterLocallyScopedExternCDecl(NamedDecl *ND,
809 const LookupResult &Previous,
811 void DiagnoseFunctionSpecifiers(Declarator& D);
812 void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R);
813 void CheckShadow(Scope *S, VarDecl *D);
814 void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange);
815 NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC,
816 QualType R, TypeSourceInfo *TInfo,
817 LookupResult &Previous, bool &Redeclaration);
818 NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC,
819 QualType R, TypeSourceInfo *TInfo,
820 LookupResult &Previous,
821 MultiTemplateParamsArg TemplateParamLists,
822 bool &Redeclaration);
823 void CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous,
824 bool &Redeclaration);
825 void CheckCompleteVariableDeclaration(VarDecl *var);
826 NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC,
827 QualType R, TypeSourceInfo *TInfo,
828 LookupResult &Previous,
829 MultiTemplateParamsArg TemplateParamLists,
830 bool IsFunctionDefinition,
831 bool &Redeclaration);
832 bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
833 void DiagnoseHiddenVirtualMethods(CXXRecordDecl *DC, CXXMethodDecl *MD);
834 void CheckFunctionDeclaration(Scope *S,
835 FunctionDecl *NewFD, LookupResult &Previous,
836 bool IsExplicitSpecialization,
837 bool &Redeclaration);
838 void CheckMain(FunctionDecl *FD);
839 Decl *ActOnParamDeclarator(Scope *S, Declarator &D);
840 ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC,
843 ParmVarDecl *CheckParameter(DeclContext *DC,
844 TypeSourceInfo *TSInfo, QualType T,
845 IdentifierInfo *Name,
846 SourceLocation NameLoc,
848 StorageClass SCAsWritten);
849 void ActOnParamDefaultArgument(Decl *param,
850 SourceLocation EqualLoc,
852 void ActOnParamUnparsedDefaultArgument(Decl *param,
853 SourceLocation EqualLoc,
854 SourceLocation ArgLoc);
855 void ActOnParamDefaultArgumentError(Decl *param);
856 bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
857 SourceLocation EqualLoc);
859 void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit,
860 bool TypeMayContainAuto);
861 void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto);
862 void ActOnInitializerError(Decl *Dcl);
863 void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc);
864 void FinalizeDeclaration(Decl *D);
865 DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
868 DeclGroupPtrTy BuildDeclaratorGroup(Decl **Group, unsigned NumDecls,
869 bool TypeMayContainAuto = true);
870 void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D,
871 SourceLocation LocAfterDecls);
872 Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D);
873 Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D);
874 void ActOnStartOfObjCMethodDef(Scope *S, Decl *D);
876 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body);
877 Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation);
879 /// \brief Diagnose any unused parameters in the given sequence of
880 /// ParmVarDecl pointers.
881 void DiagnoseUnusedParameters(ParmVarDecl * const *Begin,
882 ParmVarDecl * const *End);
884 /// \brief Diagnose whether the size of parameters or return value of a
885 /// function or obj-c method definition is pass-by-value and larger than a
886 /// specified threshold.
887 void DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Begin,
888 ParmVarDecl * const *End,
892 void DiagnoseInvalidJumps(Stmt *Body);
893 Decl *ActOnFileScopeAsmDecl(SourceLocation Loc, Expr *expr);
896 void ActOnPopScope(SourceLocation Loc, Scope *S);
897 void ActOnTranslationUnitScope(Scope *S);
899 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
900 /// no declarator (e.g. "struct foo;") is parsed.
901 Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
904 StmtResult ActOnVlaStmt(const DeclSpec &DS);
906 Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
910 Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
913 bool isAcceptableTagRedeclaration(const TagDecl *Previous,
915 SourceLocation NewTagLoc,
916 const IdentifierInfo &Name);
919 TUK_Reference, // Reference to a tag: 'struct foo *X;'
920 TUK_Declaration, // Fwd decl of a tag: 'struct foo;'
921 TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;'
922 TUK_Friend // Friend declaration: 'friend struct foo;'
925 Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
926 SourceLocation KWLoc, CXXScopeSpec &SS,
927 IdentifierInfo *Name, SourceLocation NameLoc,
928 AttributeList *Attr, AccessSpecifier AS,
929 MultiTemplateParamsArg TemplateParameterLists,
930 bool &OwnedDecl, bool &IsDependent, bool ScopedEnum,
931 bool ScopedEnumUsesClassTag, TypeResult UnderlyingType);
933 Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc,
934 unsigned TagSpec, SourceLocation TagLoc,
936 IdentifierInfo *Name, SourceLocation NameLoc,
938 MultiTemplateParamsArg TempParamLists);
940 TypeResult ActOnDependentTag(Scope *S,
943 const CXXScopeSpec &SS,
944 IdentifierInfo *Name,
945 SourceLocation TagLoc,
946 SourceLocation NameLoc);
948 void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
949 IdentifierInfo *ClassName,
950 llvm::SmallVectorImpl<Decl *> &Decls);
951 Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart,
952 Declarator &D, Expr *BitfieldWidth);
954 FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart,
955 Declarator &D, Expr *BitfieldWidth,
958 FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T,
959 TypeSourceInfo *TInfo,
960 RecordDecl *Record, SourceLocation Loc,
961 bool Mutable, Expr *BitfieldWidth,
963 AccessSpecifier AS, NamedDecl *PrevDecl,
966 enum CXXSpecialMember {
969 CXXCopyConstructor = 1,
970 CXXCopyAssignment = 2,
973 bool CheckNontrivialField(FieldDecl *FD);
974 void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem);
975 CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD);
976 void ActOnLastBitfield(SourceLocation DeclStart, Decl *IntfDecl,
977 llvm::SmallVectorImpl<Decl *> &AllIvarDecls);
978 Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, Decl *IntfDecl,
979 Declarator &D, Expr *BitfieldWidth,
980 tok::ObjCKeywordKind visibility);
982 // This is used for both record definitions and ObjC interface declarations.
983 void ActOnFields(Scope* S, SourceLocation RecLoc, Decl *TagDecl,
984 Decl **Fields, unsigned NumFields,
985 SourceLocation LBrac, SourceLocation RBrac,
986 AttributeList *AttrList);
988 /// ActOnTagStartDefinition - Invoked when we have entered the
989 /// scope of a tag's definition (e.g., for an enumeration, class,
990 /// struct, or union).
991 void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
993 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
994 /// C++ record definition's base-specifiers clause and are starting its
995 /// member declarations.
996 void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl,
997 ClassVirtSpecifiers &CVS,
998 SourceLocation LBraceLoc);
1000 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
1001 /// the definition of a tag (enumeration, class, struct, or union).
1002 void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl,
1003 SourceLocation RBraceLoc);
1005 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
1006 /// error parsing the definition of a tag.
1007 void ActOnTagDefinitionError(Scope *S, Decl *TagDecl);
1009 EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum,
1010 EnumConstantDecl *LastEnumConst,
1011 SourceLocation IdLoc,
1015 Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant,
1016 SourceLocation IdLoc, IdentifierInfo *Id,
1017 AttributeList *Attrs,
1018 SourceLocation EqualLoc, Expr *Val);
1019 void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc,
1020 SourceLocation RBraceLoc, Decl *EnumDecl,
1021 Decl **Elements, unsigned NumElements,
1022 Scope *S, AttributeList *Attr);
1024 DeclContext *getContainingDC(DeclContext *DC);
1026 /// Set the current declaration context until it gets popped.
1027 void PushDeclContext(Scope *S, DeclContext *DC);
1028 void PopDeclContext();
1030 /// EnterDeclaratorContext - Used when we must lookup names in the context
1031 /// of a declarator's nested name specifier.
1032 void EnterDeclaratorContext(Scope *S, DeclContext *DC);
1033 void ExitDeclaratorContext(Scope *S);
1035 DeclContext *getFunctionLevelDeclContext();
1037 /// getCurFunctionDecl - If inside of a function body, this returns a pointer
1038 /// to the function decl for the function being parsed. If we're currently
1039 /// in a 'block', this returns the containing context.
1040 FunctionDecl *getCurFunctionDecl();
1042 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1043 /// the method decl for the method being parsed. If we're currently
1044 /// in a 'block', this returns the containing context.
1045 ObjCMethodDecl *getCurMethodDecl();
1047 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1048 /// or C function we're in, otherwise return null. If we're currently
1049 /// in a 'block', this returns the containing context.
1050 NamedDecl *getCurFunctionOrMethodDecl();
1052 /// Add this decl to the scope shadowed decl chains.
1053 void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true);
1055 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
1056 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
1057 /// true if 'D' belongs to the given declaration context.
1058 bool isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S = 0);
1060 /// Finds the scope corresponding to the given decl context, if it
1061 /// happens to be an enclosing scope. Otherwise return NULL.
1062 static Scope *getScopeForDeclContext(Scope *S, DeclContext *DC);
1064 /// Subroutines of ActOnDeclarator().
1065 TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T,
1066 TypeSourceInfo *TInfo);
1067 void MergeTypeDefDecl(TypedefDecl *New, LookupResult &OldDecls);
1068 bool MergeFunctionDecl(FunctionDecl *New, Decl *Old);
1069 bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old);
1070 void MergeVarDeclTypes(VarDecl *New, VarDecl *Old);
1071 void MergeVarDecl(VarDecl *New, LookupResult &OldDecls);
1072 bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old);
1074 // AssignmentAction - This is used by all the assignment diagnostic functions
1075 // to represent what is actually causing the operation
1076 enum AssignmentAction {
1086 /// C++ Overloading.
1088 /// This is a legitimate overload: the existing declarations are
1089 /// functions or function templates with different signatures.
1092 /// This is not an overload because the signature exactly matches
1093 /// an existing declaration.
1096 /// This is not an overload because the lookup results contain a
1100 OverloadKind CheckOverload(Scope *S,
1102 const LookupResult &OldDecls,
1103 NamedDecl *&OldDecl,
1104 bool IsForUsingDecl);
1105 bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl);
1107 bool TryImplicitConversion(InitializationSequence &Sequence,
1108 const InitializedEntity &Entity,
1110 bool SuppressUserConversions,
1112 bool InOverloadResolution,
1115 bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType);
1116 bool IsFloatingPointPromotion(QualType FromType, QualType ToType);
1117 bool IsComplexPromotion(QualType FromType, QualType ToType);
1118 bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
1119 bool InOverloadResolution,
1120 QualType& ConvertedType, bool &IncompatibleObjC);
1121 bool isObjCPointerConversion(QualType FromType, QualType ToType,
1122 QualType& ConvertedType, bool &IncompatibleObjC);
1123 bool IsBlockPointerConversion(QualType FromType, QualType ToType,
1124 QualType& ConvertedType);
1125 bool FunctionArgTypesAreEqual(const FunctionProtoType *OldType,
1126 const FunctionProtoType *NewType);
1128 bool CheckPointerConversion(Expr *From, QualType ToType,
1130 CXXCastPath& BasePath,
1131 bool IgnoreBaseAccess);
1132 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType,
1133 bool InOverloadResolution,
1134 QualType &ConvertedType);
1135 bool CheckMemberPointerConversion(Expr *From, QualType ToType,
1137 CXXCastPath &BasePath,
1138 bool IgnoreBaseAccess);
1139 bool IsQualificationConversion(QualType FromType, QualType ToType,
1141 bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
1144 ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity,
1145 const VarDecl *NRVOCandidate,
1146 QualType ResultType,
1149 ExprResult PerformCopyInitialization(const InitializedEntity &Entity,
1150 SourceLocation EqualLoc,
1152 bool PerformObjectArgumentInitialization(Expr *&From,
1153 NestedNameSpecifier *Qualifier,
1154 NamedDecl *FoundDecl,
1155 CXXMethodDecl *Method);
1157 bool PerformContextuallyConvertToBool(Expr *&From);
1158 bool PerformContextuallyConvertToObjCId(Expr *&From);
1161 ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *FromE,
1162 const PartialDiagnostic &NotIntDiag,
1163 const PartialDiagnostic &IncompleteDiag,
1164 const PartialDiagnostic &ExplicitConvDiag,
1165 const PartialDiagnostic &ExplicitConvNote,
1166 const PartialDiagnostic &AmbigDiag,
1167 const PartialDiagnostic &AmbigNote,
1168 const PartialDiagnostic &ConvDiag);
1170 bool PerformObjectMemberConversion(Expr *&From,
1171 NestedNameSpecifier *Qualifier,
1172 NamedDecl *FoundDecl,
1175 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
1176 // TODO: make this is a typesafe union.
1177 typedef llvm::SmallPtrSet<DeclContext *, 16> AssociatedNamespaceSet;
1178 typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet;
1180 void AddOverloadCandidate(NamedDecl *Function,
1181 DeclAccessPair FoundDecl,
1182 Expr **Args, unsigned NumArgs,
1183 OverloadCandidateSet &CandidateSet);
1185 void AddOverloadCandidate(FunctionDecl *Function,
1186 DeclAccessPair FoundDecl,
1187 Expr **Args, unsigned NumArgs,
1188 OverloadCandidateSet& CandidateSet,
1189 bool SuppressUserConversions = false,
1190 bool PartialOverloading = false);
1191 void AddFunctionCandidates(const UnresolvedSetImpl &Functions,
1192 Expr **Args, unsigned NumArgs,
1193 OverloadCandidateSet& CandidateSet,
1194 bool SuppressUserConversions = false);
1195 void AddMethodCandidate(DeclAccessPair FoundDecl,
1196 QualType ObjectType,
1197 Expr::Classification ObjectClassification,
1198 Expr **Args, unsigned NumArgs,
1199 OverloadCandidateSet& CandidateSet,
1200 bool SuppressUserConversion = false);
1201 void AddMethodCandidate(CXXMethodDecl *Method,
1202 DeclAccessPair FoundDecl,
1203 CXXRecordDecl *ActingContext, QualType ObjectType,
1204 Expr::Classification ObjectClassification,
1205 Expr **Args, unsigned NumArgs,
1206 OverloadCandidateSet& CandidateSet,
1207 bool SuppressUserConversions = false);
1208 void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
1209 DeclAccessPair FoundDecl,
1210 CXXRecordDecl *ActingContext,
1211 const TemplateArgumentListInfo *ExplicitTemplateArgs,
1212 QualType ObjectType,
1213 Expr::Classification ObjectClassification,
1214 Expr **Args, unsigned NumArgs,
1215 OverloadCandidateSet& CandidateSet,
1216 bool SuppressUserConversions = false);
1217 void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
1218 DeclAccessPair FoundDecl,
1219 const TemplateArgumentListInfo *ExplicitTemplateArgs,
1220 Expr **Args, unsigned NumArgs,
1221 OverloadCandidateSet& CandidateSet,
1222 bool SuppressUserConversions = false);
1223 void AddConversionCandidate(CXXConversionDecl *Conversion,
1224 DeclAccessPair FoundDecl,
1225 CXXRecordDecl *ActingContext,
1226 Expr *From, QualType ToType,
1227 OverloadCandidateSet& CandidateSet);
1228 void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate,
1229 DeclAccessPair FoundDecl,
1230 CXXRecordDecl *ActingContext,
1231 Expr *From, QualType ToType,
1232 OverloadCandidateSet &CandidateSet);
1233 void AddSurrogateCandidate(CXXConversionDecl *Conversion,
1234 DeclAccessPair FoundDecl,
1235 CXXRecordDecl *ActingContext,
1236 const FunctionProtoType *Proto,
1237 Expr *Object, Expr **Args, unsigned NumArgs,
1238 OverloadCandidateSet& CandidateSet);
1239 void AddMemberOperatorCandidates(OverloadedOperatorKind Op,
1240 SourceLocation OpLoc,
1241 Expr **Args, unsigned NumArgs,
1242 OverloadCandidateSet& CandidateSet,
1243 SourceRange OpRange = SourceRange());
1244 void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys,
1245 Expr **Args, unsigned NumArgs,
1246 OverloadCandidateSet& CandidateSet,
1247 bool IsAssignmentOperator = false,
1248 unsigned NumContextualBoolArguments = 0);
1249 void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op,
1250 SourceLocation OpLoc,
1251 Expr **Args, unsigned NumArgs,
1252 OverloadCandidateSet& CandidateSet);
1253 void AddArgumentDependentLookupCandidates(DeclarationName Name,
1255 Expr **Args, unsigned NumArgs,
1256 const TemplateArgumentListInfo *ExplicitTemplateArgs,
1257 OverloadCandidateSet& CandidateSet,
1258 bool PartialOverloading = false);
1260 // Emit as a 'note' the specific overload candidate
1261 void NoteOverloadCandidate(FunctionDecl *Fn);
1263 // Emit as a series of 'note's all template and non-templates
1264 // identified by the expression Expr
1265 void NoteAllOverloadCandidates(Expr* E);
1267 // [PossiblyAFunctionType] --> [Return]
1268 // NonFunctionType --> NonFunctionType
1270 // R (*)(A) --> R (A)
1271 // R (&)(A) --> R (A)
1272 // R (S::*)(A) --> R (A)
1273 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType);
1275 FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType,
1277 DeclAccessPair &Found);
1279 FunctionDecl *ResolveSingleFunctionTemplateSpecialization(Expr *From,
1280 bool Complain = false,
1281 DeclAccessPair* Found = 0);
1283 Expr *FixOverloadedFunctionReference(Expr *E,
1284 DeclAccessPair FoundDecl,
1286 ExprResult FixOverloadedFunctionReference(ExprResult,
1287 DeclAccessPair FoundDecl,
1290 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE,
1291 Expr **Args, unsigned NumArgs,
1292 OverloadCandidateSet &CandidateSet,
1293 bool PartialOverloading = false);
1295 ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn,
1296 UnresolvedLookupExpr *ULE,
1297 SourceLocation LParenLoc,
1298 Expr **Args, unsigned NumArgs,
1299 SourceLocation RParenLoc,
1302 ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc,
1304 const UnresolvedSetImpl &Fns,
1307 ExprResult CreateOverloadedBinOp(SourceLocation OpLoc,
1309 const UnresolvedSetImpl &Fns,
1310 Expr *LHS, Expr *RHS);
1312 ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc,
1313 SourceLocation RLoc,
1314 Expr *Base,Expr *Idx);
1317 BuildCallToMemberFunction(Scope *S, Expr *MemExpr,
1318 SourceLocation LParenLoc, Expr **Args,
1319 unsigned NumArgs, SourceLocation RParenLoc);
1321 BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc,
1322 Expr **Args, unsigned NumArgs,
1323 SourceLocation RParenLoc);
1325 ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
1326 SourceLocation OpLoc);
1328 /// CheckCallReturnType - Checks that a call expression's return type is
1329 /// complete. Returns true on failure. The location passed in is the location
1330 /// that best represents the call.
1331 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc,
1332 CallExpr *CE, FunctionDecl *FD);
1334 /// Helpers for dealing with blocks and functions.
1335 bool CheckParmsForFunctionDef(ParmVarDecl **Param, ParmVarDecl **ParamEnd,
1336 bool CheckParameterNames);
1337 void CheckCXXDefaultArguments(FunctionDecl *FD);
1338 void CheckExtraCXXDefaultArguments(Declarator &D);
1339 Scope *getNonFieldDeclScope(Scope *S);
1341 /// \name Name lookup
1343 /// These routines provide name lookup that is used during semantic
1344 /// analysis to resolve the various kinds of names (identifiers,
1345 /// overloaded operator names, constructor names, etc.) into zero or
1346 /// more declarations within a particular scope. The major entry
1347 /// points are LookupName, which performs unqualified name lookup,
1348 /// and LookupQualifiedName, which performs qualified name lookup.
1350 /// All name lookup is performed based on some specific criteria,
1351 /// which specify what names will be visible to name lookup and how
1352 /// far name lookup should work. These criteria are important both
1353 /// for capturing language semantics (certain lookups will ignore
1354 /// certain names, for example) and for performance, since name
1355 /// lookup is often a bottleneck in the compilation of C++. Name
1356 /// lookup criteria is specified via the LookupCriteria enumeration.
1358 /// The results of name lookup can vary based on the kind of name
1359 /// lookup performed, the current language, and the translation
1360 /// unit. In C, for example, name lookup will either return nothing
1361 /// (no entity found) or a single declaration. In C++, name lookup
1362 /// can additionally refer to a set of overloaded functions or
1363 /// result in an ambiguity. All of the possible results of name
1364 /// lookup are captured by the LookupResult class, which provides
1365 /// the ability to distinguish among them.
1368 /// @brief Describes the kind of name lookup to perform.
1369 enum LookupNameKind {
1370 /// Ordinary name lookup, which finds ordinary names (functions,
1371 /// variables, typedefs, etc.) in C and most kinds of names
1372 /// (functions, variables, members, types, etc.) in C++.
1373 LookupOrdinaryName = 0,
1374 /// Tag name lookup, which finds the names of enums, classes,
1375 /// structs, and unions.
1377 /// Label name lookup.
1379 /// Member name lookup, which finds the names of
1380 /// class/struct/union members.
1382 /// Look up of an operator name (e.g., operator+) for use with
1383 /// operator overloading. This lookup is similar to ordinary name
1384 /// lookup, but will ignore any declarations that are class members.
1386 /// Look up of a name that precedes the '::' scope resolution
1387 /// operator in C++. This lookup completely ignores operator, object,
1388 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
1389 LookupNestedNameSpecifierName,
1390 /// Look up a namespace name within a C++ using directive or
1391 /// namespace alias definition, ignoring non-namespace names (C++
1392 /// [basic.lookup.udir]p1).
1393 LookupNamespaceName,
1394 /// Look up all declarations in a scope with the given name,
1395 /// including resolved using declarations. This is appropriate
1396 /// for checking redeclarations for a using declaration.
1397 LookupUsingDeclName,
1398 /// Look up an ordinary name that is going to be redeclared as a
1399 /// name with linkage. This lookup ignores any declarations that
1400 /// are outside of the current scope unless they have linkage. See
1401 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
1402 LookupRedeclarationWithLinkage,
1403 /// Look up the name of an Objective-C protocol.
1404 LookupObjCProtocolName,
1405 /// \brief Look up any declaration with any name.
1409 /// \brief Specifies whether (or how) name lookup is being performed for a
1410 /// redeclaration (vs. a reference).
1411 enum RedeclarationKind {
1412 /// \brief The lookup is a reference to this name that is not for the
1413 /// purpose of redeclaring the name.
1414 NotForRedeclaration = 0,
1415 /// \brief The lookup results will be used for redeclaration of a name,
1416 /// if an entity by that name already exists.
1421 bool CppLookupName(LookupResult &R, Scope *S);
1424 /// \brief Look up a name, looking for a single declaration. Return
1425 /// null if the results were absent, ambiguous, or overloaded.
1427 /// It is preferable to use the elaborated form and explicitly handle
1428 /// ambiguity and overloaded.
1429 NamedDecl *LookupSingleName(Scope *S, DeclarationName Name,
1431 LookupNameKind NameKind,
1432 RedeclarationKind Redecl
1433 = NotForRedeclaration);
1434 bool LookupName(LookupResult &R, Scope *S,
1435 bool AllowBuiltinCreation = false);
1436 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
1437 bool InUnqualifiedLookup = false);
1438 bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
1439 bool AllowBuiltinCreation = false,
1440 bool EnteringContext = false);
1441 ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc);
1443 void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
1444 QualType T1, QualType T2,
1445 UnresolvedSetImpl &Functions);
1447 LabelDecl *LookupOrCreateLabel(IdentifierInfo *II, SourceLocation Loc,
1448 bool isLocalLabel = false);
1450 DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class);
1451 CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class);
1453 void ArgumentDependentLookup(DeclarationName Name, bool Operator,
1454 Expr **Args, unsigned NumArgs,
1455 ADLResult &Functions);
1457 void LookupVisibleDecls(Scope *S, LookupNameKind Kind,
1458 VisibleDeclConsumer &Consumer,
1459 bool IncludeGlobalScope = true);
1460 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
1461 VisibleDeclConsumer &Consumer,
1462 bool IncludeGlobalScope = true);
1464 /// \brief The context in which typo-correction occurs.
1466 /// The typo-correction context affects which keywords (if any) are
1467 /// considered when trying to correct for typos.
1468 enum CorrectTypoContext {
1469 /// \brief An unknown context, where any keyword might be valid.
1471 /// \brief A context where no keywords are used (e.g. we expect an actual
1474 /// \brief A context where we're correcting a type name.
1476 /// \brief An expression context.
1478 /// \brief A type cast, or anything else that can be followed by a '<'.
1480 /// \brief A member lookup context.
1482 /// \brief An Objective-C ivar lookup context (e.g., self->ivar).
1484 /// \brief An Objective-C property lookup context (e.g., self.prop).
1485 CTC_ObjCPropertyLookup,
1486 /// \brief The receiver of an Objective-C message send within an
1487 /// Objective-C method where 'super' is a valid keyword.
1488 CTC_ObjCMessageReceiver
1491 DeclarationName CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS,
1492 DeclContext *MemberContext = 0,
1493 bool EnteringContext = false,
1494 CorrectTypoContext CTC = CTC_Unknown,
1495 const ObjCObjectPointerType *OPT = 0);
1497 void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs,
1498 AssociatedNamespaceSet &AssociatedNamespaces,
1499 AssociatedClassSet &AssociatedClasses);
1501 bool DiagnoseAmbiguousLookup(LookupResult &Result);
1504 ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id,
1505 SourceLocation IdLoc,
1506 bool TypoCorrection = false);
1507 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID,
1508 Scope *S, bool ForRedeclaration,
1509 SourceLocation Loc);
1510 NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II,
1512 void AddKnownFunctionAttributes(FunctionDecl *FD);
1514 // More parsing and symbol table subroutines.
1516 // Decl attributes - this routine is the top level dispatcher.
1517 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD,
1518 bool NonInheritable = true, bool Inheritable = true);
1519 void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL,
1520 bool NonInheritable = true, bool Inheritable = true);
1522 bool CheckRegparmAttr(const AttributeList &attr, unsigned &value);
1523 bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC);
1524 bool CheckNoReturnAttr(const AttributeList &attr);
1526 void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method,
1527 bool &IncompleteImpl, unsigned DiagID);
1528 void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod,
1529 ObjCMethodDecl *MethodDecl,
1530 bool IsProtocolMethodDecl);
1532 bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl,
1533 ObjCInterfaceDecl *IDecl);
1535 typedef llvm::DenseSet<Selector, llvm::DenseMapInfo<Selector> > SelectorSet;
1537 /// CheckProtocolMethodDefs - This routine checks unimplemented
1538 /// methods declared in protocol, and those referenced by it.
1539 /// \param IDecl - Used for checking for methods which may have been
1541 void CheckProtocolMethodDefs(SourceLocation ImpLoc,
1542 ObjCProtocolDecl *PDecl,
1543 bool& IncompleteImpl,
1544 const SelectorSet &InsMap,
1545 const SelectorSet &ClsMap,
1546 ObjCContainerDecl *CDecl);
1548 /// CheckImplementationIvars - This routine checks if the instance variables
1549 /// listed in the implelementation match those listed in the interface.
1550 void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
1551 ObjCIvarDecl **Fields, unsigned nIvars,
1552 SourceLocation Loc);
1554 /// \brief Determine whether we can synthesize a provisional ivar for the
1556 ObjCPropertyDecl *canSynthesizeProvisionalIvar(IdentifierInfo *II);
1558 /// \brief Determine whether we can synthesize a provisional ivar for the
1560 bool canSynthesizeProvisionalIvar(ObjCPropertyDecl *Property);
1562 /// ImplMethodsVsClassMethods - This is main routine to warn if any method
1563 /// remains unimplemented in the class or category @implementation.
1564 void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl,
1565 ObjCContainerDecl* IDecl,
1566 bool IncompleteImpl = false);
1568 /// DiagnoseUnimplementedProperties - This routine warns on those properties
1569 /// which must be implemented by this implementation.
1570 void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl,
1571 ObjCContainerDecl *CDecl,
1572 const SelectorSet &InsMap);
1574 /// DefaultSynthesizeProperties - This routine default synthesizes all
1575 /// properties which must be synthesized in class's @implementation.
1576 void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl,
1577 ObjCInterfaceDecl *IDecl);
1579 /// CollectImmediateProperties - This routine collects all properties in
1580 /// the class and its conforming protocols; but not those it its super class.
1581 void CollectImmediateProperties(ObjCContainerDecl *CDecl,
1582 llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap,
1583 llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& SuperPropMap);
1586 /// LookupPropertyDecl - Looks up a property in the current class and all
1588 ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl,
1589 IdentifierInfo *II);
1591 /// Called by ActOnProperty to handle @property declarations in
1592 //// class extensions.
1593 Decl *HandlePropertyInClassExtension(Scope *S,
1594 ObjCCategoryDecl *CDecl,
1595 SourceLocation AtLoc,
1596 FieldDeclarator &FD,
1599 const bool isAssign,
1600 const bool isReadWrite,
1601 const unsigned Attributes,
1602 bool *isOverridingProperty,
1604 tok::ObjCKeywordKind MethodImplKind);
1606 /// Called by ActOnProperty and HandlePropertyInClassExtension to
1607 /// handle creating the ObjcPropertyDecl for a category or @interface.
1608 ObjCPropertyDecl *CreatePropertyDecl(Scope *S,
1609 ObjCContainerDecl *CDecl,
1610 SourceLocation AtLoc,
1611 FieldDeclarator &FD,
1614 const bool isAssign,
1615 const bool isReadWrite,
1616 const unsigned Attributes,
1618 tok::ObjCKeywordKind MethodImplKind,
1619 DeclContext *lexicalDC = 0);
1621 /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
1622 /// warning) when atomic property has one but not the other user-declared
1623 /// setter or getter.
1624 void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl,
1625 ObjCContainerDecl* IDecl);
1627 void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID);
1629 /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
1630 /// true, or false, accordingly.
1631 bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method,
1632 const ObjCMethodDecl *PrevMethod,
1633 bool matchBasedOnSizeAndAlignment = false,
1634 bool matchBasedOnStrictEqulity = false);
1636 /// MatchAllMethodDeclarations - Check methods declaraed in interface or
1637 /// or protocol against those declared in their implementations.
1638 void MatchAllMethodDeclarations(const SelectorSet &InsMap,
1639 const SelectorSet &ClsMap,
1640 SelectorSet &InsMapSeen,
1641 SelectorSet &ClsMapSeen,
1642 ObjCImplDecl* IMPDecl,
1643 ObjCContainerDecl* IDecl,
1644 bool &IncompleteImpl,
1645 bool ImmediateClass);
1648 /// AddMethodToGlobalPool - Add an instance or factory method to the global
1649 /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
1650 void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
1652 /// LookupMethodInGlobalPool - Returns the instance or factory method and
1653 /// optionally warns if there are multiple signatures.
1654 ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
1655 bool receiverIdOrClass,
1656 bool warn, bool instance);
1659 /// AddInstanceMethodToGlobalPool - All instance methods in a translation
1660 /// unit are added to a global pool. This allows us to efficiently associate
1661 /// a selector with a method declaraation for purposes of typechecking
1662 /// messages sent to "id" (where the class of the object is unknown).
1663 void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
1664 AddMethodToGlobalPool(Method, impl, /*instance*/true);
1667 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
1668 void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) {
1669 AddMethodToGlobalPool(Method, impl, /*instance*/false);
1672 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
1673 /// there are multiple signatures.
1674 ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R,
1675 bool receiverIdOrClass=false,
1677 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
1678 warn, /*instance*/true);
1681 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
1682 /// there are multiple signatures.
1683 ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R,
1684 bool receiverIdOrClass=false,
1686 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
1687 warn, /*instance*/false);
1690 /// LookupImplementedMethodInGlobalPool - Returns the method which has an
1692 ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel);
1694 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
1696 void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI,
1697 llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars);
1698 //===--------------------------------------------------------------------===//
1699 // Statement Parsing Callbacks: SemaStmt.cpp.
1703 FullExprArg(Sema &actions) : E(0) { }
1705 // FIXME: The const_cast here is ugly. RValue references would make this
1706 // much nicer (or we could duplicate a bunch of the move semantics
1707 // emulation code from Ownership.h).
1708 FullExprArg(const FullExprArg& Other) : E(Other.E) {}
1710 ExprResult release() {
1714 Expr *get() const { return E; }
1716 Expr *operator->() {
1721 // FIXME: No need to make the entire Sema class a friend when it's just
1722 // Sema::MakeFullExpr that needs access to the constructor below.
1725 explicit FullExprArg(Expr *expr) : E(expr) {}
1730 FullExprArg MakeFullExpr(Expr *Arg) {
1731 return FullExprArg(ActOnFinishFullExpr(Arg).release());
1734 StmtResult ActOnExprStmt(FullExprArg Expr);
1736 StmtResult ActOnNullStmt(SourceLocation SemiLoc,
1737 bool LeadingEmptyMacro = false);
1738 StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R,
1741 StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,
1742 SourceLocation StartLoc,
1743 SourceLocation EndLoc);
1744 void ActOnForEachDeclStmt(DeclGroupPtrTy Decl);
1745 StmtResult ActOnForEachLValueExpr(Expr *E);
1746 StmtResult ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal,
1747 SourceLocation DotDotDotLoc, Expr *RHSVal,
1748 SourceLocation ColonLoc);
1749 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt);
1751 StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc,
1752 SourceLocation ColonLoc,
1753 Stmt *SubStmt, Scope *CurScope);
1754 StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl,
1755 SourceLocation ColonLoc, Stmt *SubStmt);
1757 StmtResult ActOnIfStmt(SourceLocation IfLoc,
1758 FullExprArg CondVal, Decl *CondVar,
1760 SourceLocation ElseLoc, Stmt *ElseVal);
1761 StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc,
1764 StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc,
1765 Stmt *Switch, Stmt *Body);
1766 StmtResult ActOnWhileStmt(SourceLocation WhileLoc,
1768 Decl *CondVar, Stmt *Body);
1769 StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body,
1770 SourceLocation WhileLoc,
1771 SourceLocation CondLParen, Expr *Cond,
1772 SourceLocation CondRParen);
1774 StmtResult ActOnForStmt(SourceLocation ForLoc,
1775 SourceLocation LParenLoc,
1776 Stmt *First, FullExprArg Second,
1779 SourceLocation RParenLoc,
1781 StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc,
1782 SourceLocation LParenLoc,
1783 Stmt *First, Expr *Second,
1784 SourceLocation RParenLoc, Stmt *Body);
1786 StmtResult ActOnGotoStmt(SourceLocation GotoLoc,
1787 SourceLocation LabelLoc,
1788 LabelDecl *TheDecl);
1789 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc,
1790 SourceLocation StarLoc,
1792 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope);
1793 StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope);
1795 const VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E,
1796 bool AllowFunctionParameters);
1798 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
1799 StmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp);
1801 StmtResult ActOnAsmStmt(SourceLocation AsmLoc,
1802 bool IsSimple, bool IsVolatile,
1803 unsigned NumOutputs, unsigned NumInputs,
1804 IdentifierInfo **Names,
1805 MultiExprArg Constraints,
1808 MultiExprArg Clobbers,
1809 SourceLocation RParenLoc,
1810 bool MSAsm = false);
1813 VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType,
1814 IdentifierInfo *Name, SourceLocation NameLoc,
1815 bool Invalid = false);
1817 Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D);
1819 StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen,
1820 Decl *Parm, Stmt *Body);
1822 StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body);
1824 StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
1825 MultiStmtArg Catch, Stmt *Finally);
1827 StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw);
1828 StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
1830 StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
1834 VarDecl *BuildExceptionDeclaration(Scope *S,
1835 TypeSourceInfo *TInfo,
1836 IdentifierInfo *Name,
1837 SourceLocation Loc);
1838 Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D);
1840 StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc,
1841 Decl *ExDecl, Stmt *HandlerBlock);
1842 StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
1843 MultiStmtArg Handlers);
1844 void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock);
1846 bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const;
1848 /// \brief If it's a file scoped decl that must warn if not used, keep track
1850 void MarkUnusedFileScopedDecl(const DeclaratorDecl *D);
1852 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
1853 /// whose result is unused, warn.
1854 void DiagnoseUnusedExprResult(const Stmt *S);
1855 void DiagnoseUnusedDecl(const NamedDecl *ND);
1857 ParsingDeclState PushParsingDeclaration() {
1858 return DelayedDiagnostics.pushParsingDecl();
1860 void PopParsingDeclaration(ParsingDeclState state, Decl *decl) {
1861 DelayedDiagnostics::popParsingDecl(*this, state, decl);
1864 typedef ProcessingContextState ParsingClassState;
1865 ParsingClassState PushParsingClass() {
1866 return DelayedDiagnostics.pushContext();
1868 void PopParsingClass(ParsingClassState state) {
1869 DelayedDiagnostics.popContext(state);
1872 void EmitDeprecationWarning(NamedDecl *D, llvm::StringRef Message,
1873 SourceLocation Loc, bool UnknownObjCClass=false);
1875 void HandleDelayedDeprecationCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
1877 //===--------------------------------------------------------------------===//
1878 // Expression Parsing Callbacks: SemaExpr.cpp.
1880 bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc,
1881 bool UnknownObjCClass=false);
1882 bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD,
1883 ObjCMethodDecl *Getter,
1884 SourceLocation Loc);
1885 void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc,
1886 Expr **Args, unsigned NumArgs);
1888 void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext);
1890 void PopExpressionEvaluationContext();
1892 void MarkDeclarationReferenced(SourceLocation Loc, Decl *D);
1893 void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T);
1894 void MarkDeclarationsReferencedInExpr(Expr *E);
1896 /// \brief Conditionally issue a diagnostic based on the current
1897 /// evaluation context.
1899 /// \param stmt - If stmt is non-null, delay reporting the diagnostic until
1900 /// the function body is parsed, and then do a basic reachability analysis to
1901 /// determine if the statement is reachable. If it is unreachable, the
1902 /// diagnostic will not be emitted.
1903 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *stmt,
1904 const PartialDiagnostic &PD);
1906 // Primary Expressions.
1907 SourceRange getExprRange(Expr *E) const;
1909 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, UnqualifiedId &Name,
1910 bool HasTrailingLParen, bool IsAddressOfOperand);
1912 bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R,
1913 CorrectTypoContext CTC = CTC_Unknown);
1915 ExprResult LookupInObjCMethod(LookupResult &R, Scope *S, IdentifierInfo *II,
1916 bool AllowBuiltinCreation=false);
1918 ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS,
1919 const DeclarationNameInfo &NameInfo,
1920 bool isAddressOfOperand,
1921 const TemplateArgumentListInfo *TemplateArgs);
1923 ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
1926 const CXXScopeSpec *SS = 0);
1927 ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty,
1929 const DeclarationNameInfo &NameInfo,
1930 const CXXScopeSpec *SS = 0);
1932 BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS,
1933 SourceLocation nameLoc,
1934 IndirectFieldDecl *indirectField,
1935 Expr *baseObjectExpr = 0,
1936 SourceLocation opLoc = SourceLocation());
1937 ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS,
1939 const TemplateArgumentListInfo *TemplateArgs);
1940 ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS,
1942 const TemplateArgumentListInfo *TemplateArgs,
1943 bool IsDefiniteInstance);
1944 bool UseArgumentDependentLookup(const CXXScopeSpec &SS,
1945 const LookupResult &R,
1946 bool HasTrailingLParen);
1948 ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS,
1949 const DeclarationNameInfo &NameInfo);
1950 ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS,
1951 const DeclarationNameInfo &NameInfo,
1952 const TemplateArgumentListInfo *TemplateArgs);
1954 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
1957 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS,
1958 const DeclarationNameInfo &NameInfo,
1961 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
1962 ExprResult ActOnNumericConstant(const Token &);
1963 ExprResult ActOnCharacterConstant(const Token &);
1964 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *Val);
1965 ExprResult ActOnParenOrParenListExpr(SourceLocation L,
1968 ParsedType TypeOfCast = ParsedType());
1970 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
1971 /// fragments (e.g. "foo" "bar" L"baz").
1972 ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks);
1974 // Binary/Unary Operators. 'Tok' is the token for the operator.
1975 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
1977 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc,
1978 UnaryOperatorKind Opc, Expr *input);
1979 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
1980 tok::TokenKind Op, Expr *Input);
1982 ExprResult CreateSizeOfAlignOfExpr(TypeSourceInfo *T,
1983 SourceLocation OpLoc,
1984 bool isSizeOf, SourceRange R);
1985 ExprResult CreateSizeOfAlignOfExpr(Expr *E, SourceLocation OpLoc,
1986 bool isSizeOf, SourceRange R);
1988 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc, bool isSizeof, bool isType,
1989 void *TyOrEx, const SourceRange &ArgRange);
1991 ExprResult CheckPlaceholderExpr(Expr *E, SourceLocation Loc);
1993 bool CheckSizeOfAlignOfOperand(QualType type, SourceLocation OpLoc,
1994 SourceRange R, bool isSizeof);
1995 ExprResult ActOnSizeofParameterPackExpr(Scope *S,
1996 SourceLocation OpLoc,
1997 IdentifierInfo &Name,
1998 SourceLocation NameLoc,
1999 SourceLocation RParenLoc);
2000 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc,
2001 tok::TokenKind Kind, Expr *Input);
2003 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc,
2004 Expr *Idx, SourceLocation RLoc);
2005 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
2006 Expr *Idx, SourceLocation RLoc);
2008 ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType,
2009 SourceLocation OpLoc, bool IsArrow,
2011 NamedDecl *FirstQualifierInScope,
2012 const DeclarationNameInfo &NameInfo,
2013 const TemplateArgumentListInfo *TemplateArgs);
2015 ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType,
2016 SourceLocation OpLoc, bool IsArrow,
2017 const CXXScopeSpec &SS,
2018 NamedDecl *FirstQualifierInScope,
2020 const TemplateArgumentListInfo *TemplateArgs,
2021 bool SuppressQualifierCheck = false);
2023 ExprResult LookupMemberExpr(LookupResult &R, Expr *&Base,
2024 bool &IsArrow, SourceLocation OpLoc,
2027 bool HasTemplateArgs);
2029 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType,
2030 const CXXScopeSpec &SS,
2031 const LookupResult &R);
2033 ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType,
2034 bool IsArrow, SourceLocation OpLoc,
2035 const CXXScopeSpec &SS,
2036 NamedDecl *FirstQualifierInScope,
2037 const DeclarationNameInfo &NameInfo,
2038 const TemplateArgumentListInfo *TemplateArgs);
2040 ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base,
2041 SourceLocation OpLoc,
2042 tok::TokenKind OpKind,
2044 UnqualifiedId &Member,
2046 bool HasTrailingLParen);
2048 void ActOnDefaultCtorInitializers(Decl *CDtorDecl);
2049 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn,
2050 FunctionDecl *FDecl,
2051 const FunctionProtoType *Proto,
2052 Expr **Args, unsigned NumArgs,
2053 SourceLocation RParenLoc);
2055 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
2056 /// This provides the location of the left/right parens and a list of comma
2058 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc,
2059 MultiExprArg Args, SourceLocation RParenLoc,
2060 Expr *ExecConfig = 0);
2061 ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
2062 SourceLocation LParenLoc,
2063 Expr **Args, unsigned NumArgs,
2064 SourceLocation RParenLoc,
2065 Expr *ExecConfig = 0);
2067 ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc,
2068 MultiExprArg ExecConfig, SourceLocation GGGLoc);
2070 ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc,
2071 ParsedType Ty, SourceLocation RParenLoc,
2073 ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc,
2075 SourceLocation RParenLoc,
2078 bool TypeIsVectorType(ParsedType Ty) {
2079 return GetTypeFromParser(Ty)->isVectorType();
2082 ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME);
2083 ExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc,
2084 SourceLocation RParenLoc, Expr *E,
2085 TypeSourceInfo *TInfo);
2087 ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc,
2089 SourceLocation RParenLoc,
2092 ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc,
2093 TypeSourceInfo *TInfo,
2094 SourceLocation RParenLoc,
2097 ExprResult ActOnInitList(SourceLocation LParenLoc,
2098 MultiExprArg InitList,
2099 SourceLocation RParenLoc);
2101 ExprResult ActOnDesignatedInitializer(Designation &Desig,
2106 ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc,
2107 tok::TokenKind Kind, Expr *LHS, Expr *RHS);
2108 ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc,
2109 BinaryOperatorKind Opc, Expr *lhs, Expr *rhs);
2110 ExprResult CreateBuiltinBinOp(SourceLocation TokLoc,
2111 BinaryOperatorKind Opc, Expr *lhs, Expr *rhs);
2113 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
2114 /// in the case of a the GNU conditional expr extension.
2115 ExprResult ActOnConditionalOp(SourceLocation QuestionLoc,
2116 SourceLocation ColonLoc,
2117 Expr *Cond, Expr *LHS, Expr *RHS);
2119 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
2120 ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc,
2123 ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt,
2124 SourceLocation RPLoc); // "({..})"
2126 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
2127 struct OffsetOfComponent {
2128 SourceLocation LocStart, LocEnd;
2129 bool isBrackets; // true if [expr], false if .ident
2131 IdentifierInfo *IdentInfo;
2136 /// __builtin_offsetof(type, a.b[123][456].c)
2137 ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc,
2138 TypeSourceInfo *TInfo,
2139 OffsetOfComponent *CompPtr,
2140 unsigned NumComponents,
2141 SourceLocation RParenLoc);
2142 ExprResult ActOnBuiltinOffsetOf(Scope *S,
2143 SourceLocation BuiltinLoc,
2144 SourceLocation TypeLoc,
2146 OffsetOfComponent *CompPtr,
2147 unsigned NumComponents,
2148 SourceLocation RParenLoc);
2150 // __builtin_choose_expr(constExpr, expr1, expr2)
2151 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc,
2152 Expr *cond, Expr *expr1,
2153 Expr *expr2, SourceLocation RPLoc);
2155 // __builtin_va_arg(expr, type)
2156 ExprResult ActOnVAArg(SourceLocation BuiltinLoc,
2157 Expr *expr, ParsedType type,
2158 SourceLocation RPLoc);
2159 ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc,
2160 Expr *expr, TypeSourceInfo *TInfo,
2161 SourceLocation RPLoc);
2164 ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc);
2166 //===------------------------- "Block" Extension ------------------------===//
2168 /// ActOnBlockStart - This callback is invoked when a block literal is
2170 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope);
2172 /// ActOnBlockArguments - This callback allows processing of block arguments.
2173 /// If there are no arguments, this is still invoked.
2174 void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope);
2176 /// ActOnBlockError - If there is an error parsing a block, this callback
2177 /// is invoked to pop the information about the block from the action impl.
2178 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope);
2180 /// ActOnBlockStmtExpr - This is called when the body of a block statement
2181 /// literal was successfully completed. ^(int x){...}
2182 ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc,
2183 Stmt *Body, Scope *CurScope);
2185 //===---------------------------- C++ Features --------------------------===//
2187 // Act on C++ namespaces
2188 Decl *ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc,
2189 SourceLocation IdentLoc,
2190 IdentifierInfo *Ident,
2191 SourceLocation LBrace,
2192 AttributeList *AttrList);
2193 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace);
2195 NamespaceDecl *getStdNamespace() const;
2196 NamespaceDecl *getOrCreateStdNamespace();
2198 CXXRecordDecl *getStdBadAlloc() const;
2200 Decl *ActOnUsingDirective(Scope *CurScope,
2201 SourceLocation UsingLoc,
2202 SourceLocation NamespcLoc,
2204 SourceLocation IdentLoc,
2205 IdentifierInfo *NamespcName,
2206 AttributeList *AttrList);
2208 void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir);
2210 Decl *ActOnNamespaceAliasDef(Scope *CurScope,
2211 SourceLocation NamespaceLoc,
2212 SourceLocation AliasLoc,
2213 IdentifierInfo *Alias,
2215 SourceLocation IdentLoc,
2216 IdentifierInfo *Ident);
2218 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow);
2219 bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target,
2220 const LookupResult &PreviousDecls);
2221 UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD,
2224 bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc,
2226 const CXXScopeSpec &SS,
2227 SourceLocation NameLoc,
2228 const LookupResult &Previous);
2229 bool CheckUsingDeclQualifier(SourceLocation UsingLoc,
2230 const CXXScopeSpec &SS,
2231 SourceLocation NameLoc);
2233 NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
2234 SourceLocation UsingLoc,
2236 const DeclarationNameInfo &NameInfo,
2237 AttributeList *AttrList,
2238 bool IsInstantiation,
2240 SourceLocation TypenameLoc);
2242 bool CheckInheritedConstructorUsingDecl(UsingDecl *UD);
2244 Decl *ActOnUsingDeclaration(Scope *CurScope,
2246 bool HasUsingKeyword,
2247 SourceLocation UsingLoc,
2249 UnqualifiedId &Name,
2250 AttributeList *AttrList,
2252 SourceLocation TypenameLoc);
2254 /// AddCXXDirectInitializerToDecl - This action is called immediately after
2255 /// ActOnDeclarator, when a C++ direct initializer is present.
2256 /// e.g: "int x(1);"
2257 void AddCXXDirectInitializerToDecl(Decl *Dcl,
2258 SourceLocation LParenLoc,
2260 SourceLocation RParenLoc,
2261 bool TypeMayContainAuto);
2263 /// InitializeVarWithConstructor - Creates an CXXConstructExpr
2264 /// and sets it as the initializer for the the passed in VarDecl.
2265 bool InitializeVarWithConstructor(VarDecl *VD,
2266 CXXConstructorDecl *Constructor,
2267 MultiExprArg Exprs);
2269 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
2270 /// including handling of its default argument expressions.
2272 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
2274 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
2275 CXXConstructorDecl *Constructor, MultiExprArg Exprs,
2276 bool RequiresZeroInit, unsigned ConstructKind,
2277 SourceRange ParenRange);
2279 // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
2280 // the constructor can be elidable?
2282 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
2283 CXXConstructorDecl *Constructor, bool Elidable,
2284 MultiExprArg Exprs, bool RequiresZeroInit,
2285 unsigned ConstructKind,
2286 SourceRange ParenRange);
2288 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
2289 /// the default expr if needed.
2290 ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc,
2292 ParmVarDecl *Param);
2294 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
2295 /// constructed variable.
2296 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType);
2298 /// \brief Declare the implicit default constructor for the given class.
2300 /// \param ClassDecl The class declaration into which the implicit
2301 /// default constructor will be added.
2303 /// \returns The implicitly-declared default constructor.
2304 CXXConstructorDecl *DeclareImplicitDefaultConstructor(
2305 CXXRecordDecl *ClassDecl);
2307 /// DefineImplicitDefaultConstructor - Checks for feasibility of
2308 /// defining this constructor as the default constructor.
2309 void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
2310 CXXConstructorDecl *Constructor);
2312 /// \brief Declare the implicit destructor for the given class.
2314 /// \param ClassDecl The class declaration into which the implicit
2315 /// destructor will be added.
2317 /// \returns The implicitly-declared destructor.
2318 CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl);
2320 /// DefineImplicitDestructor - Checks for feasibility of
2321 /// defining this destructor as the default destructor.
2322 void DefineImplicitDestructor(SourceLocation CurrentLocation,
2323 CXXDestructorDecl *Destructor);
2325 /// \brief Declare all inherited constructors for the given class.
2327 /// \param ClassDecl The class declaration into which the inherited
2328 /// constructors will be added.
2329 void DeclareInheritedConstructors(CXXRecordDecl *ClassDecl);
2331 /// \brief Declare the implicit copy constructor for the given class.
2333 /// \param S The scope of the class, which may be NULL if this is a
2334 /// template instantiation.
2336 /// \param ClassDecl The class declaration into which the implicit
2337 /// copy constructor will be added.
2339 /// \returns The implicitly-declared copy constructor.
2340 CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl);
2342 /// DefineImplicitCopyConstructor - Checks for feasibility of
2343 /// defining this constructor as the copy constructor.
2344 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation,
2345 CXXConstructorDecl *Constructor,
2346 unsigned TypeQuals);
2348 /// \brief Declare the implicit copy assignment operator for the given class.
2350 /// \param S The scope of the class, which may be NULL if this is a
2351 /// template instantiation.
2353 /// \param ClassDecl The class declaration into which the implicit
2354 /// copy-assignment operator will be added.
2356 /// \returns The implicitly-declared copy assignment operator.
2357 CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl);
2359 /// \brief Defined an implicitly-declared copy assignment operator.
2360 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation,
2361 CXXMethodDecl *MethodDecl);
2363 /// \brief Force the declaration of any implicitly-declared members of this
2365 void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class);
2367 /// MaybeBindToTemporary - If the passed in expression has a record type with
2368 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
2369 /// it simply returns the passed in expression.
2370 ExprResult MaybeBindToTemporary(Expr *E);
2372 bool CompleteConstructorCall(CXXConstructorDecl *Constructor,
2373 MultiExprArg ArgsPtr,
2375 ASTOwningVector<Expr*> &ConvertedArgs);
2377 ParsedType getDestructorName(SourceLocation TildeLoc,
2378 IdentifierInfo &II, SourceLocation NameLoc,
2379 Scope *S, CXXScopeSpec &SS,
2380 ParsedType ObjectType,
2381 bool EnteringContext);
2383 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
2384 ExprResult ActOnCXXNamedCast(SourceLocation OpLoc,
2385 tok::TokenKind Kind,
2386 SourceLocation LAngleBracketLoc,
2388 SourceLocation RAngleBracketLoc,
2389 SourceLocation LParenLoc,
2391 SourceLocation RParenLoc);
2393 ExprResult BuildCXXNamedCast(SourceLocation OpLoc,
2394 tok::TokenKind Kind,
2397 SourceRange AngleBrackets,
2398 SourceRange Parens);
2400 ExprResult BuildCXXTypeId(QualType TypeInfoType,
2401 SourceLocation TypeidLoc,
2402 TypeSourceInfo *Operand,
2403 SourceLocation RParenLoc);
2404 ExprResult BuildCXXTypeId(QualType TypeInfoType,
2405 SourceLocation TypeidLoc,
2407 SourceLocation RParenLoc);
2409 /// ActOnCXXTypeid - Parse typeid( something ).
2410 ExprResult ActOnCXXTypeid(SourceLocation OpLoc,
2411 SourceLocation LParenLoc, bool isType,
2413 SourceLocation RParenLoc);
2415 ExprResult BuildCXXUuidof(QualType TypeInfoType,
2416 SourceLocation TypeidLoc,
2417 TypeSourceInfo *Operand,
2418 SourceLocation RParenLoc);
2419 ExprResult BuildCXXUuidof(QualType TypeInfoType,
2420 SourceLocation TypeidLoc,
2422 SourceLocation RParenLoc);
2424 /// ActOnCXXUuidof - Parse __uuidof( something ).
2425 ExprResult ActOnCXXUuidof(SourceLocation OpLoc,
2426 SourceLocation LParenLoc, bool isType,
2428 SourceLocation RParenLoc);
2431 //// ActOnCXXThis - Parse 'this' pointer.
2432 ExprResult ActOnCXXThis(SourceLocation loc);
2434 /// tryCaptureCXXThis - Try to capture a 'this' pointer. Returns a
2435 /// pointer to an instance method whose 'this' pointer is
2436 /// capturable, or null if this is not possible.
2437 CXXMethodDecl *tryCaptureCXXThis();
2439 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
2440 ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind);
2442 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
2443 ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc);
2445 //// ActOnCXXThrow - Parse throw expressions.
2446 ExprResult ActOnCXXThrow(SourceLocation OpLoc, Expr *expr);
2447 bool CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E);
2449 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
2450 /// Can be interpreted either as function-style casting ("int(x)")
2451 /// or class type construction ("ClassType(x,y,z)")
2452 /// or creation of a value-initialized type ("int()").
2453 ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep,
2454 SourceLocation LParenLoc,
2456 SourceLocation RParenLoc);
2458 ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type,
2459 SourceLocation LParenLoc,
2461 SourceLocation RParenLoc);
2463 /// ActOnCXXNew - Parsed a C++ 'new' expression.
2464 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
2465 SourceLocation PlacementLParen,
2466 MultiExprArg PlacementArgs,
2467 SourceLocation PlacementRParen,
2468 SourceRange TypeIdParens, Declarator &D,
2469 SourceLocation ConstructorLParen,
2470 MultiExprArg ConstructorArgs,
2471 SourceLocation ConstructorRParen);
2472 ExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
2473 SourceLocation PlacementLParen,
2474 MultiExprArg PlacementArgs,
2475 SourceLocation PlacementRParen,
2476 SourceRange TypeIdParens,
2478 TypeSourceInfo *AllocTypeInfo,
2480 SourceLocation ConstructorLParen,
2481 MultiExprArg ConstructorArgs,
2482 SourceLocation ConstructorRParen,
2483 bool TypeMayContainAuto = true);
2485 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
2487 bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range,
2488 bool UseGlobal, QualType AllocType, bool IsArray,
2489 Expr **PlaceArgs, unsigned NumPlaceArgs,
2490 FunctionDecl *&OperatorNew,
2491 FunctionDecl *&OperatorDelete);
2492 bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range,
2493 DeclarationName Name, Expr** Args,
2494 unsigned NumArgs, DeclContext *Ctx,
2495 bool AllowMissing, FunctionDecl *&Operator);
2496 void DeclareGlobalNewDelete();
2497 void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return,
2499 bool addMallocAttr = false);
2501 bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD,
2502 DeclarationName Name, FunctionDecl* &Operator);
2504 /// ActOnCXXDelete - Parsed a C++ 'delete' expression
2505 ExprResult ActOnCXXDelete(SourceLocation StartLoc,
2506 bool UseGlobal, bool ArrayForm,
2509 DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D);
2510 ExprResult CheckConditionVariable(VarDecl *ConditionVar,
2511 SourceLocation StmtLoc,
2512 bool ConvertToBoolean);
2514 ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen,
2515 Expr *Operand, SourceLocation RParen);
2516 ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand,
2517 SourceLocation RParen);
2519 /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
2520 /// pseudo-functions.
2521 ExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT,
2522 SourceLocation KWLoc,
2524 SourceLocation RParen);
2526 ExprResult BuildUnaryTypeTrait(UnaryTypeTrait OTT,
2527 SourceLocation KWLoc,
2529 SourceLocation RParen);
2531 /// ActOnBinaryTypeTrait - Parsed one of the bianry type trait support
2532 /// pseudo-functions.
2533 ExprResult ActOnBinaryTypeTrait(BinaryTypeTrait OTT,
2534 SourceLocation KWLoc,
2537 SourceLocation RParen);
2539 ExprResult BuildBinaryTypeTrait(BinaryTypeTrait BTT,
2540 SourceLocation KWLoc,
2541 TypeSourceInfo *LhsT,
2542 TypeSourceInfo *RhsT,
2543 SourceLocation RParen);
2545 ExprResult ActOnStartCXXMemberReference(Scope *S,
2547 SourceLocation OpLoc,
2548 tok::TokenKind OpKind,
2549 ParsedType &ObjectType,
2550 bool &MayBePseudoDestructor);
2552 ExprResult DiagnoseDtorReference(SourceLocation NameLoc, Expr *MemExpr);
2554 ExprResult BuildPseudoDestructorExpr(Expr *Base,
2555 SourceLocation OpLoc,
2556 tok::TokenKind OpKind,
2557 const CXXScopeSpec &SS,
2558 TypeSourceInfo *ScopeType,
2559 SourceLocation CCLoc,
2560 SourceLocation TildeLoc,
2561 PseudoDestructorTypeStorage DestroyedType,
2562 bool HasTrailingLParen);
2564 ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base,
2565 SourceLocation OpLoc,
2566 tok::TokenKind OpKind,
2568 UnqualifiedId &FirstTypeName,
2569 SourceLocation CCLoc,
2570 SourceLocation TildeLoc,
2571 UnqualifiedId &SecondTypeName,
2572 bool HasTrailingLParen);
2574 /// MaybeCreateExprWithCleanups - If the current full-expression
2575 /// requires any cleanups, surround it with a ExprWithCleanups node.
2576 /// Otherwise, just returns the passed-in expression.
2577 Expr *MaybeCreateExprWithCleanups(Expr *SubExpr);
2578 Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt);
2579 ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr);
2581 ExprResult ActOnFinishFullExpr(Expr *Expr);
2582 StmtResult ActOnFinishFullStmt(Stmt *Stmt);
2584 // Marks SS invalid if it represents an incomplete type.
2585 bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC);
2587 DeclContext *computeDeclContext(QualType T);
2588 DeclContext *computeDeclContext(const CXXScopeSpec &SS,
2589 bool EnteringContext = false);
2590 bool isDependentScopeSpecifier(const CXXScopeSpec &SS);
2591 CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS);
2592 bool isUnknownSpecialization(const CXXScopeSpec &SS);
2594 /// \brief The parser has parsed a global nested-name-specifier '::'.
2596 /// \param S The scope in which this nested-name-specifier occurs.
2598 /// \param CCLoc The location of the '::'.
2600 /// \param SS The nested-name-specifier, which will be updated in-place
2601 /// to reflect the parsed nested-name-specifier.
2603 /// \returns true if an error occurred, false otherwise.
2604 bool ActOnCXXGlobalScopeSpecifier(Scope *S, SourceLocation CCLoc,
2607 bool isAcceptableNestedNameSpecifier(NamedDecl *SD);
2608 NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS);
2610 bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS,
2611 SourceLocation IdLoc,
2613 ParsedType ObjectType);
2615 bool BuildCXXNestedNameSpecifier(Scope *S,
2616 IdentifierInfo &Identifier,
2617 SourceLocation IdentifierLoc,
2618 SourceLocation CCLoc,
2619 QualType ObjectType,
2620 bool EnteringContext,
2622 NamedDecl *ScopeLookupResult,
2623 bool ErrorRecoveryLookup);
2625 /// \brief The parser has parsed a nested-name-specifier 'identifier::'.
2627 /// \param S The scope in which this nested-name-specifier occurs.
2629 /// \param Identifier The identifier preceding the '::'.
2631 /// \param IdentifierLoc The location of the identifier.
2633 /// \param CCLoc The location of the '::'.
2635 /// \param ObjectType The type of the object, if we're parsing
2636 /// nested-name-specifier in a member access expression.
2638 /// \param EnteringContext Whether we're entering the context nominated by
2639 /// this nested-name-specifier.
2641 /// \param SS The nested-name-specifier, which is both an input
2642 /// parameter (the nested-name-specifier before this type) and an
2643 /// output parameter (containing the full nested-name-specifier,
2644 /// including this new type).
2646 /// \returns true if an error occurred, false otherwise.
2647 bool ActOnCXXNestedNameSpecifier(Scope *S,
2648 IdentifierInfo &Identifier,
2649 SourceLocation IdentifierLoc,
2650 SourceLocation CCLoc,
2651 ParsedType ObjectType,
2652 bool EnteringContext,
2655 bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS,
2656 IdentifierInfo &Identifier,
2657 SourceLocation IdentifierLoc,
2658 SourceLocation ColonLoc,
2659 ParsedType ObjectType,
2660 bool EnteringContext);
2662 /// \brief The parser has parsed a nested-name-specifier 'type::'.
2664 /// \param S The scope in which this nested-name-specifier occurs.
2666 /// \param Type The type, which will be a template specialization
2667 /// type, preceding the '::'.
2669 /// \param CCLoc The location of the '::'.
2671 /// \param SS The nested-name-specifier, which is both an input
2672 /// parameter (the nested-name-specifier before this type) and an
2673 /// output parameter (containing the full nested-name-specifier,
2674 /// including this new type).
2676 /// \returns true if an error occurred, false otherwise.
2677 bool ActOnCXXNestedNameSpecifier(Scope *S,
2679 SourceLocation CCLoc,
2682 /// \brief Given a C++ nested-name-specifier, produce an annotation value
2683 /// that the parser can use later to reconstruct the given
2684 /// nested-name-specifier.
2686 /// \param SS A nested-name-specifier.
2688 /// \returns A pointer containing all of the information in the
2689 /// nested-name-specifier \p SS.
2690 void *SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS);
2692 /// \brief Given an annotation pointer for a nested-name-specifier, restore
2693 /// the nested-name-specifier structure.
2695 /// \param Annotation The annotation pointer, produced by
2696 /// \c SaveNestedNameSpecifierAnnotation().
2698 /// \param AnnotationRange The source range corresponding to the annotation.
2700 /// \param SS The nested-name-specifier that will be updated with the contents
2701 /// of the annotation pointer.
2702 void RestoreNestedNameSpecifierAnnotation(void *Annotation,
2703 SourceRange AnnotationRange,
2706 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2708 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2709 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2710 /// After this method is called, according to [C++ 3.4.3p3], names should be
2711 /// looked up in the declarator-id's scope, until the declarator is parsed and
2712 /// ActOnCXXExitDeclaratorScope is called.
2713 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2714 bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS);
2716 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2717 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2718 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2719 /// Used to indicate that names should revert to being looked up in the
2721 void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS);
2723 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
2724 /// initializer for the declaration 'Dcl'.
2725 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
2726 /// static data member of class X, names should be looked up in the scope of
2728 void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl);
2730 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
2731 /// initializer for the declaration 'Dcl'.
2732 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl);
2734 // ParseObjCStringLiteral - Parse Objective-C string literals.
2735 ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs,
2737 unsigned NumStrings);
2739 Expr *BuildObjCEncodeExpression(SourceLocation AtLoc,
2740 TypeSourceInfo *EncodedTypeInfo,
2741 SourceLocation RParenLoc);
2742 ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
2743 CXXMethodDecl *Method);
2745 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc,
2746 SourceLocation EncodeLoc,
2747 SourceLocation LParenLoc,
2749 SourceLocation RParenLoc);
2751 // ParseObjCSelectorExpression - Build selector expression for @selector
2752 ExprResult ParseObjCSelectorExpression(Selector Sel,
2753 SourceLocation AtLoc,
2754 SourceLocation SelLoc,
2755 SourceLocation LParenLoc,
2756 SourceLocation RParenLoc);
2758 // ParseObjCProtocolExpression - Build protocol expression for @protocol
2759 ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName,
2760 SourceLocation AtLoc,
2761 SourceLocation ProtoLoc,
2762 SourceLocation LParenLoc,
2763 SourceLocation RParenLoc);
2765 //===--------------------------------------------------------------------===//
2768 Decl *ActOnStartLinkageSpecification(Scope *S,
2769 SourceLocation ExternLoc,
2770 SourceLocation LangLoc,
2771 llvm::StringRef Lang,
2772 SourceLocation LBraceLoc);
2773 Decl *ActOnFinishLinkageSpecification(Scope *S,
2775 SourceLocation RBraceLoc);
2778 //===--------------------------------------------------------------------===//
2781 bool isCurrentClassName(const IdentifierInfo &II, Scope *S,
2782 const CXXScopeSpec *SS = 0);
2784 Decl *ActOnAccessSpecifier(AccessSpecifier Access,
2785 SourceLocation ASLoc,
2786 SourceLocation ColonLoc);
2788 Decl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS,
2790 MultiTemplateParamsArg TemplateParameterLists,
2791 Expr *BitfieldWidth, const VirtSpecifiers &VS,
2792 Expr *Init, bool IsDefinition,
2793 bool Deleted = false);
2795 MemInitResult ActOnMemInitializer(Decl *ConstructorD,
2798 IdentifierInfo *MemberOrBase,
2799 ParsedType TemplateTypeTy,
2800 SourceLocation IdLoc,
2801 SourceLocation LParenLoc,
2802 Expr **Args, unsigned NumArgs,
2803 SourceLocation RParenLoc,
2804 SourceLocation EllipsisLoc);
2806 MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr **Args,
2807 unsigned NumArgs, SourceLocation IdLoc,
2808 SourceLocation LParenLoc,
2809 SourceLocation RParenLoc);
2811 MemInitResult BuildBaseInitializer(QualType BaseType,
2812 TypeSourceInfo *BaseTInfo,
2813 Expr **Args, unsigned NumArgs,
2814 SourceLocation LParenLoc,
2815 SourceLocation RParenLoc,
2816 CXXRecordDecl *ClassDecl,
2817 SourceLocation EllipsisLoc);
2819 MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo,
2820 Expr **Args, unsigned NumArgs,
2821 SourceLocation RParenLoc,
2822 SourceLocation LParenLoc,
2823 CXXRecordDecl *ClassDecl,
2824 SourceLocation EllipsisLoc);
2826 bool SetCtorInitializers(CXXConstructorDecl *Constructor,
2827 CXXCtorInitializer **Initializers,
2828 unsigned NumInitializers, bool AnyErrors);
2830 void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
2833 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
2834 /// mark all the non-trivial destructors of its members and bases as
2836 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc,
2837 CXXRecordDecl *Record);
2839 /// \brief The list of classes whose vtables have been used within
2840 /// this translation unit, and the source locations at which the
2841 /// first use occurred.
2842 typedef std::pair<CXXRecordDecl*, SourceLocation> VTableUse;
2844 /// \brief The list of vtables that are required but have not yet been
2846 llvm::SmallVector<VTableUse, 16> VTableUses;
2848 /// \brief The set of classes whose vtables have been used within
2849 /// this translation unit, and a bit that will be true if the vtable is
2850 /// required to be emitted (otherwise, it should be emitted only if needed
2851 /// by code generation).
2852 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed;
2854 /// \brief A list of all of the dynamic classes in this translation
2856 llvm::SmallVector<CXXRecordDecl *, 16> DynamicClasses;
2858 /// \brief Note that the vtable for the given class was used at the
2860 void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class,
2861 bool DefinitionRequired = false);
2863 /// MarkVirtualMembersReferenced - Will mark all members of the given
2864 /// CXXRecordDecl referenced.
2865 void MarkVirtualMembersReferenced(SourceLocation Loc,
2866 const CXXRecordDecl *RD);
2868 /// \brief Define all of the vtables that have been used in this
2869 /// translation unit and reference any virtual members used by those
2872 /// \returns true if any work was done, false otherwise.
2873 bool DefineUsedVTables();
2875 void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl);
2877 void ActOnMemInitializers(Decl *ConstructorDecl,
2878 SourceLocation ColonLoc,
2879 MemInitTy **MemInits, unsigned NumMemInits,
2882 void CheckCompletedCXXClass(CXXRecordDecl *Record);
2883 void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc,
2885 SourceLocation LBrac,
2886 SourceLocation RBrac,
2887 AttributeList *AttrList);
2889 void ActOnReenterTemplateScope(Scope *S, Decl *Template);
2890 void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record);
2891 void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
2892 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param);
2893 void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method);
2894 void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record);
2896 Decl *ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
2898 Expr *AssertMessageExpr);
2900 FriendDecl *CheckFriendTypeDecl(SourceLocation FriendLoc,
2901 TypeSourceInfo *TSInfo);
2902 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS,
2903 MultiTemplateParamsArg TemplateParams);
2904 Decl *ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition,
2905 MultiTemplateParamsArg TemplateParams);
2907 QualType CheckConstructorDeclarator(Declarator &D, QualType R,
2909 void CheckConstructor(CXXConstructorDecl *Constructor);
2910 QualType CheckDestructorDeclarator(Declarator &D, QualType R,
2912 bool CheckDestructor(CXXDestructorDecl *Destructor);
2913 void CheckConversionDeclarator(Declarator &D, QualType &R,
2915 Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion);
2917 //===--------------------------------------------------------------------===//
2918 // C++ Derived Classes
2921 /// ActOnBaseSpecifier - Parsed a base specifier
2922 CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class,
2923 SourceRange SpecifierRange,
2924 bool Virtual, AccessSpecifier Access,
2925 TypeSourceInfo *TInfo,
2926 SourceLocation EllipsisLoc);
2928 BaseResult ActOnBaseSpecifier(Decl *classdecl,
2929 SourceRange SpecifierRange,
2930 bool Virtual, AccessSpecifier Access,
2931 ParsedType basetype,
2932 SourceLocation BaseLoc,
2933 SourceLocation EllipsisLoc);
2935 bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases,
2937 void ActOnBaseSpecifiers(Decl *ClassDecl, BaseTy **Bases, unsigned NumBases);
2939 bool IsDerivedFrom(QualType Derived, QualType Base);
2940 bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths);
2942 // FIXME: I don't like this name.
2943 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath);
2945 bool BasePathInvolvesVirtualBase(const CXXCastPath &BasePath);
2947 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
2948 SourceLocation Loc, SourceRange Range,
2949 CXXCastPath *BasePath = 0,
2950 bool IgnoreAccess = false);
2951 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base,
2952 unsigned InaccessibleBaseID,
2953 unsigned AmbigiousBaseConvID,
2954 SourceLocation Loc, SourceRange Range,
2955 DeclarationName Name,
2956 CXXCastPath *BasePath);
2958 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths);
2960 /// CheckOverridingFunctionReturnType - Checks whether the return types are
2961 /// covariant, according to C++ [class.virtual]p5.
2962 bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New,
2963 const CXXMethodDecl *Old);
2965 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
2966 /// spec is a subset of base spec.
2967 bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
2968 const CXXMethodDecl *Old);
2970 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange);
2972 /// CheckOverrideControl - Check C++0x override control semantics.
2973 void CheckOverrideControl(const Decl *D);
2975 /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
2976 /// overrides a virtual member function marked 'final', according to
2977 /// C++0x [class.virtual]p3.
2978 bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New,
2979 const CXXMethodDecl *Old);
2982 //===--------------------------------------------------------------------===//
2983 // C++ Access Control
2993 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl,
2994 NamedDecl *PrevMemberDecl,
2995 AccessSpecifier LexicalAS);
2997 AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E,
2998 DeclAccessPair FoundDecl);
2999 AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E,
3000 DeclAccessPair FoundDecl);
3001 AccessResult CheckAllocationAccess(SourceLocation OperatorLoc,
3002 SourceRange PlacementRange,
3003 CXXRecordDecl *NamingClass,
3004 DeclAccessPair FoundDecl);
3005 AccessResult CheckConstructorAccess(SourceLocation Loc,
3006 CXXConstructorDecl *D,
3007 const InitializedEntity &Entity,
3008 AccessSpecifier Access,
3009 bool IsCopyBindingRefToTemp = false);
3010 AccessResult CheckDestructorAccess(SourceLocation Loc,
3011 CXXDestructorDecl *Dtor,
3012 const PartialDiagnostic &PDiag);
3013 AccessResult CheckDirectMemberAccess(SourceLocation Loc,
3015 const PartialDiagnostic &PDiag);
3016 AccessResult CheckMemberOperatorAccess(SourceLocation Loc,
3019 DeclAccessPair FoundDecl);
3020 AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr,
3021 DeclAccessPair FoundDecl);
3022 AccessResult CheckBaseClassAccess(SourceLocation AccessLoc,
3023 QualType Base, QualType Derived,
3024 const CXXBasePath &Path,
3026 bool ForceCheck = false,
3027 bool ForceUnprivileged = false);
3028 void CheckLookupAccess(const LookupResult &R);
3030 void HandleDependentAccessCheck(const DependentDiagnostic &DD,
3031 const MultiLevelTemplateArgumentList &TemplateArgs);
3032 void PerformDependentDiagnostics(const DeclContext *Pattern,
3033 const MultiLevelTemplateArgumentList &TemplateArgs);
3035 void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx);
3037 /// A flag to suppress access checking.
3038 bool SuppressAccessChecking;
3040 /// \brief When true, access checking violations are treated as SFINAE
3041 /// failures rather than hard errors.
3042 bool AccessCheckingSFINAE;
3044 void ActOnStartSuppressingAccessChecks();
3045 void ActOnStopSuppressingAccessChecks();
3047 enum AbstractDiagSelID {
3051 AbstractVariableType,
3056 bool RequireNonAbstractType(SourceLocation Loc, QualType T,
3057 const PartialDiagnostic &PD);
3058 void DiagnoseAbstractType(const CXXRecordDecl *RD);
3060 bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID,
3061 AbstractDiagSelID SelID = AbstractNone);
3063 //===--------------------------------------------------------------------===//
3064 // C++ Overloaded Operators [C++ 13.5]
3067 bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl);
3069 bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl);
3071 //===--------------------------------------------------------------------===//
3072 // C++ Templates [C++ 14]
3074 void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS,
3075 QualType ObjectType, bool EnteringContext,
3076 bool &MemberOfUnknownSpecialization);
3078 TemplateNameKind isTemplateName(Scope *S,
3080 bool hasTemplateKeyword,
3081 UnqualifiedId &Name,
3082 ParsedType ObjectType,
3083 bool EnteringContext,
3084 TemplateTy &Template,
3085 bool &MemberOfUnknownSpecialization);
3087 bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
3088 SourceLocation IILoc,
3090 const CXXScopeSpec *SS,
3091 TemplateTy &SuggestedTemplate,
3092 TemplateNameKind &SuggestedKind);
3094 bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl);
3095 TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl);
3097 Decl *ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis,
3098 SourceLocation EllipsisLoc,
3099 SourceLocation KeyLoc,
3100 IdentifierInfo *ParamName,
3101 SourceLocation ParamNameLoc,
3102 unsigned Depth, unsigned Position,
3103 SourceLocation EqualLoc,
3104 ParsedType DefaultArg);
3106 QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc);
3107 Decl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D,
3110 SourceLocation EqualLoc,
3112 Decl *ActOnTemplateTemplateParameter(Scope *S,
3113 SourceLocation TmpLoc,
3114 TemplateParamsTy *Params,
3115 SourceLocation EllipsisLoc,
3116 IdentifierInfo *ParamName,
3117 SourceLocation ParamNameLoc,
3120 SourceLocation EqualLoc,
3121 ParsedTemplateArgument DefaultArg);
3124 ActOnTemplateParameterList(unsigned Depth,
3125 SourceLocation ExportLoc,
3126 SourceLocation TemplateLoc,
3127 SourceLocation LAngleLoc,
3128 Decl **Params, unsigned NumParams,
3129 SourceLocation RAngleLoc);
3131 /// \brief The context in which we are checking a template parameter
3133 enum TemplateParamListContext {
3135 TPC_FunctionTemplate,
3136 TPC_ClassTemplateMember,
3137 TPC_FriendFunctionTemplate,
3138 TPC_FriendFunctionTemplateDefinition
3141 bool CheckTemplateParameterList(TemplateParameterList *NewParams,
3142 TemplateParameterList *OldParams,
3143 TemplateParamListContext TPC);
3144 TemplateParameterList *
3145 MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc,
3146 const CXXScopeSpec &SS,
3147 TemplateParameterList **ParamLists,
3148 unsigned NumParamLists,
3150 bool &IsExplicitSpecialization,
3153 DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
3154 SourceLocation KWLoc, CXXScopeSpec &SS,
3155 IdentifierInfo *Name, SourceLocation NameLoc,
3156 AttributeList *Attr,
3157 TemplateParameterList *TemplateParams,
3158 AccessSpecifier AS);
3160 void translateTemplateArguments(const ASTTemplateArgsPtr &In,
3161 TemplateArgumentListInfo &Out);
3163 QualType CheckTemplateIdType(TemplateName Template,
3164 SourceLocation TemplateLoc,
3165 const TemplateArgumentListInfo &TemplateArgs);
3168 ActOnTemplateIdType(TemplateTy Template, SourceLocation TemplateLoc,
3169 SourceLocation LAngleLoc,
3170 ASTTemplateArgsPtr TemplateArgs,
3171 SourceLocation RAngleLoc);
3173 TypeResult ActOnTagTemplateIdType(CXXScopeSpec &SS,
3176 TypeSpecifierType TagSpec,
3177 SourceLocation TagLoc);
3179 ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS,
3182 const TemplateArgumentListInfo &TemplateArgs);
3183 ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS,
3184 const DeclarationNameInfo &NameInfo,
3185 const TemplateArgumentListInfo &TemplateArgs);
3187 TemplateNameKind ActOnDependentTemplateName(Scope *S,
3188 SourceLocation TemplateKWLoc,
3190 UnqualifiedId &Name,
3191 ParsedType ObjectType,
3192 bool EnteringContext,
3193 TemplateTy &Template);
3196 ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK,
3197 SourceLocation KWLoc,
3199 TemplateTy Template,
3200 SourceLocation TemplateNameLoc,
3201 SourceLocation LAngleLoc,
3202 ASTTemplateArgsPtr TemplateArgs,
3203 SourceLocation RAngleLoc,
3204 AttributeList *Attr,
3205 MultiTemplateParamsArg TemplateParameterLists);
3207 Decl *ActOnTemplateDeclarator(Scope *S,
3208 MultiTemplateParamsArg TemplateParameterLists,
3211 Decl *ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope,
3212 MultiTemplateParamsArg TemplateParameterLists,
3216 CheckSpecializationInstantiationRedecl(SourceLocation NewLoc,
3217 TemplateSpecializationKind NewTSK,
3218 NamedDecl *PrevDecl,
3219 TemplateSpecializationKind PrevTSK,
3220 SourceLocation PrevPtOfInstantiation,
3223 bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD,
3224 const TemplateArgumentListInfo &ExplicitTemplateArgs,
3225 LookupResult &Previous);
3227 bool CheckFunctionTemplateSpecialization(FunctionDecl *FD,
3228 const TemplateArgumentListInfo *ExplicitTemplateArgs,
3229 LookupResult &Previous);
3230 bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous);
3233 ActOnExplicitInstantiation(Scope *S,
3234 SourceLocation ExternLoc,
3235 SourceLocation TemplateLoc,
3237 SourceLocation KWLoc,
3238 const CXXScopeSpec &SS,
3239 TemplateTy Template,
3240 SourceLocation TemplateNameLoc,
3241 SourceLocation LAngleLoc,
3242 ASTTemplateArgsPtr TemplateArgs,
3243 SourceLocation RAngleLoc,
3244 AttributeList *Attr);
3247 ActOnExplicitInstantiation(Scope *S,
3248 SourceLocation ExternLoc,
3249 SourceLocation TemplateLoc,
3251 SourceLocation KWLoc,
3253 IdentifierInfo *Name,
3254 SourceLocation NameLoc,
3255 AttributeList *Attr);
3257 DeclResult ActOnExplicitInstantiation(Scope *S,
3258 SourceLocation ExternLoc,
3259 SourceLocation TemplateLoc,
3263 SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template,
3264 SourceLocation TemplateLoc,
3265 SourceLocation RAngleLoc,
3267 llvm::SmallVectorImpl<TemplateArgument> &Converted);
3269 /// \brief Specifies the context in which a particular template
3270 /// argument is being checked.
3271 enum CheckTemplateArgumentKind {
3272 /// \brief The template argument was specified in the code or was
3273 /// instantiated with some deduced template arguments.
3276 /// \brief The template argument was deduced via template argument
3280 /// \brief The template argument was deduced from an array bound
3281 /// via template argument deduction.
3282 CTAK_DeducedFromArrayBound
3285 bool CheckTemplateArgument(NamedDecl *Param,
3286 const TemplateArgumentLoc &Arg,
3287 NamedDecl *Template,
3288 SourceLocation TemplateLoc,
3289 SourceLocation RAngleLoc,
3290 unsigned ArgumentPackIndex,
3291 llvm::SmallVectorImpl<TemplateArgument> &Converted,
3292 CheckTemplateArgumentKind CTAK = CTAK_Specified);
3294 bool CheckTemplateArgumentList(TemplateDecl *Template,
3295 SourceLocation TemplateLoc,
3296 const TemplateArgumentListInfo &TemplateArgs,
3297 bool PartialTemplateArgs,
3298 llvm::SmallVectorImpl<TemplateArgument> &Converted);
3300 bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param,
3301 const TemplateArgumentLoc &Arg,
3302 llvm::SmallVectorImpl<TemplateArgument> &Converted);
3304 bool CheckTemplateArgument(TemplateTypeParmDecl *Param,
3305 TypeSourceInfo *Arg);
3306 bool CheckTemplateArgumentPointerToMember(Expr *Arg,
3307 TemplateArgument &Converted);
3308 bool CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
3309 QualType InstantiatedParamType, Expr *&Arg,
3310 TemplateArgument &Converted,
3311 CheckTemplateArgumentKind CTAK = CTAK_Specified);
3312 bool CheckTemplateArgument(TemplateTemplateParmDecl *Param,
3313 const TemplateArgumentLoc &Arg);
3316 BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg,
3318 SourceLocation Loc);
3320 BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
3321 SourceLocation Loc);
3323 /// \brief Enumeration describing how template parameter lists are compared
3325 enum TemplateParameterListEqualKind {
3326 /// \brief We are matching the template parameter lists of two templates
3327 /// that might be redeclarations.
3330 /// template<typename T> struct X;
3331 /// template<typename T> struct X;
3335 /// \brief We are matching the template parameter lists of two template
3336 /// template parameters as part of matching the template parameter lists
3337 /// of two templates that might be redeclarations.
3340 /// template<template<int I> class TT> struct X;
3341 /// template<template<int Value> class Other> struct X;
3343 TPL_TemplateTemplateParmMatch,
3345 /// \brief We are matching the template parameter lists of a template
3346 /// template argument against the template parameter lists of a template
3347 /// template parameter.
3350 /// template<template<int Value> class Metafun> struct X;
3351 /// template<int Value> struct integer_c;
3352 /// X<integer_c> xic;
3354 TPL_TemplateTemplateArgumentMatch
3357 bool TemplateParameterListsAreEqual(TemplateParameterList *New,
3358 TemplateParameterList *Old,
3360 TemplateParameterListEqualKind Kind,
3361 SourceLocation TemplateArgLoc
3362 = SourceLocation());
3364 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams);
3366 /// \brief Called when the parser has parsed a C++ typename
3367 /// specifier, e.g., "typename T::type".
3369 /// \param S The scope in which this typename type occurs.
3370 /// \param TypenameLoc the location of the 'typename' keyword
3371 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3372 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
3373 /// \param IdLoc the location of the identifier.
3375 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
3376 const CXXScopeSpec &SS, const IdentifierInfo &II,
3377 SourceLocation IdLoc);
3379 /// \brief Called when the parser has parsed a C++ typename
3380 /// specifier that ends in a template-id, e.g.,
3381 /// "typename MetaFun::template apply<T1, T2>".
3383 /// \param S The scope in which this typename type occurs.
3384 /// \param TypenameLoc the location of the 'typename' keyword
3385 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3386 /// \param TemplateLoc the location of the 'template' keyword, if any.
3387 /// \param Ty the type that the typename specifier refers to.
3389 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc,
3390 const CXXScopeSpec &SS, SourceLocation TemplateLoc,
3393 QualType CheckTypenameType(ElaboratedTypeKeyword Keyword,
3394 NestedNameSpecifier *NNS,
3395 const IdentifierInfo &II,
3396 SourceLocation KeywordLoc,
3397 SourceRange NNSRange,
3398 SourceLocation IILoc);
3400 TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T,
3402 DeclarationName Name);
3403 bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS);
3405 ExprResult RebuildExprInCurrentInstantiation(Expr *E);
3408 getTemplateArgumentBindingsText(const TemplateParameterList *Params,
3409 const TemplateArgumentList &Args);
3412 getTemplateArgumentBindingsText(const TemplateParameterList *Params,
3413 const TemplateArgument *Args,
3416 //===--------------------------------------------------------------------===//
3417 // C++ Variadic Templates (C++0x [temp.variadic])
3418 //===--------------------------------------------------------------------===//
3420 /// \brief The context in which an unexpanded parameter pack is
3421 /// being diagnosed.
3423 /// Note that the values of this enumeration line up with the first
3424 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
3425 enum UnexpandedParameterPackContext {
3426 /// \brief An arbitrary expression.
3427 UPPC_Expression = 0,
3429 /// \brief The base type of a class type.
3432 /// \brief The type of an arbitrary declaration.
3433 UPPC_DeclarationType,
3435 /// \brief The type of a data member.
3436 UPPC_DataMemberType,
3438 /// \brief The size of a bit-field.
3441 /// \brief The expression in a static assertion.
3442 UPPC_StaticAssertExpression,
3444 /// \brief The fixed underlying type of an enumeration.
3445 UPPC_FixedUnderlyingType,
3447 /// \brief The enumerator value.
3448 UPPC_EnumeratorValue,
3450 /// \brief A using declaration.
3451 UPPC_UsingDeclaration,
3453 /// \brief A friend declaration.
3454 UPPC_FriendDeclaration,
3456 /// \brief A declaration qualifier.
3457 UPPC_DeclarationQualifier,
3459 /// \brief An initializer.
3462 /// \brief A default argument.
3463 UPPC_DefaultArgument,
3465 /// \brief The type of a non-type template parameter.
3466 UPPC_NonTypeTemplateParameterType,
3468 /// \brief The type of an exception.
3471 /// \brief Partial specialization.
3472 UPPC_PartialSpecialization
3475 /// \brief If the given type contains an unexpanded parameter pack,
3476 /// diagnose the error.
3478 /// \param Loc The source location where a diagnostc should be emitted.
3480 /// \param T The type that is being checked for unexpanded parameter
3483 /// \returns true if an error ocurred, false otherwise.
3484 bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T,
3485 UnexpandedParameterPackContext UPPC);
3487 /// \brief If the given expression contains an unexpanded parameter
3488 /// pack, diagnose the error.
3490 /// \param E The expression that is being checked for unexpanded
3491 /// parameter packs.
3493 /// \returns true if an error ocurred, false otherwise.
3494 bool DiagnoseUnexpandedParameterPack(Expr *E,
3495 UnexpandedParameterPackContext UPPC = UPPC_Expression);
3497 /// \brief If the given nested-name-specifier contains an unexpanded
3498 /// parameter pack, diagnose the error.
3500 /// \param SS The nested-name-specifier that is being checked for
3501 /// unexpanded parameter packs.
3503 /// \returns true if an error ocurred, false otherwise.
3504 bool DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS,
3505 UnexpandedParameterPackContext UPPC);
3507 /// \brief If the given name contains an unexpanded parameter pack,
3508 /// diagnose the error.
3510 /// \param NameInfo The name (with source location information) that
3511 /// is being checked for unexpanded parameter packs.
3513 /// \returns true if an error ocurred, false otherwise.
3514 bool DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo,
3515 UnexpandedParameterPackContext UPPC);
3517 /// \brief If the given template name contains an unexpanded parameter pack,
3518 /// diagnose the error.
3520 /// \param Loc The location of the template name.
3522 /// \param Template The template name that is being checked for unexpanded
3523 /// parameter packs.
3525 /// \returns true if an error ocurred, false otherwise.
3526 bool DiagnoseUnexpandedParameterPack(SourceLocation Loc,
3527 TemplateName Template,
3528 UnexpandedParameterPackContext UPPC);
3530 /// \brief If the given template argument contains an unexpanded parameter
3531 /// pack, diagnose the error.
3533 /// \param Arg The template argument that is being checked for unexpanded
3534 /// parameter packs.
3536 /// \returns true if an error ocurred, false otherwise.
3537 bool DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg,
3538 UnexpandedParameterPackContext UPPC);
3540 /// \brief Collect the set of unexpanded parameter packs within the given
3541 /// template argument.
3543 /// \param Arg The template argument that will be traversed to find
3544 /// unexpanded parameter packs.
3545 void collectUnexpandedParameterPacks(TemplateArgument Arg,
3546 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
3548 /// \brief Collect the set of unexpanded parameter packs within the given
3549 /// template argument.
3551 /// \param Arg The template argument that will be traversed to find
3552 /// unexpanded parameter packs.
3553 void collectUnexpandedParameterPacks(TemplateArgumentLoc Arg,
3554 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
3556 /// \brief Collect the set of unexpanded parameter packs within the given
3559 /// \param T The type that will be traversed to find
3560 /// unexpanded parameter packs.
3561 void collectUnexpandedParameterPacks(QualType T,
3562 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
3564 /// \brief Collect the set of unexpanded parameter packs within the given
3567 /// \param TL The type that will be traversed to find
3568 /// unexpanded parameter packs.
3569 void collectUnexpandedParameterPacks(TypeLoc TL,
3570 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded);
3572 /// \brief Invoked when parsing a template argument followed by an
3573 /// ellipsis, which creates a pack expansion.
3575 /// \param Arg The template argument preceding the ellipsis, which
3576 /// may already be invalid.
3578 /// \param EllipsisLoc The location of the ellipsis.
3579 ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg,
3580 SourceLocation EllipsisLoc);
3582 /// \brief Invoked when parsing a type followed by an ellipsis, which
3583 /// creates a pack expansion.
3585 /// \param Type The type preceding the ellipsis, which will become
3586 /// the pattern of the pack expansion.
3588 /// \param EllipsisLoc The location of the ellipsis.
3589 TypeResult ActOnPackExpansion(ParsedType Type, SourceLocation EllipsisLoc);
3591 /// \brief Construct a pack expansion type from the pattern of the pack
3593 TypeSourceInfo *CheckPackExpansion(TypeSourceInfo *Pattern,
3594 SourceLocation EllipsisLoc,
3595 llvm::Optional<unsigned> NumExpansions);
3597 /// \brief Construct a pack expansion type from the pattern of the pack
3599 QualType CheckPackExpansion(QualType Pattern,
3600 SourceRange PatternRange,
3601 SourceLocation EllipsisLoc,
3602 llvm::Optional<unsigned> NumExpansions);
3604 /// \brief Invoked when parsing an expression followed by an ellipsis, which
3605 /// creates a pack expansion.
3607 /// \param Pattern The expression preceding the ellipsis, which will become
3608 /// the pattern of the pack expansion.
3610 /// \param EllipsisLoc The location of the ellipsis.
3611 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc);
3613 /// \brief Invoked when parsing an expression followed by an ellipsis, which
3614 /// creates a pack expansion.
3616 /// \param Pattern The expression preceding the ellipsis, which will become
3617 /// the pattern of the pack expansion.
3619 /// \param EllipsisLoc The location of the ellipsis.
3620 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
3621 llvm::Optional<unsigned> NumExpansions);
3623 /// \brief Determine whether we could expand a pack expansion with the
3624 /// given set of parameter packs into separate arguments by repeatedly
3625 /// transforming the pattern.
3627 /// \param EllipsisLoc The location of the ellipsis that identifies the
3630 /// \param PatternRange The source range that covers the entire pattern of
3631 /// the pack expansion.
3633 /// \param Unexpanded The set of unexpanded parameter packs within the
3636 /// \param NumUnexpanded The number of unexpanded parameter packs in
3639 /// \param ShouldExpand Will be set to \c true if the transformer should
3640 /// expand the corresponding pack expansions into separate arguments. When
3641 /// set, \c NumExpansions must also be set.
3643 /// \param RetainExpansion Whether the caller should add an unexpanded
3644 /// pack expansion after all of the expanded arguments. This is used
3645 /// when extending explicitly-specified template argument packs per
3646 /// C++0x [temp.arg.explicit]p9.
3648 /// \param NumExpansions The number of separate arguments that will be in
3649 /// the expanded form of the corresponding pack expansion. This is both an
3650 /// input and an output parameter, which can be set by the caller if the
3651 /// number of expansions is known a priori (e.g., due to a prior substitution)
3652 /// and will be set by the callee when the number of expansions is known.
3653 /// The callee must set this value when \c ShouldExpand is \c true; it may
3654 /// set this value in other cases.
3656 /// \returns true if an error occurred (e.g., because the parameter packs
3657 /// are to be instantiated with arguments of different lengths), false
3658 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
3660 bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc,
3661 SourceRange PatternRange,
3662 const UnexpandedParameterPack *Unexpanded,
3663 unsigned NumUnexpanded,
3664 const MultiLevelTemplateArgumentList &TemplateArgs,
3666 bool &RetainExpansion,
3667 llvm::Optional<unsigned> &NumExpansions);
3669 /// \brief Determine the number of arguments in the given pack expansion
3672 /// This routine already assumes that the pack expansion type can be
3673 /// expanded and that the number of arguments in the expansion is
3674 /// consistent across all of the unexpanded parameter packs in its pattern.
3675 unsigned getNumArgumentsInExpansion(QualType T,
3676 const MultiLevelTemplateArgumentList &TemplateArgs);
3678 /// \brief Determine whether the given declarator contains any unexpanded
3679 /// parameter packs.
3681 /// This routine is used by the parser to disambiguate function declarators
3682 /// with an ellipsis prior to the ')', e.g.,
3688 /// To determine whether we have an (unnamed) function parameter pack or
3689 /// a variadic function.
3691 /// \returns true if the declarator contains any unexpanded parameter packs,
3692 /// false otherwise.
3693 bool containsUnexpandedParameterPacks(Declarator &D);
3695 //===--------------------------------------------------------------------===//
3696 // C++ Template Argument Deduction (C++ [temp.deduct])
3697 //===--------------------------------------------------------------------===//
3699 /// \brief Describes the result of template argument deduction.
3701 /// The TemplateDeductionResult enumeration describes the result of
3702 /// template argument deduction, as returned from
3703 /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
3704 /// structure provides additional information about the results of
3705 /// template argument deduction, e.g., the deduced template argument
3706 /// list (if successful) or the specific template parameters or
3707 /// deduced arguments that were involved in the failure.
3708 enum TemplateDeductionResult {
3709 /// \brief Template argument deduction was successful.
3711 /// \brief Template argument deduction exceeded the maximum template
3712 /// instantiation depth (which has already been diagnosed).
3713 TDK_InstantiationDepth,
3714 /// \brief Template argument deduction did not deduce a value
3715 /// for every template parameter.
3717 /// \brief Template argument deduction produced inconsistent
3718 /// deduced values for the given template parameter.
3720 /// \brief Template argument deduction failed due to inconsistent
3721 /// cv-qualifiers on a template parameter type that would
3722 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
3723 /// but were given a non-const "X".
3725 /// \brief Substitution of the deduced template argument values
3726 /// resulted in an error.
3727 TDK_SubstitutionFailure,
3728 /// \brief Substitution of the deduced template argument values
3729 /// into a non-deduced context produced a type or value that
3730 /// produces a type that does not match the original template
3731 /// arguments provided.
3732 TDK_NonDeducedMismatch,
3733 /// \brief When performing template argument deduction for a function
3734 /// template, there were too many call arguments.
3735 TDK_TooManyArguments,
3736 /// \brief When performing template argument deduction for a function
3737 /// template, there were too few call arguments.
3738 TDK_TooFewArguments,
3739 /// \brief The explicitly-specified template arguments were not valid
3740 /// template arguments for the given template.
3741 TDK_InvalidExplicitArguments,
3742 /// \brief The arguments included an overloaded function name that could
3743 /// not be resolved to a suitable function.
3744 TDK_FailedOverloadResolution
3747 TemplateDeductionResult
3748 DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial,
3749 const TemplateArgumentList &TemplateArgs,
3750 sema::TemplateDeductionInfo &Info);
3752 TemplateDeductionResult
3753 SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3754 const TemplateArgumentListInfo &ExplicitTemplateArgs,
3755 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3756 llvm::SmallVectorImpl<QualType> &ParamTypes,
3757 QualType *FunctionType,
3758 sema::TemplateDeductionInfo &Info);
3760 TemplateDeductionResult
3761 FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate,
3762 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced,
3763 unsigned NumExplicitlySpecified,
3764 FunctionDecl *&Specialization,
3765 sema::TemplateDeductionInfo &Info);
3767 TemplateDeductionResult
3768 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3769 const TemplateArgumentListInfo *ExplicitTemplateArgs,
3770 Expr **Args, unsigned NumArgs,
3771 FunctionDecl *&Specialization,
3772 sema::TemplateDeductionInfo &Info);
3774 TemplateDeductionResult
3775 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3776 const TemplateArgumentListInfo *ExplicitTemplateArgs,
3777 QualType ArgFunctionType,
3778 FunctionDecl *&Specialization,
3779 sema::TemplateDeductionInfo &Info);
3781 TemplateDeductionResult
3782 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3784 CXXConversionDecl *&Specialization,
3785 sema::TemplateDeductionInfo &Info);
3787 TemplateDeductionResult
3788 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate,
3789 const TemplateArgumentListInfo *ExplicitTemplateArgs,
3790 FunctionDecl *&Specialization,
3791 sema::TemplateDeductionInfo &Info);
3793 bool DeduceAutoType(QualType AutoType, Expr *Initializer, QualType &Result);
3795 FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1,
3796 FunctionTemplateDecl *FT2,
3798 TemplatePartialOrderingContext TPOC,
3799 unsigned NumCallArguments);
3800 UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin,
3801 UnresolvedSetIterator SEnd,
3802 TemplatePartialOrderingContext TPOC,
3803 unsigned NumCallArguments,
3805 const PartialDiagnostic &NoneDiag,
3806 const PartialDiagnostic &AmbigDiag,
3807 const PartialDiagnostic &CandidateDiag,
3808 bool Complain = true);
3810 ClassTemplatePartialSpecializationDecl *
3811 getMoreSpecializedPartialSpecialization(
3812 ClassTemplatePartialSpecializationDecl *PS1,
3813 ClassTemplatePartialSpecializationDecl *PS2,
3814 SourceLocation Loc);
3816 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs,
3819 llvm::SmallVectorImpl<bool> &Used);
3820 void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate,
3821 llvm::SmallVectorImpl<bool> &Deduced);
3823 //===--------------------------------------------------------------------===//
3824 // C++ Template Instantiation
3827 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D,
3828 const TemplateArgumentList *Innermost = 0,
3829 bool RelativeToPrimary = false,
3830 const FunctionDecl *Pattern = 0);
3832 /// \brief A template instantiation that is currently in progress.
3833 struct ActiveTemplateInstantiation {
3834 /// \brief The kind of template instantiation we are performing
3835 enum InstantiationKind {
3836 /// We are instantiating a template declaration. The entity is
3837 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
3838 TemplateInstantiation,
3840 /// We are instantiating a default argument for a template
3841 /// parameter. The Entity is the template, and
3842 /// TemplateArgs/NumTemplateArguments provides the template
3843 /// arguments as specified.
3844 /// FIXME: Use a TemplateArgumentList
3845 DefaultTemplateArgumentInstantiation,
3847 /// We are instantiating a default argument for a function.
3848 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
3849 /// provides the template arguments as specified.
3850 DefaultFunctionArgumentInstantiation,
3852 /// We are substituting explicit template arguments provided for
3853 /// a function template. The entity is a FunctionTemplateDecl.
3854 ExplicitTemplateArgumentSubstitution,
3856 /// We are substituting template argument determined as part of
3857 /// template argument deduction for either a class template
3858 /// partial specialization or a function template. The
3859 /// Entity is either a ClassTemplatePartialSpecializationDecl or
3860 /// a FunctionTemplateDecl.
3861 DeducedTemplateArgumentSubstitution,
3863 /// We are substituting prior template arguments into a new
3864 /// template parameter. The template parameter itself is either a
3865 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
3866 PriorTemplateArgumentSubstitution,
3868 /// We are checking the validity of a default template argument that
3869 /// has been used when naming a template-id.
3870 DefaultTemplateArgumentChecking
3873 /// \brief The point of instantiation within the source code.
3874 SourceLocation PointOfInstantiation;
3876 /// \brief The template (or partial specialization) in which we are
3877 /// performing the instantiation, for substitutions of prior template
3879 NamedDecl *Template;
3881 /// \brief The entity that is being instantiated.
3884 /// \brief The list of template arguments we are substituting, if they
3885 /// are not part of the entity.
3886 const TemplateArgument *TemplateArgs;
3888 /// \brief The number of template arguments in TemplateArgs.
3889 unsigned NumTemplateArgs;
3891 /// \brief The template deduction info object associated with the
3892 /// substitution or checking of explicit or deduced template arguments.
3893 sema::TemplateDeductionInfo *DeductionInfo;
3895 /// \brief The source range that covers the construct that cause
3896 /// the instantiation, e.g., the template-id that causes a class
3897 /// template instantiation.
3898 SourceRange InstantiationRange;
3900 ActiveTemplateInstantiation()
3901 : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0),
3902 NumTemplateArgs(0), DeductionInfo(0) {}
3904 /// \brief Determines whether this template is an actual instantiation
3905 /// that should be counted toward the maximum instantiation depth.
3906 bool isInstantiationRecord() const;
3908 friend bool operator==(const ActiveTemplateInstantiation &X,
3909 const ActiveTemplateInstantiation &Y) {
3910 if (X.Kind != Y.Kind)
3913 if (X.Entity != Y.Entity)
3917 case TemplateInstantiation:
3920 case PriorTemplateArgumentSubstitution:
3921 case DefaultTemplateArgumentChecking:
3922 if (X.Template != Y.Template)
3927 case DefaultTemplateArgumentInstantiation:
3928 case ExplicitTemplateArgumentSubstitution:
3929 case DeducedTemplateArgumentSubstitution:
3930 case DefaultFunctionArgumentInstantiation:
3931 return X.TemplateArgs == Y.TemplateArgs;
3938 friend bool operator!=(const ActiveTemplateInstantiation &X,
3939 const ActiveTemplateInstantiation &Y) {
3944 /// \brief List of active template instantiations.
3946 /// This vector is treated as a stack. As one template instantiation
3947 /// requires another template instantiation, additional
3948 /// instantiations are pushed onto the stack up to a
3949 /// user-configurable limit LangOptions::InstantiationDepth.
3950 llvm::SmallVector<ActiveTemplateInstantiation, 16>
3951 ActiveTemplateInstantiations;
3953 /// \brief Whether we are in a SFINAE context that is not associated with
3954 /// template instantiation.
3956 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
3957 /// of a template instantiation or template argument deduction.
3958 bool InNonInstantiationSFINAEContext;
3960 /// \brief The number of ActiveTemplateInstantiation entries in
3961 /// \c ActiveTemplateInstantiations that are not actual instantiations and,
3962 /// therefore, should not be counted as part of the instantiation depth.
3963 unsigned NonInstantiationEntries;
3965 /// \brief The last template from which a template instantiation
3966 /// error or warning was produced.
3968 /// This value is used to suppress printing of redundant template
3969 /// instantiation backtraces when there are multiple errors in the
3970 /// same instantiation. FIXME: Does this belong in Sema? It's tough
3971 /// to implement it anywhere else.
3972 ActiveTemplateInstantiation LastTemplateInstantiationErrorContext;
3974 /// \brief The current index into pack expansion arguments that will be
3975 /// used for substitution of parameter packs.
3977 /// The pack expansion index will be -1 to indicate that parameter packs
3978 /// should be instantiated as themselves. Otherwise, the index specifies
3979 /// which argument within the parameter pack will be used for substitution.
3980 int ArgumentPackSubstitutionIndex;
3982 /// \brief RAII object used to change the argument pack substitution index
3983 /// within a \c Sema object.
3985 /// See \c ArgumentPackSubstitutionIndex for more information.
3986 class ArgumentPackSubstitutionIndexRAII {
3988 int OldSubstitutionIndex;
3991 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex)
3992 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) {
3993 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex;
3996 ~ArgumentPackSubstitutionIndexRAII() {
3997 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex;
4001 friend class ArgumentPackSubstitutionRAII;
4003 /// \brief The stack of calls expression undergoing template instantiation.
4005 /// The top of this stack is used by a fixit instantiating unresolved
4006 /// function calls to fix the AST to match the textual change it prints.
4007 llvm::SmallVector<CallExpr *, 8> CallsUndergoingInstantiation;
4009 /// \brief For each declaration that involved template argument deduction, the
4010 /// set of diagnostics that were suppressed during that template argument
4013 /// FIXME: Serialize this structure to the AST file.
4014 llvm::DenseMap<Decl *, llvm::SmallVector<PartialDiagnosticAt, 1> >
4015 SuppressedDiagnostics;
4017 /// \brief A stack object to be created when performing template
4020 /// Construction of an object of type \c InstantiatingTemplate
4021 /// pushes the current instantiation onto the stack of active
4022 /// instantiations. If the size of this stack exceeds the maximum
4023 /// number of recursive template instantiations, construction
4024 /// produces an error and evaluates true.
4026 /// Destruction of this object will pop the named instantiation off
4028 struct InstantiatingTemplate {
4029 /// \brief Note that we are instantiating a class template,
4030 /// function template, or a member thereof.
4031 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4033 SourceRange InstantiationRange = SourceRange());
4035 /// \brief Note that we are instantiating a default argument in a
4037 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4038 TemplateDecl *Template,
4039 const TemplateArgument *TemplateArgs,
4040 unsigned NumTemplateArgs,
4041 SourceRange InstantiationRange = SourceRange());
4043 /// \brief Note that we are instantiating a default argument in a
4045 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4046 FunctionTemplateDecl *FunctionTemplate,
4047 const TemplateArgument *TemplateArgs,
4048 unsigned NumTemplateArgs,
4049 ActiveTemplateInstantiation::InstantiationKind Kind,
4050 sema::TemplateDeductionInfo &DeductionInfo,
4051 SourceRange InstantiationRange = SourceRange());
4053 /// \brief Note that we are instantiating as part of template
4054 /// argument deduction for a class template partial
4056 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4057 ClassTemplatePartialSpecializationDecl *PartialSpec,
4058 const TemplateArgument *TemplateArgs,
4059 unsigned NumTemplateArgs,
4060 sema::TemplateDeductionInfo &DeductionInfo,
4061 SourceRange InstantiationRange = SourceRange());
4063 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4065 const TemplateArgument *TemplateArgs,
4066 unsigned NumTemplateArgs,
4067 SourceRange InstantiationRange = SourceRange());
4069 /// \brief Note that we are substituting prior template arguments into a
4070 /// non-type or template template parameter.
4071 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4072 NamedDecl *Template,
4073 NonTypeTemplateParmDecl *Param,
4074 const TemplateArgument *TemplateArgs,
4075 unsigned NumTemplateArgs,
4076 SourceRange InstantiationRange);
4078 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4079 NamedDecl *Template,
4080 TemplateTemplateParmDecl *Param,
4081 const TemplateArgument *TemplateArgs,
4082 unsigned NumTemplateArgs,
4083 SourceRange InstantiationRange);
4085 /// \brief Note that we are checking the default template argument
4086 /// against the template parameter for a given template-id.
4087 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation,
4088 TemplateDecl *Template,
4090 const TemplateArgument *TemplateArgs,
4091 unsigned NumTemplateArgs,
4092 SourceRange InstantiationRange);
4095 /// \brief Note that we have finished instantiating this template.
4098 ~InstantiatingTemplate() { Clear(); }
4100 /// \brief Determines whether we have exceeded the maximum
4101 /// recursive template instantiations.
4102 operator bool() const { return Invalid; }
4107 bool SavedInNonInstantiationSFINAEContext;
4108 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation,
4109 SourceRange InstantiationRange);
4111 InstantiatingTemplate(const InstantiatingTemplate&); // not implemented
4113 InstantiatingTemplate&
4114 operator=(const InstantiatingTemplate&); // not implemented
4117 void PrintInstantiationStack();
4119 /// \brief Determines whether we are currently in a context where
4120 /// template argument substitution failures are not considered
4123 /// \returns An empty \c llvm::Optional if we're not in a SFINAE context.
4124 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
4125 /// template-deduction context object, which can be used to capture
4126 /// diagnostics that will be suppressed.
4127 llvm::Optional<sema::TemplateDeductionInfo *> isSFINAEContext() const;
4129 /// \brief RAII class used to determine whether SFINAE has
4130 /// trapped any errors that occur during template argument
4134 unsigned PrevSFINAEErrors;
4135 bool PrevInNonInstantiationSFINAEContext;
4136 bool PrevAccessCheckingSFINAE;
4139 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false)
4140 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors),
4141 PrevInNonInstantiationSFINAEContext(
4142 SemaRef.InNonInstantiationSFINAEContext),
4143 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE)
4145 if (!SemaRef.isSFINAEContext())
4146 SemaRef.InNonInstantiationSFINAEContext = true;
4147 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE;
4151 SemaRef.NumSFINAEErrors = PrevSFINAEErrors;
4152 SemaRef.InNonInstantiationSFINAEContext
4153 = PrevInNonInstantiationSFINAEContext;
4154 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE;
4157 /// \brief Determine whether any SFINAE errors have been trapped.
4158 bool hasErrorOccurred() const {
4159 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors;
4163 /// \brief The current instantiation scope used to store local
4165 LocalInstantiationScope *CurrentInstantiationScope;
4167 /// \brief The number of typos corrected by CorrectTypo.
4168 unsigned TyposCorrected;
4170 typedef llvm::DenseMap<IdentifierInfo *, std::pair<llvm::StringRef, bool> >
4171 UnqualifiedTyposCorrectedMap;
4173 /// \brief A cache containing the results of typo correction for unqualified
4176 /// The string is the string that we corrected to (which may be empty, if
4177 /// there was no correction), while the boolean will be true when the
4178 /// string represents a keyword.
4179 UnqualifiedTyposCorrectedMap UnqualifiedTyposCorrected;
4181 /// \brief Worker object for performing CFG-based warnings.
4182 sema::AnalysisBasedWarnings AnalysisWarnings;
4184 /// \brief An entity for which implicit template instantiation is required.
4186 /// The source location associated with the declaration is the first place in
4187 /// the source code where the declaration was "used". It is not necessarily
4188 /// the point of instantiation (which will be either before or after the
4189 /// namespace-scope declaration that triggered this implicit instantiation),
4190 /// However, it is the location that diagnostics should generally refer to,
4191 /// because users will need to know what code triggered the instantiation.
4192 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation;
4194 /// \brief The queue of implicit template instantiations that are required
4195 /// but have not yet been performed.
4196 std::deque<PendingImplicitInstantiation> PendingInstantiations;
4198 /// \brief The queue of implicit template instantiations that are required
4199 /// and must be performed within the current local scope.
4201 /// This queue is only used for member functions of local classes in
4202 /// templates, which must be instantiated in the same scope as their
4203 /// enclosing function, so that they can reference function-local
4204 /// types, static variables, enumerators, etc.
4205 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations;
4207 void PerformPendingInstantiations(bool LocalOnly = false);
4209 TypeSourceInfo *SubstType(TypeSourceInfo *T,
4210 const MultiLevelTemplateArgumentList &TemplateArgs,
4211 SourceLocation Loc, DeclarationName Entity);
4213 QualType SubstType(QualType T,
4214 const MultiLevelTemplateArgumentList &TemplateArgs,
4215 SourceLocation Loc, DeclarationName Entity);
4217 TypeSourceInfo *SubstType(TypeLoc TL,
4218 const MultiLevelTemplateArgumentList &TemplateArgs,
4219 SourceLocation Loc, DeclarationName Entity);
4221 TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T,
4222 const MultiLevelTemplateArgumentList &TemplateArgs,
4224 DeclarationName Entity);
4225 ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D,
4226 const MultiLevelTemplateArgumentList &TemplateArgs,
4227 llvm::Optional<unsigned> NumExpansions);
4228 bool SubstParmTypes(SourceLocation Loc,
4229 ParmVarDecl **Params, unsigned NumParams,
4230 const MultiLevelTemplateArgumentList &TemplateArgs,
4231 llvm::SmallVectorImpl<QualType> &ParamTypes,
4232 llvm::SmallVectorImpl<ParmVarDecl *> *OutParams = 0);
4233 ExprResult SubstExpr(Expr *E,
4234 const MultiLevelTemplateArgumentList &TemplateArgs);
4236 /// \brief Substitute the given template arguments into a list of
4237 /// expressions, expanding pack expansions if required.
4239 /// \param Exprs The list of expressions to substitute into.
4241 /// \param NumExprs The number of expressions in \p Exprs.
4243 /// \param IsCall Whether this is some form of call, in which case
4244 /// default arguments will be dropped.
4246 /// \param TemplateArgs The set of template arguments to substitute.
4248 /// \param Outputs Will receive all of the substituted arguments.
4250 /// \returns true if an error occurred, false otherwise.
4251 bool SubstExprs(Expr **Exprs, unsigned NumExprs, bool IsCall,
4252 const MultiLevelTemplateArgumentList &TemplateArgs,
4253 llvm::SmallVectorImpl<Expr *> &Outputs);
4255 StmtResult SubstStmt(Stmt *S,
4256 const MultiLevelTemplateArgumentList &TemplateArgs);
4258 Decl *SubstDecl(Decl *D, DeclContext *Owner,
4259 const MultiLevelTemplateArgumentList &TemplateArgs);
4262 SubstBaseSpecifiers(CXXRecordDecl *Instantiation,
4263 CXXRecordDecl *Pattern,
4264 const MultiLevelTemplateArgumentList &TemplateArgs);
4267 InstantiateClass(SourceLocation PointOfInstantiation,
4268 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern,
4269 const MultiLevelTemplateArgumentList &TemplateArgs,
4270 TemplateSpecializationKind TSK,
4271 bool Complain = true);
4273 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs,
4274 Decl *Pattern, Decl *Inst);
4277 InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation,
4278 ClassTemplateSpecializationDecl *ClassTemplateSpec,
4279 TemplateSpecializationKind TSK,
4280 bool Complain = true);
4282 void InstantiateClassMembers(SourceLocation PointOfInstantiation,
4283 CXXRecordDecl *Instantiation,
4284 const MultiLevelTemplateArgumentList &TemplateArgs,
4285 TemplateSpecializationKind TSK);
4287 void InstantiateClassTemplateSpecializationMembers(
4288 SourceLocation PointOfInstantiation,
4289 ClassTemplateSpecializationDecl *ClassTemplateSpec,
4290 TemplateSpecializationKind TSK);
4292 NestedNameSpecifier *
4293 SubstNestedNameSpecifier(NestedNameSpecifier *NNS,
4295 const MultiLevelTemplateArgumentList &TemplateArgs);
4297 NestedNameSpecifierLoc
4298 SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
4299 const MultiLevelTemplateArgumentList &TemplateArgs);
4302 SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
4303 const MultiLevelTemplateArgumentList &TemplateArgs);
4305 SubstTemplateName(TemplateName Name, SourceLocation Loc,
4306 const MultiLevelTemplateArgumentList &TemplateArgs);
4307 bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs,
4308 TemplateArgumentListInfo &Result,
4309 const MultiLevelTemplateArgumentList &TemplateArgs);
4311 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation,
4312 FunctionDecl *Function,
4313 bool Recursive = false,
4314 bool DefinitionRequired = false);
4315 void InstantiateStaticDataMemberDefinition(
4316 SourceLocation PointOfInstantiation,
4318 bool Recursive = false,
4319 bool DefinitionRequired = false);
4321 void InstantiateMemInitializers(CXXConstructorDecl *New,
4322 const CXXConstructorDecl *Tmpl,
4323 const MultiLevelTemplateArgumentList &TemplateArgs);
4325 NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D,
4326 const MultiLevelTemplateArgumentList &TemplateArgs);
4327 DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC,
4328 const MultiLevelTemplateArgumentList &TemplateArgs);
4330 // Objective-C declarations.
4331 Decl *ActOnStartClassInterface(SourceLocation AtInterfaceLoc,
4332 IdentifierInfo *ClassName,
4333 SourceLocation ClassLoc,
4334 IdentifierInfo *SuperName,
4335 SourceLocation SuperLoc,
4336 Decl * const *ProtoRefs,
4337 unsigned NumProtoRefs,
4338 const SourceLocation *ProtoLocs,
4339 SourceLocation EndProtoLoc,
4340 AttributeList *AttrList);
4342 Decl *ActOnCompatiblityAlias(
4343 SourceLocation AtCompatibilityAliasLoc,
4344 IdentifierInfo *AliasName, SourceLocation AliasLocation,
4345 IdentifierInfo *ClassName, SourceLocation ClassLocation);
4347 void CheckForwardProtocolDeclarationForCircularDependency(
4348 IdentifierInfo *PName,
4349 SourceLocation &PLoc, SourceLocation PrevLoc,
4350 const ObjCList<ObjCProtocolDecl> &PList);
4352 Decl *ActOnStartProtocolInterface(
4353 SourceLocation AtProtoInterfaceLoc,
4354 IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc,
4355 Decl * const *ProtoRefNames, unsigned NumProtoRefs,
4356 const SourceLocation *ProtoLocs,
4357 SourceLocation EndProtoLoc,
4358 AttributeList *AttrList);
4360 Decl *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
4361 IdentifierInfo *ClassName,
4362 SourceLocation ClassLoc,
4363 IdentifierInfo *CategoryName,
4364 SourceLocation CategoryLoc,
4365 Decl * const *ProtoRefs,
4366 unsigned NumProtoRefs,
4367 const SourceLocation *ProtoLocs,
4368 SourceLocation EndProtoLoc);
4370 Decl *ActOnStartClassImplementation(
4371 SourceLocation AtClassImplLoc,
4372 IdentifierInfo *ClassName, SourceLocation ClassLoc,
4373 IdentifierInfo *SuperClassname,
4374 SourceLocation SuperClassLoc);
4376 Decl *ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc,
4377 IdentifierInfo *ClassName,
4378 SourceLocation ClassLoc,
4379 IdentifierInfo *CatName,
4380 SourceLocation CatLoc);
4382 Decl *ActOnForwardClassDeclaration(SourceLocation Loc,
4383 IdentifierInfo **IdentList,
4384 SourceLocation *IdentLocs,
4387 Decl *ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc,
4388 const IdentifierLocPair *IdentList,
4390 AttributeList *attrList);
4392 void FindProtocolDeclaration(bool WarnOnDeclarations,
4393 const IdentifierLocPair *ProtocolId,
4394 unsigned NumProtocols,
4395 llvm::SmallVectorImpl<Decl *> &Protocols);
4397 /// Ensure attributes are consistent with type.
4398 /// \param [in, out] Attributes The attributes to check; they will
4399 /// be modified to be consistent with \arg PropertyTy.
4400 void CheckObjCPropertyAttributes(Decl *PropertyPtrTy,
4402 unsigned &Attributes);
4404 /// Process the specified property declaration and create decls for the
4405 /// setters and getters as needed.
4406 /// \param property The property declaration being processed
4407 /// \param DC The semantic container for the property
4408 /// \param redeclaredProperty Declaration for property if redeclared
4409 /// in class extension.
4410 /// \param lexicalDC Container for redeclaredProperty.
4411 void ProcessPropertyDecl(ObjCPropertyDecl *property,
4412 ObjCContainerDecl *DC,
4413 ObjCPropertyDecl *redeclaredProperty = 0,
4414 ObjCContainerDecl *lexicalDC = 0);
4416 void DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
4417 ObjCPropertyDecl *SuperProperty,
4418 const IdentifierInfo *Name);
4419 void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl);
4421 void CompareMethodParamsInBaseAndSuper(Decl *IDecl,
4422 ObjCMethodDecl *MethodDecl,
4425 void CompareProperties(Decl *CDecl, Decl *MergeProtocols);
4427 void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT,
4428 ObjCInterfaceDecl *ID);
4430 void MatchOneProtocolPropertiesInClass(Decl *CDecl,
4431 ObjCProtocolDecl *PDecl);
4433 void ActOnAtEnd(Scope *S, SourceRange AtEnd, Decl *classDecl,
4434 Decl **allMethods = 0, unsigned allNum = 0,
4435 Decl **allProperties = 0, unsigned pNum = 0,
4436 DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0);
4438 Decl *ActOnProperty(Scope *S, SourceLocation AtLoc,
4439 FieldDeclarator &FD, ObjCDeclSpec &ODS,
4440 Selector GetterSel, Selector SetterSel,
4441 Decl *ClassCategory,
4442 bool *OverridingProperty,
4443 tok::ObjCKeywordKind MethodImplKind,
4444 DeclContext *lexicalDC = 0);
4446 Decl *ActOnPropertyImplDecl(Scope *S,
4447 SourceLocation AtLoc,
4448 SourceLocation PropertyLoc,
4449 bool ImplKind,Decl *ClassImplDecl,
4450 IdentifierInfo *PropertyId,
4451 IdentifierInfo *PropertyIvar,
4452 SourceLocation PropertyIvarLoc);
4454 struct ObjCArgInfo {
4455 IdentifierInfo *Name;
4456 SourceLocation NameLoc;
4457 // The Type is null if no type was specified, and the DeclSpec is invalid
4460 ObjCDeclSpec DeclSpec;
4462 /// ArgAttrs - Attribute list for this argument.
4463 AttributeList *ArgAttrs;
4466 Decl *ActOnMethodDeclaration(
4468 SourceLocation BeginLoc, // location of the + or -.
4469 SourceLocation EndLoc, // location of the ; or {.
4470 tok::TokenKind MethodType,
4471 Decl *ClassDecl, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
4473 // optional arguments. The number of types/arguments is obtained
4474 // from the Sel.getNumArgs().
4475 ObjCArgInfo *ArgInfo,
4476 DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args
4477 AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind,
4478 bool isVariadic = false);
4480 // Helper method for ActOnClassMethod/ActOnInstanceMethod.
4481 // Will search "local" class/category implementations for a method decl.
4482 // Will also search in class's root looking for instance method.
4483 // Returns 0 if no method is found.
4484 ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel,
4485 ObjCInterfaceDecl *CDecl);
4486 ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel,
4487 ObjCInterfaceDecl *ClassDecl);
4490 HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
4492 DeclarationName MemberName,
4493 SourceLocation MemberLoc,
4494 SourceLocation SuperLoc, QualType SuperType,
4498 ActOnClassPropertyRefExpr(IdentifierInfo &receiverName,
4499 IdentifierInfo &propertyName,
4500 SourceLocation receiverNameLoc,
4501 SourceLocation propertyNameLoc);
4503 ObjCMethodDecl *tryCaptureObjCSelf();
4505 /// \brief Describes the kind of message expression indicated by a message
4506 /// send that starts with an identifier.
4507 enum ObjCMessageKind {
4508 /// \brief The message is sent to 'super'.
4510 /// \brief The message is an instance message.
4511 ObjCInstanceMessage,
4512 /// \brief The message is a class message, and the identifier is a type
4517 ObjCMessageKind getObjCMessageKind(Scope *S,
4518 IdentifierInfo *Name,
4519 SourceLocation NameLoc,
4521 bool HasTrailingDot,
4522 ParsedType &ReceiverType);
4524 ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc,
4526 SourceLocation LBracLoc,
4527 SourceLocation SelectorLoc,
4528 SourceLocation RBracLoc,
4531 ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo,
4532 QualType ReceiverType,
4533 SourceLocation SuperLoc,
4535 ObjCMethodDecl *Method,
4536 SourceLocation LBracLoc,
4537 SourceLocation SelectorLoc,
4538 SourceLocation RBracLoc,
4541 ExprResult ActOnClassMessage(Scope *S,
4542 ParsedType Receiver,
4544 SourceLocation LBracLoc,
4545 SourceLocation SelectorLoc,
4546 SourceLocation RBracLoc,
4549 ExprResult BuildInstanceMessage(Expr *Receiver,
4550 QualType ReceiverType,
4551 SourceLocation SuperLoc,
4553 ObjCMethodDecl *Method,
4554 SourceLocation LBracLoc,
4555 SourceLocation SelectorLoc,
4556 SourceLocation RBracLoc,
4559 ExprResult ActOnInstanceMessage(Scope *S,
4562 SourceLocation LBracLoc,
4563 SourceLocation SelectorLoc,
4564 SourceLocation RBracLoc,
4568 enum PragmaOptionsAlignKind {
4569 POAK_Native, // #pragma options align=native
4570 POAK_Natural, // #pragma options align=natural
4571 POAK_Packed, // #pragma options align=packed
4572 POAK_Power, // #pragma options align=power
4573 POAK_Mac68k, // #pragma options align=mac68k
4574 POAK_Reset // #pragma options align=reset
4577 /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
4578 void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind,
4579 SourceLocation PragmaLoc,
4580 SourceLocation KindLoc);
4582 enum PragmaPackKind {
4583 PPK_Default, // #pragma pack([n])
4584 PPK_Show, // #pragma pack(show), only supported by MSVC.
4585 PPK_Push, // #pragma pack(push, [identifier], [n])
4586 PPK_Pop // #pragma pack(pop, [identifier], [n])
4589 /// ActOnPragmaPack - Called on well formed #pragma pack(...).
4590 void ActOnPragmaPack(PragmaPackKind Kind,
4591 IdentifierInfo *Name,
4593 SourceLocation PragmaLoc,
4594 SourceLocation LParenLoc,
4595 SourceLocation RParenLoc);
4597 /// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
4598 void ActOnPragmaUnused(const Token &Identifier,
4600 SourceLocation PragmaLoc);
4602 /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
4603 void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType,
4604 SourceLocation PragmaLoc);
4606 NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II);
4607 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W);
4609 /// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
4610 void ActOnPragmaWeakID(IdentifierInfo* WeakName,
4611 SourceLocation PragmaLoc,
4612 SourceLocation WeakNameLoc);
4614 /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
4615 void ActOnPragmaWeakAlias(IdentifierInfo* WeakName,
4616 IdentifierInfo* AliasName,
4617 SourceLocation PragmaLoc,
4618 SourceLocation WeakNameLoc,
4619 SourceLocation AliasNameLoc);
4621 /// ActOnPragmaFPContract - Called on well formed
4622 /// #pragma {STDC,OPENCL} FP_CONTRACT
4623 void ActOnPragmaFPContract(tok::OnOffSwitch OOS);
4625 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
4626 /// a the record decl, to handle '#pragma pack' and '#pragma options align'.
4627 void AddAlignmentAttributesForRecord(RecordDecl *RD);
4629 /// FreePackedContext - Deallocate and null out PackContext.
4630 void FreePackedContext();
4632 /// PushNamespaceVisibilityAttr - Note that we've entered a
4633 /// namespace with a visibility attribute.
4634 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr);
4636 /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
4637 /// add an appropriate visibility attribute.
4638 void AddPushedVisibilityAttribute(Decl *RD);
4640 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
4641 /// for '#pragma GCC visibility' and visibility attributes on namespaces.
4642 void PopPragmaVisibility();
4644 /// FreeVisContext - Deallocate and null out VisContext.
4645 void FreeVisContext();
4647 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4648 void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, Expr *E);
4649 void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, TypeSourceInfo *T);
4651 /// CastCategory - Get the correct forwarded implicit cast result category
4652 /// from the inner expression.
4653 ExprValueKind CastCategory(Expr *E);
4655 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
4656 /// cast. If there is already an implicit cast, merge into the existing one.
4657 /// If isLvalue, the result of the cast is an lvalue.
4658 void ImpCastExprToType(Expr *&Expr, QualType Type, CastKind CK,
4659 ExprValueKind VK = VK_RValue,
4660 const CXXCastPath *BasePath = 0);
4662 /// IgnoredValueConversions - Given that an expression's result is
4663 /// syntactically ignored, perform any conversions that are
4665 void IgnoredValueConversions(Expr *&expr);
4667 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
4668 // functions and arrays to their respective pointers (C99 6.3.2.1).
4669 Expr *UsualUnaryConversions(Expr *&expr);
4671 // DefaultFunctionArrayConversion - converts functions and arrays
4672 // to their respective pointers (C99 6.3.2.1).
4673 void DefaultFunctionArrayConversion(Expr *&expr);
4675 // DefaultFunctionArrayLvalueConversion - converts functions and
4676 // arrays to their respective pointers and performs the
4677 // lvalue-to-rvalue conversion.
4678 void DefaultFunctionArrayLvalueConversion(Expr *&expr);
4680 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
4681 // the operand. This is DefaultFunctionArrayLvalueConversion,
4682 // except that it assumes the operand isn't of function or array
4684 void DefaultLvalueConversion(Expr *&expr);
4686 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
4687 // do not have a prototype. Integer promotions are performed on each
4688 // argument, and arguments that have type float are promoted to double.
4689 void DefaultArgumentPromotion(Expr *&Expr);
4691 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
4692 enum VariadicCallType {
4696 VariadicConstructor,
4697 VariadicDoesNotApply
4700 /// GatherArgumentsForCall - Collector argument expressions for various
4701 /// form of call prototypes.
4702 bool GatherArgumentsForCall(SourceLocation CallLoc,
4703 FunctionDecl *FDecl,
4704 const FunctionProtoType *Proto,
4705 unsigned FirstProtoArg,
4706 Expr **Args, unsigned NumArgs,
4707 llvm::SmallVector<Expr *, 8> &AllArgs,
4708 VariadicCallType CallType = VariadicDoesNotApply);
4710 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
4711 // will warn if the resulting type is not a POD type.
4712 bool DefaultVariadicArgumentPromotion(Expr *&Expr, VariadicCallType CT,
4713 FunctionDecl *FDecl);
4715 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
4716 // operands and then handles various conversions that are common to binary
4717 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
4718 // routine returns the first non-arithmetic type found. The client is
4719 // responsible for emitting appropriate error diagnostics.
4720 QualType UsualArithmeticConversions(Expr *&lExpr, Expr *&rExpr,
4721 bool isCompAssign = false);
4723 /// AssignConvertType - All of the 'assignment' semantic checks return this
4724 /// enum to indicate whether the assignment was allowed. These checks are
4725 /// done for simple assignments, as well as initialization, return from
4726 /// function, argument passing, etc. The query is phrased in terms of a
4727 /// source and destination type.
4728 enum AssignConvertType {
4729 /// Compatible - the types are compatible according to the standard.
4732 /// PointerToInt - The assignment converts a pointer to an int, which we
4733 /// accept as an extension.
4736 /// IntToPointer - The assignment converts an int to a pointer, which we
4737 /// accept as an extension.
4740 /// FunctionVoidPointer - The assignment is between a function pointer and
4741 /// void*, which the standard doesn't allow, but we accept as an extension.
4742 FunctionVoidPointer,
4744 /// IncompatiblePointer - The assignment is between two pointers types that
4745 /// are not compatible, but we accept them as an extension.
4746 IncompatiblePointer,
4748 /// IncompatiblePointer - The assignment is between two pointers types which
4749 /// point to integers which have a different sign, but are otherwise identical.
4750 /// This is a subset of the above, but broken out because it's by far the most
4751 /// common case of incompatible pointers.
4752 IncompatiblePointerSign,
4754 /// CompatiblePointerDiscardsQualifiers - The assignment discards
4755 /// c/v/r qualifiers, which we accept as an extension.
4756 CompatiblePointerDiscardsQualifiers,
4758 /// IncompatiblePointerDiscardsQualifiers - The assignment
4759 /// discards qualifiers that we don't permit to be discarded,
4760 /// like address spaces.
4761 IncompatiblePointerDiscardsQualifiers,
4763 /// IncompatibleNestedPointerQualifiers - The assignment is between two
4764 /// nested pointer types, and the qualifiers other than the first two
4765 /// levels differ e.g. char ** -> const char **, but we accept them as an
4767 IncompatibleNestedPointerQualifiers,
4769 /// IncompatibleVectors - The assignment is between two vector types that
4770 /// have the same size, which we accept as an extension.
4771 IncompatibleVectors,
4773 /// IntToBlockPointer - The assignment converts an int to a block
4774 /// pointer. We disallow this.
4777 /// IncompatibleBlockPointer - The assignment is between two block
4778 /// pointers types that are not compatible.
4779 IncompatibleBlockPointer,
4781 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
4782 /// id type and something else (that is incompatible with it). For example,
4783 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
4784 IncompatibleObjCQualifiedId,
4786 /// Incompatible - We reject this conversion outright, it is invalid to
4787 /// represent it in the AST.
4791 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
4792 /// assignment conversion type specified by ConvTy. This returns true if the
4793 /// conversion was invalid or false if the conversion was accepted.
4794 bool DiagnoseAssignmentResult(AssignConvertType ConvTy,
4796 QualType DstType, QualType SrcType,
4797 Expr *SrcExpr, AssignmentAction Action,
4798 bool *Complained = 0);
4800 /// CheckAssignmentConstraints - Perform type checking for assignment,
4801 /// argument passing, variable initialization, and function return values.
4803 AssignConvertType CheckAssignmentConstraints(SourceLocation Loc,
4804 QualType lhs, QualType rhs);
4806 /// Check assignment constraints and prepare for a conversion of the
4807 /// RHS to the LHS type.
4808 AssignConvertType CheckAssignmentConstraints(QualType lhs, Expr *&rhs,
4811 // CheckSingleAssignmentConstraints - Currently used by
4812 // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
4813 // this routine performs the default function/array converions.
4814 AssignConvertType CheckSingleAssignmentConstraints(QualType lhs,
4817 // \brief If the lhs type is a transparent union, check whether we
4818 // can initialize the transparent union with the given expression.
4819 AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs,
4822 bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType);
4824 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType);
4826 bool PerformImplicitConversion(Expr *&From, QualType ToType,
4827 AssignmentAction Action,
4828 bool AllowExplicit = false);
4829 bool PerformImplicitConversion(Expr *&From, QualType ToType,
4830 AssignmentAction Action,
4832 ImplicitConversionSequence& ICS);
4833 bool PerformImplicitConversion(Expr *&From, QualType ToType,
4834 const ImplicitConversionSequence& ICS,
4835 AssignmentAction Action,
4836 bool CStyle = false);
4837 bool PerformImplicitConversion(Expr *&From, QualType ToType,
4838 const StandardConversionSequence& SCS,
4839 AssignmentAction Action,
4842 /// the following "Check" methods will return a valid/converted QualType
4843 /// or a null QualType (indicating an error diagnostic was issued).
4845 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
4846 QualType InvalidOperands(SourceLocation l, Expr *&lex, Expr *&rex);
4847 QualType CheckPointerToMemberOperands( // C++ 5.5
4848 Expr *&lex, Expr *&rex, ExprValueKind &VK,
4849 SourceLocation OpLoc, bool isIndirect);
4850 QualType CheckMultiplyDivideOperands( // C99 6.5.5
4851 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign,
4853 QualType CheckRemainderOperands( // C99 6.5.5
4854 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
4855 QualType CheckAdditionOperands( // C99 6.5.6
4856 Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
4857 QualType CheckSubtractionOperands( // C99 6.5.6
4858 Expr *&lex, Expr *&rex, SourceLocation OpLoc, QualType* CompLHSTy = 0);
4859 QualType CheckShiftOperands( // C99 6.5.7
4860 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc,
4861 bool isCompAssign = false);
4862 QualType CheckCompareOperands( // C99 6.5.8/9
4863 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc,
4865 QualType CheckBitwiseOperands( // C99 6.5.[10...12]
4866 Expr *&lex, Expr *&rex, SourceLocation OpLoc, bool isCompAssign = false);
4867 QualType CheckLogicalOperands( // C99 6.5.[13,14]
4868 Expr *&lex, Expr *&rex, SourceLocation OpLoc, unsigned Opc);
4869 // CheckAssignmentOperands is used for both simple and compound assignment.
4870 // For simple assignment, pass both expressions and a null converted type.
4871 // For compound assignment, pass both expressions and the converted type.
4872 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2]
4873 Expr *lex, Expr *&rex, SourceLocation OpLoc, QualType convertedType);
4875 void ConvertPropertyForRValue(Expr *&E);
4876 void ConvertPropertyForLValue(Expr *&LHS, Expr *&RHS, QualType& LHSTy);
4878 QualType CheckConditionalOperands( // C99 6.5.15
4879 Expr *&cond, Expr *&lhs, Expr *&rhs,
4880 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
4881 QualType CXXCheckConditionalOperands( // C++ 5.16
4882 Expr *&cond, Expr *&lhs, Expr *&rhs,
4883 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc);
4884 QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2,
4885 bool *NonStandardCompositeType = 0);
4887 QualType FindCompositeObjCPointerType(Expr *&LHS, Expr *&RHS,
4888 SourceLocation questionLoc);
4890 bool DiagnoseConditionalForNull(Expr *LHS, Expr *RHS,
4891 SourceLocation QuestionLoc);
4893 /// type checking for vector binary operators.
4894 QualType CheckVectorOperands(SourceLocation l, Expr *&lex, Expr *&rex);
4895 QualType CheckVectorCompareOperands(Expr *&lex, Expr *&rx,
4896 SourceLocation l, bool isRel);
4898 /// type checking declaration initializers (C99 6.7.8)
4899 bool CheckInitList(const InitializedEntity &Entity,
4900 InitListExpr *&InitList, QualType &DeclType);
4901 bool CheckForConstantInitializer(Expr *e, QualType t);
4903 // type checking C++ declaration initializers (C++ [dcl.init]).
4905 /// ReferenceCompareResult - Expresses the result of comparing two
4906 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
4907 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
4908 enum ReferenceCompareResult {
4909 /// Ref_Incompatible - The two types are incompatible, so direct
4910 /// reference binding is not possible.
4911 Ref_Incompatible = 0,
4912 /// Ref_Related - The two types are reference-related, which means
4913 /// that their unqualified forms (T1 and T2) are either the same
4914 /// or T1 is a base class of T2.
4916 /// Ref_Compatible_With_Added_Qualification - The two types are
4917 /// reference-compatible with added qualification, meaning that
4918 /// they are reference-compatible and the qualifiers on T1 (cv1)
4919 /// are greater than the qualifiers on T2 (cv2).
4920 Ref_Compatible_With_Added_Qualification,
4921 /// Ref_Compatible - The two types are reference-compatible and
4922 /// have equivalent qualifiers (cv1 == cv2).
4926 ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc,
4927 QualType T1, QualType T2,
4928 bool &DerivedToBase,
4929 bool &ObjCConversion);
4931 /// CheckCastTypes - Check type constraints for casting between types under
4932 /// C semantics, or forward to CXXCheckCStyleCast in C++.
4933 bool CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *&CastExpr,
4934 CastKind &Kind, ExprValueKind &VK, CXXCastPath &BasePath,
4935 bool FunctionalStyle = false);
4937 // CheckVectorCast - check type constraints for vectors.
4938 // Since vectors are an extension, there are no C standard reference for this.
4939 // We allow casting between vectors and integer datatypes of the same size.
4940 // returns true if the cast is invalid
4941 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty,
4944 // CheckExtVectorCast - check type constraints for extended vectors.
4945 // Since vectors are an extension, there are no C standard reference for this.
4946 // We allow casting between vectors and integer datatypes of the same size,
4947 // or vectors and the element type of that vector.
4948 // returns true if the cast is invalid
4949 bool CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *&CastExpr,
4952 /// CXXCheckCStyleCast - Check constraints of a C-style or function-style
4953 /// cast under C++ semantics.
4954 bool CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK,
4955 Expr *&CastExpr, CastKind &Kind,
4956 CXXCastPath &BasePath, bool FunctionalStyle);
4958 /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
4959 /// \param Method - May be null.
4960 /// \param [out] ReturnType - The return type of the send.
4961 /// \return true iff there were any incompatible types.
4962 bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel,
4963 ObjCMethodDecl *Method, bool isClassMessage,
4964 SourceLocation lbrac, SourceLocation rbrac,
4965 QualType &ReturnType, ExprValueKind &VK);
4967 /// CheckBooleanCondition - Diagnose problems involving the use of
4968 /// the given expression as a boolean condition (e.g. in an if
4969 /// statement). Also performs the standard function and array
4970 /// decays, possibly changing the input variable.
4972 /// \param Loc - A location associated with the condition, e.g. the
4974 /// \return true iff there were any errors
4975 bool CheckBooleanCondition(Expr *&CondExpr, SourceLocation Loc);
4977 ExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc,
4980 /// DiagnoseAssignmentAsCondition - Given that an expression is
4981 /// being used as a boolean condition, warn if it's an assignment.
4982 void DiagnoseAssignmentAsCondition(Expr *E);
4984 /// \brief Redundant parentheses over an equality comparison can indicate
4985 /// that the user intended an assignment used as condition.
4986 void DiagnoseEqualityWithExtraParens(ParenExpr *parenE);
4988 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
4989 bool CheckCXXBooleanCondition(Expr *&CondExpr);
4991 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
4992 /// the specified width and sign. If an overflow occurs, detect it and emit
4993 /// the specified diagnostic.
4994 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal,
4995 unsigned NewWidth, bool NewSign,
4996 SourceLocation Loc, unsigned DiagID);
4998 /// Checks that the Objective-C declaration is declared in the global scope.
4999 /// Emits an error and marks the declaration as invalid if it's not declared
5000 /// in the global scope.
5001 bool CheckObjCDeclScope(Decl *D);
5003 /// VerifyIntegerConstantExpression - verifies that an expression is an ICE,
5004 /// and reports the appropriate diagnostics. Returns false on success.
5005 /// Can optionally return the value of the expression.
5006 bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0);
5008 /// VerifyBitField - verifies that a bit field expression is an ICE and has
5009 /// the correct width, and that the field type is valid.
5010 /// Returns false on success.
5011 /// Can optionally return whether the bit-field is of width 0
5012 bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName,
5013 QualType FieldTy, const Expr *BitWidth,
5014 bool *ZeroWidth = 0);
5016 /// \name Code completion
5018 /// \brief Describes the context in which code completion occurs.
5019 enum ParserCompletionContext {
5020 /// \brief Code completion occurs at top-level or namespace context.
5022 /// \brief Code completion occurs within a class, struct, or union.
5024 /// \brief Code completion occurs within an Objective-C interface, protocol,
5027 /// \brief Code completion occurs within an Objective-C implementation or
5028 /// category implementation
5029 PCC_ObjCImplementation,
5030 /// \brief Code completion occurs within the list of instance variables
5031 /// in an Objective-C interface, protocol, category, or implementation.
5032 PCC_ObjCInstanceVariableList,
5033 /// \brief Code completion occurs following one or more template
5036 /// \brief Code completion occurs following one or more template
5037 /// headers within a class.
5039 /// \brief Code completion occurs within an expression.
5041 /// \brief Code completion occurs within a statement, which may
5042 /// also be an expression or a declaration.
5044 /// \brief Code completion occurs at the beginning of the
5045 /// initialization statement (or expression) in a for loop.
5047 /// \brief Code completion occurs within the condition of an if,
5048 /// while, switch, or for statement.
5050 /// \brief Code completion occurs within the body of a function on a
5051 /// recovery path, where we do not have a specific handle on our position
5053 PCC_RecoveryInFunction,
5054 /// \brief Code completion occurs where only a type is permitted.
5056 /// \brief Code completion occurs in a parenthesized expression, which
5057 /// might also be a type cast.
5058 PCC_ParenthesizedExpression,
5059 /// \brief Code completion occurs within a sequence of declaration
5060 /// specifiers within a function, method, or block.
5061 PCC_LocalDeclarationSpecifiers
5064 void CodeCompleteOrdinaryName(Scope *S,
5065 ParserCompletionContext CompletionContext);
5066 void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS,
5067 bool AllowNonIdentifiers,
5068 bool AllowNestedNameSpecifiers);
5070 struct CodeCompleteExpressionData;
5071 void CodeCompleteExpression(Scope *S,
5072 const CodeCompleteExpressionData &Data);
5073 void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base,
5074 SourceLocation OpLoc,
5076 void CodeCompletePostfixExpression(Scope *S, ExprResult LHS);
5077 void CodeCompleteTag(Scope *S, unsigned TagSpec);
5078 void CodeCompleteTypeQualifiers(DeclSpec &DS);
5079 void CodeCompleteCase(Scope *S);
5080 void CodeCompleteCall(Scope *S, Expr *Fn, Expr **Args, unsigned NumArgs);
5081 void CodeCompleteInitializer(Scope *S, Decl *D);
5082 void CodeCompleteReturn(Scope *S);
5083 void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS);
5085 void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
5086 bool EnteringContext);
5087 void CodeCompleteUsing(Scope *S);
5088 void CodeCompleteUsingDirective(Scope *S);
5089 void CodeCompleteNamespaceDecl(Scope *S);
5090 void CodeCompleteNamespaceAliasDecl(Scope *S);
5091 void CodeCompleteOperatorName(Scope *S);
5092 void CodeCompleteConstructorInitializer(Decl *Constructor,
5093 CXXCtorInitializer** Initializers,
5094 unsigned NumInitializers);
5096 void CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl,
5098 void CodeCompleteObjCAtVisibility(Scope *S);
5099 void CodeCompleteObjCAtStatement(Scope *S);
5100 void CodeCompleteObjCAtExpression(Scope *S);
5101 void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
5102 void CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl);
5103 void CodeCompleteObjCPropertySetter(Scope *S, Decl *ClassDecl);
5104 void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
5106 void CodeCompleteObjCMessageReceiver(Scope *S);
5107 void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
5108 IdentifierInfo **SelIdents,
5109 unsigned NumSelIdents,
5110 bool AtArgumentExpression);
5111 void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
5112 IdentifierInfo **SelIdents,
5113 unsigned NumSelIdents,
5114 bool AtArgumentExpression,
5115 bool IsSuper = false);
5116 void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver,
5117 IdentifierInfo **SelIdents,
5118 unsigned NumSelIdents,
5119 bool AtArgumentExpression,
5120 ObjCInterfaceDecl *Super = 0);
5121 void CodeCompleteObjCForCollection(Scope *S,
5122 DeclGroupPtrTy IterationVar);
5123 void CodeCompleteObjCSelector(Scope *S,
5124 IdentifierInfo **SelIdents,
5125 unsigned NumSelIdents);
5126 void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols,
5127 unsigned NumProtocols);
5128 void CodeCompleteObjCProtocolDecl(Scope *S);
5129 void CodeCompleteObjCInterfaceDecl(Scope *S);
5130 void CodeCompleteObjCSuperclass(Scope *S,
5131 IdentifierInfo *ClassName,
5132 SourceLocation ClassNameLoc);
5133 void CodeCompleteObjCImplementationDecl(Scope *S);
5134 void CodeCompleteObjCInterfaceCategory(Scope *S,
5135 IdentifierInfo *ClassName,
5136 SourceLocation ClassNameLoc);
5137 void CodeCompleteObjCImplementationCategory(Scope *S,
5138 IdentifierInfo *ClassName,
5139 SourceLocation ClassNameLoc);
5140 void CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl);
5141 void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
5142 IdentifierInfo *PropertyName,
5144 void CodeCompleteObjCMethodDecl(Scope *S,
5145 bool IsInstanceMethod,
5146 ParsedType ReturnType,
5148 void CodeCompleteObjCMethodDeclSelector(Scope *S,
5149 bool IsInstanceMethod,
5150 bool AtParameterName,
5151 ParsedType ReturnType,
5152 IdentifierInfo **SelIdents,
5153 unsigned NumSelIdents);
5154 void CodeCompletePreprocessorDirective(bool InConditional);
5155 void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
5156 void CodeCompletePreprocessorMacroName(bool IsDefinition);
5157 void CodeCompletePreprocessorExpression();
5158 void CodeCompletePreprocessorMacroArgument(Scope *S,
5159 IdentifierInfo *Macro,
5160 MacroInfo *MacroInfo,
5162 void CodeCompleteNaturalLanguage();
5163 void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
5164 llvm::SmallVectorImpl<CodeCompletionResult> &Results);
5167 void PrintStats() const {}
5169 //===--------------------------------------------------------------------===//
5170 // Extra semantic analysis beyond the C type system
5173 SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL,
5174 unsigned ByteNo) const;
5177 void CheckArrayAccess(const ArraySubscriptExpr *E);
5178 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall);
5179 bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall);
5181 bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall);
5182 bool CheckObjCString(Expr *Arg);
5184 ExprResult CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
5185 bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
5187 bool SemaBuiltinVAStart(CallExpr *TheCall);
5188 bool SemaBuiltinUnorderedCompare(CallExpr *TheCall);
5189 bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs);
5192 // Used by C++ template instantiation.
5193 ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall);
5196 bool SemaBuiltinPrefetch(CallExpr *TheCall);
5197 bool SemaBuiltinObjectSize(CallExpr *TheCall);
5198 bool SemaBuiltinLongjmp(CallExpr *TheCall);
5199 ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
5200 bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
5201 llvm::APSInt &Result);
5203 bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall,
5204 bool HasVAListArg, unsigned format_idx,
5205 unsigned firstDataArg, bool isPrintf);
5207 void CheckFormatString(const StringLiteral *FExpr, const Expr *OrigFormatExpr,
5208 const CallExpr *TheCall, bool HasVAListArg,
5209 unsigned format_idx, unsigned firstDataArg,
5212 void CheckNonNullArguments(const NonNullAttr *NonNull,
5213 const CallExpr *TheCall);
5215 void CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg,
5216 unsigned format_idx, unsigned firstDataArg,
5219 void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
5220 SourceLocation ReturnLoc);
5221 void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex);
5222 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation());
5224 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field,
5227 /// \brief The parser's current scope.
5229 /// The parser maintains this state here.
5233 friend class Parser;
5234 friend class InitializationSequence;
5236 /// \brief Retrieve the parser's current scope.
5237 Scope *getCurScope() const { return CurScope; }
5240 /// \brief RAII object that enters a new expression evaluation context.
5241 class EnterExpressionEvaluationContext {
5245 EnterExpressionEvaluationContext(Sema &Actions,
5246 Sema::ExpressionEvaluationContext NewContext)
5247 : Actions(Actions) {
5248 Actions.PushExpressionEvaluationContext(NewContext);
5251 ~EnterExpressionEvaluationContext() {
5252 Actions.PopExpressionEvaluationContext();
5256 } // end namespace clang