zcov: / lib/Sema/Sema.h


Files: 1 Branches Taken: 54.8% 23 / 42
Generated: 2010-02-10 01:31 Branches Executed: 61.9% 26 / 42
Line Coverage: 97.0% 163 / 168


Programs: 52 Runs 78468


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

Generated: 2010-02-10 01:31 by zcov