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 /// \brief A mapping from external names to the most recent
271 /// locally-scoped external declaration with that name.
273 /// This map contains external declarations introduced in local
278 /// void foo(int, int);
282 /// Here, the name "foo" will be associated with the declaration on
283 /// "foo" within f. This name is not visible outside of
284 /// "f". However, we still find it in two cases:
286 /// - If we are declaring another external with the name "foo", we
287 /// can find "foo" as a previous declaration, so that the types
288 /// of this external declaration can be checked for
291 /// - If we would implicitly declare "foo" (e.g., due to a call to
292 /// "foo" in C when no prototype or definition is visible), then
293 /// we find this declaration of "foo" and complain that it is
295 llvm::DenseMap
<DeclarationName
, NamedDecl
*> LocallyScopedExternalDecls
;
297 /// \brief All the tentative definitions encountered in the TU.
298 llvm::SmallVector
<VarDecl
*, 2> TentativeDefinitions
;
300 /// \brief The set of file scoped decls seen so far that have not been used
301 /// and must warn if not used. Only contains the first declaration.
302 llvm::SmallVector
<const DeclaratorDecl
*, 4> UnusedFileScopedDecls
;
304 class DelayedDiagnostics
;
306 class ParsingDeclState
{
307 unsigned SavedStackSize
;
308 friend class Sema::DelayedDiagnostics
;
311 class ProcessingContextState
{
312 unsigned SavedParsingDepth
;
313 unsigned SavedActiveStackBase
;
314 friend class Sema::DelayedDiagnostics
;
317 /// A class which encapsulates the logic for delaying diagnostics
318 /// during parsing and other processing.
319 class DelayedDiagnostics
{
320 /// \brief The stack of diagnostics that were delayed due to being
321 /// produced during the parsing of a declaration.
322 sema::DelayedDiagnostic
*Stack
;
324 /// \brief The number of objects on the delayed-diagnostics stack.
327 /// \brief The current capacity of the delayed-diagnostics stack.
328 unsigned StackCapacity
;
330 /// \brief The index of the first "active" delayed diagnostic in
331 /// the stack. When parsing class definitions, we ignore active
332 /// delayed diagnostics from the surrounding context.
333 unsigned ActiveStackBase
;
335 /// \brief The depth of the declarations we're currently parsing.
336 /// This gets saved and reset whenever we enter a class definition.
337 unsigned ParsingDepth
;
340 DelayedDiagnostics() : Stack(0), StackSize(0), StackCapacity(0),
341 ActiveStackBase(0), ParsingDepth(0) {}
343 ~DelayedDiagnostics() {
344 delete[] reinterpret_cast<char*>(Stack
);
347 /// Adds a delayed diagnostic.
348 void add(const sema::DelayedDiagnostic
&diag
);
350 /// Determines whether diagnostics should be delayed.
351 bool shouldDelayDiagnostics() { return ParsingDepth
> 0; }
353 /// Observe that we've started parsing a declaration. Access and
354 /// deprecation diagnostics will be delayed; when the declaration
355 /// is completed, all active delayed diagnostics will be evaluated
356 /// in its context, and then active diagnostics stack will be
357 /// popped down to the saved depth.
358 ParsingDeclState
pushParsingDecl() {
361 ParsingDeclState state
;
362 state
.SavedStackSize
= StackSize
;
366 /// Observe that we're completed parsing a declaration.
367 static void popParsingDecl(Sema
&S
, ParsingDeclState state
, Decl
*decl
);
369 /// Observe that we've started processing a different context, the
370 /// contents of which are semantically separate from the
371 /// declarations it may lexically appear in. This sets aside the
372 /// current stack of active diagnostics and starts afresh.
373 ProcessingContextState
pushContext() {
374 assert(StackSize
>= ActiveStackBase
);
376 ProcessingContextState state
;
377 state
.SavedParsingDepth
= ParsingDepth
;
378 state
.SavedActiveStackBase
= ActiveStackBase
;
380 ActiveStackBase
= StackSize
;
386 /// Observe that we've stopped processing a context. This
387 /// restores the previous stack of active diagnostics.
388 void popContext(ProcessingContextState state
) {
389 assert(ActiveStackBase
== StackSize
);
390 assert(ParsingDepth
== 0);
391 ActiveStackBase
= state
.SavedActiveStackBase
;
392 ParsingDepth
= state
.SavedParsingDepth
;
394 } DelayedDiagnostics
;
396 /// A RAII object to temporarily push a declaration context.
400 DeclContext
*SavedContext
;
401 ProcessingContextState SavedContextState
;
404 ContextRAII(Sema
&S
, DeclContext
*ContextToPush
)
405 : S(S
), SavedContext(S
.CurContext
),
406 SavedContextState(S
.DelayedDiagnostics
.pushContext())
408 assert(ContextToPush
&& "pushing null context");
409 S
.CurContext
= ContextToPush
;
413 if (!SavedContext
) return;
414 S
.CurContext
= SavedContext
;
415 S
.DelayedDiagnostics
.popContext(SavedContextState
);
424 /// WeakUndeclaredIdentifiers - Identifiers contained in
425 /// #pragma weak before declared. rare. may alias another
426 /// identifier, declared or undeclared
428 IdentifierInfo
*alias
; // alias (optional)
429 SourceLocation loc
; // for diagnostics
430 bool used
; // identifier later declared?
433 : alias(0), loc(SourceLocation()), used(false) {}
434 WeakInfo(IdentifierInfo
*Alias
, SourceLocation Loc
)
435 : alias(Alias
), loc(Loc
), used(false) {}
436 inline IdentifierInfo
* getAlias() const { return alias
; }
437 inline SourceLocation
getLocation() const { return loc
; }
438 void setUsed(bool Used
=true) { used
= Used
; }
439 inline bool getUsed() { return used
; }
440 bool operator==(WeakInfo RHS
) const {
441 return alias
== RHS
.getAlias() && loc
== RHS
.getLocation();
443 bool operator!=(WeakInfo RHS
) const { return !(*this == RHS
); }
445 llvm::DenseMap
<IdentifierInfo
*,WeakInfo
> WeakUndeclaredIdentifiers
;
447 /// WeakTopLevelDecl - Translation-unit scoped declarations generated by
448 /// #pragma weak during processing of other Decls.
449 /// I couldn't figure out a clean way to generate these in-line, so
450 /// we store them here and handle separately -- which is a hack.
451 /// It would be best to refactor this.
452 llvm::SmallVector
<Decl
*,2> WeakTopLevelDecl
;
454 IdentifierResolver IdResolver
;
456 /// Translation Unit Scope - useful to Objective-C actions that need
457 /// to lookup file scope declarations in the "ordinary" C decl namespace.
458 /// For example, user-defined classes, built-in "id" type, etc.
461 /// \brief The C++ "std" namespace, where the standard library resides.
462 LazyDeclPtr StdNamespace
;
464 /// \brief The C++ "std::bad_alloc" class, which is defined by the C++
465 /// standard library.
466 LazyDeclPtr StdBadAlloc
;
468 /// \brief The C++ "type_info" declaration, which is defined in <typeinfo>.
469 RecordDecl
*CXXTypeInfoDecl
;
471 /// \brief The MSVC "_GUID" struct, which is defined in MSVC header files.
472 RecordDecl
*MSVCGuidDecl
;
474 /// A flag to remember whether the implicit forms of operator new and delete
475 /// have been declared.
476 bool GlobalNewDeleteDeclared
;
478 /// \brief The set of declarations that have been referenced within
479 /// a potentially evaluated expression.
480 typedef llvm::SmallVector
<std::pair
<SourceLocation
, Decl
*>, 10>
481 PotentiallyReferencedDecls
;
483 /// \brief A set of diagnostics that may be emitted.
484 typedef llvm::SmallVector
<std::pair
<SourceLocation
, PartialDiagnostic
>, 10>
485 PotentiallyEmittedDiagnostics
;
487 /// \brief Describes how the expressions currently being parsed are
488 /// evaluated at run-time, if at all.
489 enum ExpressionEvaluationContext
{
490 /// \brief The current expression and its subexpressions occur within an
491 /// unevaluated operand (C++0x [expr]p8), such as a constant expression
492 /// or the subexpression of \c sizeof, where the type or the value of the
493 /// expression may be significant but no code will be generated to evaluate
494 /// the value of the expression at run time.
497 /// \brief The current expression is potentially evaluated at run time,
498 /// which means that code may be generated to evaluate the value of the
499 /// expression at run time.
500 PotentiallyEvaluated
,
502 /// \brief The current expression may be potentially evaluated or it may
503 /// be unevaluated, but it is impossible to tell from the lexical context.
504 /// This evaluation context is used primary for the operand of the C++
505 /// \c typeid expression, whose argument is potentially evaluated only when
506 /// it is an lvalue of polymorphic class type (C++ [basic.def.odr]p2).
507 PotentiallyPotentiallyEvaluated
,
509 /// \brief The current expression is potentially evaluated, but any
510 /// declarations referenced inside that expression are only used if
511 /// in fact the current expression is used.
513 /// This value is used when parsing default function arguments, for which
514 /// we would like to provide diagnostics (e.g., passing non-POD arguments
515 /// through varargs) but do not want to mark declarations as "referenced"
516 /// until the default argument is used.
517 PotentiallyEvaluatedIfUsed
520 /// \brief Data structure used to record current or nested
521 /// expression evaluation contexts.
522 struct ExpressionEvaluationContextRecord
{
523 /// \brief The expression evaluation context.
524 ExpressionEvaluationContext Context
;
526 /// \brief The number of temporaries that were active when we
527 /// entered this expression evaluation context.
528 unsigned NumTemporaries
;
530 /// \brief The set of declarations referenced within a
531 /// potentially potentially-evaluated context.
533 /// When leaving a potentially potentially-evaluated context, each
534 /// of these elements will be as referenced if the corresponding
535 /// potentially potentially evaluated expression is potentially
537 PotentiallyReferencedDecls
*PotentiallyReferenced
;
539 /// \brief The set of diagnostics to emit should this potentially
540 /// potentially-evaluated context become evaluated.
541 PotentiallyEmittedDiagnostics
*PotentiallyDiagnosed
;
543 ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context
,
544 unsigned NumTemporaries
)
545 : Context(Context
), NumTemporaries(NumTemporaries
),
546 PotentiallyReferenced(0), PotentiallyDiagnosed(0) { }
548 void addReferencedDecl(SourceLocation Loc
, Decl
*Decl
) {
549 if (!PotentiallyReferenced
)
550 PotentiallyReferenced
= new PotentiallyReferencedDecls
;
551 PotentiallyReferenced
->push_back(std::make_pair(Loc
, Decl
));
554 void addDiagnostic(SourceLocation Loc
, const PartialDiagnostic
&PD
) {
555 if (!PotentiallyDiagnosed
)
556 PotentiallyDiagnosed
= new PotentiallyEmittedDiagnostics
;
557 PotentiallyDiagnosed
->push_back(std::make_pair(Loc
, PD
));
561 delete PotentiallyReferenced
;
562 delete PotentiallyDiagnosed
;
563 PotentiallyReferenced
= 0;
564 PotentiallyDiagnosed
= 0;
568 /// A stack of expression evaluation contexts.
569 llvm::SmallVector
<ExpressionEvaluationContextRecord
, 8> ExprEvalContexts
;
571 /// \brief Whether the code handled by Sema should be considered a
572 /// complete translation unit or not.
574 /// When true (which is generally the case), Sema will perform
575 /// end-of-translation-unit semantic tasks (such as creating
576 /// initializers for tentative definitions in C) once parsing has
577 /// completed. This flag will be false when building PCH files,
578 /// since a PCH file is by definition not a complete translation
580 bool CompleteTranslationUnit
;
582 llvm::BumpPtrAllocator BumpAlloc
;
584 /// \brief The number of SFINAE diagnostics that have been trapped.
585 unsigned NumSFINAEErrors
;
587 typedef llvm::DenseMap
<ParmVarDecl
*, llvm::SmallVector
<ParmVarDecl
*, 1> >
588 UnparsedDefaultArgInstantiationsMap
;
590 /// \brief A mapping from parameters with unparsed default arguments to the
591 /// set of instantiations of each parameter.
593 /// This mapping is a temporary data structure used when parsing
594 /// nested class templates or nested classes of class templates,
595 /// where we might end up instantiating an inner class before the
596 /// default arguments of its methods have been parsed.
597 UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations
;
599 // Contains the locations of the beginning of unparsed default
600 // argument locations.
601 llvm::DenseMap
<ParmVarDecl
*,SourceLocation
> UnparsedDefaultArgLocs
;
603 typedef std::pair
<ObjCMethodList
, ObjCMethodList
> GlobalMethods
;
604 typedef llvm::DenseMap
<Selector
, GlobalMethods
> GlobalMethodPool
;
606 /// Method Pool - allows efficient lookup when typechecking messages to "id".
607 /// We need to maintain a list, since selectors can have differing signatures
608 /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
609 /// of selectors are "overloaded").
610 GlobalMethodPool MethodPool
;
612 /// Method selectors used in a @selector expression. Used for implementation
614 llvm::DenseMap
<Selector
, SourceLocation
> ReferencedSelectors
;
616 GlobalMethodPool::iterator
ReadMethodPool(Selector Sel
);
618 /// Private Helper predicate to check for 'self'.
619 bool isSelfExpr(Expr
*RExpr
);
621 Sema(Preprocessor
&pp
, ASTContext
&ctxt
, ASTConsumer
&consumer
,
622 bool CompleteTranslationUnit
= true,
623 CodeCompleteConsumer
*CompletionConsumer
= 0);
626 /// \brief Perform initialization that occurs after the parser has been
627 /// initialized but before it parses anything.
630 const LangOptions
&getLangOptions() const { return LangOpts
; }
631 OpenCLOptions
&getOpenCLOptions() { return OpenCLFeatures
; }
632 FPOptions
&getFPOptions() { return FPFeatures
; }
634 Diagnostic
&getDiagnostics() const { return Diags
; }
635 SourceManager
&getSourceManager() const { return SourceMgr
; }
636 const TargetAttributesSema
&getTargetAttributesSema() const;
637 Preprocessor
&getPreprocessor() const { return PP
; }
638 ASTContext
&getASTContext() const { return Context
; }
639 ASTConsumer
&getASTConsumer() const { return Consumer
; }
641 /// \brief Helper class that creates diagnostics with optional
642 /// template instantiation stacks.
644 /// This class provides a wrapper around the basic DiagnosticBuilder
645 /// class that emits diagnostics. SemaDiagnosticBuilder is
646 /// responsible for emitting the diagnostic (as DiagnosticBuilder
647 /// does) and, if the diagnostic comes from inside a template
648 /// instantiation, printing the template instantiation stack as
650 class SemaDiagnosticBuilder
: public DiagnosticBuilder
{
655 SemaDiagnosticBuilder(DiagnosticBuilder
&DB
, Sema
&SemaRef
, unsigned DiagID
)
656 : DiagnosticBuilder(DB
), SemaRef(SemaRef
), DiagID(DiagID
) { }
658 explicit SemaDiagnosticBuilder(Sema
&SemaRef
)
659 : DiagnosticBuilder(DiagnosticBuilder::Suppress
), SemaRef(SemaRef
) { }
661 ~SemaDiagnosticBuilder();
664 /// \brief Emit a diagnostic.
665 SemaDiagnosticBuilder
Diag(SourceLocation Loc
, unsigned DiagID
);
667 /// \brief Emit a partial diagnostic.
668 SemaDiagnosticBuilder
Diag(SourceLocation Loc
, const PartialDiagnostic
& PD
);
670 /// \brief Build a partial diagnostic.
671 PartialDiagnostic
PDiag(unsigned DiagID
= 0); // in SemaInternal.h
673 ExprResult
Owned(Expr
* E
) { return E
; }
674 ExprResult
Owned(ExprResult R
) { return R
; }
675 StmtResult
Owned(Stmt
* S
) { return S
; }
677 void ActOnEndOfTranslationUnit();
679 Scope
*getScopeForContext(DeclContext
*Ctx
);
681 void PushFunctionScope();
682 void PushBlockScope(Scope
*BlockScope
, BlockDecl
*Block
);
683 void PopFunctionOrBlockScope();
685 sema::FunctionScopeInfo
*getCurFunction() const {
686 return FunctionScopes
.back();
689 bool hasAnyErrorsInThisFunction() const;
691 /// \brief Retrieve the current block, if any.
692 sema::BlockScopeInfo
*getCurBlock();
694 /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls
695 llvm::SmallVector
<Decl
*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl
; }
697 //===--------------------------------------------------------------------===//
698 // Type Analysis / Processing: SemaType.cpp.
701 QualType
adjustParameterType(QualType T
);
702 QualType
BuildQualifiedType(QualType T
, SourceLocation Loc
, Qualifiers Qs
);
703 QualType
BuildQualifiedType(QualType T
, SourceLocation Loc
, unsigned CVR
) {
704 return BuildQualifiedType(T
, Loc
, Qualifiers::fromCVRMask(CVR
));
706 QualType
BuildPointerType(QualType T
,
707 SourceLocation Loc
, DeclarationName Entity
);
708 QualType
BuildReferenceType(QualType T
, bool LValueRef
,
709 SourceLocation Loc
, DeclarationName Entity
);
710 QualType
BuildArrayType(QualType T
, ArrayType::ArraySizeModifier ASM
,
711 Expr
*ArraySize
, unsigned Quals
,
712 SourceRange Brackets
, DeclarationName Entity
);
713 QualType
BuildExtVectorType(QualType T
, Expr
*ArraySize
,
714 SourceLocation AttrLoc
);
715 QualType
BuildFunctionType(QualType T
,
716 QualType
*ParamTypes
, unsigned NumParamTypes
,
717 bool Variadic
, unsigned Quals
,
718 RefQualifierKind RefQualifier
,
719 SourceLocation Loc
, DeclarationName Entity
,
720 FunctionType::ExtInfo Info
);
721 QualType
BuildMemberPointerType(QualType T
, QualType Class
,
723 DeclarationName Entity
);
724 QualType
BuildBlockPointerType(QualType T
,
725 SourceLocation Loc
, DeclarationName Entity
);
726 QualType
BuildParenType(QualType T
);
728 TypeSourceInfo
*GetTypeForDeclarator(Declarator
&D
, Scope
*S
,
729 TagDecl
**OwnedDecl
= 0);
730 TypeSourceInfo
*GetTypeSourceInfoForDeclarator(Declarator
&D
, QualType T
,
731 TypeSourceInfo
*ReturnTypeInfo
);
732 /// \brief Package the given type and TSI into a ParsedType.
733 ParsedType
CreateParsedType(QualType T
, TypeSourceInfo
*TInfo
);
734 DeclarationNameInfo
GetNameForDeclarator(Declarator
&D
);
735 DeclarationNameInfo
GetNameFromUnqualifiedId(const UnqualifiedId
&Name
);
736 static QualType
GetTypeFromParser(ParsedType Ty
, TypeSourceInfo
**TInfo
= 0);
737 bool CheckSpecifiedExceptionType(QualType T
, const SourceRange
&Range
);
738 bool CheckDistantExceptionSpec(QualType T
);
739 bool CheckEquivalentExceptionSpec(FunctionDecl
*Old
, FunctionDecl
*New
);
740 bool CheckEquivalentExceptionSpec(
741 const FunctionProtoType
*Old
, SourceLocation OldLoc
,
742 const FunctionProtoType
*New
, SourceLocation NewLoc
);
743 bool CheckEquivalentExceptionSpec(
744 const PartialDiagnostic
&DiagID
, const PartialDiagnostic
& NoteID
,
745 const FunctionProtoType
*Old
, SourceLocation OldLoc
,
746 const FunctionProtoType
*New
, SourceLocation NewLoc
,
747 bool *MissingExceptionSpecification
= 0,
748 bool *MissingEmptyExceptionSpecification
= 0);
749 bool CheckExceptionSpecSubset(
750 const PartialDiagnostic
&DiagID
, const PartialDiagnostic
& NoteID
,
751 const FunctionProtoType
*Superset
, SourceLocation SuperLoc
,
752 const FunctionProtoType
*Subset
, SourceLocation SubLoc
);
753 bool CheckParamExceptionSpec(const PartialDiagnostic
& NoteID
,
754 const FunctionProtoType
*Target
, SourceLocation TargetLoc
,
755 const FunctionProtoType
*Source
, SourceLocation SourceLoc
);
757 TypeResult
ActOnTypeName(Scope
*S
, Declarator
&D
);
759 bool RequireCompleteType(SourceLocation Loc
, QualType T
,
760 const PartialDiagnostic
&PD
,
761 std::pair
<SourceLocation
, PartialDiagnostic
> Note
);
762 bool RequireCompleteType(SourceLocation Loc
, QualType T
,
763 const PartialDiagnostic
&PD
);
764 bool RequireCompleteType(SourceLocation Loc
, QualType T
,
767 QualType
getElaboratedType(ElaboratedTypeKeyword Keyword
,
768 const CXXScopeSpec
&SS
, QualType T
);
770 QualType
BuildTypeofExprType(Expr
*E
, SourceLocation Loc
);
771 QualType
BuildDecltypeType(Expr
*E
, SourceLocation Loc
);
773 //===--------------------------------------------------------------------===//
774 // Symbol table / Decl tracking callbacks: SemaDecl.cpp.
777 DeclGroupPtrTy
ConvertDeclToDeclGroup(Decl
*Ptr
);
779 void DiagnoseUseOfUnimplementedSelectors();
781 ParsedType
getTypeName(IdentifierInfo
&II
, SourceLocation NameLoc
,
782 Scope
*S
, CXXScopeSpec
*SS
= 0,
783 bool isClassName
= false,
784 bool HasTrailingDot
= false,
785 ParsedType ObjectType
= ParsedType());
786 TypeSpecifierType
isTagName(IdentifierInfo
&II
, Scope
*S
);
787 bool DiagnoseUnknownTypeName(const IdentifierInfo
&II
,
788 SourceLocation IILoc
,
791 ParsedType
&SuggestedType
);
793 Decl
*ActOnDeclarator(Scope
*S
, Declarator
&D
);
795 Decl
*HandleDeclarator(Scope
*S
, Declarator
&D
,
796 MultiTemplateParamsArg TemplateParameterLists
,
797 bool IsFunctionDefinition
);
798 void RegisterLocallyScopedExternCDecl(NamedDecl
*ND
,
799 const LookupResult
&Previous
,
801 void DiagnoseFunctionSpecifiers(Declarator
& D
);
802 void CheckShadow(Scope
*S
, VarDecl
*D
, const LookupResult
& R
);
803 void CheckShadow(Scope
*S
, VarDecl
*D
);
804 void CheckCastAlign(Expr
*Op
, QualType T
, SourceRange TRange
);
805 NamedDecl
* ActOnTypedefDeclarator(Scope
* S
, Declarator
& D
, DeclContext
* DC
,
806 QualType R
, TypeSourceInfo
*TInfo
,
807 LookupResult
&Previous
, bool &Redeclaration
);
808 NamedDecl
* ActOnVariableDeclarator(Scope
* S
, Declarator
& D
, DeclContext
* DC
,
809 QualType R
, TypeSourceInfo
*TInfo
,
810 LookupResult
&Previous
,
811 MultiTemplateParamsArg TemplateParamLists
,
812 bool &Redeclaration
);
813 void CheckVariableDeclaration(VarDecl
*NewVD
, LookupResult
&Previous
,
814 bool &Redeclaration
);
815 void CheckCompleteVariableDeclaration(VarDecl
*var
);
816 NamedDecl
* ActOnFunctionDeclarator(Scope
* S
, Declarator
& D
, DeclContext
* DC
,
817 QualType R
, TypeSourceInfo
*TInfo
,
818 LookupResult
&Previous
,
819 MultiTemplateParamsArg TemplateParamLists
,
820 bool IsFunctionDefinition
,
821 bool &Redeclaration
);
822 bool AddOverriddenMethods(CXXRecordDecl
*DC
, CXXMethodDecl
*MD
);
823 void DiagnoseHiddenVirtualMethods(CXXRecordDecl
*DC
, CXXMethodDecl
*MD
);
824 void CheckFunctionDeclaration(Scope
*S
,
825 FunctionDecl
*NewFD
, LookupResult
&Previous
,
826 bool IsExplicitSpecialization
,
827 bool &Redeclaration
);
828 void CheckMain(FunctionDecl
*FD
);
829 Decl
*ActOnParamDeclarator(Scope
*S
, Declarator
&D
);
830 ParmVarDecl
*BuildParmVarDeclForTypedef(DeclContext
*DC
,
833 ParmVarDecl
*CheckParameter(DeclContext
*DC
,
834 TypeSourceInfo
*TSInfo
, QualType T
,
835 IdentifierInfo
*Name
,
836 SourceLocation NameLoc
,
838 StorageClass SCAsWritten
);
839 void ActOnParamDefaultArgument(Decl
*param
,
840 SourceLocation EqualLoc
,
842 void ActOnParamUnparsedDefaultArgument(Decl
*param
,
843 SourceLocation EqualLoc
,
844 SourceLocation ArgLoc
);
845 void ActOnParamDefaultArgumentError(Decl
*param
);
846 bool SetParamDefaultArgument(ParmVarDecl
*Param
, Expr
*DefaultArg
,
847 SourceLocation EqualLoc
);
849 void AddInitializerToDecl(Decl
*dcl
, Expr
*init
);
850 void AddInitializerToDecl(Decl
*dcl
, Expr
*init
, bool DirectInit
);
851 void ActOnUninitializedDecl(Decl
*dcl
, bool TypeContainsUndeducedAuto
);
852 void ActOnInitializerError(Decl
*Dcl
);
853 void SetDeclDeleted(Decl
*dcl
, SourceLocation DelLoc
);
854 DeclGroupPtrTy
FinalizeDeclaratorGroup(Scope
*S
, const DeclSpec
&DS
,
857 void ActOnFinishKNRParamDeclarations(Scope
*S
, Declarator
&D
,
858 SourceLocation LocAfterDecls
);
859 Decl
*ActOnStartOfFunctionDef(Scope
*S
, Declarator
&D
);
860 Decl
*ActOnStartOfFunctionDef(Scope
*S
, Decl
*D
);
861 void ActOnStartOfObjCMethodDef(Scope
*S
, Decl
*D
);
863 Decl
*ActOnFinishFunctionBody(Decl
*Decl
, Stmt
*Body
);
864 Decl
*ActOnFinishFunctionBody(Decl
*Decl
, Stmt
*Body
, bool IsInstantiation
);
866 /// \brief Diagnose any unused parameters in the given sequence of
867 /// ParmVarDecl pointers.
868 void DiagnoseUnusedParameters(ParmVarDecl
* const *Begin
,
869 ParmVarDecl
* const *End
);
871 /// \brief Diagnose whether the size of parameters or return value of a
872 /// function or obj-c method definition is pass-by-value and larger than a
873 /// specified threshold.
874 void DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl
* const *Begin
,
875 ParmVarDecl
* const *End
,
879 void DiagnoseInvalidJumps(Stmt
*Body
);
880 Decl
*ActOnFileScopeAsmDecl(SourceLocation Loc
, Expr
*expr
);
883 void ActOnPopScope(SourceLocation Loc
, Scope
*S
);
884 void ActOnTranslationUnitScope(Scope
*S
);
886 /// ParsedFreeStandingDeclSpec - This method is invoked when a declspec with
887 /// no declarator (e.g. "struct foo;") is parsed.
888 Decl
*ParsedFreeStandingDeclSpec(Scope
*S
, AccessSpecifier AS
,
891 StmtResult
ActOnVlaStmt(const DeclSpec
&DS
);
893 Decl
*BuildAnonymousStructOrUnion(Scope
*S
, DeclSpec
&DS
,
897 Decl
*BuildMicrosoftCAnonymousStruct(Scope
*S
, DeclSpec
&DS
,
900 bool isAcceptableTagRedeclaration(const TagDecl
*Previous
,
902 SourceLocation NewTagLoc
,
903 const IdentifierInfo
&Name
);
906 TUK_Reference
, // Reference to a tag: 'struct foo *X;'
907 TUK_Declaration
, // Fwd decl of a tag: 'struct foo;'
908 TUK_Definition
, // Definition of a tag: 'struct foo { int X; } Y;'
909 TUK_Friend
// Friend declaration: 'friend struct foo;'
912 Decl
*ActOnTag(Scope
*S
, unsigned TagSpec
, TagUseKind TUK
,
913 SourceLocation KWLoc
, CXXScopeSpec
&SS
,
914 IdentifierInfo
*Name
, SourceLocation NameLoc
,
915 AttributeList
*Attr
, AccessSpecifier AS
,
916 MultiTemplateParamsArg TemplateParameterLists
,
917 bool &OwnedDecl
, bool &IsDependent
, bool ScopedEnum
,
918 bool ScopedEnumUsesClassTag
, TypeResult UnderlyingType
);
920 Decl
*ActOnTemplatedFriendTag(Scope
*S
, SourceLocation FriendLoc
,
921 unsigned TagSpec
, SourceLocation TagLoc
,
923 IdentifierInfo
*Name
, SourceLocation NameLoc
,
925 MultiTemplateParamsArg TempParamLists
);
927 TypeResult
ActOnDependentTag(Scope
*S
,
930 const CXXScopeSpec
&SS
,
931 IdentifierInfo
*Name
,
932 SourceLocation TagLoc
,
933 SourceLocation NameLoc
);
935 void ActOnDefs(Scope
*S
, Decl
*TagD
, SourceLocation DeclStart
,
936 IdentifierInfo
*ClassName
,
937 llvm::SmallVectorImpl
<Decl
*> &Decls
);
938 Decl
*ActOnField(Scope
*S
, Decl
*TagD
, SourceLocation DeclStart
,
939 Declarator
&D
, Expr
*BitfieldWidth
);
941 FieldDecl
*HandleField(Scope
*S
, RecordDecl
*TagD
, SourceLocation DeclStart
,
942 Declarator
&D
, Expr
*BitfieldWidth
,
945 FieldDecl
*CheckFieldDecl(DeclarationName Name
, QualType T
,
946 TypeSourceInfo
*TInfo
,
947 RecordDecl
*Record
, SourceLocation Loc
,
948 bool Mutable
, Expr
*BitfieldWidth
,
950 AccessSpecifier AS
, NamedDecl
*PrevDecl
,
953 enum CXXSpecialMember
{
956 CXXCopyConstructor
= 1,
957 CXXCopyAssignment
= 2,
960 bool CheckNontrivialField(FieldDecl
*FD
);
961 void DiagnoseNontrivial(const RecordType
* Record
, CXXSpecialMember mem
);
962 CXXSpecialMember
getSpecialMember(const CXXMethodDecl
*MD
);
963 void ActOnLastBitfield(SourceLocation DeclStart
, Decl
*IntfDecl
,
964 llvm::SmallVectorImpl
<Decl
*> &AllIvarDecls
);
965 Decl
*ActOnIvar(Scope
*S
, SourceLocation DeclStart
, Decl
*IntfDecl
,
966 Declarator
&D
, Expr
*BitfieldWidth
,
967 tok::ObjCKeywordKind visibility
);
969 // This is used for both record definitions and ObjC interface declarations.
970 void ActOnFields(Scope
* S
, SourceLocation RecLoc
, Decl
*TagDecl
,
971 Decl
**Fields
, unsigned NumFields
,
972 SourceLocation LBrac
, SourceLocation RBrac
,
973 AttributeList
*AttrList
);
975 /// ActOnTagStartDefinition - Invoked when we have entered the
976 /// scope of a tag's definition (e.g., for an enumeration, class,
977 /// struct, or union).
978 void ActOnTagStartDefinition(Scope
*S
, Decl
*TagDecl
);
980 /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
981 /// C++ record definition's base-specifiers clause and are starting its
982 /// member declarations.
983 void ActOnStartCXXMemberDeclarations(Scope
*S
, Decl
*TagDecl
,
984 ClassVirtSpecifiers
&CVS
,
985 SourceLocation LBraceLoc
);
987 /// ActOnTagFinishDefinition - Invoked once we have finished parsing
988 /// the definition of a tag (enumeration, class, struct, or union).
989 void ActOnTagFinishDefinition(Scope
*S
, Decl
*TagDecl
,
990 SourceLocation RBraceLoc
);
992 /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
993 /// error parsing the definition of a tag.
994 void ActOnTagDefinitionError(Scope
*S
, Decl
*TagDecl
);
996 EnumConstantDecl
*CheckEnumConstant(EnumDecl
*Enum
,
997 EnumConstantDecl
*LastEnumConst
,
998 SourceLocation IdLoc
,
1002 Decl
*ActOnEnumConstant(Scope
*S
, Decl
*EnumDecl
, Decl
*LastEnumConstant
,
1003 SourceLocation IdLoc
, IdentifierInfo
*Id
,
1004 AttributeList
*Attrs
,
1005 SourceLocation EqualLoc
, Expr
*Val
);
1006 void ActOnEnumBody(SourceLocation EnumLoc
, SourceLocation LBraceLoc
,
1007 SourceLocation RBraceLoc
, Decl
*EnumDecl
,
1008 Decl
**Elements
, unsigned NumElements
,
1009 Scope
*S
, AttributeList
*Attr
);
1011 DeclContext
*getContainingDC(DeclContext
*DC
);
1013 /// Set the current declaration context until it gets popped.
1014 void PushDeclContext(Scope
*S
, DeclContext
*DC
);
1015 void PopDeclContext();
1017 /// EnterDeclaratorContext - Used when we must lookup names in the context
1018 /// of a declarator's nested name specifier.
1019 void EnterDeclaratorContext(Scope
*S
, DeclContext
*DC
);
1020 void ExitDeclaratorContext(Scope
*S
);
1022 DeclContext
*getFunctionLevelDeclContext();
1024 /// getCurFunctionDecl - If inside of a function body, this returns a pointer
1025 /// to the function decl for the function being parsed. If we're currently
1026 /// in a 'block', this returns the containing context.
1027 FunctionDecl
*getCurFunctionDecl();
1029 /// getCurMethodDecl - If inside of a method body, this returns a pointer to
1030 /// the method decl for the method being parsed. If we're currently
1031 /// in a 'block', this returns the containing context.
1032 ObjCMethodDecl
*getCurMethodDecl();
1034 /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method
1035 /// or C function we're in, otherwise return null. If we're currently
1036 /// in a 'block', this returns the containing context.
1037 NamedDecl
*getCurFunctionOrMethodDecl();
1039 /// Add this decl to the scope shadowed decl chains.
1040 void PushOnScopeChains(NamedDecl
*D
, Scope
*S
, bool AddToContext
= true);
1042 /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
1043 /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns
1044 /// true if 'D' belongs to the given declaration context.
1045 bool isDeclInScope(NamedDecl
*&D
, DeclContext
*Ctx
, Scope
*S
= 0);
1047 /// Finds the scope corresponding to the given decl context, if it
1048 /// happens to be an enclosing scope. Otherwise return NULL.
1049 static Scope
*getScopeForDeclContext(Scope
*S
, DeclContext
*DC
);
1051 /// Subroutines of ActOnDeclarator().
1052 TypedefDecl
*ParseTypedefDecl(Scope
*S
, Declarator
&D
, QualType T
,
1053 TypeSourceInfo
*TInfo
);
1054 void MergeTypeDefDecl(TypedefDecl
*New
, LookupResult
&OldDecls
);
1055 bool MergeFunctionDecl(FunctionDecl
*New
, Decl
*Old
);
1056 bool MergeCompatibleFunctionDecls(FunctionDecl
*New
, FunctionDecl
*Old
);
1057 void MergeVarDecl(VarDecl
*New
, LookupResult
&OldDecls
);
1058 bool MergeCXXFunctionDecl(FunctionDecl
*New
, FunctionDecl
*Old
);
1060 // AssignmentAction - This is used by all the assignment diagnostic functions
1061 // to represent what is actually causing the operation
1062 enum AssignmentAction
{
1072 /// C++ Overloading.
1074 /// This is a legitimate overload: the existing declarations are
1075 /// functions or function templates with different signatures.
1078 /// This is not an overload because the signature exactly matches
1079 /// an existing declaration.
1082 /// This is not an overload because the lookup results contain a
1086 OverloadKind
CheckOverload(Scope
*S
,
1088 const LookupResult
&OldDecls
,
1089 NamedDecl
*&OldDecl
,
1090 bool IsForUsingDecl
);
1091 bool IsOverload(FunctionDecl
*New
, FunctionDecl
*Old
, bool IsForUsingDecl
);
1093 bool TryImplicitConversion(InitializationSequence
&Sequence
,
1094 const InitializedEntity
&Entity
,
1096 bool SuppressUserConversions
,
1098 bool InOverloadResolution
,
1101 bool IsIntegralPromotion(Expr
*From
, QualType FromType
, QualType ToType
);
1102 bool IsFloatingPointPromotion(QualType FromType
, QualType ToType
);
1103 bool IsComplexPromotion(QualType FromType
, QualType ToType
);
1104 bool IsPointerConversion(Expr
*From
, QualType FromType
, QualType ToType
,
1105 bool InOverloadResolution
,
1106 QualType
& ConvertedType
, bool &IncompatibleObjC
);
1107 bool isObjCPointerConversion(QualType FromType
, QualType ToType
,
1108 QualType
& ConvertedType
, bool &IncompatibleObjC
);
1109 bool IsBlockPointerConversion(QualType FromType
, QualType ToType
,
1110 QualType
& ConvertedType
);
1111 bool FunctionArgTypesAreEqual(const FunctionProtoType
*OldType
,
1112 const FunctionProtoType
*NewType
);
1114 bool CheckPointerConversion(Expr
*From
, QualType ToType
,
1116 CXXCastPath
& BasePath
,
1117 bool IgnoreBaseAccess
);
1118 bool IsMemberPointerConversion(Expr
*From
, QualType FromType
, QualType ToType
,
1119 bool InOverloadResolution
,
1120 QualType
&ConvertedType
);
1121 bool CheckMemberPointerConversion(Expr
*From
, QualType ToType
,
1123 CXXCastPath
&BasePath
,
1124 bool IgnoreBaseAccess
);
1125 bool IsQualificationConversion(QualType FromType
, QualType ToType
,
1127 bool DiagnoseMultipleUserDefinedConversion(Expr
*From
, QualType ToType
);
1130 ExprResult
PerformMoveOrCopyInitialization(const InitializedEntity
&Entity
,
1131 const VarDecl
*NRVOCandidate
,
1132 QualType ResultType
,
1135 ExprResult
PerformCopyInitialization(const InitializedEntity
&Entity
,
1136 SourceLocation EqualLoc
,
1138 bool PerformObjectArgumentInitialization(Expr
*&From
,
1139 NestedNameSpecifier
*Qualifier
,
1140 NamedDecl
*FoundDecl
,
1141 CXXMethodDecl
*Method
);
1143 bool PerformContextuallyConvertToBool(Expr
*&From
);
1144 bool PerformContextuallyConvertToObjCId(Expr
*&From
);
1147 ConvertToIntegralOrEnumerationType(SourceLocation Loc
, Expr
*FromE
,
1148 const PartialDiagnostic
&NotIntDiag
,
1149 const PartialDiagnostic
&IncompleteDiag
,
1150 const PartialDiagnostic
&ExplicitConvDiag
,
1151 const PartialDiagnostic
&ExplicitConvNote
,
1152 const PartialDiagnostic
&AmbigDiag
,
1153 const PartialDiagnostic
&AmbigNote
,
1154 const PartialDiagnostic
&ConvDiag
);
1156 bool PerformObjectMemberConversion(Expr
*&From
,
1157 NestedNameSpecifier
*Qualifier
,
1158 NamedDecl
*FoundDecl
,
1161 // Members have to be NamespaceDecl* or TranslationUnitDecl*.
1162 // TODO: make this is a typesafe union.
1163 typedef llvm::SmallPtrSet
<DeclContext
*, 16> AssociatedNamespaceSet
;
1164 typedef llvm::SmallPtrSet
<CXXRecordDecl
*, 16> AssociatedClassSet
;
1166 void AddOverloadCandidate(NamedDecl
*Function
,
1167 DeclAccessPair FoundDecl
,
1168 Expr
**Args
, unsigned NumArgs
,
1169 OverloadCandidateSet
&CandidateSet
);
1171 void AddOverloadCandidate(FunctionDecl
*Function
,
1172 DeclAccessPair FoundDecl
,
1173 Expr
**Args
, unsigned NumArgs
,
1174 OverloadCandidateSet
& CandidateSet
,
1175 bool SuppressUserConversions
= false,
1176 bool PartialOverloading
= false);
1177 void AddFunctionCandidates(const UnresolvedSetImpl
&Functions
,
1178 Expr
**Args
, unsigned NumArgs
,
1179 OverloadCandidateSet
& CandidateSet
,
1180 bool SuppressUserConversions
= false);
1181 void AddMethodCandidate(DeclAccessPair FoundDecl
,
1182 QualType ObjectType
,
1183 Expr::Classification ObjectClassification
,
1184 Expr
**Args
, unsigned NumArgs
,
1185 OverloadCandidateSet
& CandidateSet
,
1186 bool SuppressUserConversion
= false);
1187 void AddMethodCandidate(CXXMethodDecl
*Method
,
1188 DeclAccessPair FoundDecl
,
1189 CXXRecordDecl
*ActingContext
, QualType ObjectType
,
1190 Expr::Classification ObjectClassification
,
1191 Expr
**Args
, unsigned NumArgs
,
1192 OverloadCandidateSet
& CandidateSet
,
1193 bool SuppressUserConversions
= false);
1194 void AddMethodTemplateCandidate(FunctionTemplateDecl
*MethodTmpl
,
1195 DeclAccessPair FoundDecl
,
1196 CXXRecordDecl
*ActingContext
,
1197 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
1198 QualType ObjectType
,
1199 Expr::Classification ObjectClassification
,
1200 Expr
**Args
, unsigned NumArgs
,
1201 OverloadCandidateSet
& CandidateSet
,
1202 bool SuppressUserConversions
= false);
1203 void AddTemplateOverloadCandidate(FunctionTemplateDecl
*FunctionTemplate
,
1204 DeclAccessPair FoundDecl
,
1205 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
1206 Expr
**Args
, unsigned NumArgs
,
1207 OverloadCandidateSet
& CandidateSet
,
1208 bool SuppressUserConversions
= false);
1209 void AddConversionCandidate(CXXConversionDecl
*Conversion
,
1210 DeclAccessPair FoundDecl
,
1211 CXXRecordDecl
*ActingContext
,
1212 Expr
*From
, QualType ToType
,
1213 OverloadCandidateSet
& CandidateSet
);
1214 void AddTemplateConversionCandidate(FunctionTemplateDecl
*FunctionTemplate
,
1215 DeclAccessPair FoundDecl
,
1216 CXXRecordDecl
*ActingContext
,
1217 Expr
*From
, QualType ToType
,
1218 OverloadCandidateSet
&CandidateSet
);
1219 void AddSurrogateCandidate(CXXConversionDecl
*Conversion
,
1220 DeclAccessPair FoundDecl
,
1221 CXXRecordDecl
*ActingContext
,
1222 const FunctionProtoType
*Proto
,
1223 Expr
*Object
, Expr
**Args
, unsigned NumArgs
,
1224 OverloadCandidateSet
& CandidateSet
);
1225 void AddMemberOperatorCandidates(OverloadedOperatorKind Op
,
1226 SourceLocation OpLoc
,
1227 Expr
**Args
, unsigned NumArgs
,
1228 OverloadCandidateSet
& CandidateSet
,
1229 SourceRange OpRange
= SourceRange());
1230 void AddBuiltinCandidate(QualType ResultTy
, QualType
*ParamTys
,
1231 Expr
**Args
, unsigned NumArgs
,
1232 OverloadCandidateSet
& CandidateSet
,
1233 bool IsAssignmentOperator
= false,
1234 unsigned NumContextualBoolArguments
= 0);
1235 void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op
,
1236 SourceLocation OpLoc
,
1237 Expr
**Args
, unsigned NumArgs
,
1238 OverloadCandidateSet
& CandidateSet
);
1239 void AddArgumentDependentLookupCandidates(DeclarationName Name
,
1241 Expr
**Args
, unsigned NumArgs
,
1242 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
1243 OverloadCandidateSet
& CandidateSet
,
1244 bool PartialOverloading
= false);
1246 void NoteOverloadCandidate(FunctionDecl
*Fn
);
1248 FunctionDecl
*ResolveAddressOfOverloadedFunction(Expr
*From
, QualType ToType
,
1250 DeclAccessPair
&Found
);
1251 FunctionDecl
*ResolveSingleFunctionTemplateSpecialization(Expr
*From
);
1253 Expr
*FixOverloadedFunctionReference(Expr
*E
,
1254 DeclAccessPair FoundDecl
,
1256 ExprResult
FixOverloadedFunctionReference(ExprResult
,
1257 DeclAccessPair FoundDecl
,
1260 void AddOverloadedCallCandidates(UnresolvedLookupExpr
*ULE
,
1261 Expr
**Args
, unsigned NumArgs
,
1262 OverloadCandidateSet
&CandidateSet
,
1263 bool PartialOverloading
= false);
1265 ExprResult
BuildOverloadedCallExpr(Scope
*S
, Expr
*Fn
,
1266 UnresolvedLookupExpr
*ULE
,
1267 SourceLocation LParenLoc
,
1268 Expr
**Args
, unsigned NumArgs
,
1269 SourceLocation RParenLoc
,
1272 ExprResult
CreateOverloadedUnaryOp(SourceLocation OpLoc
,
1274 const UnresolvedSetImpl
&Fns
,
1277 ExprResult
CreateOverloadedBinOp(SourceLocation OpLoc
,
1279 const UnresolvedSetImpl
&Fns
,
1280 Expr
*LHS
, Expr
*RHS
);
1282 ExprResult
CreateOverloadedArraySubscriptExpr(SourceLocation LLoc
,
1283 SourceLocation RLoc
,
1284 Expr
*Base
,Expr
*Idx
);
1287 BuildCallToMemberFunction(Scope
*S
, Expr
*MemExpr
,
1288 SourceLocation LParenLoc
, Expr
**Args
,
1289 unsigned NumArgs
, SourceLocation RParenLoc
);
1291 BuildCallToObjectOfClassType(Scope
*S
, Expr
*Object
, SourceLocation LParenLoc
,
1292 Expr
**Args
, unsigned NumArgs
,
1293 SourceLocation RParenLoc
);
1295 ExprResult
BuildOverloadedArrowExpr(Scope
*S
, Expr
*Base
,
1296 SourceLocation OpLoc
);
1298 /// CheckCallReturnType - Checks that a call expression's return type is
1299 /// complete. Returns true on failure. The location passed in is the location
1300 /// that best represents the call.
1301 bool CheckCallReturnType(QualType ReturnType
, SourceLocation Loc
,
1302 CallExpr
*CE
, FunctionDecl
*FD
);
1304 /// Helpers for dealing with blocks and functions.
1305 bool CheckParmsForFunctionDef(ParmVarDecl
**Param
, ParmVarDecl
**ParamEnd
,
1306 bool CheckParameterNames
);
1307 void CheckCXXDefaultArguments(FunctionDecl
*FD
);
1308 void CheckExtraCXXDefaultArguments(Declarator
&D
);
1309 Scope
*getNonFieldDeclScope(Scope
*S
);
1311 /// \name Name lookup
1313 /// These routines provide name lookup that is used during semantic
1314 /// analysis to resolve the various kinds of names (identifiers,
1315 /// overloaded operator names, constructor names, etc.) into zero or
1316 /// more declarations within a particular scope. The major entry
1317 /// points are LookupName, which performs unqualified name lookup,
1318 /// and LookupQualifiedName, which performs qualified name lookup.
1320 /// All name lookup is performed based on some specific criteria,
1321 /// which specify what names will be visible to name lookup and how
1322 /// far name lookup should work. These criteria are important both
1323 /// for capturing language semantics (certain lookups will ignore
1324 /// certain names, for example) and for performance, since name
1325 /// lookup is often a bottleneck in the compilation of C++. Name
1326 /// lookup criteria is specified via the LookupCriteria enumeration.
1328 /// The results of name lookup can vary based on the kind of name
1329 /// lookup performed, the current language, and the translation
1330 /// unit. In C, for example, name lookup will either return nothing
1331 /// (no entity found) or a single declaration. In C++, name lookup
1332 /// can additionally refer to a set of overloaded functions or
1333 /// result in an ambiguity. All of the possible results of name
1334 /// lookup are captured by the LookupResult class, which provides
1335 /// the ability to distinguish among them.
1338 /// @brief Describes the kind of name lookup to perform.
1339 enum LookupNameKind
{
1340 /// Ordinary name lookup, which finds ordinary names (functions,
1341 /// variables, typedefs, etc.) in C and most kinds of names
1342 /// (functions, variables, members, types, etc.) in C++.
1343 LookupOrdinaryName
= 0,
1344 /// Tag name lookup, which finds the names of enums, classes,
1345 /// structs, and unions.
1347 /// Label name lookup.
1349 /// Member name lookup, which finds the names of
1350 /// class/struct/union members.
1352 /// Look up of an operator name (e.g., operator+) for use with
1353 /// operator overloading. This lookup is similar to ordinary name
1354 /// lookup, but will ignore any declarations that are class members.
1356 /// Look up of a name that precedes the '::' scope resolution
1357 /// operator in C++. This lookup completely ignores operator, object,
1358 /// function, and enumerator names (C++ [basic.lookup.qual]p1).
1359 LookupNestedNameSpecifierName
,
1360 /// Look up a namespace name within a C++ using directive or
1361 /// namespace alias definition, ignoring non-namespace names (C++
1362 /// [basic.lookup.udir]p1).
1363 LookupNamespaceName
,
1364 /// Look up all declarations in a scope with the given name,
1365 /// including resolved using declarations. This is appropriate
1366 /// for checking redeclarations for a using declaration.
1367 LookupUsingDeclName
,
1368 /// Look up an ordinary name that is going to be redeclared as a
1369 /// name with linkage. This lookup ignores any declarations that
1370 /// are outside of the current scope unless they have linkage. See
1371 /// C99 6.2.2p4-5 and C++ [basic.link]p6.
1372 LookupRedeclarationWithLinkage
,
1373 /// Look up the name of an Objective-C protocol.
1374 LookupObjCProtocolName
,
1375 /// \brief Look up any declaration with any name.
1379 /// \brief Specifies whether (or how) name lookup is being performed for a
1380 /// redeclaration (vs. a reference).
1381 enum RedeclarationKind
{
1382 /// \brief The lookup is a reference to this name that is not for the
1383 /// purpose of redeclaring the name.
1384 NotForRedeclaration
= 0,
1385 /// \brief The lookup results will be used for redeclaration of a name,
1386 /// if an entity by that name already exists.
1391 bool CppLookupName(LookupResult
&R
, Scope
*S
);
1394 /// \brief Look up a name, looking for a single declaration. Return
1395 /// null if the results were absent, ambiguous, or overloaded.
1397 /// It is preferable to use the elaborated form and explicitly handle
1398 /// ambiguity and overloaded.
1399 NamedDecl
*LookupSingleName(Scope
*S
, DeclarationName Name
,
1401 LookupNameKind NameKind
,
1402 RedeclarationKind Redecl
1403 = NotForRedeclaration
);
1404 bool LookupName(LookupResult
&R
, Scope
*S
,
1405 bool AllowBuiltinCreation
= false);
1406 bool LookupQualifiedName(LookupResult
&R
, DeclContext
*LookupCtx
,
1407 bool InUnqualifiedLookup
= false);
1408 bool LookupParsedName(LookupResult
&R
, Scope
*S
, CXXScopeSpec
*SS
,
1409 bool AllowBuiltinCreation
= false,
1410 bool EnteringContext
= false);
1411 ObjCProtocolDecl
*LookupProtocol(IdentifierInfo
*II
, SourceLocation IdLoc
);
1413 void LookupOverloadedOperatorName(OverloadedOperatorKind Op
, Scope
*S
,
1414 QualType T1
, QualType T2
,
1415 UnresolvedSetImpl
&Functions
);
1417 LabelDecl
*LookupOrCreateLabel(IdentifierInfo
*II
, SourceLocation Loc
,
1418 bool isLocalLabel
= false);
1420 DeclContextLookupResult
LookupConstructors(CXXRecordDecl
*Class
);
1421 CXXDestructorDecl
*LookupDestructor(CXXRecordDecl
*Class
);
1423 void ArgumentDependentLookup(DeclarationName Name
, bool Operator
,
1424 Expr
**Args
, unsigned NumArgs
,
1425 ADLResult
&Functions
);
1427 void LookupVisibleDecls(Scope
*S
, LookupNameKind Kind
,
1428 VisibleDeclConsumer
&Consumer
,
1429 bool IncludeGlobalScope
= true);
1430 void LookupVisibleDecls(DeclContext
*Ctx
, LookupNameKind Kind
,
1431 VisibleDeclConsumer
&Consumer
,
1432 bool IncludeGlobalScope
= true);
1434 /// \brief The context in which typo-correction occurs.
1436 /// The typo-correction context affects which keywords (if any) are
1437 /// considered when trying to correct for typos.
1438 enum CorrectTypoContext
{
1439 /// \brief An unknown context, where any keyword might be valid.
1441 /// \brief A context where no keywords are used (e.g. we expect an actual
1444 /// \brief A context where we're correcting a type name.
1446 /// \brief An expression context.
1448 /// \brief A type cast, or anything else that can be followed by a '<'.
1450 /// \brief A member lookup context.
1452 /// \brief An Objective-C ivar lookup context (e.g., self->ivar).
1454 /// \brief An Objective-C property lookup context (e.g., self.prop).
1455 CTC_ObjCPropertyLookup
,
1456 /// \brief The receiver of an Objective-C message send within an
1457 /// Objective-C method where 'super' is a valid keyword.
1458 CTC_ObjCMessageReceiver
1461 DeclarationName
CorrectTypo(LookupResult
&R
, Scope
*S
, CXXScopeSpec
*SS
,
1462 DeclContext
*MemberContext
= 0,
1463 bool EnteringContext
= false,
1464 CorrectTypoContext CTC
= CTC_Unknown
,
1465 const ObjCObjectPointerType
*OPT
= 0);
1467 void FindAssociatedClassesAndNamespaces(Expr
**Args
, unsigned NumArgs
,
1468 AssociatedNamespaceSet
&AssociatedNamespaces
,
1469 AssociatedClassSet
&AssociatedClasses
);
1471 bool DiagnoseAmbiguousLookup(LookupResult
&Result
);
1474 ObjCInterfaceDecl
*getObjCInterfaceDecl(IdentifierInfo
*&Id
,
1475 SourceLocation IdLoc
,
1476 bool TypoCorrection
= false);
1477 NamedDecl
*LazilyCreateBuiltin(IdentifierInfo
*II
, unsigned ID
,
1478 Scope
*S
, bool ForRedeclaration
,
1479 SourceLocation Loc
);
1480 NamedDecl
*ImplicitlyDefineFunction(SourceLocation Loc
, IdentifierInfo
&II
,
1482 void AddKnownFunctionAttributes(FunctionDecl
*FD
);
1484 // More parsing and symbol table subroutines.
1486 // Decl attributes - this routine is the top level dispatcher.
1487 void ProcessDeclAttributes(Scope
*S
, Decl
*D
, const Declarator
&PD
,
1488 bool NonInheritable
= true, bool Inheritable
= true);
1489 void ProcessDeclAttributeList(Scope
*S
, Decl
*D
, const AttributeList
*AL
,
1490 bool NonInheritable
= true, bool Inheritable
= true);
1492 bool CheckRegparmAttr(const AttributeList
&attr
, unsigned &value
);
1493 bool CheckCallingConvAttr(const AttributeList
&attr
, CallingConv
&CC
);
1494 bool CheckNoReturnAttr(const AttributeList
&attr
);
1496 void WarnUndefinedMethod(SourceLocation ImpLoc
, ObjCMethodDecl
*method
,
1497 bool &IncompleteImpl
, unsigned DiagID
);
1498 void WarnConflictingTypedMethods(ObjCMethodDecl
*ImpMethod
,
1499 ObjCMethodDecl
*IntfMethod
);
1501 bool isPropertyReadonly(ObjCPropertyDecl
*PropertyDecl
,
1502 ObjCInterfaceDecl
*IDecl
);
1504 typedef llvm::DenseSet
<Selector
, llvm::DenseMapInfo
<Selector
> > SelectorSet
;
1506 /// CheckProtocolMethodDefs - This routine checks unimplemented
1507 /// methods declared in protocol, and those referenced by it.
1508 /// \param IDecl - Used for checking for methods which may have been
1510 void CheckProtocolMethodDefs(SourceLocation ImpLoc
,
1511 ObjCProtocolDecl
*PDecl
,
1512 bool& IncompleteImpl
,
1513 const SelectorSet
&InsMap
,
1514 const SelectorSet
&ClsMap
,
1515 ObjCContainerDecl
*CDecl
);
1517 /// CheckImplementationIvars - This routine checks if the instance variables
1518 /// listed in the implelementation match those listed in the interface.
1519 void CheckImplementationIvars(ObjCImplementationDecl
*ImpDecl
,
1520 ObjCIvarDecl
**Fields
, unsigned nIvars
,
1521 SourceLocation Loc
);
1523 /// \brief Determine whether we can synthesize a provisional ivar for the
1525 ObjCPropertyDecl
*canSynthesizeProvisionalIvar(IdentifierInfo
*II
);
1527 /// \brief Determine whether we can synthesize a provisional ivar for the
1529 bool canSynthesizeProvisionalIvar(ObjCPropertyDecl
*Property
);
1531 /// ImplMethodsVsClassMethods - This is main routine to warn if any method
1532 /// remains unimplemented in the class or category @implementation.
1533 void ImplMethodsVsClassMethods(Scope
*S
, ObjCImplDecl
* IMPDecl
,
1534 ObjCContainerDecl
* IDecl
,
1535 bool IncompleteImpl
= false);
1537 /// DiagnoseUnimplementedProperties - This routine warns on those properties
1538 /// which must be implemented by this implementation.
1539 void DiagnoseUnimplementedProperties(Scope
*S
, ObjCImplDecl
* IMPDecl
,
1540 ObjCContainerDecl
*CDecl
,
1541 const SelectorSet
&InsMap
);
1543 /// DefaultSynthesizeProperties - This routine default synthesizes all
1544 /// properties which must be synthesized in class's @implementation.
1545 void DefaultSynthesizeProperties (Scope
*S
, ObjCImplDecl
* IMPDecl
,
1546 ObjCInterfaceDecl
*IDecl
);
1548 /// CollectImmediateProperties - This routine collects all properties in
1549 /// the class and its conforming protocols; but not those it its super class.
1550 void CollectImmediateProperties(ObjCContainerDecl
*CDecl
,
1551 llvm::DenseMap
<IdentifierInfo
*, ObjCPropertyDecl
*>& PropMap
,
1552 llvm::DenseMap
<IdentifierInfo
*, ObjCPropertyDecl
*>& SuperPropMap
);
1555 /// LookupPropertyDecl - Looks up a property in the current class and all
1557 ObjCPropertyDecl
*LookupPropertyDecl(const ObjCContainerDecl
*CDecl
,
1558 IdentifierInfo
*II
);
1560 /// Called by ActOnProperty to handle @property declarations in
1561 //// class extensions.
1562 Decl
*HandlePropertyInClassExtension(Scope
*S
,
1563 ObjCCategoryDecl
*CDecl
,
1564 SourceLocation AtLoc
,
1565 FieldDeclarator
&FD
,
1568 const bool isAssign
,
1569 const bool isReadWrite
,
1570 const unsigned Attributes
,
1571 bool *isOverridingProperty
,
1573 tok::ObjCKeywordKind MethodImplKind
);
1575 /// Called by ActOnProperty and HandlePropertyInClassExtension to
1576 /// handle creating the ObjcPropertyDecl for a category or @interface.
1577 ObjCPropertyDecl
*CreatePropertyDecl(Scope
*S
,
1578 ObjCContainerDecl
*CDecl
,
1579 SourceLocation AtLoc
,
1580 FieldDeclarator
&FD
,
1583 const bool isAssign
,
1584 const bool isReadWrite
,
1585 const unsigned Attributes
,
1587 tok::ObjCKeywordKind MethodImplKind
,
1588 DeclContext
*lexicalDC
= 0);
1590 /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
1591 /// warning) when atomic property has one but not the other user-declared
1592 /// setter or getter.
1593 void AtomicPropertySetterGetterRules(ObjCImplDecl
* IMPDecl
,
1594 ObjCContainerDecl
* IDecl
);
1596 void DiagnoseDuplicateIvars(ObjCInterfaceDecl
*ID
, ObjCInterfaceDecl
*SID
);
1598 /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
1599 /// true, or false, accordingly.
1600 bool MatchTwoMethodDeclarations(const ObjCMethodDecl
*Method
,
1601 const ObjCMethodDecl
*PrevMethod
,
1602 bool matchBasedOnSizeAndAlignment
= false,
1603 bool matchBasedOnStrictEqulity
= false);
1605 /// MatchAllMethodDeclarations - Check methods declaraed in interface or
1606 /// or protocol against those declared in their implementations.
1607 void MatchAllMethodDeclarations(const SelectorSet
&InsMap
,
1608 const SelectorSet
&ClsMap
,
1609 SelectorSet
&InsMapSeen
,
1610 SelectorSet
&ClsMapSeen
,
1611 ObjCImplDecl
* IMPDecl
,
1612 ObjCContainerDecl
* IDecl
,
1613 bool &IncompleteImpl
,
1614 bool ImmediateClass
);
1617 /// AddMethodToGlobalPool - Add an instance or factory method to the global
1618 /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
1619 void AddMethodToGlobalPool(ObjCMethodDecl
*Method
, bool impl
, bool instance
);
1621 /// LookupMethodInGlobalPool - Returns the instance or factory method and
1622 /// optionally warns if there are multiple signatures.
1623 ObjCMethodDecl
*LookupMethodInGlobalPool(Selector Sel
, SourceRange R
,
1624 bool receiverIdOrClass
,
1625 bool warn
, bool instance
);
1628 /// AddInstanceMethodToGlobalPool - All instance methods in a translation
1629 /// unit are added to a global pool. This allows us to efficiently associate
1630 /// a selector with a method declaraation for purposes of typechecking
1631 /// messages sent to "id" (where the class of the object is unknown).
1632 void AddInstanceMethodToGlobalPool(ObjCMethodDecl
*Method
, bool impl
=false) {
1633 AddMethodToGlobalPool(Method
, impl
, /*instance*/true);
1636 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
1637 void AddFactoryMethodToGlobalPool(ObjCMethodDecl
*Method
, bool impl
=false) {
1638 AddMethodToGlobalPool(Method
, impl
, /*instance*/false);
1641 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
1642 /// there are multiple signatures.
1643 ObjCMethodDecl
*LookupInstanceMethodInGlobalPool(Selector Sel
, SourceRange R
,
1644 bool receiverIdOrClass
=false,
1646 return LookupMethodInGlobalPool(Sel
, R
, receiverIdOrClass
,
1647 warn
, /*instance*/true);
1650 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
1651 /// there are multiple signatures.
1652 ObjCMethodDecl
*LookupFactoryMethodInGlobalPool(Selector Sel
, SourceRange R
,
1653 bool receiverIdOrClass
=false,
1655 return LookupMethodInGlobalPool(Sel
, R
, receiverIdOrClass
,
1656 warn
, /*instance*/false);
1659 /// LookupImplementedMethodInGlobalPool - Returns the method which has an
1661 ObjCMethodDecl
*LookupImplementedMethodInGlobalPool(Selector Sel
);
1663 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
1665 void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl
*OI
,
1666 llvm::SmallVectorImpl
<ObjCIvarDecl
*> &Ivars
);
1667 //===--------------------------------------------------------------------===//
1668 // Statement Parsing Callbacks: SemaStmt.cpp.
1672 FullExprArg(Sema
&actions
) : E(0) { }
1674 // FIXME: The const_cast here is ugly. RValue references would make this
1675 // much nicer (or we could duplicate a bunch of the move semantics
1676 // emulation code from Ownership.h).
1677 FullExprArg(const FullExprArg
& Other
) : E(Other
.E
) {}
1679 ExprResult
release() {
1683 Expr
*get() const { return E
; }
1685 Expr
*operator->() {
1690 // FIXME: No need to make the entire Sema class a friend when it's just
1691 // Sema::MakeFullExpr that needs access to the constructor below.
1694 explicit FullExprArg(Expr
*expr
) : E(expr
) {}
1699 FullExprArg
MakeFullExpr(Expr
*Arg
) {
1700 return FullExprArg(ActOnFinishFullExpr(Arg
).release());
1703 StmtResult
ActOnExprStmt(FullExprArg Expr
);
1705 StmtResult
ActOnNullStmt(SourceLocation SemiLoc
,
1706 bool LeadingEmptyMacro
= false);
1707 StmtResult
ActOnCompoundStmt(SourceLocation L
, SourceLocation R
,
1710 StmtResult
ActOnDeclStmt(DeclGroupPtrTy Decl
,
1711 SourceLocation StartLoc
,
1712 SourceLocation EndLoc
);
1713 void ActOnForEachDeclStmt(DeclGroupPtrTy Decl
);
1714 StmtResult
ActOnForEachLValueExpr(Expr
*E
);
1715 StmtResult
ActOnCaseStmt(SourceLocation CaseLoc
, Expr
*LHSVal
,
1716 SourceLocation DotDotDotLoc
, Expr
*RHSVal
,
1717 SourceLocation ColonLoc
);
1718 void ActOnCaseStmtBody(Stmt
*CaseStmt
, Stmt
*SubStmt
);
1720 StmtResult
ActOnDefaultStmt(SourceLocation DefaultLoc
,
1721 SourceLocation ColonLoc
,
1722 Stmt
*SubStmt
, Scope
*CurScope
);
1723 StmtResult
ActOnLabelStmt(SourceLocation IdentLoc
, LabelDecl
*TheDecl
,
1724 SourceLocation ColonLoc
, Stmt
*SubStmt
);
1726 StmtResult
ActOnIfStmt(SourceLocation IfLoc
,
1727 FullExprArg CondVal
, Decl
*CondVar
,
1729 SourceLocation ElseLoc
, Stmt
*ElseVal
);
1730 StmtResult
ActOnStartOfSwitchStmt(SourceLocation SwitchLoc
,
1733 StmtResult
ActOnFinishSwitchStmt(SourceLocation SwitchLoc
,
1734 Stmt
*Switch
, Stmt
*Body
);
1735 StmtResult
ActOnWhileStmt(SourceLocation WhileLoc
,
1737 Decl
*CondVar
, Stmt
*Body
);
1738 StmtResult
ActOnDoStmt(SourceLocation DoLoc
, Stmt
*Body
,
1739 SourceLocation WhileLoc
,
1740 SourceLocation CondLParen
, Expr
*Cond
,
1741 SourceLocation CondRParen
);
1743 StmtResult
ActOnForStmt(SourceLocation ForLoc
,
1744 SourceLocation LParenLoc
,
1745 Stmt
*First
, FullExprArg Second
,
1748 SourceLocation RParenLoc
,
1750 StmtResult
ActOnObjCForCollectionStmt(SourceLocation ForColLoc
,
1751 SourceLocation LParenLoc
,
1752 Stmt
*First
, Expr
*Second
,
1753 SourceLocation RParenLoc
, Stmt
*Body
);
1755 StmtResult
ActOnGotoStmt(SourceLocation GotoLoc
,
1756 SourceLocation LabelLoc
,
1757 LabelDecl
*TheDecl
);
1758 StmtResult
ActOnIndirectGotoStmt(SourceLocation GotoLoc
,
1759 SourceLocation StarLoc
,
1761 StmtResult
ActOnContinueStmt(SourceLocation ContinueLoc
, Scope
*CurScope
);
1762 StmtResult
ActOnBreakStmt(SourceLocation GotoLoc
, Scope
*CurScope
);
1764 const VarDecl
*getCopyElisionCandidate(QualType ReturnType
, Expr
*E
,
1765 bool AllowFunctionParameters
);
1767 StmtResult
ActOnReturnStmt(SourceLocation ReturnLoc
, Expr
*RetValExp
);
1768 StmtResult
ActOnBlockReturnStmt(SourceLocation ReturnLoc
, Expr
*RetValExp
);
1770 StmtResult
ActOnAsmStmt(SourceLocation AsmLoc
,
1771 bool IsSimple
, bool IsVolatile
,
1772 unsigned NumOutputs
, unsigned NumInputs
,
1773 IdentifierInfo
**Names
,
1774 MultiExprArg Constraints
,
1777 MultiExprArg Clobbers
,
1778 SourceLocation RParenLoc
,
1779 bool MSAsm
= false);
1782 VarDecl
*BuildObjCExceptionDecl(TypeSourceInfo
*TInfo
, QualType ExceptionType
,
1783 IdentifierInfo
*Name
, SourceLocation NameLoc
,
1784 bool Invalid
= false);
1786 Decl
*ActOnObjCExceptionDecl(Scope
*S
, Declarator
&D
);
1788 StmtResult
ActOnObjCAtCatchStmt(SourceLocation AtLoc
, SourceLocation RParen
,
1789 Decl
*Parm
, Stmt
*Body
);
1791 StmtResult
ActOnObjCAtFinallyStmt(SourceLocation AtLoc
, Stmt
*Body
);
1793 StmtResult
ActOnObjCAtTryStmt(SourceLocation AtLoc
, Stmt
*Try
,
1794 MultiStmtArg Catch
, Stmt
*Finally
);
1796 StmtResult
BuildObjCAtThrowStmt(SourceLocation AtLoc
, Expr
*Throw
);
1797 StmtResult
ActOnObjCAtThrowStmt(SourceLocation AtLoc
, Expr
*Throw
,
1799 StmtResult
ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc
,
1803 VarDecl
*BuildExceptionDeclaration(Scope
*S
,
1804 TypeSourceInfo
*TInfo
,
1805 IdentifierInfo
*Name
,
1806 SourceLocation Loc
);
1807 Decl
*ActOnExceptionDeclarator(Scope
*S
, Declarator
&D
);
1809 StmtResult
ActOnCXXCatchBlock(SourceLocation CatchLoc
,
1810 Decl
*ExDecl
, Stmt
*HandlerBlock
);
1811 StmtResult
ActOnCXXTryBlock(SourceLocation TryLoc
, Stmt
*TryBlock
,
1812 MultiStmtArg Handlers
);
1813 void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt
*TryBlock
);
1815 bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl
*D
) const;
1817 /// \brief If it's a file scoped decl that must warn if not used, keep track
1819 void MarkUnusedFileScopedDecl(const DeclaratorDecl
*D
);
1821 /// DiagnoseUnusedExprResult - If the statement passed in is an expression
1822 /// whose result is unused, warn.
1823 void DiagnoseUnusedExprResult(const Stmt
*S
);
1824 void DiagnoseUnusedDecl(const NamedDecl
*ND
);
1826 ParsingDeclState
PushParsingDeclaration() {
1827 return DelayedDiagnostics
.pushParsingDecl();
1829 void PopParsingDeclaration(ParsingDeclState state
, Decl
*decl
) {
1830 DelayedDiagnostics::popParsingDecl(*this, state
, decl
);
1833 typedef ProcessingContextState ParsingClassState
;
1834 ParsingClassState
PushParsingClass() {
1835 return DelayedDiagnostics
.pushContext();
1837 void PopParsingClass(ParsingClassState state
) {
1838 DelayedDiagnostics
.popContext(state
);
1841 void EmitDeprecationWarning(NamedDecl
*D
, llvm::StringRef Message
,
1842 SourceLocation Loc
, bool UnknownObjCClass
=false);
1844 void HandleDelayedDeprecationCheck(sema::DelayedDiagnostic
&DD
, Decl
*Ctx
);
1846 //===--------------------------------------------------------------------===//
1847 // Expression Parsing Callbacks: SemaExpr.cpp.
1849 bool DiagnoseUseOfDecl(NamedDecl
*D
, SourceLocation Loc
,
1850 bool UnknownObjCClass
=false);
1851 bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl
*PD
,
1852 ObjCMethodDecl
*Getter
,
1853 SourceLocation Loc
);
1854 void DiagnoseSentinelCalls(NamedDecl
*D
, SourceLocation Loc
,
1855 Expr
**Args
, unsigned NumArgs
);
1857 void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext
);
1859 void PopExpressionEvaluationContext();
1861 void MarkDeclarationReferenced(SourceLocation Loc
, Decl
*D
);
1862 void MarkDeclarationsReferencedInType(SourceLocation Loc
, QualType T
);
1863 void MarkDeclarationsReferencedInExpr(Expr
*E
);
1864 bool DiagRuntimeBehavior(SourceLocation Loc
, const PartialDiagnostic
&PD
);
1866 // Primary Expressions.
1867 SourceRange
getExprRange(Expr
*E
) const;
1869 ExprResult
ActOnIdExpression(Scope
*S
, CXXScopeSpec
&SS
, UnqualifiedId
&Name
,
1870 bool HasTrailingLParen
, bool IsAddressOfOperand
);
1872 bool DiagnoseEmptyLookup(Scope
*S
, CXXScopeSpec
&SS
, LookupResult
&R
,
1873 CorrectTypoContext CTC
= CTC_Unknown
);
1875 ExprResult
LookupInObjCMethod(LookupResult
&R
, Scope
*S
, IdentifierInfo
*II
,
1876 bool AllowBuiltinCreation
=false);
1878 ExprResult
ActOnDependentIdExpression(const CXXScopeSpec
&SS
,
1879 const DeclarationNameInfo
&NameInfo
,
1880 bool isAddressOfOperand
,
1881 const TemplateArgumentListInfo
*TemplateArgs
);
1883 ExprResult
BuildDeclRefExpr(ValueDecl
*D
, QualType Ty
,
1886 const CXXScopeSpec
*SS
= 0);
1887 ExprResult
BuildDeclRefExpr(ValueDecl
*D
, QualType Ty
,
1889 const DeclarationNameInfo
&NameInfo
,
1890 const CXXScopeSpec
*SS
= 0);
1892 BuildAnonymousStructUnionMemberReference(const CXXScopeSpec
&SS
,
1893 SourceLocation nameLoc
,
1894 IndirectFieldDecl
*indirectField
,
1895 Expr
*baseObjectExpr
= 0,
1896 SourceLocation opLoc
= SourceLocation());
1897 ExprResult
BuildPossibleImplicitMemberExpr(const CXXScopeSpec
&SS
,
1899 const TemplateArgumentListInfo
*TemplateArgs
);
1900 ExprResult
BuildImplicitMemberExpr(const CXXScopeSpec
&SS
,
1902 const TemplateArgumentListInfo
*TemplateArgs
,
1903 bool IsDefiniteInstance
);
1904 bool UseArgumentDependentLookup(const CXXScopeSpec
&SS
,
1905 const LookupResult
&R
,
1906 bool HasTrailingLParen
);
1908 ExprResult
BuildQualifiedDeclarationNameExpr(CXXScopeSpec
&SS
,
1909 const DeclarationNameInfo
&NameInfo
);
1910 ExprResult
BuildDependentDeclRefExpr(const CXXScopeSpec
&SS
,
1911 const DeclarationNameInfo
&NameInfo
,
1912 const TemplateArgumentListInfo
*TemplateArgs
);
1914 ExprResult
BuildDeclarationNameExpr(const CXXScopeSpec
&SS
,
1917 ExprResult
BuildDeclarationNameExpr(const CXXScopeSpec
&SS
,
1918 const DeclarationNameInfo
&NameInfo
,
1921 ExprResult
ActOnPredefinedExpr(SourceLocation Loc
, tok::TokenKind Kind
);
1922 ExprResult
ActOnNumericConstant(const Token
&);
1923 ExprResult
ActOnCharacterConstant(const Token
&);
1924 ExprResult
ActOnParenExpr(SourceLocation L
, SourceLocation R
, Expr
*Val
);
1925 ExprResult
ActOnParenOrParenListExpr(SourceLocation L
,
1928 ParsedType TypeOfCast
= ParsedType());
1930 /// ActOnStringLiteral - The specified tokens were lexed as pasted string
1931 /// fragments (e.g. "foo" "bar" L"baz").
1932 ExprResult
ActOnStringLiteral(const Token
*Toks
, unsigned NumToks
);
1934 // Binary/Unary Operators. 'Tok' is the token for the operator.
1935 ExprResult
CreateBuiltinUnaryOp(SourceLocation OpLoc
, UnaryOperatorKind Opc
,
1937 ExprResult
BuildUnaryOp(Scope
*S
, SourceLocation OpLoc
,
1938 UnaryOperatorKind Opc
, Expr
*input
);
1939 ExprResult
ActOnUnaryOp(Scope
*S
, SourceLocation OpLoc
,
1940 tok::TokenKind Op
, Expr
*Input
);
1942 ExprResult
CreateSizeOfAlignOfExpr(TypeSourceInfo
*T
,
1943 SourceLocation OpLoc
,
1944 bool isSizeOf
, SourceRange R
);
1945 ExprResult
CreateSizeOfAlignOfExpr(Expr
*E
, SourceLocation OpLoc
,
1946 bool isSizeOf
, SourceRange R
);
1948 ActOnSizeOfAlignOfExpr(SourceLocation OpLoc
, bool isSizeof
, bool isType
,
1949 void *TyOrEx
, const SourceRange
&ArgRange
);
1951 ExprResult
CheckPlaceholderExpr(Expr
*E
, SourceLocation Loc
);
1953 bool CheckSizeOfAlignOfOperand(QualType type
, SourceLocation OpLoc
,
1954 SourceRange R
, bool isSizeof
);
1955 ExprResult
ActOnSizeofParameterPackExpr(Scope
*S
,
1956 SourceLocation OpLoc
,
1957 IdentifierInfo
&Name
,
1958 SourceLocation NameLoc
,
1959 SourceLocation RParenLoc
);
1960 ExprResult
ActOnPostfixUnaryOp(Scope
*S
, SourceLocation OpLoc
,
1961 tok::TokenKind Kind
, Expr
*Input
);
1963 ExprResult
ActOnArraySubscriptExpr(Scope
*S
, Expr
*Base
, SourceLocation LLoc
,
1964 Expr
*Idx
, SourceLocation RLoc
);
1965 ExprResult
CreateBuiltinArraySubscriptExpr(Expr
*Base
, SourceLocation LLoc
,
1966 Expr
*Idx
, SourceLocation RLoc
);
1968 ExprResult
BuildMemberReferenceExpr(Expr
*Base
, QualType BaseType
,
1969 SourceLocation OpLoc
, bool IsArrow
,
1971 NamedDecl
*FirstQualifierInScope
,
1972 const DeclarationNameInfo
&NameInfo
,
1973 const TemplateArgumentListInfo
*TemplateArgs
);
1975 ExprResult
BuildMemberReferenceExpr(Expr
*Base
, QualType BaseType
,
1976 SourceLocation OpLoc
, bool IsArrow
,
1977 const CXXScopeSpec
&SS
,
1978 NamedDecl
*FirstQualifierInScope
,
1980 const TemplateArgumentListInfo
*TemplateArgs
,
1981 bool SuppressQualifierCheck
= false);
1983 ExprResult
LookupMemberExpr(LookupResult
&R
, Expr
*&Base
,
1984 bool &IsArrow
, SourceLocation OpLoc
,
1987 bool HasTemplateArgs
);
1989 bool CheckQualifiedMemberReference(Expr
*BaseExpr
, QualType BaseType
,
1990 const CXXScopeSpec
&SS
,
1991 const LookupResult
&R
);
1993 ExprResult
ActOnDependentMemberExpr(Expr
*Base
, QualType BaseType
,
1994 bool IsArrow
, SourceLocation OpLoc
,
1995 const CXXScopeSpec
&SS
,
1996 NamedDecl
*FirstQualifierInScope
,
1997 const DeclarationNameInfo
&NameInfo
,
1998 const TemplateArgumentListInfo
*TemplateArgs
);
2000 ExprResult
ActOnMemberAccessExpr(Scope
*S
, Expr
*Base
,
2001 SourceLocation OpLoc
,
2002 tok::TokenKind OpKind
,
2004 UnqualifiedId
&Member
,
2006 bool HasTrailingLParen
);
2008 void ActOnDefaultCtorInitializers(Decl
*CDtorDecl
);
2009 bool ConvertArgumentsForCall(CallExpr
*Call
, Expr
*Fn
,
2010 FunctionDecl
*FDecl
,
2011 const FunctionProtoType
*Proto
,
2012 Expr
**Args
, unsigned NumArgs
,
2013 SourceLocation RParenLoc
);
2015 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
2016 /// This provides the location of the left/right parens and a list of comma
2018 ExprResult
ActOnCallExpr(Scope
*S
, Expr
*Fn
, SourceLocation LParenLoc
,
2019 MultiExprArg Args
, SourceLocation RParenLoc
,
2020 Expr
*ExecConfig
= 0);
2021 ExprResult
BuildResolvedCallExpr(Expr
*Fn
, NamedDecl
*NDecl
,
2022 SourceLocation LParenLoc
,
2023 Expr
**Args
, unsigned NumArgs
,
2024 SourceLocation RParenLoc
,
2025 Expr
*ExecConfig
= 0);
2027 ExprResult
ActOnCUDAExecConfigExpr(Scope
*S
, SourceLocation LLLLoc
,
2028 MultiExprArg ExecConfig
, SourceLocation GGGLoc
);
2030 ExprResult
ActOnCastExpr(Scope
*S
, SourceLocation LParenLoc
,
2031 ParsedType Ty
, SourceLocation RParenLoc
,
2033 ExprResult
BuildCStyleCastExpr(SourceLocation LParenLoc
,
2035 SourceLocation RParenLoc
,
2038 bool TypeIsVectorType(ParsedType Ty
) {
2039 return GetTypeFromParser(Ty
)->isVectorType();
2042 ExprResult
MaybeConvertParenListExprToParenExpr(Scope
*S
, Expr
*ME
);
2043 ExprResult
ActOnCastOfParenListExpr(Scope
*S
, SourceLocation LParenLoc
,
2044 SourceLocation RParenLoc
, Expr
*E
,
2045 TypeSourceInfo
*TInfo
);
2047 ExprResult
ActOnCompoundLiteral(SourceLocation LParenLoc
,
2049 SourceLocation RParenLoc
,
2052 ExprResult
BuildCompoundLiteralExpr(SourceLocation LParenLoc
,
2053 TypeSourceInfo
*TInfo
,
2054 SourceLocation RParenLoc
,
2057 ExprResult
ActOnInitList(SourceLocation LParenLoc
,
2058 MultiExprArg InitList
,
2059 SourceLocation RParenLoc
);
2061 ExprResult
ActOnDesignatedInitializer(Designation
&Desig
,
2066 ExprResult
ActOnBinOp(Scope
*S
, SourceLocation TokLoc
,
2067 tok::TokenKind Kind
, Expr
*LHS
, Expr
*RHS
);
2068 ExprResult
BuildBinOp(Scope
*S
, SourceLocation OpLoc
,
2069 BinaryOperatorKind Opc
, Expr
*lhs
, Expr
*rhs
);
2070 ExprResult
CreateBuiltinBinOp(SourceLocation TokLoc
,
2071 BinaryOperatorKind Opc
, Expr
*lhs
, Expr
*rhs
);
2073 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null
2074 /// in the case of a the GNU conditional expr extension.
2075 ExprResult
ActOnConditionalOp(SourceLocation QuestionLoc
,
2076 SourceLocation ColonLoc
,
2077 Expr
*Cond
, Expr
*LHS
, Expr
*RHS
);
2079 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
2080 ExprResult
ActOnAddrLabel(SourceLocation OpLoc
, SourceLocation LabLoc
,
2083 ExprResult
ActOnStmtExpr(SourceLocation LPLoc
, Stmt
*SubStmt
,
2084 SourceLocation RPLoc
); // "({..})"
2086 // __builtin_offsetof(type, identifier(.identifier|[expr])*)
2087 struct OffsetOfComponent
{
2088 SourceLocation LocStart
, LocEnd
;
2089 bool isBrackets
; // true if [expr], false if .ident
2091 IdentifierInfo
*IdentInfo
;
2096 /// __builtin_offsetof(type, a.b[123][456].c)
2097 ExprResult
BuildBuiltinOffsetOf(SourceLocation BuiltinLoc
,
2098 TypeSourceInfo
*TInfo
,
2099 OffsetOfComponent
*CompPtr
,
2100 unsigned NumComponents
,
2101 SourceLocation RParenLoc
);
2102 ExprResult
ActOnBuiltinOffsetOf(Scope
*S
,
2103 SourceLocation BuiltinLoc
,
2104 SourceLocation TypeLoc
,
2106 OffsetOfComponent
*CompPtr
,
2107 unsigned NumComponents
,
2108 SourceLocation RParenLoc
);
2110 // __builtin_choose_expr(constExpr, expr1, expr2)
2111 ExprResult
ActOnChooseExpr(SourceLocation BuiltinLoc
,
2112 Expr
*cond
, Expr
*expr1
,
2113 Expr
*expr2
, SourceLocation RPLoc
);
2115 // __builtin_va_arg(expr, type)
2116 ExprResult
ActOnVAArg(SourceLocation BuiltinLoc
,
2117 Expr
*expr
, ParsedType type
,
2118 SourceLocation RPLoc
);
2119 ExprResult
BuildVAArgExpr(SourceLocation BuiltinLoc
,
2120 Expr
*expr
, TypeSourceInfo
*TInfo
,
2121 SourceLocation RPLoc
);
2124 ExprResult
ActOnGNUNullExpr(SourceLocation TokenLoc
);
2126 //===------------------------- "Block" Extension ------------------------===//
2128 /// ActOnBlockStart - This callback is invoked when a block literal is
2130 void ActOnBlockStart(SourceLocation CaretLoc
, Scope
*CurScope
);
2132 /// ActOnBlockArguments - This callback allows processing of block arguments.
2133 /// If there are no arguments, this is still invoked.
2134 void ActOnBlockArguments(Declarator
&ParamInfo
, Scope
*CurScope
);
2136 /// ActOnBlockError - If there is an error parsing a block, this callback
2137 /// is invoked to pop the information about the block from the action impl.
2138 void ActOnBlockError(SourceLocation CaretLoc
, Scope
*CurScope
);
2140 /// ActOnBlockStmtExpr - This is called when the body of a block statement
2141 /// literal was successfully completed. ^(int x){...}
2142 ExprResult
ActOnBlockStmtExpr(SourceLocation CaretLoc
,
2143 Stmt
*Body
, Scope
*CurScope
);
2145 //===---------------------------- C++ Features --------------------------===//
2147 // Act on C++ namespaces
2148 Decl
*ActOnStartNamespaceDef(Scope
*S
, SourceLocation InlineLoc
,
2149 SourceLocation IdentLoc
,
2150 IdentifierInfo
*Ident
,
2151 SourceLocation LBrace
,
2152 AttributeList
*AttrList
);
2153 void ActOnFinishNamespaceDef(Decl
*Dcl
, SourceLocation RBrace
);
2155 NamespaceDecl
*getStdNamespace() const;
2156 NamespaceDecl
*getOrCreateStdNamespace();
2158 CXXRecordDecl
*getStdBadAlloc() const;
2160 Decl
*ActOnUsingDirective(Scope
*CurScope
,
2161 SourceLocation UsingLoc
,
2162 SourceLocation NamespcLoc
,
2164 SourceLocation IdentLoc
,
2165 IdentifierInfo
*NamespcName
,
2166 AttributeList
*AttrList
);
2168 void PushUsingDirective(Scope
*S
, UsingDirectiveDecl
*UDir
);
2170 Decl
*ActOnNamespaceAliasDef(Scope
*CurScope
,
2171 SourceLocation NamespaceLoc
,
2172 SourceLocation AliasLoc
,
2173 IdentifierInfo
*Alias
,
2175 SourceLocation IdentLoc
,
2176 IdentifierInfo
*Ident
);
2178 void HideUsingShadowDecl(Scope
*S
, UsingShadowDecl
*Shadow
);
2179 bool CheckUsingShadowDecl(UsingDecl
*UD
, NamedDecl
*Target
,
2180 const LookupResult
&PreviousDecls
);
2181 UsingShadowDecl
*BuildUsingShadowDecl(Scope
*S
, UsingDecl
*UD
,
2184 bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc
,
2186 const CXXScopeSpec
&SS
,
2187 SourceLocation NameLoc
,
2188 const LookupResult
&Previous
);
2189 bool CheckUsingDeclQualifier(SourceLocation UsingLoc
,
2190 const CXXScopeSpec
&SS
,
2191 SourceLocation NameLoc
);
2193 NamedDecl
*BuildUsingDeclaration(Scope
*S
, AccessSpecifier AS
,
2194 SourceLocation UsingLoc
,
2196 const DeclarationNameInfo
&NameInfo
,
2197 AttributeList
*AttrList
,
2198 bool IsInstantiation
,
2200 SourceLocation TypenameLoc
);
2202 bool CheckInheritedConstructorUsingDecl(UsingDecl
*UD
);
2204 Decl
*ActOnUsingDeclaration(Scope
*CurScope
,
2206 bool HasUsingKeyword
,
2207 SourceLocation UsingLoc
,
2209 UnqualifiedId
&Name
,
2210 AttributeList
*AttrList
,
2212 SourceLocation TypenameLoc
);
2214 /// AddCXXDirectInitializerToDecl - This action is called immediately after
2215 /// ActOnDeclarator, when a C++ direct initializer is present.
2216 /// e.g: "int x(1);"
2217 void AddCXXDirectInitializerToDecl(Decl
*Dcl
,
2218 SourceLocation LParenLoc
,
2220 SourceLocation RParenLoc
);
2222 /// InitializeVarWithConstructor - Creates an CXXConstructExpr
2223 /// and sets it as the initializer for the the passed in VarDecl.
2224 bool InitializeVarWithConstructor(VarDecl
*VD
,
2225 CXXConstructorDecl
*Constructor
,
2226 MultiExprArg Exprs
);
2228 /// BuildCXXConstructExpr - Creates a complete call to a constructor,
2229 /// including handling of its default argument expressions.
2231 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind
2233 BuildCXXConstructExpr(SourceLocation ConstructLoc
, QualType DeclInitType
,
2234 CXXConstructorDecl
*Constructor
, MultiExprArg Exprs
,
2235 bool RequiresZeroInit
, unsigned ConstructKind
,
2236 SourceRange ParenRange
);
2238 // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
2239 // the constructor can be elidable?
2241 BuildCXXConstructExpr(SourceLocation ConstructLoc
, QualType DeclInitType
,
2242 CXXConstructorDecl
*Constructor
, bool Elidable
,
2243 MultiExprArg Exprs
, bool RequiresZeroInit
,
2244 unsigned ConstructKind
,
2245 SourceRange ParenRange
);
2247 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
2248 /// the default expr if needed.
2249 ExprResult
BuildCXXDefaultArgExpr(SourceLocation CallLoc
,
2251 ParmVarDecl
*Param
);
2253 /// FinalizeVarWithDestructor - Prepare for calling destructor on the
2254 /// constructed variable.
2255 void FinalizeVarWithDestructor(VarDecl
*VD
, const RecordType
*DeclInitType
);
2257 /// \brief Declare the implicit default constructor for the given class.
2259 /// \param ClassDecl The class declaration into which the implicit
2260 /// default constructor will be added.
2262 /// \returns The implicitly-declared default constructor.
2263 CXXConstructorDecl
*DeclareImplicitDefaultConstructor(
2264 CXXRecordDecl
*ClassDecl
);
2266 /// DefineImplicitDefaultConstructor - Checks for feasibility of
2267 /// defining this constructor as the default constructor.
2268 void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation
,
2269 CXXConstructorDecl
*Constructor
);
2271 /// \brief Declare the implicit destructor for the given class.
2273 /// \param ClassDecl The class declaration into which the implicit
2274 /// destructor will be added.
2276 /// \returns The implicitly-declared destructor.
2277 CXXDestructorDecl
*DeclareImplicitDestructor(CXXRecordDecl
*ClassDecl
);
2279 /// DefineImplicitDestructor - Checks for feasibility of
2280 /// defining this destructor as the default destructor.
2281 void DefineImplicitDestructor(SourceLocation CurrentLocation
,
2282 CXXDestructorDecl
*Destructor
);
2284 /// \brief Declare all inherited constructors for the given class.
2286 /// \param ClassDecl The class declaration into which the inherited
2287 /// constructors will be added.
2288 void DeclareInheritedConstructors(CXXRecordDecl
*ClassDecl
);
2290 /// \brief Declare the implicit copy constructor for the given class.
2292 /// \param S The scope of the class, which may be NULL if this is a
2293 /// template instantiation.
2295 /// \param ClassDecl The class declaration into which the implicit
2296 /// copy constructor will be added.
2298 /// \returns The implicitly-declared copy constructor.
2299 CXXConstructorDecl
*DeclareImplicitCopyConstructor(CXXRecordDecl
*ClassDecl
);
2301 /// DefineImplicitCopyConstructor - Checks for feasibility of
2302 /// defining this constructor as the copy constructor.
2303 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation
,
2304 CXXConstructorDecl
*Constructor
,
2305 unsigned TypeQuals
);
2307 /// \brief Declare the implicit copy assignment operator for the given class.
2309 /// \param S The scope of the class, which may be NULL if this is a
2310 /// template instantiation.
2312 /// \param ClassDecl The class declaration into which the implicit
2313 /// copy-assignment operator will be added.
2315 /// \returns The implicitly-declared copy assignment operator.
2316 CXXMethodDecl
*DeclareImplicitCopyAssignment(CXXRecordDecl
*ClassDecl
);
2318 /// \brief Defined an implicitly-declared copy assignment operator.
2319 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation
,
2320 CXXMethodDecl
*MethodDecl
);
2322 /// \brief Force the declaration of any implicitly-declared members of this
2324 void ForceDeclarationOfImplicitMembers(CXXRecordDecl
*Class
);
2326 /// MaybeBindToTemporary - If the passed in expression has a record type with
2327 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise
2328 /// it simply returns the passed in expression.
2329 ExprResult
MaybeBindToTemporary(Expr
*E
);
2331 bool CompleteConstructorCall(CXXConstructorDecl
*Constructor
,
2332 MultiExprArg ArgsPtr
,
2334 ASTOwningVector
<Expr
*> &ConvertedArgs
);
2336 ParsedType
getDestructorName(SourceLocation TildeLoc
,
2337 IdentifierInfo
&II
, SourceLocation NameLoc
,
2338 Scope
*S
, CXXScopeSpec
&SS
,
2339 ParsedType ObjectType
,
2340 bool EnteringContext
);
2342 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's.
2343 ExprResult
ActOnCXXNamedCast(SourceLocation OpLoc
,
2344 tok::TokenKind Kind
,
2345 SourceLocation LAngleBracketLoc
,
2347 SourceLocation RAngleBracketLoc
,
2348 SourceLocation LParenLoc
,
2350 SourceLocation RParenLoc
);
2352 ExprResult
BuildCXXNamedCast(SourceLocation OpLoc
,
2353 tok::TokenKind Kind
,
2356 SourceRange AngleBrackets
,
2357 SourceRange Parens
);
2359 ExprResult
BuildCXXTypeId(QualType TypeInfoType
,
2360 SourceLocation TypeidLoc
,
2361 TypeSourceInfo
*Operand
,
2362 SourceLocation RParenLoc
);
2363 ExprResult
BuildCXXTypeId(QualType TypeInfoType
,
2364 SourceLocation TypeidLoc
,
2366 SourceLocation RParenLoc
);
2368 /// ActOnCXXTypeid - Parse typeid( something ).
2369 ExprResult
ActOnCXXTypeid(SourceLocation OpLoc
,
2370 SourceLocation LParenLoc
, bool isType
,
2372 SourceLocation RParenLoc
);
2374 ExprResult
BuildCXXUuidof(QualType TypeInfoType
,
2375 SourceLocation TypeidLoc
,
2376 TypeSourceInfo
*Operand
,
2377 SourceLocation RParenLoc
);
2378 ExprResult
BuildCXXUuidof(QualType TypeInfoType
,
2379 SourceLocation TypeidLoc
,
2381 SourceLocation RParenLoc
);
2383 /// ActOnCXXUuidof - Parse __uuidof( something ).
2384 ExprResult
ActOnCXXUuidof(SourceLocation OpLoc
,
2385 SourceLocation LParenLoc
, bool isType
,
2387 SourceLocation RParenLoc
);
2390 //// ActOnCXXThis - Parse 'this' pointer.
2391 ExprResult
ActOnCXXThis(SourceLocation loc
);
2393 /// tryCaptureCXXThis - Try to capture a 'this' pointer. Returns a
2394 /// pointer to an instance method whose 'this' pointer is
2395 /// capturable, or null if this is not possible.
2396 CXXMethodDecl
*tryCaptureCXXThis();
2398 /// ActOnCXXBoolLiteral - Parse {true,false} literals.
2399 ExprResult
ActOnCXXBoolLiteral(SourceLocation OpLoc
, tok::TokenKind Kind
);
2401 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'.
2402 ExprResult
ActOnCXXNullPtrLiteral(SourceLocation Loc
);
2404 //// ActOnCXXThrow - Parse throw expressions.
2405 ExprResult
ActOnCXXThrow(SourceLocation OpLoc
, Expr
*expr
);
2406 bool CheckCXXThrowOperand(SourceLocation ThrowLoc
, Expr
*&E
);
2408 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type.
2409 /// Can be interpreted either as function-style casting ("int(x)")
2410 /// or class type construction ("ClassType(x,y,z)")
2411 /// or creation of a value-initialized type ("int()").
2412 ExprResult
ActOnCXXTypeConstructExpr(ParsedType TypeRep
,
2413 SourceLocation LParenLoc
,
2415 SourceLocation RParenLoc
);
2417 ExprResult
BuildCXXTypeConstructExpr(TypeSourceInfo
*Type
,
2418 SourceLocation LParenLoc
,
2420 SourceLocation RParenLoc
);
2422 /// ActOnCXXNew - Parsed a C++ 'new' expression.
2423 ExprResult
ActOnCXXNew(SourceLocation StartLoc
, bool UseGlobal
,
2424 SourceLocation PlacementLParen
,
2425 MultiExprArg PlacementArgs
,
2426 SourceLocation PlacementRParen
,
2427 SourceRange TypeIdParens
, Declarator
&D
,
2428 SourceLocation ConstructorLParen
,
2429 MultiExprArg ConstructorArgs
,
2430 SourceLocation ConstructorRParen
);
2431 ExprResult
BuildCXXNew(SourceLocation StartLoc
, bool UseGlobal
,
2432 SourceLocation PlacementLParen
,
2433 MultiExprArg PlacementArgs
,
2434 SourceLocation PlacementRParen
,
2435 SourceRange TypeIdParens
,
2437 TypeSourceInfo
*AllocTypeInfo
,
2439 SourceLocation ConstructorLParen
,
2440 MultiExprArg ConstructorArgs
,
2441 SourceLocation ConstructorRParen
);
2443 bool CheckAllocatedType(QualType AllocType
, SourceLocation Loc
,
2445 bool FindAllocationFunctions(SourceLocation StartLoc
, SourceRange Range
,
2446 bool UseGlobal
, QualType AllocType
, bool IsArray
,
2447 Expr
**PlaceArgs
, unsigned NumPlaceArgs
,
2448 FunctionDecl
*&OperatorNew
,
2449 FunctionDecl
*&OperatorDelete
);
2450 bool FindAllocationOverload(SourceLocation StartLoc
, SourceRange Range
,
2451 DeclarationName Name
, Expr
** Args
,
2452 unsigned NumArgs
, DeclContext
*Ctx
,
2453 bool AllowMissing
, FunctionDecl
*&Operator
);
2454 void DeclareGlobalNewDelete();
2455 void DeclareGlobalAllocationFunction(DeclarationName Name
, QualType Return
,
2457 bool addMallocAttr
= false);
2459 bool FindDeallocationFunction(SourceLocation StartLoc
, CXXRecordDecl
*RD
,
2460 DeclarationName Name
, FunctionDecl
* &Operator
);
2462 /// ActOnCXXDelete - Parsed a C++ 'delete' expression
2463 ExprResult
ActOnCXXDelete(SourceLocation StartLoc
,
2464 bool UseGlobal
, bool ArrayForm
,
2467 DeclResult
ActOnCXXConditionDeclaration(Scope
*S
, Declarator
&D
);
2468 ExprResult
CheckConditionVariable(VarDecl
*ConditionVar
,
2469 SourceLocation StmtLoc
,
2470 bool ConvertToBoolean
);
2472 ExprResult
ActOnNoexceptExpr(SourceLocation KeyLoc
, SourceLocation LParen
,
2473 Expr
*Operand
, SourceLocation RParen
);
2474 ExprResult
BuildCXXNoexceptExpr(SourceLocation KeyLoc
, Expr
*Operand
,
2475 SourceLocation RParen
);
2477 /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support
2478 /// pseudo-functions.
2479 ExprResult
ActOnUnaryTypeTrait(UnaryTypeTrait OTT
,
2480 SourceLocation KWLoc
,
2482 SourceLocation RParen
);
2484 ExprResult
BuildUnaryTypeTrait(UnaryTypeTrait OTT
,
2485 SourceLocation KWLoc
,
2487 SourceLocation RParen
);
2489 /// ActOnBinaryTypeTrait - Parsed one of the bianry type trait support
2490 /// pseudo-functions.
2491 ExprResult
ActOnBinaryTypeTrait(BinaryTypeTrait OTT
,
2492 SourceLocation KWLoc
,
2495 SourceLocation RParen
);
2497 ExprResult
BuildBinaryTypeTrait(BinaryTypeTrait BTT
,
2498 SourceLocation KWLoc
,
2499 TypeSourceInfo
*LhsT
,
2500 TypeSourceInfo
*RhsT
,
2501 SourceLocation RParen
);
2503 ExprResult
ActOnStartCXXMemberReference(Scope
*S
,
2505 SourceLocation OpLoc
,
2506 tok::TokenKind OpKind
,
2507 ParsedType
&ObjectType
,
2508 bool &MayBePseudoDestructor
);
2510 ExprResult
DiagnoseDtorReference(SourceLocation NameLoc
, Expr
*MemExpr
);
2512 ExprResult
BuildPseudoDestructorExpr(Expr
*Base
,
2513 SourceLocation OpLoc
,
2514 tok::TokenKind OpKind
,
2515 const CXXScopeSpec
&SS
,
2516 TypeSourceInfo
*ScopeType
,
2517 SourceLocation CCLoc
,
2518 SourceLocation TildeLoc
,
2519 PseudoDestructorTypeStorage DestroyedType
,
2520 bool HasTrailingLParen
);
2522 ExprResult
ActOnPseudoDestructorExpr(Scope
*S
, Expr
*Base
,
2523 SourceLocation OpLoc
,
2524 tok::TokenKind OpKind
,
2526 UnqualifiedId
&FirstTypeName
,
2527 SourceLocation CCLoc
,
2528 SourceLocation TildeLoc
,
2529 UnqualifiedId
&SecondTypeName
,
2530 bool HasTrailingLParen
);
2532 /// MaybeCreateExprWithCleanups - If the current full-expression
2533 /// requires any cleanups, surround it with a ExprWithCleanups node.
2534 /// Otherwise, just returns the passed-in expression.
2535 Expr
*MaybeCreateExprWithCleanups(Expr
*SubExpr
);
2536 Stmt
*MaybeCreateStmtWithCleanups(Stmt
*SubStmt
);
2537 ExprResult
MaybeCreateExprWithCleanups(ExprResult SubExpr
);
2539 ExprResult
ActOnFinishFullExpr(Expr
*Expr
);
2540 StmtResult
ActOnFinishFullStmt(Stmt
*Stmt
);
2542 // Marks SS invalid if it represents an incomplete type.
2543 bool RequireCompleteDeclContext(CXXScopeSpec
&SS
, DeclContext
*DC
);
2545 DeclContext
*computeDeclContext(QualType T
);
2546 DeclContext
*computeDeclContext(const CXXScopeSpec
&SS
,
2547 bool EnteringContext
= false);
2548 bool isDependentScopeSpecifier(const CXXScopeSpec
&SS
);
2549 CXXRecordDecl
*getCurrentInstantiationOf(NestedNameSpecifier
*NNS
);
2550 bool isUnknownSpecialization(const CXXScopeSpec
&SS
);
2552 /// ActOnCXXGlobalScopeSpecifier - Return the object that represents the
2553 /// global scope ('::').
2554 NestedNameSpecifier
*
2555 ActOnCXXGlobalScopeSpecifier(Scope
*S
, SourceLocation CCLoc
);
2557 bool isAcceptableNestedNameSpecifier(NamedDecl
*SD
);
2558 NamedDecl
*FindFirstQualifierInScope(Scope
*S
, NestedNameSpecifier
*NNS
);
2560 bool isNonTypeNestedNameSpecifier(Scope
*S
, CXXScopeSpec
&SS
,
2561 SourceLocation IdLoc
,
2563 ParsedType ObjectType
);
2565 NestedNameSpecifier
*BuildCXXNestedNameSpecifier(Scope
*S
,
2567 SourceLocation IdLoc
,
2568 SourceLocation CCLoc
,
2570 QualType ObjectType
,
2571 NamedDecl
*ScopeLookupResult
,
2572 bool EnteringContext
,
2573 bool ErrorRecoveryLookup
);
2575 NestedNameSpecifier
*ActOnCXXNestedNameSpecifier(Scope
*S
,
2577 SourceLocation IdLoc
,
2578 SourceLocation CCLoc
,
2580 ParsedType ObjectType
,
2581 bool EnteringContext
);
2583 bool IsInvalidUnlessNestedName(Scope
*S
, CXXScopeSpec
&SS
,
2585 ParsedType ObjectType
,
2586 bool EnteringContext
);
2588 /// ActOnCXXNestedNameSpecifier - Called during parsing of a
2589 /// nested-name-specifier that involves a template-id, e.g.,
2590 /// "foo::bar<int, float>::", and now we need to build a scope
2591 /// specifier. \p SS is empty or the previously parsed nested-name
2592 /// part ("foo::"), \p Type is the already-parsed class template
2593 /// specialization (or other template-id that names a type), \p
2594 /// TypeRange is the source range where the type is located, and \p
2595 /// CCLoc is the location of the trailing '::'.
2596 CXXScopeTy
*ActOnCXXNestedNameSpecifier(Scope
*S
,
2597 const CXXScopeSpec
&SS
,
2599 SourceRange TypeRange
,
2600 SourceLocation CCLoc
);
2602 bool ShouldEnterDeclaratorScope(Scope
*S
, const CXXScopeSpec
&SS
);
2604 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global
2605 /// scope or nested-name-specifier) is parsed, part of a declarator-id.
2606 /// After this method is called, according to [C++ 3.4.3p3], names should be
2607 /// looked up in the declarator-id's scope, until the declarator is parsed and
2608 /// ActOnCXXExitDeclaratorScope is called.
2609 /// The 'SS' should be a non-empty valid CXXScopeSpec.
2610 bool ActOnCXXEnterDeclaratorScope(Scope
*S
, CXXScopeSpec
&SS
);
2612 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously
2613 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same
2614 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well.
2615 /// Used to indicate that names should revert to being looked up in the
2617 void ActOnCXXExitDeclaratorScope(Scope
*S
, const CXXScopeSpec
&SS
);
2619 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an
2620 /// initializer for the declaration 'Dcl'.
2621 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a
2622 /// static data member of class X, names should be looked up in the scope of
2624 void ActOnCXXEnterDeclInitializer(Scope
*S
, Decl
*Dcl
);
2626 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an
2627 /// initializer for the declaration 'Dcl'.
2628 void ActOnCXXExitDeclInitializer(Scope
*S
, Decl
*Dcl
);
2630 // ParseObjCStringLiteral - Parse Objective-C string literals.
2631 ExprResult
ParseObjCStringLiteral(SourceLocation
*AtLocs
,
2633 unsigned NumStrings
);
2635 Expr
*BuildObjCEncodeExpression(SourceLocation AtLoc
,
2636 TypeSourceInfo
*EncodedTypeInfo
,
2637 SourceLocation RParenLoc
);
2638 ExprResult
BuildCXXMemberCallExpr(Expr
*Exp
, NamedDecl
*FoundDecl
,
2639 CXXMethodDecl
*Method
);
2641 ExprResult
ParseObjCEncodeExpression(SourceLocation AtLoc
,
2642 SourceLocation EncodeLoc
,
2643 SourceLocation LParenLoc
,
2645 SourceLocation RParenLoc
);
2647 // ParseObjCSelectorExpression - Build selector expression for @selector
2648 ExprResult
ParseObjCSelectorExpression(Selector Sel
,
2649 SourceLocation AtLoc
,
2650 SourceLocation SelLoc
,
2651 SourceLocation LParenLoc
,
2652 SourceLocation RParenLoc
);
2654 // ParseObjCProtocolExpression - Build protocol expression for @protocol
2655 ExprResult
ParseObjCProtocolExpression(IdentifierInfo
* ProtocolName
,
2656 SourceLocation AtLoc
,
2657 SourceLocation ProtoLoc
,
2658 SourceLocation LParenLoc
,
2659 SourceLocation RParenLoc
);
2661 //===--------------------------------------------------------------------===//
2664 Decl
*ActOnStartLinkageSpecification(Scope
*S
,
2665 SourceLocation ExternLoc
,
2666 SourceLocation LangLoc
,
2667 llvm::StringRef Lang
,
2668 SourceLocation LBraceLoc
);
2669 Decl
*ActOnFinishLinkageSpecification(Scope
*S
,
2671 SourceLocation RBraceLoc
);
2674 //===--------------------------------------------------------------------===//
2677 bool isCurrentClassName(const IdentifierInfo
&II
, Scope
*S
,
2678 const CXXScopeSpec
*SS
= 0);
2680 Decl
*ActOnAccessSpecifier(AccessSpecifier Access
,
2681 SourceLocation ASLoc
,
2682 SourceLocation ColonLoc
);
2684 Decl
*ActOnCXXMemberDeclarator(Scope
*S
, AccessSpecifier AS
,
2686 MultiTemplateParamsArg TemplateParameterLists
,
2687 Expr
*BitfieldWidth
, const VirtSpecifiers
&VS
,
2688 Expr
*Init
, bool IsDefinition
,
2689 bool Deleted
= false);
2691 MemInitResult
ActOnMemInitializer(Decl
*ConstructorD
,
2694 IdentifierInfo
*MemberOrBase
,
2695 ParsedType TemplateTypeTy
,
2696 SourceLocation IdLoc
,
2697 SourceLocation LParenLoc
,
2698 Expr
**Args
, unsigned NumArgs
,
2699 SourceLocation RParenLoc
,
2700 SourceLocation EllipsisLoc
);
2702 MemInitResult
BuildMemberInitializer(ValueDecl
*Member
, Expr
**Args
,
2703 unsigned NumArgs
, SourceLocation IdLoc
,
2704 SourceLocation LParenLoc
,
2705 SourceLocation RParenLoc
);
2707 MemInitResult
BuildBaseInitializer(QualType BaseType
,
2708 TypeSourceInfo
*BaseTInfo
,
2709 Expr
**Args
, unsigned NumArgs
,
2710 SourceLocation LParenLoc
,
2711 SourceLocation RParenLoc
,
2712 CXXRecordDecl
*ClassDecl
,
2713 SourceLocation EllipsisLoc
);
2715 MemInitResult
BuildDelegatingInitializer(TypeSourceInfo
*TInfo
,
2716 Expr
**Args
, unsigned NumArgs
,
2717 SourceLocation RParenLoc
,
2718 SourceLocation LParenLoc
,
2719 CXXRecordDecl
*ClassDecl
,
2720 SourceLocation EllipsisLoc
);
2722 bool SetCtorInitializers(CXXConstructorDecl
*Constructor
,
2723 CXXCtorInitializer
**Initializers
,
2724 unsigned NumInitializers
, bool AnyErrors
);
2726 void SetIvarInitializers(ObjCImplementationDecl
*ObjCImplementation
);
2729 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl,
2730 /// mark all the non-trivial destructors of its members and bases as
2732 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc
,
2733 CXXRecordDecl
*Record
);
2735 /// \brief The list of classes whose vtables have been used within
2736 /// this translation unit, and the source locations at which the
2737 /// first use occurred.
2738 typedef std::pair
<CXXRecordDecl
*, SourceLocation
> VTableUse
;
2740 /// \brief The list of vtables that are required but have not yet been
2742 llvm::SmallVector
<VTableUse
, 16> VTableUses
;
2744 /// \brief The set of classes whose vtables have been used within
2745 /// this translation unit, and a bit that will be true if the vtable is
2746 /// required to be emitted (otherwise, it should be emitted only if needed
2747 /// by code generation).
2748 llvm::DenseMap
<CXXRecordDecl
*, bool> VTablesUsed
;
2750 /// \brief A list of all of the dynamic classes in this translation
2752 llvm::SmallVector
<CXXRecordDecl
*, 16> DynamicClasses
;
2754 /// \brief Note that the vtable for the given class was used at the
2756 void MarkVTableUsed(SourceLocation Loc
, CXXRecordDecl
*Class
,
2757 bool DefinitionRequired
= false);
2759 /// MarkVirtualMembersReferenced - Will mark all members of the given
2760 /// CXXRecordDecl referenced.
2761 void MarkVirtualMembersReferenced(SourceLocation Loc
,
2762 const CXXRecordDecl
*RD
);
2764 /// \brief Define all of the vtables that have been used in this
2765 /// translation unit and reference any virtual members used by those
2768 /// \returns true if any work was done, false otherwise.
2769 bool DefineUsedVTables();
2771 void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl
*ClassDecl
);
2773 void ActOnMemInitializers(Decl
*ConstructorDecl
,
2774 SourceLocation ColonLoc
,
2775 MemInitTy
**MemInits
, unsigned NumMemInits
,
2778 void CheckCompletedCXXClass(CXXRecordDecl
*Record
);
2779 void ActOnFinishCXXMemberSpecification(Scope
* S
, SourceLocation RLoc
,
2781 SourceLocation LBrac
,
2782 SourceLocation RBrac
,
2783 AttributeList
*AttrList
);
2785 void ActOnReenterTemplateScope(Scope
*S
, Decl
*Template
);
2786 void ActOnStartDelayedMemberDeclarations(Scope
*S
, Decl
*Record
);
2787 void ActOnStartDelayedCXXMethodDeclaration(Scope
*S
, Decl
*Method
);
2788 void ActOnDelayedCXXMethodParameter(Scope
*S
, Decl
*Param
);
2789 void ActOnFinishDelayedCXXMethodDeclaration(Scope
*S
, Decl
*Method
);
2790 void ActOnFinishDelayedMemberDeclarations(Scope
*S
, Decl
*Record
);
2792 Decl
*ActOnStaticAssertDeclaration(SourceLocation AssertLoc
,
2794 Expr
*AssertMessageExpr
);
2796 FriendDecl
*CheckFriendTypeDecl(SourceLocation FriendLoc
,
2797 TypeSourceInfo
*TSInfo
);
2798 Decl
*ActOnFriendTypeDecl(Scope
*S
, const DeclSpec
&DS
,
2799 MultiTemplateParamsArg TemplateParams
);
2800 Decl
*ActOnFriendFunctionDecl(Scope
*S
, Declarator
&D
, bool IsDefinition
,
2801 MultiTemplateParamsArg TemplateParams
);
2803 QualType
CheckConstructorDeclarator(Declarator
&D
, QualType R
,
2805 void CheckConstructor(CXXConstructorDecl
*Constructor
);
2806 QualType
CheckDestructorDeclarator(Declarator
&D
, QualType R
,
2808 bool CheckDestructor(CXXDestructorDecl
*Destructor
);
2809 void CheckConversionDeclarator(Declarator
&D
, QualType
&R
,
2811 Decl
*ActOnConversionDeclarator(CXXConversionDecl
*Conversion
);
2813 //===--------------------------------------------------------------------===//
2814 // C++ Derived Classes
2817 /// ActOnBaseSpecifier - Parsed a base specifier
2818 CXXBaseSpecifier
*CheckBaseSpecifier(CXXRecordDecl
*Class
,
2819 SourceRange SpecifierRange
,
2820 bool Virtual
, AccessSpecifier Access
,
2821 TypeSourceInfo
*TInfo
,
2822 SourceLocation EllipsisLoc
);
2824 BaseResult
ActOnBaseSpecifier(Decl
*classdecl
,
2825 SourceRange SpecifierRange
,
2826 bool Virtual
, AccessSpecifier Access
,
2827 ParsedType basetype
,
2828 SourceLocation BaseLoc
,
2829 SourceLocation EllipsisLoc
);
2831 bool AttachBaseSpecifiers(CXXRecordDecl
*Class
, CXXBaseSpecifier
**Bases
,
2833 void ActOnBaseSpecifiers(Decl
*ClassDecl
, BaseTy
**Bases
, unsigned NumBases
);
2835 bool IsDerivedFrom(QualType Derived
, QualType Base
);
2836 bool IsDerivedFrom(QualType Derived
, QualType Base
, CXXBasePaths
&Paths
);
2838 // FIXME: I don't like this name.
2839 void BuildBasePathArray(const CXXBasePaths
&Paths
, CXXCastPath
&BasePath
);
2841 bool BasePathInvolvesVirtualBase(const CXXCastPath
&BasePath
);
2843 bool CheckDerivedToBaseConversion(QualType Derived
, QualType Base
,
2844 SourceLocation Loc
, SourceRange Range
,
2845 CXXCastPath
*BasePath
= 0,
2846 bool IgnoreAccess
= false);
2847 bool CheckDerivedToBaseConversion(QualType Derived
, QualType Base
,
2848 unsigned InaccessibleBaseID
,
2849 unsigned AmbigiousBaseConvID
,
2850 SourceLocation Loc
, SourceRange Range
,
2851 DeclarationName Name
,
2852 CXXCastPath
*BasePath
);
2854 std::string
getAmbiguousPathsDisplayString(CXXBasePaths
&Paths
);
2856 /// CheckOverridingFunctionReturnType - Checks whether the return types are
2857 /// covariant, according to C++ [class.virtual]p5.
2858 bool CheckOverridingFunctionReturnType(const CXXMethodDecl
*New
,
2859 const CXXMethodDecl
*Old
);
2861 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception
2862 /// spec is a subset of base spec.
2863 bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl
*New
,
2864 const CXXMethodDecl
*Old
);
2866 bool CheckPureMethod(CXXMethodDecl
*Method
, SourceRange InitRange
);
2868 /// CheckOverrideControl - Check C++0x override control semantics.
2869 void CheckOverrideControl(const Decl
*D
);
2871 /// CheckForFunctionMarkedFinal - Checks whether a virtual member function
2872 /// overrides a virtual member function marked 'final', according to
2873 /// C++0x [class.virtual]p3.
2874 bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl
*New
,
2875 const CXXMethodDecl
*Old
);
2878 //===--------------------------------------------------------------------===//
2879 // C++ Access Control
2889 bool SetMemberAccessSpecifier(NamedDecl
*MemberDecl
,
2890 NamedDecl
*PrevMemberDecl
,
2891 AccessSpecifier LexicalAS
);
2893 AccessResult
CheckUnresolvedMemberAccess(UnresolvedMemberExpr
*E
,
2894 DeclAccessPair FoundDecl
);
2895 AccessResult
CheckUnresolvedLookupAccess(UnresolvedLookupExpr
*E
,
2896 DeclAccessPair FoundDecl
);
2897 AccessResult
CheckAllocationAccess(SourceLocation OperatorLoc
,
2898 SourceRange PlacementRange
,
2899 CXXRecordDecl
*NamingClass
,
2900 DeclAccessPair FoundDecl
);
2901 AccessResult
CheckConstructorAccess(SourceLocation Loc
,
2902 CXXConstructorDecl
*D
,
2903 const InitializedEntity
&Entity
,
2904 AccessSpecifier Access
,
2905 bool IsCopyBindingRefToTemp
= false);
2906 AccessResult
CheckDestructorAccess(SourceLocation Loc
,
2907 CXXDestructorDecl
*Dtor
,
2908 const PartialDiagnostic
&PDiag
);
2909 AccessResult
CheckDirectMemberAccess(SourceLocation Loc
,
2911 const PartialDiagnostic
&PDiag
);
2912 AccessResult
CheckMemberOperatorAccess(SourceLocation Loc
,
2915 DeclAccessPair FoundDecl
);
2916 AccessResult
CheckAddressOfMemberAccess(Expr
*OvlExpr
,
2917 DeclAccessPair FoundDecl
);
2918 AccessResult
CheckBaseClassAccess(SourceLocation AccessLoc
,
2919 QualType Base
, QualType Derived
,
2920 const CXXBasePath
&Path
,
2922 bool ForceCheck
= false,
2923 bool ForceUnprivileged
= false);
2924 void CheckLookupAccess(const LookupResult
&R
);
2926 void HandleDependentAccessCheck(const DependentDiagnostic
&DD
,
2927 const MultiLevelTemplateArgumentList
&TemplateArgs
);
2928 void PerformDependentDiagnostics(const DeclContext
*Pattern
,
2929 const MultiLevelTemplateArgumentList
&TemplateArgs
);
2931 void HandleDelayedAccessCheck(sema::DelayedDiagnostic
&DD
, Decl
*Ctx
);
2933 /// A flag to suppress access checking.
2934 bool SuppressAccessChecking
;
2936 /// \brief When true, access checking violations are treated as SFINAE
2937 /// failures rather than hard errors.
2938 bool AccessCheckingSFINAE
;
2940 void ActOnStartSuppressingAccessChecks();
2941 void ActOnStopSuppressingAccessChecks();
2943 enum AbstractDiagSelID
{
2947 AbstractVariableType
,
2952 bool RequireNonAbstractType(SourceLocation Loc
, QualType T
,
2953 const PartialDiagnostic
&PD
);
2954 void DiagnoseAbstractType(const CXXRecordDecl
*RD
);
2956 bool RequireNonAbstractType(SourceLocation Loc
, QualType T
, unsigned DiagID
,
2957 AbstractDiagSelID SelID
= AbstractNone
);
2959 //===--------------------------------------------------------------------===//
2960 // C++ Overloaded Operators [C++ 13.5]
2963 bool CheckOverloadedOperatorDeclaration(FunctionDecl
*FnDecl
);
2965 bool CheckLiteralOperatorDeclaration(FunctionDecl
*FnDecl
);
2967 //===--------------------------------------------------------------------===//
2968 // C++ Templates [C++ 14]
2970 void LookupTemplateName(LookupResult
&R
, Scope
*S
, CXXScopeSpec
&SS
,
2971 QualType ObjectType
, bool EnteringContext
,
2972 bool &MemberOfUnknownSpecialization
);
2974 TemplateNameKind
isTemplateName(Scope
*S
,
2976 bool hasTemplateKeyword
,
2977 UnqualifiedId
&Name
,
2978 ParsedType ObjectType
,
2979 bool EnteringContext
,
2980 TemplateTy
&Template
,
2981 bool &MemberOfUnknownSpecialization
);
2983 bool DiagnoseUnknownTemplateName(const IdentifierInfo
&II
,
2984 SourceLocation IILoc
,
2986 const CXXScopeSpec
*SS
,
2987 TemplateTy
&SuggestedTemplate
,
2988 TemplateNameKind
&SuggestedKind
);
2990 bool DiagnoseTemplateParameterShadow(SourceLocation Loc
, Decl
*PrevDecl
);
2991 TemplateDecl
*AdjustDeclIfTemplate(Decl
*&Decl
);
2993 Decl
*ActOnTypeParameter(Scope
*S
, bool Typename
, bool Ellipsis
,
2994 SourceLocation EllipsisLoc
,
2995 SourceLocation KeyLoc
,
2996 IdentifierInfo
*ParamName
,
2997 SourceLocation ParamNameLoc
,
2998 unsigned Depth
, unsigned Position
,
2999 SourceLocation EqualLoc
,
3000 ParsedType DefaultArg
);
3002 QualType
CheckNonTypeTemplateParameterType(QualType T
, SourceLocation Loc
);
3003 Decl
*ActOnNonTypeTemplateParameter(Scope
*S
, Declarator
&D
,
3006 SourceLocation EqualLoc
,
3008 Decl
*ActOnTemplateTemplateParameter(Scope
*S
,
3009 SourceLocation TmpLoc
,
3010 TemplateParamsTy
*Params
,
3011 SourceLocation EllipsisLoc
,
3012 IdentifierInfo
*ParamName
,
3013 SourceLocation ParamNameLoc
,
3016 SourceLocation EqualLoc
,
3017 ParsedTemplateArgument DefaultArg
);
3020 ActOnTemplateParameterList(unsigned Depth
,
3021 SourceLocation ExportLoc
,
3022 SourceLocation TemplateLoc
,
3023 SourceLocation LAngleLoc
,
3024 Decl
**Params
, unsigned NumParams
,
3025 SourceLocation RAngleLoc
);
3027 /// \brief The context in which we are checking a template parameter
3029 enum TemplateParamListContext
{
3031 TPC_FunctionTemplate
,
3032 TPC_ClassTemplateMember
,
3033 TPC_FriendFunctionTemplate
,
3034 TPC_FriendFunctionTemplateDefinition
3037 bool CheckTemplateParameterList(TemplateParameterList
*NewParams
,
3038 TemplateParameterList
*OldParams
,
3039 TemplateParamListContext TPC
);
3040 TemplateParameterList
*
3041 MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc
,
3042 const CXXScopeSpec
&SS
,
3043 TemplateParameterList
**ParamLists
,
3044 unsigned NumParamLists
,
3046 bool &IsExplicitSpecialization
,
3049 DeclResult
CheckClassTemplate(Scope
*S
, unsigned TagSpec
, TagUseKind TUK
,
3050 SourceLocation KWLoc
, CXXScopeSpec
&SS
,
3051 IdentifierInfo
*Name
, SourceLocation NameLoc
,
3052 AttributeList
*Attr
,
3053 TemplateParameterList
*TemplateParams
,
3054 AccessSpecifier AS
);
3056 void translateTemplateArguments(const ASTTemplateArgsPtr
&In
,
3057 TemplateArgumentListInfo
&Out
);
3059 QualType
CheckTemplateIdType(TemplateName Template
,
3060 SourceLocation TemplateLoc
,
3061 const TemplateArgumentListInfo
&TemplateArgs
);
3064 ActOnTemplateIdType(TemplateTy Template
, SourceLocation TemplateLoc
,
3065 SourceLocation LAngleLoc
,
3066 ASTTemplateArgsPtr TemplateArgs
,
3067 SourceLocation RAngleLoc
);
3069 TypeResult
ActOnTagTemplateIdType(CXXScopeSpec
&SS
,
3072 TypeSpecifierType TagSpec
,
3073 SourceLocation TagLoc
);
3075 ExprResult
BuildTemplateIdExpr(const CXXScopeSpec
&SS
,
3078 const TemplateArgumentListInfo
&TemplateArgs
);
3079 ExprResult
BuildQualifiedTemplateIdExpr(CXXScopeSpec
&SS
,
3080 const DeclarationNameInfo
&NameInfo
,
3081 const TemplateArgumentListInfo
&TemplateArgs
);
3083 TemplateNameKind
ActOnDependentTemplateName(Scope
*S
,
3084 SourceLocation TemplateKWLoc
,
3086 UnqualifiedId
&Name
,
3087 ParsedType ObjectType
,
3088 bool EnteringContext
,
3089 TemplateTy
&Template
);
3092 ActOnClassTemplateSpecialization(Scope
*S
, unsigned TagSpec
, TagUseKind TUK
,
3093 SourceLocation KWLoc
,
3095 TemplateTy Template
,
3096 SourceLocation TemplateNameLoc
,
3097 SourceLocation LAngleLoc
,
3098 ASTTemplateArgsPtr TemplateArgs
,
3099 SourceLocation RAngleLoc
,
3100 AttributeList
*Attr
,
3101 MultiTemplateParamsArg TemplateParameterLists
);
3103 Decl
*ActOnTemplateDeclarator(Scope
*S
,
3104 MultiTemplateParamsArg TemplateParameterLists
,
3107 Decl
*ActOnStartOfFunctionTemplateDef(Scope
*FnBodyScope
,
3108 MultiTemplateParamsArg TemplateParameterLists
,
3112 CheckSpecializationInstantiationRedecl(SourceLocation NewLoc
,
3113 TemplateSpecializationKind NewTSK
,
3114 NamedDecl
*PrevDecl
,
3115 TemplateSpecializationKind PrevTSK
,
3116 SourceLocation PrevPtOfInstantiation
,
3119 bool CheckDependentFunctionTemplateSpecialization(FunctionDecl
*FD
,
3120 const TemplateArgumentListInfo
&ExplicitTemplateArgs
,
3121 LookupResult
&Previous
);
3123 bool CheckFunctionTemplateSpecialization(FunctionDecl
*FD
,
3124 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
3125 LookupResult
&Previous
);
3126 bool CheckMemberSpecialization(NamedDecl
*Member
, LookupResult
&Previous
);
3129 ActOnExplicitInstantiation(Scope
*S
,
3130 SourceLocation ExternLoc
,
3131 SourceLocation TemplateLoc
,
3133 SourceLocation KWLoc
,
3134 const CXXScopeSpec
&SS
,
3135 TemplateTy Template
,
3136 SourceLocation TemplateNameLoc
,
3137 SourceLocation LAngleLoc
,
3138 ASTTemplateArgsPtr TemplateArgs
,
3139 SourceLocation RAngleLoc
,
3140 AttributeList
*Attr
);
3143 ActOnExplicitInstantiation(Scope
*S
,
3144 SourceLocation ExternLoc
,
3145 SourceLocation TemplateLoc
,
3147 SourceLocation KWLoc
,
3149 IdentifierInfo
*Name
,
3150 SourceLocation NameLoc
,
3151 AttributeList
*Attr
);
3153 DeclResult
ActOnExplicitInstantiation(Scope
*S
,
3154 SourceLocation ExternLoc
,
3155 SourceLocation TemplateLoc
,
3159 SubstDefaultTemplateArgumentIfAvailable(TemplateDecl
*Template
,
3160 SourceLocation TemplateLoc
,
3161 SourceLocation RAngleLoc
,
3163 llvm::SmallVectorImpl
<TemplateArgument
> &Converted
);
3165 /// \brief Specifies the context in which a particular template
3166 /// argument is being checked.
3167 enum CheckTemplateArgumentKind
{
3168 /// \brief The template argument was specified in the code or was
3169 /// instantiated with some deduced template arguments.
3172 /// \brief The template argument was deduced via template argument
3176 /// \brief The template argument was deduced from an array bound
3177 /// via template argument deduction.
3178 CTAK_DeducedFromArrayBound
3181 bool CheckTemplateArgument(NamedDecl
*Param
,
3182 const TemplateArgumentLoc
&Arg
,
3183 NamedDecl
*Template
,
3184 SourceLocation TemplateLoc
,
3185 SourceLocation RAngleLoc
,
3186 unsigned ArgumentPackIndex
,
3187 llvm::SmallVectorImpl
<TemplateArgument
> &Converted
,
3188 CheckTemplateArgumentKind CTAK
= CTAK_Specified
);
3190 bool CheckTemplateArgumentList(TemplateDecl
*Template
,
3191 SourceLocation TemplateLoc
,
3192 const TemplateArgumentListInfo
&TemplateArgs
,
3193 bool PartialTemplateArgs
,
3194 llvm::SmallVectorImpl
<TemplateArgument
> &Converted
);
3196 bool CheckTemplateTypeArgument(TemplateTypeParmDecl
*Param
,
3197 const TemplateArgumentLoc
&Arg
,
3198 llvm::SmallVectorImpl
<TemplateArgument
> &Converted
);
3200 bool CheckTemplateArgument(TemplateTypeParmDecl
*Param
,
3201 TypeSourceInfo
*Arg
);
3202 bool CheckTemplateArgumentPointerToMember(Expr
*Arg
,
3203 TemplateArgument
&Converted
);
3204 bool CheckTemplateArgument(NonTypeTemplateParmDecl
*Param
,
3205 QualType InstantiatedParamType
, Expr
*&Arg
,
3206 TemplateArgument
&Converted
,
3207 CheckTemplateArgumentKind CTAK
= CTAK_Specified
);
3208 bool CheckTemplateArgument(TemplateTemplateParmDecl
*Param
,
3209 const TemplateArgumentLoc
&Arg
);
3212 BuildExpressionFromDeclTemplateArgument(const TemplateArgument
&Arg
,
3214 SourceLocation Loc
);
3216 BuildExpressionFromIntegralTemplateArgument(const TemplateArgument
&Arg
,
3217 SourceLocation Loc
);
3219 /// \brief Enumeration describing how template parameter lists are compared
3221 enum TemplateParameterListEqualKind
{
3222 /// \brief We are matching the template parameter lists of two templates
3223 /// that might be redeclarations.
3226 /// template<typename T> struct X;
3227 /// template<typename T> struct X;
3231 /// \brief We are matching the template parameter lists of two template
3232 /// template parameters as part of matching the template parameter lists
3233 /// of two templates that might be redeclarations.
3236 /// template<template<int I> class TT> struct X;
3237 /// template<template<int Value> class Other> struct X;
3239 TPL_TemplateTemplateParmMatch
,
3241 /// \brief We are matching the template parameter lists of a template
3242 /// template argument against the template parameter lists of a template
3243 /// template parameter.
3246 /// template<template<int Value> class Metafun> struct X;
3247 /// template<int Value> struct integer_c;
3248 /// X<integer_c> xic;
3250 TPL_TemplateTemplateArgumentMatch
3253 bool TemplateParameterListsAreEqual(TemplateParameterList
*New
,
3254 TemplateParameterList
*Old
,
3256 TemplateParameterListEqualKind Kind
,
3257 SourceLocation TemplateArgLoc
3258 = SourceLocation());
3260 bool CheckTemplateDeclScope(Scope
*S
, TemplateParameterList
*TemplateParams
);
3262 /// \brief Called when the parser has parsed a C++ typename
3263 /// specifier, e.g., "typename T::type".
3265 /// \param S The scope in which this typename type occurs.
3266 /// \param TypenameLoc the location of the 'typename' keyword
3267 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3268 /// \param II the identifier we're retrieving (e.g., 'type' in the example).
3269 /// \param IdLoc the location of the identifier.
3271 ActOnTypenameType(Scope
*S
, SourceLocation TypenameLoc
,
3272 const CXXScopeSpec
&SS
, const IdentifierInfo
&II
,
3273 SourceLocation IdLoc
);
3275 /// \brief Called when the parser has parsed a C++ typename
3276 /// specifier that ends in a template-id, e.g.,
3277 /// "typename MetaFun::template apply<T1, T2>".
3279 /// \param S The scope in which this typename type occurs.
3280 /// \param TypenameLoc the location of the 'typename' keyword
3281 /// \param SS the nested-name-specifier following the typename (e.g., 'T::').
3282 /// \param TemplateLoc the location of the 'template' keyword, if any.
3283 /// \param Ty the type that the typename specifier refers to.
3285 ActOnTypenameType(Scope
*S
, SourceLocation TypenameLoc
,
3286 const CXXScopeSpec
&SS
, SourceLocation TemplateLoc
,
3289 QualType
CheckTypenameType(ElaboratedTypeKeyword Keyword
,
3290 NestedNameSpecifier
*NNS
,
3291 const IdentifierInfo
&II
,
3292 SourceLocation KeywordLoc
,
3293 SourceRange NNSRange
,
3294 SourceLocation IILoc
);
3296 TypeSourceInfo
*RebuildTypeInCurrentInstantiation(TypeSourceInfo
*T
,
3298 DeclarationName Name
);
3299 bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec
&SS
);
3301 ExprResult
RebuildExprInCurrentInstantiation(Expr
*E
);
3304 getTemplateArgumentBindingsText(const TemplateParameterList
*Params
,
3305 const TemplateArgumentList
&Args
);
3308 getTemplateArgumentBindingsText(const TemplateParameterList
*Params
,
3309 const TemplateArgument
*Args
,
3312 //===--------------------------------------------------------------------===//
3313 // C++ Variadic Templates (C++0x [temp.variadic])
3314 //===--------------------------------------------------------------------===//
3316 /// \brief The context in which an unexpanded parameter pack is
3317 /// being diagnosed.
3319 /// Note that the values of this enumeration line up with the first
3320 /// argument to the \c err_unexpanded_parameter_pack diagnostic.
3321 enum UnexpandedParameterPackContext
{
3322 /// \brief An arbitrary expression.
3323 UPPC_Expression
= 0,
3325 /// \brief The base type of a class type.
3328 /// \brief The type of an arbitrary declaration.
3329 UPPC_DeclarationType
,
3331 /// \brief The type of a data member.
3332 UPPC_DataMemberType
,
3334 /// \brief The size of a bit-field.
3337 /// \brief The expression in a static assertion.
3338 UPPC_StaticAssertExpression
,
3340 /// \brief The fixed underlying type of an enumeration.
3341 UPPC_FixedUnderlyingType
,
3343 /// \brief The enumerator value.
3344 UPPC_EnumeratorValue
,
3346 /// \brief A using declaration.
3347 UPPC_UsingDeclaration
,
3349 /// \brief A friend declaration.
3350 UPPC_FriendDeclaration
,
3352 /// \brief A declaration qualifier.
3353 UPPC_DeclarationQualifier
,
3355 /// \brief An initializer.
3358 /// \brief A default argument.
3359 UPPC_DefaultArgument
,
3361 /// \brief The type of a non-type template parameter.
3362 UPPC_NonTypeTemplateParameterType
,
3364 /// \brief The type of an exception.
3367 /// \brief Partial specialization.
3368 UPPC_PartialSpecialization
3371 /// \brief If the given type contains an unexpanded parameter pack,
3372 /// diagnose the error.
3374 /// \param Loc The source location where a diagnostc should be emitted.
3376 /// \param T The type that is being checked for unexpanded parameter
3379 /// \returns true if an error ocurred, false otherwise.
3380 bool DiagnoseUnexpandedParameterPack(SourceLocation Loc
, TypeSourceInfo
*T
,
3381 UnexpandedParameterPackContext UPPC
);
3383 /// \brief If the given expression contains an unexpanded parameter
3384 /// pack, diagnose the error.
3386 /// \param E The expression that is being checked for unexpanded
3387 /// parameter packs.
3389 /// \returns true if an error ocurred, false otherwise.
3390 bool DiagnoseUnexpandedParameterPack(Expr
*E
,
3391 UnexpandedParameterPackContext UPPC
= UPPC_Expression
);
3393 /// \brief If the given nested-name-specifier contains an unexpanded
3394 /// parameter pack, diagnose the error.
3396 /// \param SS The nested-name-specifier that is being checked for
3397 /// unexpanded parameter packs.
3399 /// \returns true if an error ocurred, false otherwise.
3400 bool DiagnoseUnexpandedParameterPack(const CXXScopeSpec
&SS
,
3401 UnexpandedParameterPackContext UPPC
);
3403 /// \brief If the given name contains an unexpanded parameter pack,
3404 /// diagnose the error.
3406 /// \param NameInfo The name (with source location information) that
3407 /// is being checked for unexpanded parameter packs.
3409 /// \returns true if an error ocurred, false otherwise.
3410 bool DiagnoseUnexpandedParameterPack(const DeclarationNameInfo
&NameInfo
,
3411 UnexpandedParameterPackContext UPPC
);
3413 /// \brief If the given template name contains an unexpanded parameter pack,
3414 /// diagnose the error.
3416 /// \param Loc The location of the template name.
3418 /// \param Template The template name that is being checked for unexpanded
3419 /// parameter packs.
3421 /// \returns true if an error ocurred, false otherwise.
3422 bool DiagnoseUnexpandedParameterPack(SourceLocation Loc
,
3423 TemplateName Template
,
3424 UnexpandedParameterPackContext UPPC
);
3426 /// \brief If the given template argument contains an unexpanded parameter
3427 /// pack, diagnose the error.
3429 /// \param Arg The template argument that is being checked for unexpanded
3430 /// parameter packs.
3432 /// \returns true if an error ocurred, false otherwise.
3433 bool DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg
,
3434 UnexpandedParameterPackContext UPPC
);
3436 /// \brief Collect the set of unexpanded parameter packs within the given
3437 /// template argument.
3439 /// \param Arg The template argument that will be traversed to find
3440 /// unexpanded parameter packs.
3441 void collectUnexpandedParameterPacks(TemplateArgument Arg
,
3442 llvm::SmallVectorImpl
<UnexpandedParameterPack
> &Unexpanded
);
3444 /// \brief Collect the set of unexpanded parameter packs within the given
3445 /// template argument.
3447 /// \param Arg The template argument that will be traversed to find
3448 /// unexpanded parameter packs.
3449 void collectUnexpandedParameterPacks(TemplateArgumentLoc Arg
,
3450 llvm::SmallVectorImpl
<UnexpandedParameterPack
> &Unexpanded
);
3452 /// \brief Collect the set of unexpanded parameter packs within the given
3455 /// \param T The type that will be traversed to find
3456 /// unexpanded parameter packs.
3457 void collectUnexpandedParameterPacks(QualType T
,
3458 llvm::SmallVectorImpl
<UnexpandedParameterPack
> &Unexpanded
);
3460 /// \brief Collect the set of unexpanded parameter packs within the given
3463 /// \param TL The type that will be traversed to find
3464 /// unexpanded parameter packs.
3465 void collectUnexpandedParameterPacks(TypeLoc TL
,
3466 llvm::SmallVectorImpl
<UnexpandedParameterPack
> &Unexpanded
);
3468 /// \brief Invoked when parsing a template argument followed by an
3469 /// ellipsis, which creates a pack expansion.
3471 /// \param Arg The template argument preceding the ellipsis, which
3472 /// may already be invalid.
3474 /// \param EllipsisLoc The location of the ellipsis.
3475 ParsedTemplateArgument
ActOnPackExpansion(const ParsedTemplateArgument
&Arg
,
3476 SourceLocation EllipsisLoc
);
3478 /// \brief Invoked when parsing a type followed by an ellipsis, which
3479 /// creates a pack expansion.
3481 /// \param Type The type preceding the ellipsis, which will become
3482 /// the pattern of the pack expansion.
3484 /// \param EllipsisLoc The location of the ellipsis.
3485 TypeResult
ActOnPackExpansion(ParsedType Type
, SourceLocation EllipsisLoc
);
3487 /// \brief Construct a pack expansion type from the pattern of the pack
3489 TypeSourceInfo
*CheckPackExpansion(TypeSourceInfo
*Pattern
,
3490 SourceLocation EllipsisLoc
,
3491 llvm::Optional
<unsigned> NumExpansions
);
3493 /// \brief Construct a pack expansion type from the pattern of the pack
3495 QualType
CheckPackExpansion(QualType Pattern
,
3496 SourceRange PatternRange
,
3497 SourceLocation EllipsisLoc
,
3498 llvm::Optional
<unsigned> NumExpansions
);
3500 /// \brief Invoked when parsing an expression followed by an ellipsis, which
3501 /// creates a pack expansion.
3503 /// \param Pattern The expression preceding the ellipsis, which will become
3504 /// the pattern of the pack expansion.
3506 /// \param EllipsisLoc The location of the ellipsis.
3507 ExprResult
ActOnPackExpansion(Expr
*Pattern
, SourceLocation EllipsisLoc
);
3509 /// \brief Invoked when parsing an expression followed by an ellipsis, which
3510 /// creates a pack expansion.
3512 /// \param Pattern The expression preceding the ellipsis, which will become
3513 /// the pattern of the pack expansion.
3515 /// \param EllipsisLoc The location of the ellipsis.
3516 ExprResult
CheckPackExpansion(Expr
*Pattern
, SourceLocation EllipsisLoc
,
3517 llvm::Optional
<unsigned> NumExpansions
);
3519 /// \brief Determine whether we could expand a pack expansion with the
3520 /// given set of parameter packs into separate arguments by repeatedly
3521 /// transforming the pattern.
3523 /// \param EllipsisLoc The location of the ellipsis that identifies the
3526 /// \param PatternRange The source range that covers the entire pattern of
3527 /// the pack expansion.
3529 /// \param Unexpanded The set of unexpanded parameter packs within the
3532 /// \param NumUnexpanded The number of unexpanded parameter packs in
3535 /// \param ShouldExpand Will be set to \c true if the transformer should
3536 /// expand the corresponding pack expansions into separate arguments. When
3537 /// set, \c NumExpansions must also be set.
3539 /// \param RetainExpansion Whether the caller should add an unexpanded
3540 /// pack expansion after all of the expanded arguments. This is used
3541 /// when extending explicitly-specified template argument packs per
3542 /// C++0x [temp.arg.explicit]p9.
3544 /// \param NumExpansions The number of separate arguments that will be in
3545 /// the expanded form of the corresponding pack expansion. This is both an
3546 /// input and an output parameter, which can be set by the caller if the
3547 /// number of expansions is known a priori (e.g., due to a prior substitution)
3548 /// and will be set by the callee when the number of expansions is known.
3549 /// The callee must set this value when \c ShouldExpand is \c true; it may
3550 /// set this value in other cases.
3552 /// \returns true if an error occurred (e.g., because the parameter packs
3553 /// are to be instantiated with arguments of different lengths), false
3554 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
3556 bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc
,
3557 SourceRange PatternRange
,
3558 const UnexpandedParameterPack
*Unexpanded
,
3559 unsigned NumUnexpanded
,
3560 const MultiLevelTemplateArgumentList
&TemplateArgs
,
3562 bool &RetainExpansion
,
3563 llvm::Optional
<unsigned> &NumExpansions
);
3565 /// \brief Determine the number of arguments in the given pack expansion
3568 /// This routine already assumes that the pack expansion type can be
3569 /// expanded and that the number of arguments in the expansion is
3570 /// consistent across all of the unexpanded parameter packs in its pattern.
3571 unsigned getNumArgumentsInExpansion(QualType T
,
3572 const MultiLevelTemplateArgumentList
&TemplateArgs
);
3574 /// \brief Determine whether the given declarator contains any unexpanded
3575 /// parameter packs.
3577 /// This routine is used by the parser to disambiguate function declarators
3578 /// with an ellipsis prior to the ')', e.g.,
3584 /// To determine whether we have an (unnamed) function parameter pack or
3585 /// a variadic function.
3587 /// \returns true if the declarator contains any unexpanded parameter packs,
3588 /// false otherwise.
3589 bool containsUnexpandedParameterPacks(Declarator
&D
);
3591 //===--------------------------------------------------------------------===//
3592 // C++ Template Argument Deduction (C++ [temp.deduct])
3593 //===--------------------------------------------------------------------===//
3595 /// \brief Describes the result of template argument deduction.
3597 /// The TemplateDeductionResult enumeration describes the result of
3598 /// template argument deduction, as returned from
3599 /// DeduceTemplateArguments(). The separate TemplateDeductionInfo
3600 /// structure provides additional information about the results of
3601 /// template argument deduction, e.g., the deduced template argument
3602 /// list (if successful) or the specific template parameters or
3603 /// deduced arguments that were involved in the failure.
3604 enum TemplateDeductionResult
{
3605 /// \brief Template argument deduction was successful.
3607 /// \brief Template argument deduction exceeded the maximum template
3608 /// instantiation depth (which has already been diagnosed).
3609 TDK_InstantiationDepth
,
3610 /// \brief Template argument deduction did not deduce a value
3611 /// for every template parameter.
3613 /// \brief Template argument deduction produced inconsistent
3614 /// deduced values for the given template parameter.
3616 /// \brief Template argument deduction failed due to inconsistent
3617 /// cv-qualifiers on a template parameter type that would
3618 /// otherwise be deduced, e.g., we tried to deduce T in "const T"
3619 /// but were given a non-const "X".
3621 /// \brief Substitution of the deduced template argument values
3622 /// resulted in an error.
3623 TDK_SubstitutionFailure
,
3624 /// \brief Substitution of the deduced template argument values
3625 /// into a non-deduced context produced a type or value that
3626 /// produces a type that does not match the original template
3627 /// arguments provided.
3628 TDK_NonDeducedMismatch
,
3629 /// \brief When performing template argument deduction for a function
3630 /// template, there were too many call arguments.
3631 TDK_TooManyArguments
,
3632 /// \brief When performing template argument deduction for a function
3633 /// template, there were too few call arguments.
3634 TDK_TooFewArguments
,
3635 /// \brief The explicitly-specified template arguments were not valid
3636 /// template arguments for the given template.
3637 TDK_InvalidExplicitArguments
,
3638 /// \brief The arguments included an overloaded function name that could
3639 /// not be resolved to a suitable function.
3640 TDK_FailedOverloadResolution
3643 TemplateDeductionResult
3644 DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl
*Partial
,
3645 const TemplateArgumentList
&TemplateArgs
,
3646 sema::TemplateDeductionInfo
&Info
);
3648 TemplateDeductionResult
3649 SubstituteExplicitTemplateArguments(FunctionTemplateDecl
*FunctionTemplate
,
3650 const TemplateArgumentListInfo
&ExplicitTemplateArgs
,
3651 llvm::SmallVectorImpl
<DeducedTemplateArgument
> &Deduced
,
3652 llvm::SmallVectorImpl
<QualType
> &ParamTypes
,
3653 QualType
*FunctionType
,
3654 sema::TemplateDeductionInfo
&Info
);
3656 TemplateDeductionResult
3657 FinishTemplateArgumentDeduction(FunctionTemplateDecl
*FunctionTemplate
,
3658 llvm::SmallVectorImpl
<DeducedTemplateArgument
> &Deduced
,
3659 unsigned NumExplicitlySpecified
,
3660 FunctionDecl
*&Specialization
,
3661 sema::TemplateDeductionInfo
&Info
);
3663 TemplateDeductionResult
3664 DeduceTemplateArguments(FunctionTemplateDecl
*FunctionTemplate
,
3665 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
3666 Expr
**Args
, unsigned NumArgs
,
3667 FunctionDecl
*&Specialization
,
3668 sema::TemplateDeductionInfo
&Info
);
3670 TemplateDeductionResult
3671 DeduceTemplateArguments(FunctionTemplateDecl
*FunctionTemplate
,
3672 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
3673 QualType ArgFunctionType
,
3674 FunctionDecl
*&Specialization
,
3675 sema::TemplateDeductionInfo
&Info
);
3677 TemplateDeductionResult
3678 DeduceTemplateArguments(FunctionTemplateDecl
*FunctionTemplate
,
3680 CXXConversionDecl
*&Specialization
,
3681 sema::TemplateDeductionInfo
&Info
);
3683 TemplateDeductionResult
3684 DeduceTemplateArguments(FunctionTemplateDecl
*FunctionTemplate
,
3685 const TemplateArgumentListInfo
*ExplicitTemplateArgs
,
3686 FunctionDecl
*&Specialization
,
3687 sema::TemplateDeductionInfo
&Info
);
3689 FunctionTemplateDecl
*getMoreSpecializedTemplate(FunctionTemplateDecl
*FT1
,
3690 FunctionTemplateDecl
*FT2
,
3692 TemplatePartialOrderingContext TPOC
,
3693 unsigned NumCallArguments
);
3694 UnresolvedSetIterator
getMostSpecialized(UnresolvedSetIterator SBegin
,
3695 UnresolvedSetIterator SEnd
,
3696 TemplatePartialOrderingContext TPOC
,
3697 unsigned NumCallArguments
,
3699 const PartialDiagnostic
&NoneDiag
,
3700 const PartialDiagnostic
&AmbigDiag
,
3701 const PartialDiagnostic
&CandidateDiag
);
3703 ClassTemplatePartialSpecializationDecl
*
3704 getMoreSpecializedPartialSpecialization(
3705 ClassTemplatePartialSpecializationDecl
*PS1
,
3706 ClassTemplatePartialSpecializationDecl
*PS2
,
3707 SourceLocation Loc
);
3709 void MarkUsedTemplateParameters(const TemplateArgumentList
&TemplateArgs
,
3712 llvm::SmallVectorImpl
<bool> &Used
);
3713 void MarkDeducedTemplateParameters(FunctionTemplateDecl
*FunctionTemplate
,
3714 llvm::SmallVectorImpl
<bool> &Deduced
);
3716 //===--------------------------------------------------------------------===//
3717 // C++ Template Instantiation
3720 MultiLevelTemplateArgumentList
getTemplateInstantiationArgs(NamedDecl
*D
,
3721 const TemplateArgumentList
*Innermost
= 0,
3722 bool RelativeToPrimary
= false,
3723 const FunctionDecl
*Pattern
= 0);
3725 /// \brief A template instantiation that is currently in progress.
3726 struct ActiveTemplateInstantiation
{
3727 /// \brief The kind of template instantiation we are performing
3728 enum InstantiationKind
{
3729 /// We are instantiating a template declaration. The entity is
3730 /// the declaration we're instantiating (e.g., a CXXRecordDecl).
3731 TemplateInstantiation
,
3733 /// We are instantiating a default argument for a template
3734 /// parameter. The Entity is the template, and
3735 /// TemplateArgs/NumTemplateArguments provides the template
3736 /// arguments as specified.
3737 /// FIXME: Use a TemplateArgumentList
3738 DefaultTemplateArgumentInstantiation
,
3740 /// We are instantiating a default argument for a function.
3741 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs
3742 /// provides the template arguments as specified.
3743 DefaultFunctionArgumentInstantiation
,
3745 /// We are substituting explicit template arguments provided for
3746 /// a function template. The entity is a FunctionTemplateDecl.
3747 ExplicitTemplateArgumentSubstitution
,
3749 /// We are substituting template argument determined as part of
3750 /// template argument deduction for either a class template
3751 /// partial specialization or a function template. The
3752 /// Entity is either a ClassTemplatePartialSpecializationDecl or
3753 /// a FunctionTemplateDecl.
3754 DeducedTemplateArgumentSubstitution
,
3756 /// We are substituting prior template arguments into a new
3757 /// template parameter. The template parameter itself is either a
3758 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl.
3759 PriorTemplateArgumentSubstitution
,
3761 /// We are checking the validity of a default template argument that
3762 /// has been used when naming a template-id.
3763 DefaultTemplateArgumentChecking
3766 /// \brief The point of instantiation within the source code.
3767 SourceLocation PointOfInstantiation
;
3769 /// \brief The template (or partial specialization) in which we are
3770 /// performing the instantiation, for substitutions of prior template
3772 NamedDecl
*Template
;
3774 /// \brief The entity that is being instantiated.
3777 /// \brief The list of template arguments we are substituting, if they
3778 /// are not part of the entity.
3779 const TemplateArgument
*TemplateArgs
;
3781 /// \brief The number of template arguments in TemplateArgs.
3782 unsigned NumTemplateArgs
;
3784 /// \brief The template deduction info object associated with the
3785 /// substitution or checking of explicit or deduced template arguments.
3786 sema::TemplateDeductionInfo
*DeductionInfo
;
3788 /// \brief The source range that covers the construct that cause
3789 /// the instantiation, e.g., the template-id that causes a class
3790 /// template instantiation.
3791 SourceRange InstantiationRange
;
3793 ActiveTemplateInstantiation()
3794 : Kind(TemplateInstantiation
), Template(0), Entity(0), TemplateArgs(0),
3795 NumTemplateArgs(0), DeductionInfo(0) {}
3797 /// \brief Determines whether this template is an actual instantiation
3798 /// that should be counted toward the maximum instantiation depth.
3799 bool isInstantiationRecord() const;
3801 friend bool operator==(const ActiveTemplateInstantiation
&X
,
3802 const ActiveTemplateInstantiation
&Y
) {
3803 if (X
.Kind
!= Y
.Kind
)
3806 if (X
.Entity
!= Y
.Entity
)
3810 case TemplateInstantiation
:
3813 case PriorTemplateArgumentSubstitution
:
3814 case DefaultTemplateArgumentChecking
:
3815 if (X
.Template
!= Y
.Template
)
3820 case DefaultTemplateArgumentInstantiation
:
3821 case ExplicitTemplateArgumentSubstitution
:
3822 case DeducedTemplateArgumentSubstitution
:
3823 case DefaultFunctionArgumentInstantiation
:
3824 return X
.TemplateArgs
== Y
.TemplateArgs
;
3831 friend bool operator!=(const ActiveTemplateInstantiation
&X
,
3832 const ActiveTemplateInstantiation
&Y
) {
3837 /// \brief List of active template instantiations.
3839 /// This vector is treated as a stack. As one template instantiation
3840 /// requires another template instantiation, additional
3841 /// instantiations are pushed onto the stack up to a
3842 /// user-configurable limit LangOptions::InstantiationDepth.
3843 llvm::SmallVector
<ActiveTemplateInstantiation
, 16>
3844 ActiveTemplateInstantiations
;
3846 /// \brief Whether we are in a SFINAE context that is not associated with
3847 /// template instantiation.
3849 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside
3850 /// of a template instantiation or template argument deduction.
3851 bool InNonInstantiationSFINAEContext
;
3853 /// \brief The number of ActiveTemplateInstantiation entries in
3854 /// \c ActiveTemplateInstantiations that are not actual instantiations and,
3855 /// therefore, should not be counted as part of the instantiation depth.
3856 unsigned NonInstantiationEntries
;
3858 /// \brief The last template from which a template instantiation
3859 /// error or warning was produced.
3861 /// This value is used to suppress printing of redundant template
3862 /// instantiation backtraces when there are multiple errors in the
3863 /// same instantiation. FIXME: Does this belong in Sema? It's tough
3864 /// to implement it anywhere else.
3865 ActiveTemplateInstantiation LastTemplateInstantiationErrorContext
;
3867 /// \brief The current index into pack expansion arguments that will be
3868 /// used for substitution of parameter packs.
3870 /// The pack expansion index will be -1 to indicate that parameter packs
3871 /// should be instantiated as themselves. Otherwise, the index specifies
3872 /// which argument within the parameter pack will be used for substitution.
3873 int ArgumentPackSubstitutionIndex
;
3875 /// \brief RAII object used to change the argument pack substitution index
3876 /// within a \c Sema object.
3878 /// See \c ArgumentPackSubstitutionIndex for more information.
3879 class ArgumentPackSubstitutionIndexRAII
{
3881 int OldSubstitutionIndex
;
3884 ArgumentPackSubstitutionIndexRAII(Sema
&Self
, int NewSubstitutionIndex
)
3885 : Self(Self
), OldSubstitutionIndex(Self
.ArgumentPackSubstitutionIndex
) {
3886 Self
.ArgumentPackSubstitutionIndex
= NewSubstitutionIndex
;
3889 ~ArgumentPackSubstitutionIndexRAII() {
3890 Self
.ArgumentPackSubstitutionIndex
= OldSubstitutionIndex
;
3894 friend class ArgumentPackSubstitutionRAII
;
3896 /// \brief The stack of calls expression undergoing template instantiation.
3898 /// The top of this stack is used by a fixit instantiating unresolved
3899 /// function calls to fix the AST to match the textual change it prints.
3900 llvm::SmallVector
<CallExpr
*, 8> CallsUndergoingInstantiation
;
3902 /// \brief For each declaration that involved template argument deduction, the
3903 /// set of diagnostics that were suppressed during that template argument
3906 /// FIXME: Serialize this structure to the AST file.
3907 llvm::DenseMap
<Decl
*, llvm::SmallVector
<PartialDiagnosticAt
, 1> >
3908 SuppressedDiagnostics
;
3910 /// \brief A stack object to be created when performing template
3913 /// Construction of an object of type \c InstantiatingTemplate
3914 /// pushes the current instantiation onto the stack of active
3915 /// instantiations. If the size of this stack exceeds the maximum
3916 /// number of recursive template instantiations, construction
3917 /// produces an error and evaluates true.
3919 /// Destruction of this object will pop the named instantiation off
3921 struct InstantiatingTemplate
{
3922 /// \brief Note that we are instantiating a class template,
3923 /// function template, or a member thereof.
3924 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3926 SourceRange InstantiationRange
= SourceRange());
3928 /// \brief Note that we are instantiating a default argument in a
3930 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3931 TemplateDecl
*Template
,
3932 const TemplateArgument
*TemplateArgs
,
3933 unsigned NumTemplateArgs
,
3934 SourceRange InstantiationRange
= SourceRange());
3936 /// \brief Note that we are instantiating a default argument in a
3938 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3939 FunctionTemplateDecl
*FunctionTemplate
,
3940 const TemplateArgument
*TemplateArgs
,
3941 unsigned NumTemplateArgs
,
3942 ActiveTemplateInstantiation::InstantiationKind Kind
,
3943 sema::TemplateDeductionInfo
&DeductionInfo
,
3944 SourceRange InstantiationRange
= SourceRange());
3946 /// \brief Note that we are instantiating as part of template
3947 /// argument deduction for a class template partial
3949 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3950 ClassTemplatePartialSpecializationDecl
*PartialSpec
,
3951 const TemplateArgument
*TemplateArgs
,
3952 unsigned NumTemplateArgs
,
3953 sema::TemplateDeductionInfo
&DeductionInfo
,
3954 SourceRange InstantiationRange
= SourceRange());
3956 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3958 const TemplateArgument
*TemplateArgs
,
3959 unsigned NumTemplateArgs
,
3960 SourceRange InstantiationRange
= SourceRange());
3962 /// \brief Note that we are substituting prior template arguments into a
3963 /// non-type or template template parameter.
3964 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3965 NamedDecl
*Template
,
3966 NonTypeTemplateParmDecl
*Param
,
3967 const TemplateArgument
*TemplateArgs
,
3968 unsigned NumTemplateArgs
,
3969 SourceRange InstantiationRange
);
3971 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3972 NamedDecl
*Template
,
3973 TemplateTemplateParmDecl
*Param
,
3974 const TemplateArgument
*TemplateArgs
,
3975 unsigned NumTemplateArgs
,
3976 SourceRange InstantiationRange
);
3978 /// \brief Note that we are checking the default template argument
3979 /// against the template parameter for a given template-id.
3980 InstantiatingTemplate(Sema
&SemaRef
, SourceLocation PointOfInstantiation
,
3981 TemplateDecl
*Template
,
3983 const TemplateArgument
*TemplateArgs
,
3984 unsigned NumTemplateArgs
,
3985 SourceRange InstantiationRange
);
3988 /// \brief Note that we have finished instantiating this template.
3991 ~InstantiatingTemplate() { Clear(); }
3993 /// \brief Determines whether we have exceeded the maximum
3994 /// recursive template instantiations.
3995 operator bool() const { return Invalid
; }
4000 bool SavedInNonInstantiationSFINAEContext
;
4001 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation
,
4002 SourceRange InstantiationRange
);
4004 InstantiatingTemplate(const InstantiatingTemplate
&); // not implemented
4006 InstantiatingTemplate
&
4007 operator=(const InstantiatingTemplate
&); // not implemented
4010 void PrintInstantiationStack();
4012 /// \brief Determines whether we are currently in a context where
4013 /// template argument substitution failures are not considered
4016 /// \returns An empty \c llvm::Optional if we're not in a SFINAE context.
4017 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest
4018 /// template-deduction context object, which can be used to capture
4019 /// diagnostics that will be suppressed.
4020 llvm::Optional
<sema::TemplateDeductionInfo
*> isSFINAEContext() const;
4022 /// \brief RAII class used to determine whether SFINAE has
4023 /// trapped any errors that occur during template argument
4027 unsigned PrevSFINAEErrors
;
4028 bool PrevInNonInstantiationSFINAEContext
;
4029 bool PrevAccessCheckingSFINAE
;
4032 explicit SFINAETrap(Sema
&SemaRef
, bool AccessCheckingSFINAE
= false)
4033 : SemaRef(SemaRef
), PrevSFINAEErrors(SemaRef
.NumSFINAEErrors
),
4034 PrevInNonInstantiationSFINAEContext(
4035 SemaRef
.InNonInstantiationSFINAEContext
),
4036 PrevAccessCheckingSFINAE(SemaRef
.AccessCheckingSFINAE
)
4038 if (!SemaRef
.isSFINAEContext())
4039 SemaRef
.InNonInstantiationSFINAEContext
= true;
4040 SemaRef
.AccessCheckingSFINAE
= AccessCheckingSFINAE
;
4044 SemaRef
.NumSFINAEErrors
= PrevSFINAEErrors
;
4045 SemaRef
.InNonInstantiationSFINAEContext
4046 = PrevInNonInstantiationSFINAEContext
;
4047 SemaRef
.AccessCheckingSFINAE
= PrevAccessCheckingSFINAE
;
4050 /// \brief Determine whether any SFINAE errors have been trapped.
4051 bool hasErrorOccurred() const {
4052 return SemaRef
.NumSFINAEErrors
> PrevSFINAEErrors
;
4056 /// \brief The current instantiation scope used to store local
4058 LocalInstantiationScope
*CurrentInstantiationScope
;
4060 /// \brief The number of typos corrected by CorrectTypo.
4061 unsigned TyposCorrected
;
4063 typedef llvm::DenseMap
<IdentifierInfo
*, std::pair
<llvm::StringRef
, bool> >
4064 UnqualifiedTyposCorrectedMap
;
4066 /// \brief A cache containing the results of typo correction for unqualified
4069 /// The string is the string that we corrected to (which may be empty, if
4070 /// there was no correction), while the boolean will be true when the
4071 /// string represents a keyword.
4072 UnqualifiedTyposCorrectedMap UnqualifiedTyposCorrected
;
4074 /// \brief Worker object for performing CFG-based warnings.
4075 sema::AnalysisBasedWarnings AnalysisWarnings
;
4077 /// \brief An entity for which implicit template instantiation is required.
4079 /// The source location associated with the declaration is the first place in
4080 /// the source code where the declaration was "used". It is not necessarily
4081 /// the point of instantiation (which will be either before or after the
4082 /// namespace-scope declaration that triggered this implicit instantiation),
4083 /// However, it is the location that diagnostics should generally refer to,
4084 /// because users will need to know what code triggered the instantiation.
4085 typedef std::pair
<ValueDecl
*, SourceLocation
> PendingImplicitInstantiation
;
4087 /// \brief The queue of implicit template instantiations that are required
4088 /// but have not yet been performed.
4089 std::deque
<PendingImplicitInstantiation
> PendingInstantiations
;
4091 /// \brief The queue of implicit template instantiations that are required
4092 /// and must be performed within the current local scope.
4094 /// This queue is only used for member functions of local classes in
4095 /// templates, which must be instantiated in the same scope as their
4096 /// enclosing function, so that they can reference function-local
4097 /// types, static variables, enumerators, etc.
4098 std::deque
<PendingImplicitInstantiation
> PendingLocalImplicitInstantiations
;
4100 void PerformPendingInstantiations(bool LocalOnly
= false);
4102 TypeSourceInfo
*SubstType(TypeSourceInfo
*T
,
4103 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4104 SourceLocation Loc
, DeclarationName Entity
);
4106 QualType
SubstType(QualType T
,
4107 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4108 SourceLocation Loc
, DeclarationName Entity
);
4110 TypeSourceInfo
*SubstType(TypeLoc TL
,
4111 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4112 SourceLocation Loc
, DeclarationName Entity
);
4114 TypeSourceInfo
*SubstFunctionDeclType(TypeSourceInfo
*T
,
4115 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4117 DeclarationName Entity
);
4118 ParmVarDecl
*SubstParmVarDecl(ParmVarDecl
*D
,
4119 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4120 llvm::Optional
<unsigned> NumExpansions
);
4121 bool SubstParmTypes(SourceLocation Loc
,
4122 ParmVarDecl
**Params
, unsigned NumParams
,
4123 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4124 llvm::SmallVectorImpl
<QualType
> &ParamTypes
,
4125 llvm::SmallVectorImpl
<ParmVarDecl
*> *OutParams
= 0);
4126 ExprResult
SubstExpr(Expr
*E
,
4127 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4129 /// \brief Substitute the given template arguments into a list of
4130 /// expressions, expanding pack expansions if required.
4132 /// \param Exprs The list of expressions to substitute into.
4134 /// \param NumExprs The number of expressions in \p Exprs.
4136 /// \param IsCall Whether this is some form of call, in which case
4137 /// default arguments will be dropped.
4139 /// \param TemplateArgs The set of template arguments to substitute.
4141 /// \param Outputs Will receive all of the substituted arguments.
4143 /// \returns true if an error occurred, false otherwise.
4144 bool SubstExprs(Expr
**Exprs
, unsigned NumExprs
, bool IsCall
,
4145 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4146 llvm::SmallVectorImpl
<Expr
*> &Outputs
);
4148 StmtResult
SubstStmt(Stmt
*S
,
4149 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4151 Decl
*SubstDecl(Decl
*D
, DeclContext
*Owner
,
4152 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4155 SubstBaseSpecifiers(CXXRecordDecl
*Instantiation
,
4156 CXXRecordDecl
*Pattern
,
4157 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4160 InstantiateClass(SourceLocation PointOfInstantiation
,
4161 CXXRecordDecl
*Instantiation
, CXXRecordDecl
*Pattern
,
4162 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4163 TemplateSpecializationKind TSK
,
4164 bool Complain
= true);
4166 void InstantiateAttrs(const MultiLevelTemplateArgumentList
&TemplateArgs
,
4167 Decl
*Pattern
, Decl
*Inst
);
4170 InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation
,
4171 ClassTemplateSpecializationDecl
*ClassTemplateSpec
,
4172 TemplateSpecializationKind TSK
,
4173 bool Complain
= true);
4175 void InstantiateClassMembers(SourceLocation PointOfInstantiation
,
4176 CXXRecordDecl
*Instantiation
,
4177 const MultiLevelTemplateArgumentList
&TemplateArgs
,
4178 TemplateSpecializationKind TSK
);
4180 void InstantiateClassTemplateSpecializationMembers(
4181 SourceLocation PointOfInstantiation
,
4182 ClassTemplateSpecializationDecl
*ClassTemplateSpec
,
4183 TemplateSpecializationKind TSK
);
4185 NestedNameSpecifier
*
4186 SubstNestedNameSpecifier(NestedNameSpecifier
*NNS
,
4188 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4190 SubstDeclarationNameInfo(const DeclarationNameInfo
&NameInfo
,
4191 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4193 SubstTemplateName(TemplateName Name
, SourceLocation Loc
,
4194 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4195 bool Subst(const TemplateArgumentLoc
*Args
, unsigned NumArgs
,
4196 TemplateArgumentListInfo
&Result
,
4197 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4199 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation
,
4200 FunctionDecl
*Function
,
4201 bool Recursive
= false,
4202 bool DefinitionRequired
= false);
4203 void InstantiateStaticDataMemberDefinition(
4204 SourceLocation PointOfInstantiation
,
4206 bool Recursive
= false,
4207 bool DefinitionRequired
= false);
4209 void InstantiateMemInitializers(CXXConstructorDecl
*New
,
4210 const CXXConstructorDecl
*Tmpl
,
4211 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4213 NamedDecl
*FindInstantiatedDecl(SourceLocation Loc
, NamedDecl
*D
,
4214 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4215 DeclContext
*FindInstantiatedContext(SourceLocation Loc
, DeclContext
*DC
,
4216 const MultiLevelTemplateArgumentList
&TemplateArgs
);
4218 // Objective-C declarations.
4219 Decl
*ActOnStartClassInterface(SourceLocation AtInterfaceLoc
,
4220 IdentifierInfo
*ClassName
,
4221 SourceLocation ClassLoc
,
4222 IdentifierInfo
*SuperName
,
4223 SourceLocation SuperLoc
,
4224 Decl
* const *ProtoRefs
,
4225 unsigned NumProtoRefs
,
4226 const SourceLocation
*ProtoLocs
,
4227 SourceLocation EndProtoLoc
,
4228 AttributeList
*AttrList
);
4230 Decl
*ActOnCompatiblityAlias(
4231 SourceLocation AtCompatibilityAliasLoc
,
4232 IdentifierInfo
*AliasName
, SourceLocation AliasLocation
,
4233 IdentifierInfo
*ClassName
, SourceLocation ClassLocation
);
4235 void CheckForwardProtocolDeclarationForCircularDependency(
4236 IdentifierInfo
*PName
,
4237 SourceLocation
&PLoc
, SourceLocation PrevLoc
,
4238 const ObjCList
<ObjCProtocolDecl
> &PList
);
4240 Decl
*ActOnStartProtocolInterface(
4241 SourceLocation AtProtoInterfaceLoc
,
4242 IdentifierInfo
*ProtocolName
, SourceLocation ProtocolLoc
,
4243 Decl
* const *ProtoRefNames
, unsigned NumProtoRefs
,
4244 const SourceLocation
*ProtoLocs
,
4245 SourceLocation EndProtoLoc
,
4246 AttributeList
*AttrList
);
4248 Decl
*ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc
,
4249 IdentifierInfo
*ClassName
,
4250 SourceLocation ClassLoc
,
4251 IdentifierInfo
*CategoryName
,
4252 SourceLocation CategoryLoc
,
4253 Decl
* const *ProtoRefs
,
4254 unsigned NumProtoRefs
,
4255 const SourceLocation
*ProtoLocs
,
4256 SourceLocation EndProtoLoc
);
4258 Decl
*ActOnStartClassImplementation(
4259 SourceLocation AtClassImplLoc
,
4260 IdentifierInfo
*ClassName
, SourceLocation ClassLoc
,
4261 IdentifierInfo
*SuperClassname
,
4262 SourceLocation SuperClassLoc
);
4264 Decl
*ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc
,
4265 IdentifierInfo
*ClassName
,
4266 SourceLocation ClassLoc
,
4267 IdentifierInfo
*CatName
,
4268 SourceLocation CatLoc
);
4270 Decl
*ActOnForwardClassDeclaration(SourceLocation Loc
,
4271 IdentifierInfo
**IdentList
,
4272 SourceLocation
*IdentLocs
,
4275 Decl
*ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc
,
4276 const IdentifierLocPair
*IdentList
,
4278 AttributeList
*attrList
);
4280 void FindProtocolDeclaration(bool WarnOnDeclarations
,
4281 const IdentifierLocPair
*ProtocolId
,
4282 unsigned NumProtocols
,
4283 llvm::SmallVectorImpl
<Decl
*> &Protocols
);
4285 /// Ensure attributes are consistent with type.
4286 /// \param [in, out] Attributes The attributes to check; they will
4287 /// be modified to be consistent with \arg PropertyTy.
4288 void CheckObjCPropertyAttributes(Decl
*PropertyPtrTy
,
4290 unsigned &Attributes
);
4292 /// Process the specified property declaration and create decls for the
4293 /// setters and getters as needed.
4294 /// \param property The property declaration being processed
4295 /// \param DC The semantic container for the property
4296 /// \param redeclaredProperty Declaration for property if redeclared
4297 /// in class extension.
4298 /// \param lexicalDC Container for redeclaredProperty.
4299 void ProcessPropertyDecl(ObjCPropertyDecl
*property
,
4300 ObjCContainerDecl
*DC
,
4301 ObjCPropertyDecl
*redeclaredProperty
= 0,
4302 ObjCContainerDecl
*lexicalDC
= 0);
4304 void DiagnosePropertyMismatch(ObjCPropertyDecl
*Property
,
4305 ObjCPropertyDecl
*SuperProperty
,
4306 const IdentifierInfo
*Name
);
4307 void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl
*IDecl
);
4309 void CompareMethodParamsInBaseAndSuper(Decl
*IDecl
,
4310 ObjCMethodDecl
*MethodDecl
,
4313 void CompareProperties(Decl
*CDecl
, Decl
*MergeProtocols
);
4315 void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl
*CAT
,
4316 ObjCInterfaceDecl
*ID
);
4318 void MatchOneProtocolPropertiesInClass(Decl
*CDecl
,
4319 ObjCProtocolDecl
*PDecl
);
4321 void ActOnAtEnd(Scope
*S
, SourceRange AtEnd
, Decl
*classDecl
,
4322 Decl
**allMethods
= 0, unsigned allNum
= 0,
4323 Decl
**allProperties
= 0, unsigned pNum
= 0,
4324 DeclGroupPtrTy
*allTUVars
= 0, unsigned tuvNum
= 0);
4326 Decl
*ActOnProperty(Scope
*S
, SourceLocation AtLoc
,
4327 FieldDeclarator
&FD
, ObjCDeclSpec
&ODS
,
4328 Selector GetterSel
, Selector SetterSel
,
4329 Decl
*ClassCategory
,
4330 bool *OverridingProperty
,
4331 tok::ObjCKeywordKind MethodImplKind
,
4332 DeclContext
*lexicalDC
= 0);
4334 Decl
*ActOnPropertyImplDecl(Scope
*S
,
4335 SourceLocation AtLoc
,
4336 SourceLocation PropertyLoc
,
4337 bool ImplKind
,Decl
*ClassImplDecl
,
4338 IdentifierInfo
*PropertyId
,
4339 IdentifierInfo
*PropertyIvar
,
4340 SourceLocation PropertyIvarLoc
);
4342 struct ObjCArgInfo
{
4343 IdentifierInfo
*Name
;
4344 SourceLocation NameLoc
;
4345 // The Type is null if no type was specified, and the DeclSpec is invalid
4348 ObjCDeclSpec DeclSpec
;
4350 /// ArgAttrs - Attribute list for this argument.
4351 AttributeList
*ArgAttrs
;
4354 Decl
*ActOnMethodDeclaration(
4356 SourceLocation BeginLoc
, // location of the + or -.
4357 SourceLocation EndLoc
, // location of the ; or {.
4358 tok::TokenKind MethodType
,
4359 Decl
*ClassDecl
, ObjCDeclSpec
&ReturnQT
, ParsedType ReturnType
,
4361 // optional arguments. The number of types/arguments is obtained
4362 // from the Sel.getNumArgs().
4363 ObjCArgInfo
*ArgInfo
,
4364 DeclaratorChunk::ParamInfo
*CParamInfo
, unsigned CNumArgs
, // c-style args
4365 AttributeList
*AttrList
, tok::ObjCKeywordKind MethodImplKind
,
4366 bool isVariadic
= false);
4368 // Helper method for ActOnClassMethod/ActOnInstanceMethod.
4369 // Will search "local" class/category implementations for a method decl.
4370 // Will also search in class's root looking for instance method.
4371 // Returns 0 if no method is found.
4372 ObjCMethodDecl
*LookupPrivateClassMethod(Selector Sel
,
4373 ObjCInterfaceDecl
*CDecl
);
4374 ObjCMethodDecl
*LookupPrivateInstanceMethod(Selector Sel
,
4375 ObjCInterfaceDecl
*ClassDecl
);
4378 HandleExprPropertyRefExpr(const ObjCObjectPointerType
*OPT
,
4380 DeclarationName MemberName
,
4381 SourceLocation MemberLoc
,
4382 SourceLocation SuperLoc
, QualType SuperType
,
4386 ActOnClassPropertyRefExpr(IdentifierInfo
&receiverName
,
4387 IdentifierInfo
&propertyName
,
4388 SourceLocation receiverNameLoc
,
4389 SourceLocation propertyNameLoc
);
4391 ObjCMethodDecl
*tryCaptureObjCSelf();
4393 /// \brief Describes the kind of message expression indicated by a message
4394 /// send that starts with an identifier.
4395 enum ObjCMessageKind
{
4396 /// \brief The message is sent to 'super'.
4398 /// \brief The message is an instance message.
4399 ObjCInstanceMessage
,
4400 /// \brief The message is a class message, and the identifier is a type
4405 ObjCMessageKind
getObjCMessageKind(Scope
*S
,
4406 IdentifierInfo
*Name
,
4407 SourceLocation NameLoc
,
4409 bool HasTrailingDot
,
4410 ParsedType
&ReceiverType
);
4412 ExprResult
ActOnSuperMessage(Scope
*S
, SourceLocation SuperLoc
,
4414 SourceLocation LBracLoc
,
4415 SourceLocation SelectorLoc
,
4416 SourceLocation RBracLoc
,
4419 ExprResult
BuildClassMessage(TypeSourceInfo
*ReceiverTypeInfo
,
4420 QualType ReceiverType
,
4421 SourceLocation SuperLoc
,
4423 ObjCMethodDecl
*Method
,
4424 SourceLocation LBracLoc
,
4425 SourceLocation SelectorLoc
,
4426 SourceLocation RBracLoc
,
4429 ExprResult
ActOnClassMessage(Scope
*S
,
4430 ParsedType Receiver
,
4432 SourceLocation LBracLoc
,
4433 SourceLocation SelectorLoc
,
4434 SourceLocation RBracLoc
,
4437 ExprResult
BuildInstanceMessage(Expr
*Receiver
,
4438 QualType ReceiverType
,
4439 SourceLocation SuperLoc
,
4441 ObjCMethodDecl
*Method
,
4442 SourceLocation LBracLoc
,
4443 SourceLocation SelectorLoc
,
4444 SourceLocation RBracLoc
,
4447 ExprResult
ActOnInstanceMessage(Scope
*S
,
4450 SourceLocation LBracLoc
,
4451 SourceLocation SelectorLoc
,
4452 SourceLocation RBracLoc
,
4456 enum PragmaOptionsAlignKind
{
4457 POAK_Native
, // #pragma options align=native
4458 POAK_Natural
, // #pragma options align=natural
4459 POAK_Packed
, // #pragma options align=packed
4460 POAK_Power
, // #pragma options align=power
4461 POAK_Mac68k
, // #pragma options align=mac68k
4462 POAK_Reset
// #pragma options align=reset
4465 /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align.
4466 void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind
,
4467 SourceLocation PragmaLoc
,
4468 SourceLocation KindLoc
);
4470 enum PragmaPackKind
{
4471 PPK_Default
, // #pragma pack([n])
4472 PPK_Show
, // #pragma pack(show), only supported by MSVC.
4473 PPK_Push
, // #pragma pack(push, [identifier], [n])
4474 PPK_Pop
// #pragma pack(pop, [identifier], [n])
4477 /// ActOnPragmaPack - Called on well formed #pragma pack(...).
4478 void ActOnPragmaPack(PragmaPackKind Kind
,
4479 IdentifierInfo
*Name
,
4481 SourceLocation PragmaLoc
,
4482 SourceLocation LParenLoc
,
4483 SourceLocation RParenLoc
);
4485 /// ActOnPragmaUnused - Called on well-formed '#pragma unused'.
4486 void ActOnPragmaUnused(const Token
&Identifier
,
4488 SourceLocation PragmaLoc
);
4490 /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... .
4491 void ActOnPragmaVisibility(bool IsPush
, const IdentifierInfo
* VisType
,
4492 SourceLocation PragmaLoc
);
4494 NamedDecl
*DeclClonePragmaWeak(NamedDecl
*ND
, IdentifierInfo
*II
);
4495 void DeclApplyPragmaWeak(Scope
*S
, NamedDecl
*ND
, WeakInfo
&W
);
4497 /// ActOnPragmaWeakID - Called on well formed #pragma weak ident.
4498 void ActOnPragmaWeakID(IdentifierInfo
* WeakName
,
4499 SourceLocation PragmaLoc
,
4500 SourceLocation WeakNameLoc
);
4502 /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
4503 void ActOnPragmaWeakAlias(IdentifierInfo
* WeakName
,
4504 IdentifierInfo
* AliasName
,
4505 SourceLocation PragmaLoc
,
4506 SourceLocation WeakNameLoc
,
4507 SourceLocation AliasNameLoc
);
4509 /// ActOnPragmaFPContract - Called on well formed
4510 /// #pragma {STDC,OPENCL} FP_CONTRACT
4511 void ActOnPragmaFPContract(tok::OnOffSwitch OOS
);
4513 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to
4514 /// a the record decl, to handle '#pragma pack' and '#pragma options align'.
4515 void AddAlignmentAttributesForRecord(RecordDecl
*RD
);
4517 /// FreePackedContext - Deallocate and null out PackContext.
4518 void FreePackedContext();
4520 /// PushNamespaceVisibilityAttr - Note that we've entered a
4521 /// namespace with a visibility attribute.
4522 void PushNamespaceVisibilityAttr(const VisibilityAttr
*Attr
);
4524 /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used,
4525 /// add an appropriate visibility attribute.
4526 void AddPushedVisibilityAttribute(Decl
*RD
);
4528 /// PopPragmaVisibility - Pop the top element of the visibility stack; used
4529 /// for '#pragma GCC visibility' and visibility attributes on namespaces.
4530 void PopPragmaVisibility();
4532 /// FreeVisContext - Deallocate and null out VisContext.
4533 void FreeVisContext();
4535 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration.
4536 void AddAlignedAttr(SourceLocation AttrLoc
, Decl
*D
, Expr
*E
);
4537 void AddAlignedAttr(SourceLocation AttrLoc
, Decl
*D
, TypeSourceInfo
*T
);
4539 /// CastCategory - Get the correct forwarded implicit cast result category
4540 /// from the inner expression.
4541 ExprValueKind
CastCategory(Expr
*E
);
4543 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit
4544 /// cast. If there is already an implicit cast, merge into the existing one.
4545 /// If isLvalue, the result of the cast is an lvalue.
4546 void ImpCastExprToType(Expr
*&Expr
, QualType Type
, CastKind CK
,
4547 ExprValueKind VK
= VK_RValue
,
4548 const CXXCastPath
*BasePath
= 0);
4550 /// IgnoredValueConversions - Given that an expression's result is
4551 /// syntactically ignored, perform any conversions that are
4553 void IgnoredValueConversions(Expr
*&expr
);
4555 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts
4556 // functions and arrays to their respective pointers (C99 6.3.2.1).
4557 Expr
*UsualUnaryConversions(Expr
*&expr
);
4559 // DefaultFunctionArrayConversion - converts functions and arrays
4560 // to their respective pointers (C99 6.3.2.1).
4561 void DefaultFunctionArrayConversion(Expr
*&expr
);
4563 // DefaultFunctionArrayLvalueConversion - converts functions and
4564 // arrays to their respective pointers and performs the
4565 // lvalue-to-rvalue conversion.
4566 void DefaultFunctionArrayLvalueConversion(Expr
*&expr
);
4568 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on
4569 // the operand. This is DefaultFunctionArrayLvalueConversion,
4570 // except that it assumes the operand isn't of function or array
4572 void DefaultLvalueConversion(Expr
*&expr
);
4574 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that
4575 // do not have a prototype. Integer promotions are performed on each
4576 // argument, and arguments that have type float are promoted to double.
4577 void DefaultArgumentPromotion(Expr
*&Expr
);
4579 // Used for emitting the right warning by DefaultVariadicArgumentPromotion
4580 enum VariadicCallType
{
4584 VariadicConstructor
,
4585 VariadicDoesNotApply
4588 /// GatherArgumentsForCall - Collector argument expressions for various
4589 /// form of call prototypes.
4590 bool GatherArgumentsForCall(SourceLocation CallLoc
,
4591 FunctionDecl
*FDecl
,
4592 const FunctionProtoType
*Proto
,
4593 unsigned FirstProtoArg
,
4594 Expr
**Args
, unsigned NumArgs
,
4595 llvm::SmallVector
<Expr
*, 8> &AllArgs
,
4596 VariadicCallType CallType
= VariadicDoesNotApply
);
4598 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but
4599 // will warn if the resulting type is not a POD type.
4600 bool DefaultVariadicArgumentPromotion(Expr
*&Expr
, VariadicCallType CT
,
4601 FunctionDecl
*FDecl
);
4603 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's
4604 // operands and then handles various conversions that are common to binary
4605 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this
4606 // routine returns the first non-arithmetic type found. The client is
4607 // responsible for emitting appropriate error diagnostics.
4608 QualType
UsualArithmeticConversions(Expr
*&lExpr
, Expr
*&rExpr
,
4609 bool isCompAssign
= false);
4611 /// AssignConvertType - All of the 'assignment' semantic checks return this
4612 /// enum to indicate whether the assignment was allowed. These checks are
4613 /// done for simple assignments, as well as initialization, return from
4614 /// function, argument passing, etc. The query is phrased in terms of a
4615 /// source and destination type.
4616 enum AssignConvertType
{
4617 /// Compatible - the types are compatible according to the standard.
4620 /// PointerToInt - The assignment converts a pointer to an int, which we
4621 /// accept as an extension.
4624 /// IntToPointer - The assignment converts an int to a pointer, which we
4625 /// accept as an extension.
4628 /// FunctionVoidPointer - The assignment is between a function pointer and
4629 /// void*, which the standard doesn't allow, but we accept as an extension.
4630 FunctionVoidPointer
,
4632 /// IncompatiblePointer - The assignment is between two pointers types that
4633 /// are not compatible, but we accept them as an extension.
4634 IncompatiblePointer
,
4636 /// IncompatiblePointer - The assignment is between two pointers types which
4637 /// point to integers which have a different sign, but are otherwise identical.
4638 /// This is a subset of the above, but broken out because it's by far the most
4639 /// common case of incompatible pointers.
4640 IncompatiblePointerSign
,
4642 /// CompatiblePointerDiscardsQualifiers - The assignment discards
4643 /// c/v/r qualifiers, which we accept as an extension.
4644 CompatiblePointerDiscardsQualifiers
,
4646 /// IncompatiblePointerDiscardsQualifiers - The assignment
4647 /// discards qualifiers that we don't permit to be discarded,
4648 /// like address spaces.
4649 IncompatiblePointerDiscardsQualifiers
,
4651 /// IncompatibleNestedPointerQualifiers - The assignment is between two
4652 /// nested pointer types, and the qualifiers other than the first two
4653 /// levels differ e.g. char ** -> const char **, but we accept them as an
4655 IncompatibleNestedPointerQualifiers
,
4657 /// IncompatibleVectors - The assignment is between two vector types that
4658 /// have the same size, which we accept as an extension.
4659 IncompatibleVectors
,
4661 /// IntToBlockPointer - The assignment converts an int to a block
4662 /// pointer. We disallow this.
4665 /// IncompatibleBlockPointer - The assignment is between two block
4666 /// pointers types that are not compatible.
4667 IncompatibleBlockPointer
,
4669 /// IncompatibleObjCQualifiedId - The assignment is between a qualified
4670 /// id type and something else (that is incompatible with it). For example,
4671 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol.
4672 IncompatibleObjCQualifiedId
,
4674 /// Incompatible - We reject this conversion outright, it is invalid to
4675 /// represent it in the AST.
4679 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the
4680 /// assignment conversion type specified by ConvTy. This returns true if the
4681 /// conversion was invalid or false if the conversion was accepted.
4682 bool DiagnoseAssignmentResult(AssignConvertType ConvTy
,
4684 QualType DstType
, QualType SrcType
,
4685 Expr
*SrcExpr
, AssignmentAction Action
,
4686 bool *Complained
= 0);
4688 /// CheckAssignmentConstraints - Perform type checking for assignment,
4689 /// argument passing, variable initialization, and function return values.
4691 AssignConvertType
CheckAssignmentConstraints(SourceLocation Loc
,
4692 QualType lhs
, QualType rhs
);
4694 /// Check assignment constraints and prepare for a conversion of the
4695 /// RHS to the LHS type.
4696 AssignConvertType
CheckAssignmentConstraints(QualType lhs
, Expr
*&rhs
,
4699 // CheckSingleAssignmentConstraints - Currently used by
4700 // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking,
4701 // this routine performs the default function/array converions.
4702 AssignConvertType
CheckSingleAssignmentConstraints(QualType lhs
,
4705 // \brief If the lhs type is a transparent union, check whether we
4706 // can initialize the transparent union with the given expression.
4707 AssignConvertType
CheckTransparentUnionArgumentConstraints(QualType lhs
,
4710 bool IsStringLiteralToNonConstPointerConversion(Expr
*From
, QualType ToType
);
4712 bool CheckExceptionSpecCompatibility(Expr
*From
, QualType ToType
);
4714 bool PerformImplicitConversion(Expr
*&From
, QualType ToType
,
4715 AssignmentAction Action
,
4716 bool AllowExplicit
= false);
4717 bool PerformImplicitConversion(Expr
*&From
, QualType ToType
,
4718 AssignmentAction Action
,
4720 ImplicitConversionSequence
& ICS
);
4721 bool PerformImplicitConversion(Expr
*&From
, QualType ToType
,
4722 const ImplicitConversionSequence
& ICS
,
4723 AssignmentAction Action
,
4724 bool CStyle
= false);
4725 bool PerformImplicitConversion(Expr
*&From
, QualType ToType
,
4726 const StandardConversionSequence
& SCS
,
4727 AssignmentAction Action
,
4730 /// the following "Check" methods will return a valid/converted QualType
4731 /// or a null QualType (indicating an error diagnostic was issued).
4733 /// type checking binary operators (subroutines of CreateBuiltinBinOp).
4734 QualType
InvalidOperands(SourceLocation l
, Expr
*&lex
, Expr
*&rex
);
4735 QualType
CheckPointerToMemberOperands( // C++ 5.5
4736 Expr
*&lex
, Expr
*&rex
, ExprValueKind
&VK
,
4737 SourceLocation OpLoc
, bool isIndirect
);
4738 QualType
CheckMultiplyDivideOperands( // C99 6.5.5
4739 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, bool isCompAssign
,
4741 QualType
CheckRemainderOperands( // C99 6.5.5
4742 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, bool isCompAssign
= false);
4743 QualType
CheckAdditionOperands( // C99 6.5.6
4744 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, QualType
* CompLHSTy
= 0);
4745 QualType
CheckSubtractionOperands( // C99 6.5.6
4746 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, QualType
* CompLHSTy
= 0);
4747 QualType
CheckShiftOperands( // C99 6.5.7
4748 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, bool isCompAssign
= false);
4749 QualType
CheckCompareOperands( // C99 6.5.8/9
4750 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, unsigned Opc
,
4752 QualType
CheckBitwiseOperands( // C99 6.5.[10...12]
4753 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, bool isCompAssign
= false);
4754 QualType
CheckLogicalOperands( // C99 6.5.[13,14]
4755 Expr
*&lex
, Expr
*&rex
, SourceLocation OpLoc
, unsigned Opc
);
4756 // CheckAssignmentOperands is used for both simple and compound assignment.
4757 // For simple assignment, pass both expressions and a null converted type.
4758 // For compound assignment, pass both expressions and the converted type.
4759 QualType
CheckAssignmentOperands( // C99 6.5.16.[1,2]
4760 Expr
*lex
, Expr
*&rex
, SourceLocation OpLoc
, QualType convertedType
);
4762 void ConvertPropertyForRValue(Expr
*&E
);
4763 void ConvertPropertyForLValue(Expr
*&LHS
, Expr
*&RHS
, QualType
& LHSTy
);
4765 QualType
CheckConditionalOperands( // C99 6.5.15
4766 Expr
*&cond
, Expr
*&lhs
, Expr
*&rhs
,
4767 ExprValueKind
&VK
, ExprObjectKind
&OK
, SourceLocation questionLoc
);
4768 QualType
CXXCheckConditionalOperands( // C++ 5.16
4769 Expr
*&cond
, Expr
*&lhs
, Expr
*&rhs
,
4770 ExprValueKind
&VK
, ExprObjectKind
&OK
, SourceLocation questionLoc
);
4771 QualType
FindCompositePointerType(SourceLocation Loc
, Expr
*&E1
, Expr
*&E2
,
4772 bool *NonStandardCompositeType
= 0);
4774 QualType
FindCompositeObjCPointerType(Expr
*&LHS
, Expr
*&RHS
,
4775 SourceLocation questionLoc
);
4777 /// type checking for vector binary operators.
4778 QualType
CheckVectorOperands(SourceLocation l
, Expr
*&lex
, Expr
*&rex
);
4779 QualType
CheckVectorCompareOperands(Expr
*&lex
, Expr
*&rx
,
4780 SourceLocation l
, bool isRel
);
4782 /// type checking declaration initializers (C99 6.7.8)
4783 bool CheckInitList(const InitializedEntity
&Entity
,
4784 InitListExpr
*&InitList
, QualType
&DeclType
);
4785 bool CheckForConstantInitializer(Expr
*e
, QualType t
);
4787 // type checking C++ declaration initializers (C++ [dcl.init]).
4789 /// ReferenceCompareResult - Expresses the result of comparing two
4790 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the
4791 /// purposes of initialization by reference (C++ [dcl.init.ref]p4).
4792 enum ReferenceCompareResult
{
4793 /// Ref_Incompatible - The two types are incompatible, so direct
4794 /// reference binding is not possible.
4795 Ref_Incompatible
= 0,
4796 /// Ref_Related - The two types are reference-related, which means
4797 /// that their unqualified forms (T1 and T2) are either the same
4798 /// or T1 is a base class of T2.
4800 /// Ref_Compatible_With_Added_Qualification - The two types are
4801 /// reference-compatible with added qualification, meaning that
4802 /// they are reference-compatible and the qualifiers on T1 (cv1)
4803 /// are greater than the qualifiers on T2 (cv2).
4804 Ref_Compatible_With_Added_Qualification
,
4805 /// Ref_Compatible - The two types are reference-compatible and
4806 /// have equivalent qualifiers (cv1 == cv2).
4810 ReferenceCompareResult
CompareReferenceRelationship(SourceLocation Loc
,
4811 QualType T1
, QualType T2
,
4812 bool &DerivedToBase
,
4813 bool &ObjCConversion
);
4815 /// CheckCastTypes - Check type constraints for casting between types under
4816 /// C semantics, or forward to CXXCheckCStyleCast in C++.
4817 bool CheckCastTypes(SourceRange TyRange
, QualType CastTy
, Expr
*&CastExpr
,
4818 CastKind
&Kind
, ExprValueKind
&VK
, CXXCastPath
&BasePath
,
4819 bool FunctionalStyle
= false);
4821 // CheckVectorCast - check type constraints for vectors.
4822 // Since vectors are an extension, there are no C standard reference for this.
4823 // We allow casting between vectors and integer datatypes of the same size.
4824 // returns true if the cast is invalid
4825 bool CheckVectorCast(SourceRange R
, QualType VectorTy
, QualType Ty
,
4828 // CheckExtVectorCast - check type constraints for extended vectors.
4829 // Since vectors are an extension, there are no C standard reference for this.
4830 // We allow casting between vectors and integer datatypes of the same size,
4831 // or vectors and the element type of that vector.
4832 // returns true if the cast is invalid
4833 bool CheckExtVectorCast(SourceRange R
, QualType VectorTy
, Expr
*&CastExpr
,
4836 /// CXXCheckCStyleCast - Check constraints of a C-style or function-style
4837 /// cast under C++ semantics.
4838 bool CXXCheckCStyleCast(SourceRange R
, QualType CastTy
, ExprValueKind
&VK
,
4839 Expr
*&CastExpr
, CastKind
&Kind
,
4840 CXXCastPath
&BasePath
, bool FunctionalStyle
);
4842 /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
4843 /// \param Method - May be null.
4844 /// \param [out] ReturnType - The return type of the send.
4845 /// \return true iff there were any incompatible types.
4846 bool CheckMessageArgumentTypes(Expr
**Args
, unsigned NumArgs
, Selector Sel
,
4847 ObjCMethodDecl
*Method
, bool isClassMessage
,
4848 SourceLocation lbrac
, SourceLocation rbrac
,
4849 QualType
&ReturnType
, ExprValueKind
&VK
);
4851 /// CheckBooleanCondition - Diagnose problems involving the use of
4852 /// the given expression as a boolean condition (e.g. in an if
4853 /// statement). Also performs the standard function and array
4854 /// decays, possibly changing the input variable.
4856 /// \param Loc - A location associated with the condition, e.g. the
4858 /// \return true iff there were any errors
4859 bool CheckBooleanCondition(Expr
*&CondExpr
, SourceLocation Loc
);
4861 ExprResult
ActOnBooleanCondition(Scope
*S
, SourceLocation Loc
,
4864 /// DiagnoseAssignmentAsCondition - Given that an expression is
4865 /// being used as a boolean condition, warn if it's an assignment.
4866 void DiagnoseAssignmentAsCondition(Expr
*E
);
4868 /// \brief Redundant parentheses over an equality comparison can indicate
4869 /// that the user intended an assignment used as condition.
4870 void DiagnoseEqualityWithExtraParens(ParenExpr
*parenE
);
4872 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
4873 bool CheckCXXBooleanCondition(Expr
*&CondExpr
);
4875 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have
4876 /// the specified width and sign. If an overflow occurs, detect it and emit
4877 /// the specified diagnostic.
4878 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt
&OldVal
,
4879 unsigned NewWidth
, bool NewSign
,
4880 SourceLocation Loc
, unsigned DiagID
);
4882 /// Checks that the Objective-C declaration is declared in the global scope.
4883 /// Emits an error and marks the declaration as invalid if it's not declared
4884 /// in the global scope.
4885 bool CheckObjCDeclScope(Decl
*D
);
4887 /// VerifyIntegerConstantExpression - verifies that an expression is an ICE,
4888 /// and reports the appropriate diagnostics. Returns false on success.
4889 /// Can optionally return the value of the expression.
4890 bool VerifyIntegerConstantExpression(const Expr
*E
, llvm::APSInt
*Result
= 0);
4892 /// VerifyBitField - verifies that a bit field expression is an ICE and has
4893 /// the correct width, and that the field type is valid.
4894 /// Returns false on success.
4895 /// Can optionally return whether the bit-field is of width 0
4896 bool VerifyBitField(SourceLocation FieldLoc
, IdentifierInfo
*FieldName
,
4897 QualType FieldTy
, const Expr
*BitWidth
,
4898 bool *ZeroWidth
= 0);
4900 /// \name Code completion
4902 /// \brief Describes the context in which code completion occurs.
4903 enum ParserCompletionContext
{
4904 /// \brief Code completion occurs at top-level or namespace context.
4906 /// \brief Code completion occurs within a class, struct, or union.
4908 /// \brief Code completion occurs within an Objective-C interface, protocol,
4911 /// \brief Code completion occurs within an Objective-C implementation or
4912 /// category implementation
4913 PCC_ObjCImplementation
,
4914 /// \brief Code completion occurs within the list of instance variables
4915 /// in an Objective-C interface, protocol, category, or implementation.
4916 PCC_ObjCInstanceVariableList
,
4917 /// \brief Code completion occurs following one or more template
4920 /// \brief Code completion occurs following one or more template
4921 /// headers within a class.
4923 /// \brief Code completion occurs within an expression.
4925 /// \brief Code completion occurs within a statement, which may
4926 /// also be an expression or a declaration.
4928 /// \brief Code completion occurs at the beginning of the
4929 /// initialization statement (or expression) in a for loop.
4931 /// \brief Code completion occurs within the condition of an if,
4932 /// while, switch, or for statement.
4934 /// \brief Code completion occurs within the body of a function on a
4935 /// recovery path, where we do not have a specific handle on our position
4937 PCC_RecoveryInFunction
,
4938 /// \brief Code completion occurs where only a type is permitted.
4940 /// \brief Code completion occurs in a parenthesized expression, which
4941 /// might also be a type cast.
4942 PCC_ParenthesizedExpression
,
4943 /// \brief Code completion occurs within a sequence of declaration
4944 /// specifiers within a function, method, or block.
4945 PCC_LocalDeclarationSpecifiers
4948 void CodeCompleteOrdinaryName(Scope
*S
,
4949 ParserCompletionContext CompletionContext
);
4950 void CodeCompleteDeclSpec(Scope
*S
, DeclSpec
&DS
,
4951 bool AllowNonIdentifiers
,
4952 bool AllowNestedNameSpecifiers
);
4954 struct CodeCompleteExpressionData
;
4955 void CodeCompleteExpression(Scope
*S
,
4956 const CodeCompleteExpressionData
&Data
);
4957 void CodeCompleteMemberReferenceExpr(Scope
*S
, Expr
*Base
,
4958 SourceLocation OpLoc
,
4960 void CodeCompletePostfixExpression(Scope
*S
, ExprResult LHS
);
4961 void CodeCompleteTag(Scope
*S
, unsigned TagSpec
);
4962 void CodeCompleteTypeQualifiers(DeclSpec
&DS
);
4963 void CodeCompleteCase(Scope
*S
);
4964 void CodeCompleteCall(Scope
*S
, Expr
*Fn
, Expr
**Args
, unsigned NumArgs
);
4965 void CodeCompleteInitializer(Scope
*S
, Decl
*D
);
4966 void CodeCompleteReturn(Scope
*S
);
4967 void CodeCompleteAssignmentRHS(Scope
*S
, Expr
*LHS
);
4969 void CodeCompleteQualifiedId(Scope
*S
, CXXScopeSpec
&SS
,
4970 bool EnteringContext
);
4971 void CodeCompleteUsing(Scope
*S
);
4972 void CodeCompleteUsingDirective(Scope
*S
);
4973 void CodeCompleteNamespaceDecl(Scope
*S
);
4974 void CodeCompleteNamespaceAliasDecl(Scope
*S
);
4975 void CodeCompleteOperatorName(Scope
*S
);
4976 void CodeCompleteConstructorInitializer(Decl
*Constructor
,
4977 CXXCtorInitializer
** Initializers
,
4978 unsigned NumInitializers
);
4980 void CodeCompleteObjCAtDirective(Scope
*S
, Decl
*ObjCImpDecl
,
4982 void CodeCompleteObjCAtVisibility(Scope
*S
);
4983 void CodeCompleteObjCAtStatement(Scope
*S
);
4984 void CodeCompleteObjCAtExpression(Scope
*S
);
4985 void CodeCompleteObjCPropertyFlags(Scope
*S
, ObjCDeclSpec
&ODS
);
4986 void CodeCompleteObjCPropertyGetter(Scope
*S
, Decl
*ClassDecl
);
4987 void CodeCompleteObjCPropertySetter(Scope
*S
, Decl
*ClassDecl
);
4988 void CodeCompleteObjCPassingType(Scope
*S
, ObjCDeclSpec
&DS
,
4990 void CodeCompleteObjCMessageReceiver(Scope
*S
);
4991 void CodeCompleteObjCSuperMessage(Scope
*S
, SourceLocation SuperLoc
,
4992 IdentifierInfo
**SelIdents
,
4993 unsigned NumSelIdents
,
4994 bool AtArgumentExpression
);
4995 void CodeCompleteObjCClassMessage(Scope
*S
, ParsedType Receiver
,
4996 IdentifierInfo
**SelIdents
,
4997 unsigned NumSelIdents
,
4998 bool AtArgumentExpression
,
4999 bool IsSuper
= false);
5000 void CodeCompleteObjCInstanceMessage(Scope
*S
, ExprTy
*Receiver
,
5001 IdentifierInfo
**SelIdents
,
5002 unsigned NumSelIdents
,
5003 bool AtArgumentExpression
,
5004 ObjCInterfaceDecl
*Super
= 0);
5005 void CodeCompleteObjCForCollection(Scope
*S
,
5006 DeclGroupPtrTy IterationVar
);
5007 void CodeCompleteObjCSelector(Scope
*S
,
5008 IdentifierInfo
**SelIdents
,
5009 unsigned NumSelIdents
);
5010 void CodeCompleteObjCProtocolReferences(IdentifierLocPair
*Protocols
,
5011 unsigned NumProtocols
);
5012 void CodeCompleteObjCProtocolDecl(Scope
*S
);
5013 void CodeCompleteObjCInterfaceDecl(Scope
*S
);
5014 void CodeCompleteObjCSuperclass(Scope
*S
,
5015 IdentifierInfo
*ClassName
,
5016 SourceLocation ClassNameLoc
);
5017 void CodeCompleteObjCImplementationDecl(Scope
*S
);
5018 void CodeCompleteObjCInterfaceCategory(Scope
*S
,
5019 IdentifierInfo
*ClassName
,
5020 SourceLocation ClassNameLoc
);
5021 void CodeCompleteObjCImplementationCategory(Scope
*S
,
5022 IdentifierInfo
*ClassName
,
5023 SourceLocation ClassNameLoc
);
5024 void CodeCompleteObjCPropertyDefinition(Scope
*S
, Decl
*ObjCImpDecl
);
5025 void CodeCompleteObjCPropertySynthesizeIvar(Scope
*S
,
5026 IdentifierInfo
*PropertyName
,
5028 void CodeCompleteObjCMethodDecl(Scope
*S
,
5029 bool IsInstanceMethod
,
5030 ParsedType ReturnType
,
5032 void CodeCompleteObjCMethodDeclSelector(Scope
*S
,
5033 bool IsInstanceMethod
,
5034 bool AtParameterName
,
5035 ParsedType ReturnType
,
5036 IdentifierInfo
**SelIdents
,
5037 unsigned NumSelIdents
);
5038 void CodeCompletePreprocessorDirective(bool InConditional
);
5039 void CodeCompleteInPreprocessorConditionalExclusion(Scope
*S
);
5040 void CodeCompletePreprocessorMacroName(bool IsDefinition
);
5041 void CodeCompletePreprocessorExpression();
5042 void CodeCompletePreprocessorMacroArgument(Scope
*S
,
5043 IdentifierInfo
*Macro
,
5044 MacroInfo
*MacroInfo
,
5046 void CodeCompleteNaturalLanguage();
5047 void GatherGlobalCodeCompletions(CodeCompletionAllocator
&Allocator
,
5048 llvm::SmallVectorImpl
<CodeCompletionResult
> &Results
);
5051 void PrintStats() const {}
5053 //===--------------------------------------------------------------------===//
5054 // Extra semantic analysis beyond the C type system
5057 SourceLocation
getLocationOfStringLiteralByte(const StringLiteral
*SL
,
5058 unsigned ByteNo
) const;
5061 void CheckArrayAccess(const ArraySubscriptExpr
*E
);
5062 bool CheckFunctionCall(FunctionDecl
*FDecl
, CallExpr
*TheCall
);
5063 bool CheckBlockCall(NamedDecl
*NDecl
, CallExpr
*TheCall
);
5065 bool CheckablePrintfAttr(const FormatAttr
*Format
, CallExpr
*TheCall
);
5066 bool CheckObjCString(Expr
*Arg
);
5068 ExprResult
CheckBuiltinFunctionCall(unsigned BuiltinID
, CallExpr
*TheCall
);
5069 bool CheckARMBuiltinFunctionCall(unsigned BuiltinID
, CallExpr
*TheCall
);
5071 bool SemaBuiltinVAStart(CallExpr
*TheCall
);
5072 bool SemaBuiltinUnorderedCompare(CallExpr
*TheCall
);
5073 bool SemaBuiltinFPClassification(CallExpr
*TheCall
, unsigned NumArgs
);
5076 // Used by C++ template instantiation.
5077 ExprResult
SemaBuiltinShuffleVector(CallExpr
*TheCall
);
5080 bool SemaBuiltinPrefetch(CallExpr
*TheCall
);
5081 bool SemaBuiltinObjectSize(CallExpr
*TheCall
);
5082 bool SemaBuiltinLongjmp(CallExpr
*TheCall
);
5083 ExprResult
SemaBuiltinAtomicOverloaded(ExprResult TheCallResult
);
5084 bool SemaBuiltinConstantArg(CallExpr
*TheCall
, int ArgNum
,
5085 llvm::APSInt
&Result
);
5087 bool SemaCheckStringLiteral(const Expr
*E
, const CallExpr
*TheCall
,
5088 bool HasVAListArg
, unsigned format_idx
,
5089 unsigned firstDataArg
, bool isPrintf
);
5091 void CheckFormatString(const StringLiteral
*FExpr
, const Expr
*OrigFormatExpr
,
5092 const CallExpr
*TheCall
, bool HasVAListArg
,
5093 unsigned format_idx
, unsigned firstDataArg
,
5096 void CheckNonNullArguments(const NonNullAttr
*NonNull
,
5097 const CallExpr
*TheCall
);
5099 void CheckPrintfScanfArguments(const CallExpr
*TheCall
, bool HasVAListArg
,
5100 unsigned format_idx
, unsigned firstDataArg
,
5103 void CheckReturnStackAddr(Expr
*RetValExp
, QualType lhsType
,
5104 SourceLocation ReturnLoc
);
5105 void CheckFloatComparison(SourceLocation loc
, Expr
* lex
, Expr
* rex
);
5106 void CheckImplicitConversions(Expr
*E
, SourceLocation CC
= SourceLocation());
5108 void CheckBitFieldInitialization(SourceLocation InitLoc
, FieldDecl
*Field
,
5111 /// \brief The parser's current scope.
5113 /// The parser maintains this state here.
5117 friend class Parser
;
5118 friend class InitializationSequence
;
5120 /// \brief Retrieve the parser's current scope.
5121 Scope
*getCurScope() const { return CurScope
; }
5124 /// \brief RAII object that enters a new expression evaluation context.
5125 class EnterExpressionEvaluationContext
{
5129 EnterExpressionEvaluationContext(Sema
&Actions
,
5130 Sema::ExpressionEvaluationContext NewContext
)
5131 : Actions(Actions
) {
5132 Actions
.PushExpressionEvaluationContext(NewContext
);
5135 ~EnterExpressionEvaluationContext() {
5136 Actions
.PopExpressionEvaluationContext();
5140 } // end namespace clang