Sema.h revision 0f4be74ff0273e505d383f89174ef539828424ed
1ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project//===--- Sema.h - Semantic Analysis & AST Building --------------*- C++ -*-===// 2ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// 3ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// The LLVM Compiler Infrastructure 4ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// 5df143a5041f03a22808b59c76698770b74692815Selim Gurun// This file is distributed under the University of Illinois Open Source 6ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// License. See LICENSE.TXT for details. 7ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// 8ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project//===----------------------------------------------------------------------===// 9ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// 10ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// This file defines the Sema class, which performs semantic analysis and 11ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// builds ASTs. 12ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project// 13ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project//===----------------------------------------------------------------------===// 14ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 15ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project#ifndef LLVM_CLANG_SEMA_SEMA_H 16ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project#define LLVM_CLANG_SEMA_SEMA_H 17ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 18ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project#include "clang/Sema/Ownership.h" 19ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project#include "clang/Sema/AnalysisBasedWarnings.h" 20ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project#include "clang/Sema/IdentifierResolver.h" 21ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project#include "clang/Sema/ObjCMethodList.h" 2294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun#include "clang/Sema/DeclSpec.h" 23df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/AST/Expr.h" 24df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/AST/DeclarationName.h" 25df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/AST/ExternalASTSource.h" 26df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/AST/TypeLoc.h" 27df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/Basic/Specifiers.h" 28df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/Basic/TemplateKinds.h" 29df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/Basic/TypeTraits.h" 30df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "clang/Basic/ExpressionTraits.h" 31df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "llvm/ADT/OwningPtr.h" 32df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "llvm/ADT/SmallPtrSet.h" 33df143a5041f03a22808b59c76698770b74692815Selim Gurun#include "llvm/ADT/SmallVector.h" 34df143a5041f03a22808b59c76698770b74692815Selim Gurun#include <deque> 35df143a5041f03a22808b59c76698770b74692815Selim Gurun#include <string> 36df143a5041f03a22808b59c76698770b74692815Selim Gurun 37df143a5041f03a22808b59c76698770b74692815Selim Gurunnamespace llvm { 38df143a5041f03a22808b59c76698770b74692815Selim Gurun class APSInt; 39df143a5041f03a22808b59c76698770b74692815Selim Gurun template <typename ValueT> struct DenseMapInfo; 40df143a5041f03a22808b59c76698770b74692815Selim Gurun template <typename ValueT, typename ValueInfoT> class DenseSet; 41df143a5041f03a22808b59c76698770b74692815Selim Gurun} 42df143a5041f03a22808b59c76698770b74692815Selim Gurun 43df143a5041f03a22808b59c76698770b74692815Selim Gurunnamespace clang { 44df143a5041f03a22808b59c76698770b74692815Selim Gurun class ADLResult; 45ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ASTConsumer; 4660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ASTContext; 4760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ASTMutationListener; 4860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ArrayType; 4960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class AttributeList; 5060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class BlockDecl; 5160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CXXBasePath; 5260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CXXBasePaths; 5360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott typedef llvm::SmallVector<CXXBaseSpecifier*, 4> CXXCastPath; 5460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CXXConstructorDecl; 55ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class CXXConversionDecl; 56ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class CXXDestructorDecl; 57ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class CXXFieldCollector; 58ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class CXXMemberCallExpr; 59ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class CXXMethodDecl; 60ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class CXXScopeSpec; 6160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CXXTemporary; 6260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CXXTryStmt; 6360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CallExpr; 6460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ClassTemplateDecl; 65ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ClassTemplatePartialSpecializationDecl; 66ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ClassTemplateSpecializationDecl; 6760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CodeCompleteConsumer; 6860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CodeCompletionAllocator; 6960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class CodeCompletionResult; 70df143a5041f03a22808b59c76698770b74692815Selim Gurun class Decl; 71df143a5041f03a22808b59c76698770b74692815Selim Gurun class DeclAccessPair; 72df143a5041f03a22808b59c76698770b74692815Selim Gurun class DeclContext; 73df143a5041f03a22808b59c76698770b74692815Selim Gurun class DeclRefExpr; 74df143a5041f03a22808b59c76698770b74692815Selim Gurun class DeclaratorDecl; 75df143a5041f03a22808b59c76698770b74692815Selim Gurun class DeducedTemplateArgument; 76df143a5041f03a22808b59c76698770b74692815Selim Gurun class DependentDiagnostic; 77df143a5041f03a22808b59c76698770b74692815Selim Gurun class DesignatedInitExpr; 78df143a5041f03a22808b59c76698770b74692815Selim Gurun class Designation; 79df143a5041f03a22808b59c76698770b74692815Selim Gurun class EnumConstantDecl; 80df143a5041f03a22808b59c76698770b74692815Selim Gurun class Expr; 8160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ExtVectorType; 8260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ExternalSemaSource; 83df143a5041f03a22808b59c76698770b74692815Selim Gurun class FormatAttr; 84df143a5041f03a22808b59c76698770b74692815Selim Gurun class FriendDecl; 85df143a5041f03a22808b59c76698770b74692815Selim Gurun class FunctionDecl; 86df143a5041f03a22808b59c76698770b74692815Selim Gurun class FunctionProtoType; 8760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class FunctionTemplateDecl; 88ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ImplicitConversionSequence; 89ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class InitListExpr; 90ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class InitializationKind; 91ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class InitializationSequence; 92ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class InitializedEntity; 93ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class IntegerLiteral; 94ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class LabelStmt; 95ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class LangOptions; 96ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class LocalInstantiationScope; 9794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class LookupResult; 98ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class MacroInfo; 9960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class MultiLevelTemplateArgumentList; 100ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class NamedDecl; 101ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class NonNullAttr; 102ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCCategoryDecl; 103ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCCategoryImplDecl; 104ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCCompatibleAliasDecl; 105ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCContainerDecl; 106ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCImplDecl; 107ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCImplementationDecl; 10894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class ObjCInterfaceDecl; 10994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class ObjCIvarDecl; 110ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project template <class T> class ObjCList; 111ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCMethodDecl; 112ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCPropertyDecl; 113ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ObjCProtocolDecl; 114ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class OverloadCandidateSet; 115ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class OverloadExpr; 116ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ParenListExpr; 117ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ParmVarDecl; 118ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class Preprocessor; 11994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class PseudoDestructorTypeStorage; 12094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class QualType; 121ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class StandardConversionSequence; 122ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class Stmt; 123ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class StringLiteral; 124df143a5041f03a22808b59c76698770b74692815Selim Gurun class SwitchStmt; 125df143a5041f03a22808b59c76698770b74692815Selim Gurun class TargetAttributesSema; 12694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class TemplateArgument; 12794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class TemplateArgumentList; 128ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TemplateArgumentLoc; 129ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TemplateDecl; 130ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TemplateParameterList; 131ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TemplatePartialOrderingContext; 132ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TemplateTemplateParmDecl; 133ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class Token; 134ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TypeAliasDecl; 135ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TypedefDecl; 136ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TypedefNameDecl; 137ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class TypeLoc; 138ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class UnqualifiedId; 139ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class UnresolvedLookupExpr; 140ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class UnresolvedMemberExpr; 14194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class UnresolvedSetImpl; 14294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class UnresolvedSetIterator; 14394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class UsingDecl; 14494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class UsingShadowDecl; 14594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class ValueDecl; 14694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class VarDecl; 14794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class VisibilityAttr; 14894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class VisibleDeclConsumer; 14994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class IndirectFieldDecl; 150ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 151ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Projectnamespace sema { 152ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class AccessedEntity; 153ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class BlockScopeInfo; 15494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class DelayedDiagnostic; 15594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class FunctionScopeInfo; 15694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class TemplateDeductionInfo; 15794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun} 15894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 15994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// \brief Holds a QualType and a TypeSourceInfo* that came out of a declarator 16094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// parsing. 16194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// 16294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// LocInfoType is a "transient" type, only needed for passing to/from Parser 16394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// and Sema, when we want to preserve type source info for a parsed type. 16494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// It will not participate in the type system semantics in any way. 16594442ad4107000e6d49f9b85a46a591495a57632Selim Gurunclass LocInfoType : public Type { 16694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun enum { 16794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun // The last number that can fit in Type's TC. 168ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // Avoids conflict with an existing Type class. 16994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun LocInfo = Type::TypeLast + 1 17094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun }; 17194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 17294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun TypeSourceInfo *DeclInfo; 17394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 174ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project LocInfoType(QualType ty, TypeSourceInfo *TInfo) 17594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun : Type((TypeClass)LocInfo, ty, ty->isDependentType(), 176ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ty->isVariablyModifiedType(), 177ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ty->containsUnexpandedParameterPack()), 178ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclInfo(TInfo) { 179ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project assert(getTypeClass() == (TypeClass)LocInfo && "LocInfo didn't fit in TC?"); 180ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 18194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun friend class Sema; 182ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 183df143a5041f03a22808b59c76698770b74692815Selim Gurunpublic: 18494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun QualType getType() const { return getCanonicalTypeInternal(); } 18594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun TypeSourceInfo *getTypeSourceInfo() const { return DeclInfo; } 18694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 18794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void getAsStringInternal(std::string &Str, 188df143a5041f03a22808b59c76698770b74692815Selim Gurun const PrintingPolicy &Policy) const; 189df143a5041f03a22808b59c76698770b74692815Selim Gurun 19094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun static bool classof(const Type *T) { 191ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return T->getTypeClass() == (TypeClass)LocInfo; 19294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun } 193ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project static bool classof(const LocInfoType *) { return true; } 194ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project}; 195ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 19694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun// FIXME: No way to easily map from TemplateTypeParmTypes to 19794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun// TemplateTypeParmDecls, so we have this horrible PointerUnion. 19894442ad4107000e6d49f9b85a46a591495a57632Selim Guruntypedef std::pair<llvm::PointerUnion<const TemplateTypeParmType*, NamedDecl*>, 19994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun SourceLocation> UnexpandedParameterPack; 20094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 20194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun/// Sema - This implements semantic analysis and AST building for C. 20294442ad4107000e6d49f9b85a46a591495a57632Selim Gurunclass Sema { 20394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Sema(const Sema&); // DO NOT IMPLEMENT 20494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void operator=(const Sema&); // DO NOT IMPLEMENT 20594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun mutable const TargetAttributesSema* TheTargetAttributesSema; 20694442ad4107000e6d49f9b85a46a591495a57632Selim Gurunpublic: 20794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef OpaquePtr<DeclGroupRef> DeclGroupPtrTy; 20894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef OpaquePtr<TemplateName> TemplateTy; 20994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef OpaquePtr<QualType> TypeTy; 21094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef Attr AttrTy; 21194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef CXXBaseSpecifier BaseTy; 21294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef CXXCtorInitializer MemInitTy; 21394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef Expr ExprTy; 214ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project typedef Stmt StmtTy; 215ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project typedef TemplateParameterList TemplateParamsTy; 216ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project typedef NestedNameSpecifier CXXScopeTy; 21794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 21894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun OpenCLOptions OpenCLFeatures; 219ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FPOptions FPFeatures; 220ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 221ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const LangOptions &LangOpts; 222ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Preprocessor &PP; 223ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ASTContext &Context; 224ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ASTConsumer &Consumer; 225ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Diagnostic &Diags; 226ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceManager &SourceMgr; 227ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 228ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Source of additional semantic information. 229ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ExternalSemaSource *ExternalSource; 230ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 231ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Code-completion consumer. 232ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CodeCompleteConsumer *CodeCompleter; 233ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 23494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// CurContext - This is the current declaration context of parsing. 235ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclContext *CurContext; 236ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 237ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// VAListTagName - The declaration name corresponding to __va_list_tag. 238ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This is used as part of a hack to omit that class from ADL results. 239ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclarationName VAListTagName; 240ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 24194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// PackContext - Manages the stack for #pragma pack. An alignment 242ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// of 0 indicates default alignment. 243ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void *PackContext; // Really a "PragmaPackStack*" 24494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 24594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool MSStructPragmaOn; // True when #pragma ms_struct on 246ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 24760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// VisContext - Manages the stack for #pragma GCC visibility. 24860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void *VisContext; // Really a "PragmaVisStack*" 24960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 250ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Stack containing information about each of the nested 251ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// function, block, and method scopes that are currently active. 252ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 253ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This array is never empty. Clients should ignore the first 254ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// element, which is used to cache a single FunctionScopeInfo 25594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// that's used to parse every top-level function. 256ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVector<sema::FunctionScopeInfo *, 4> FunctionScopes; 257ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 258ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// ExprTemporaries - This is the stack of temporaries that are created by 259ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// the current full expression. 260ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVector<CXXTemporary*, 8> ExprTemporaries; 261ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 26294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// ExtVectorDecls - This is a list all the extended vector types. This allows 26394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// us to associate a raw vector type with one of the ext_vector type names. 26494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// This is only necessary for issuing pretty diagnostics. 26594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun llvm::SmallVector<TypedefNameDecl*, 24> ExtVectorDecls; 266ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 267ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes. 26894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun llvm::OwningPtr<CXXFieldCollector> FieldCollector; 269ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 270ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project typedef llvm::SmallPtrSet<const CXXRecordDecl*, 8> RecordDeclSetTy; 271ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 272ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// PureVirtualClassDiagSet - a set of class declarations which we have 273ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// emitted a list of pure virtual functions. Used to prevent emitting the 274ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// same list more than once. 275ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::OwningPtr<RecordDeclSetTy> PureVirtualClassDiagSet; 276ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 277ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// ParsingInitForAutoVars - a set of declarations with auto types for which 278ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// we are currently parsing the initializer. 27960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott llvm::SmallPtrSet<const Decl*, 4> ParsingInitForAutoVars; 28060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 28160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief A mapping from external names to the most recent 282ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// locally-scoped external declaration with that name. 283ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 284ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This map contains external declarations introduced in local 285ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// scoped, e.g., 286ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 287ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \code 28860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// void f() { 289ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// void foo(int, int); 290ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// } 291ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \endcode 292ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 293ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Here, the name "foo" will be associated with the declaration on 294ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// "foo" within f. This name is not visible outside of 295ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// "f". However, we still find it in two cases: 29660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// 297ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// - If we are declaring another external with the name "foo", we 29894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// can find "foo" as a previous declaration, so that the types 299ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// of this external declaration can be checked for 300ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// compatibility. 301ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 302ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// - If we would implicitly declare "foo" (e.g., due to a call to 303ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// "foo" in C when no prototype or definition is visible), then 304ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// we find this declaration of "foo" and complain that it is 30594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// not visible. 30694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun llvm::DenseMap<DeclarationName, NamedDecl *> LocallyScopedExternalDecls; 307ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 308ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief All the tentative definitions encountered in the TU. 309ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVector<VarDecl *, 2> TentativeDefinitions; 31094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 31194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// \brief The set of file scoped decls seen so far that have not been used 312ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// and must warn if not used. Only contains the first declaration. 313ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVector<const DeclaratorDecl*, 4> UnusedFileScopedDecls; 314ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 31560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief Callback to the parser to parse templated functions when needed. 31660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott typedef void LateTemplateParserCB(void *P, const FunctionDecl *FD); 31760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott LateTemplateParserCB *LateTemplateParser; 318ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void *OpaqueParser; 319ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 32060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void SetLateTemplateParser(LateTemplateParserCB *LTP, void *P) { 321ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project LateTemplateParser = LTP; 322ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project OpaqueParser = P; 32394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun } 324ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 325ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class DelayedDiagnostics; 326ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 327ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class ParsingDeclState { 328ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned SavedStackSize; 329ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project friend class Sema::DelayedDiagnostics; 33094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun }; 33194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 33294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class ProcessingContextState { 33394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun unsigned SavedParsingDepth; 334ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned SavedActiveStackBase; 335ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project friend class Sema::DelayedDiagnostics; 33660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott }; 33760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 338ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// A class which encapsulates the logic for delaying diagnostics 339ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// during parsing and other processing. 340ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class DelayedDiagnostics { 341ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The stack of diagnostics that were delayed due to being 342ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// produced during the parsing of a declaration. 343ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project sema::DelayedDiagnostic *Stack; 344ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 345ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The number of objects on the delayed-diagnostics stack. 346ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned StackSize; 34760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 34860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief The current capacity of the delayed-diagnostics stack. 34960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott unsigned StackCapacity; 350ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 351ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The index of the first "active" delayed diagnostic in 352ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// the stack. When parsing class definitions, we ignore active 353ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// delayed diagnostics from the surrounding context. 354ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned ActiveStackBase; 355ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 356ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The depth of the declarations we're currently parsing. 357ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This gets saved and reset whenever we enter a class definition. 358ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned ParsingDepth; 35960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 360ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project public: 361ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DelayedDiagnostics() : Stack(0), StackSize(0), StackCapacity(0), 362ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ActiveStackBase(0), ParsingDepth(0) {} 36360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 36460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ~DelayedDiagnostics() { 36560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott delete[] reinterpret_cast<char*>(Stack); 36660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 36760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 36860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Adds a delayed diagnostic. 36960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void add(const sema::DelayedDiagnostic &diag); 37060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 37160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Determines whether diagnostics should be delayed. 37260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott bool shouldDelayDiagnostics() { return ParsingDepth > 0; } 37360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 37460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Observe that we've started parsing a declaration. Access and 375df143a5041f03a22808b59c76698770b74692815Selim Gurun /// deprecation diagnostics will be delayed; when the declaration 37660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// is completed, all active delayed diagnostics will be evaluated 37760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// in its context, and then active diagnostics stack will be 37860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// popped down to the saved depth. 37960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ParsingDeclState pushParsingDecl() { 38060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ParsingDepth++; 381df143a5041f03a22808b59c76698770b74692815Selim Gurun 38260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ParsingDeclState state; 38360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott state.SavedStackSize = StackSize; 38460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott return state; 38560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 38660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 38760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Observe that we're completed parsing a declaration. 38860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott static void popParsingDecl(Sema &S, ParsingDeclState state, Decl *decl); 38960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 39060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Observe that we've started processing a different context, the 39160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// contents of which are semantically separate from the 39260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// declarations it may lexically appear in. This sets aside the 39360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// current stack of active diagnostics and starts afresh. 39460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ProcessingContextState pushContext() { 39560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott assert(StackSize >= ActiveStackBase); 39660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 39760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ProcessingContextState state; 39860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott state.SavedParsingDepth = ParsingDepth; 39960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott state.SavedActiveStackBase = ActiveStackBase; 40060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 40160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ActiveStackBase = StackSize; 40260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ParsingDepth = 0; 40360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 40460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott return state; 40560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 40660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 40760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Observe that we've stopped processing a context. This 408df143a5041f03a22808b59c76698770b74692815Selim Gurun /// restores the previous stack of active diagnostics. 40960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void popContext(ProcessingContextState state) { 41060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott assert(ActiveStackBase == StackSize); 41160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott assert(ParsingDepth == 0); 41260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ActiveStackBase = state.SavedActiveStackBase; 413df143a5041f03a22808b59c76698770b74692815Selim Gurun ParsingDepth = state.SavedParsingDepth; 41460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 41560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } DelayedDiagnostics; 41660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 41760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// A RAII object to temporarily push a declaration context. 41860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class ContextRAII { 41960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott private: 42060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Sema &S; 42160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott DeclContext *SavedContext; 42260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ProcessingContextState SavedContextState; 42360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 42460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott public: 42560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ContextRAII(Sema &S, DeclContext *ContextToPush) 42660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott : S(S), SavedContext(S.CurContext), 42760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SavedContextState(S.DelayedDiagnostics.pushContext()) 42860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott { 42960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott assert(ContextToPush && "pushing null context"); 43060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott S.CurContext = ContextToPush; 43160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 43260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 43360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void pop() { 43460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott if (!SavedContext) return; 43560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott S.CurContext = SavedContext; 43660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott S.DelayedDiagnostics.popContext(SavedContextState); 437ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SavedContext = 0; 43860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 43960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 44060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ~ContextRAII() { 44160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott pop(); 442ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 443ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project }; 444df143a5041f03a22808b59c76698770b74692815Selim Gurun 445df143a5041f03a22808b59c76698770b74692815Selim Gurun /// WeakUndeclaredIdentifiers - Identifiers contained in 44660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// #pragma weak before declared. rare. may alias another 447ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// identifier, declared or undeclared 448ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project class WeakInfo { 449ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *alias; // alias (optional) 450ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation loc; // for diagnostics 451ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool used; // identifier later declared? 452ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project public: 453ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project WeakInfo() 454ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project : alias(0), loc(SourceLocation()), used(false) {} 455ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project WeakInfo(IdentifierInfo *Alias, SourceLocation Loc) 456ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project : alias(Alias), loc(Loc), used(false) {} 457ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project inline IdentifierInfo * getAlias() const { return alias; } 458ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project inline SourceLocation getLocation() const { return loc; } 459ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void setUsed(bool Used=true) { used = Used; } 460ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project inline bool getUsed() { return used; } 461ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool operator==(WeakInfo RHS) const { 462ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return alias == RHS.getAlias() && loc == RHS.getLocation(); 463ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 464ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool operator!=(WeakInfo RHS) const { return !(*this == RHS); } 465ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project }; 466ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::DenseMap<IdentifierInfo*,WeakInfo> WeakUndeclaredIdentifiers; 467ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 468ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// WeakTopLevelDecl - Translation-unit scoped declarations generated by 469ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// #pragma weak during processing of other Decls. 47060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// I couldn't figure out a clean way to generate these in-line, so 47160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// we store them here and handle separately -- which is a hack. 47260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// It would be best to refactor this. 47360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott llvm::SmallVector<Decl*,2> WeakTopLevelDecl; 47460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 47560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott IdentifierResolver IdResolver; 476ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 477ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Translation Unit Scope - useful to Objective-C actions that need 47860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// to lookup file scope declarations in the "ordinary" C decl namespace. 479df143a5041f03a22808b59c76698770b74692815Selim Gurun /// For example, user-defined classes, built-in "id" type, etc. 480ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Scope *TUScope; 481df143a5041f03a22808b59c76698770b74692815Selim Gurun 482ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The C++ "std" namespace, where the standard library resides. 483ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project LazyDeclPtr StdNamespace; 484ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 485ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The C++ "std::bad_alloc" class, which is defined by the C++ 486ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// standard library. 48760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott LazyDeclPtr StdBadAlloc; 488ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 489ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The C++ "type_info" declaration, which is defined in <typeinfo>. 490ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project RecordDecl *CXXTypeInfoDecl; 491ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 492ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The MSVC "_GUID" struct, which is defined in MSVC header files. 493ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project RecordDecl *MSVCGuidDecl; 494ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 495ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// A flag to remember whether the implicit forms of operator new and delete 496ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// have been declared. 497ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool GlobalNewDeleteDeclared; 498ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 499ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The set of declarations that have been referenced within 500ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// a potentially evaluated expression. 501ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project typedef llvm::SmallVector<std::pair<SourceLocation, Decl *>, 10> 502ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyReferencedDecls; 503ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 504ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief A set of diagnostics that may be emitted. 505ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project typedef llvm::SmallVector<std::pair<SourceLocation, PartialDiagnostic>, 10> 506ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyEmittedDiagnostics; 507ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 508ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Describes how the expressions currently being parsed are 509ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// evaluated at run-time, if at all. 510ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project enum ExpressionEvaluationContext { 511ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The current expression and its subexpressions occur within an 512ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// unevaluated operand (C++0x [expr]p8), such as a constant expression 513ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// or the subexpression of \c sizeof, where the type or the value of the 514ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// expression may be significant but no code will be generated to evaluate 515ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// the value of the expression at run time. 516ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Unevaluated, 517ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 518ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The current expression is potentially evaluated at run time, 519ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// which means that code may be generated to evaluate the value of the 520ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// expression at run time. 521ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyEvaluated, 522ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 523ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The current expression may be potentially evaluated or it may 524ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// be unevaluated, but it is impossible to tell from the lexical context. 525ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This evaluation context is used primary for the operand of the C++ 526ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \c typeid expression, whose argument is potentially evaluated only when 527ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// it is an lvalue of polymorphic class type (C++ [basic.def.odr]p2). 528ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyPotentiallyEvaluated, 529ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 530ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The current expression is potentially evaluated, but any 531ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// declarations referenced inside that expression are only used if 532ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// in fact the current expression is used. 533ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 534ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This value is used when parsing default function arguments, for which 535ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// we would like to provide diagnostics (e.g., passing non-POD arguments 536ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// through varargs) but do not want to mark declarations as "referenced" 537ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// until the default argument is used. 538ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyEvaluatedIfUsed 539ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project }; 54094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 541ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Data structure used to record current or nested 54260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// expression evaluation contexts. 54360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott struct ExpressionEvaluationContextRecord { 54460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief The expression evaluation context. 54560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ExpressionEvaluationContext Context; 54660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 547ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The number of temporaries that were active when we 548ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// entered this expression evaluation context. 549ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned NumTemporaries; 55094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 551ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The set of declarations referenced within a 552ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// potentially potentially-evaluated context. 553ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 554ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// When leaving a potentially potentially-evaluated context, each 555ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// of these elements will be as referenced if the corresponding 556ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// potentially potentially evaluated expression is potentially 557ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// evaluated. 55860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott PotentiallyReferencedDecls *PotentiallyReferenced; 559df143a5041f03a22808b59c76698770b74692815Selim Gurun 56094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// \brief The set of diagnostics to emit should this potentially 561df143a5041f03a22808b59c76698770b74692815Selim Gurun /// potentially-evaluated context become evaluated. 562df143a5041f03a22808b59c76698770b74692815Selim Gurun PotentiallyEmittedDiagnostics *PotentiallyDiagnosed; 563df143a5041f03a22808b59c76698770b74692815Selim Gurun 56460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ExpressionEvaluationContextRecord(ExpressionEvaluationContext Context, 565ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned NumTemporaries) 566ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project : Context(Context), NumTemporaries(NumTemporaries), 567ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyReferenced(0), PotentiallyDiagnosed(0) { } 568ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 569ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void addReferencedDecl(SourceLocation Loc, Decl *Decl) { 570ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project if (!PotentiallyReferenced) 571ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyReferenced = new PotentiallyReferencedDecls; 572ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyReferenced->push_back(std::make_pair(Loc, Decl)); 573ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 574ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 575ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void addDiagnostic(SourceLocation Loc, const PartialDiagnostic &PD) { 576ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project if (!PotentiallyDiagnosed) 577ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyDiagnosed = new PotentiallyEmittedDiagnostics; 578ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyDiagnosed->push_back(std::make_pair(Loc, PD)); 579ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 580ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 581ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void Destroy() { 582ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project delete PotentiallyReferenced; 583ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project delete PotentiallyDiagnosed; 584ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project PotentiallyReferenced = 0; 58560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott PotentiallyDiagnosed = 0; 586ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 58760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott }; 58860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 58960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// A stack of expression evaluation contexts. 590df143a5041f03a22808b59c76698770b74692815Selim Gurun llvm::SmallVector<ExpressionEvaluationContextRecord, 8> ExprEvalContexts; 591ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 592ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Whether the code handled by Sema should be considered a 593ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// complete translation unit or not. 594ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 595ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// When true (which is generally the case), Sema will perform 596ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// end-of-translation-unit semantic tasks (such as creating 597ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// initializers for tentative definitions in C) once parsing has 598ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// completed. This flag will be false when building PCH files, 599ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// since a PCH file is by definition not a complete translation 600ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// unit. 601ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CompleteTranslationUnit; 602ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 603ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::BumpPtrAllocator BumpAlloc; 604ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 605ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief The number of SFINAE diagnostics that have been trapped. 606ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned NumSFINAEErrors; 607ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 60894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef llvm::DenseMap<ParmVarDecl *, llvm::SmallVector<ParmVarDecl *, 1> > 609ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project UnparsedDefaultArgInstantiationsMap; 610ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 611ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief A mapping from parameters with unparsed default arguments to the 612ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// set of instantiations of each parameter. 613ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 614ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This mapping is a temporary data structure used when parsing 615ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// nested class templates or nested classes of class templates, 616ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// where we might end up instantiating an inner class before the 617ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// default arguments of its methods have been parsed. 618ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project UnparsedDefaultArgInstantiationsMap UnparsedDefaultArgInstantiations; 619ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 620ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // Contains the locations of the beginning of unparsed default 621ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // argument locations. 622ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::DenseMap<ParmVarDecl *,SourceLocation> UnparsedDefaultArgLocs; 623ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 624ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// UndefinedInternals - all the used, undefined objects with 625ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// internal linkage in this translation unit. 626ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::DenseMap<NamedDecl*, SourceLocation> UndefinedInternals; 627ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 62894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun typedef std::pair<ObjCMethodList, ObjCMethodList> GlobalMethods; 62960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott typedef llvm::DenseMap<Selector, GlobalMethods> GlobalMethodPool; 63094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 631ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Method Pool - allows efficient lookup when typechecking messages to "id". 632ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// We need to maintain a list, since selectors can have differing signatures 633ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// across classes. In Cocoa, this happens to be extremely uncommon (only 1% 634ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// of selectors are "overloaded"). 635ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project GlobalMethodPool MethodPool; 63660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 63760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Method selectors used in a @selector expression. Used for implementation 63860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// of -Wselector. 639ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::DenseMap<Selector, SourceLocation> ReferencedSelectors; 640ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 641ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project GlobalMethodPool::iterator ReadMethodPool(Selector Sel); 642ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 643ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Private Helper predicate to check for 'self'. 644ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool isSelfExpr(Expr *RExpr); 645ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Projectpublic: 64660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, 64760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott bool CompleteTranslationUnit = true, 64860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott CodeCompleteConsumer *CompletionConsumer = 0); 64960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ~Sema(); 650ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 651ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Perform initialization that occurs after the parser has been 652ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// initialized but before it parses anything. 653ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void Initialize(); 65460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 65560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott const LangOptions &getLangOptions() const { return LangOpts; } 65660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott OpenCLOptions &getOpenCLOptions() { return OpenCLFeatures; } 657ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FPOptions &getFPOptions() { return FPFeatures; } 658ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 659ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Diagnostic &getDiagnostics() const { return Diags; } 660ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceManager &getSourceManager() const { return SourceMgr; } 661ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const TargetAttributesSema &getTargetAttributesSema() const; 662ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Preprocessor &getPreprocessor() const { return PP; } 663ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ASTContext &getASTContext() const { return Context; } 664ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ASTConsumer &getASTConsumer() const { return Consumer; } 665ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ASTMutationListener *getASTMutationListener() const; 66660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 66760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief Helper class that creates diagnostics with optional 66860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// template instantiation stacks. 66960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// 670ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This class provides a wrapper around the basic DiagnosticBuilder 671ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// class that emits diagnostics. SemaDiagnosticBuilder is 67260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// responsible for emitting the diagnostic (as DiagnosticBuilder 673ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// does) and, if the diagnostic comes from inside a template 67460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// instantiation, printing the template instantiation stack as 67560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// well. 67660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott class SemaDiagnosticBuilder : public DiagnosticBuilder { 67760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Sema &SemaRef; 67860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott unsigned DiagID; 67960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 68060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott public: 68160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SemaDiagnosticBuilder(DiagnosticBuilder &DB, Sema &SemaRef, unsigned DiagID) 68260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott : DiagnosticBuilder(DB), SemaRef(SemaRef), DiagID(DiagID) { } 68360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 68460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott explicit SemaDiagnosticBuilder(Sema &SemaRef) 68560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott : DiagnosticBuilder(DiagnosticBuilder::Suppress), SemaRef(SemaRef) { } 68660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 68760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ~SemaDiagnosticBuilder(); 68860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott }; 68960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 69060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief Emit a diagnostic. 69160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID); 69260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 69360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief Emit a partial diagnostic. 69460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SemaDiagnosticBuilder Diag(SourceLocation Loc, const PartialDiagnostic& PD); 69560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 69660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief Build a partial diagnostic. 69760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott PartialDiagnostic PDiag(unsigned DiagID = 0); // in SemaInternal.h 69860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 69960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott bool findMacroSpelling(SourceLocation &loc, llvm::StringRef name); 70060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 70160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ExprResult Owned(Expr* E) { return E; } 70260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ExprResult Owned(ExprResult R) { return R; } 70360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott StmtResult Owned(Stmt* S) { return S; } 704ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 705ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnEndOfTranslationUnit(); 706ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 707ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Scope *getScopeForContext(DeclContext *Ctx); 708ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 709ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void PushFunctionScope(); 710ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void PushBlockScope(Scope *BlockScope, BlockDecl *Block); 711ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void PopFunctionOrBlockScope(const sema::AnalysisBasedWarnings::Policy *WP =0, 712ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const Decl *D = 0, const BlockExpr *blkExpr = 0); 713ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 714ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project sema::FunctionScopeInfo *getCurFunction() const { 715ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return FunctionScopes.back(); 716ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 717ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 71860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott bool hasAnyErrorsInThisFunction() const; 71960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 72060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// \brief Retrieve the current block, if any. 72160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott sema::BlockScopeInfo *getCurBlock(); 72260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 723ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// WeakTopLevelDeclDecls - access to #pragma weak-generated Decls 724ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVector<Decl*,2> &WeakTopLevelDecls() { return WeakTopLevelDecl; } 725ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 726ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project //===--------------------------------------------------------------------===// 72760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott // Type Analysis / Processing: SemaType.cpp. 728ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // 729ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 73060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott QualType adjustParameterType(QualType T); 73160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott QualType BuildQualifiedType(QualType T, SourceLocation Loc, Qualifiers Qs); 73260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott QualType BuildQualifiedType(QualType T, SourceLocation Loc, unsigned CVR) { 733ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return BuildQualifiedType(T, Loc, Qualifiers::fromCVRMask(CVR)); 734ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 735ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildPointerType(QualType T, 736ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation Loc, DeclarationName Entity); 737ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildReferenceType(QualType T, bool LValueRef, 738ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation Loc, DeclarationName Entity); 739ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, 740ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Expr *ArraySize, unsigned Quals, 741ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceRange Brackets, DeclarationName Entity); 742ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildExtVectorType(QualType T, Expr *ArraySize, 743ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation AttrLoc); 744ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildFunctionType(QualType T, 745ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType *ParamTypes, unsigned NumParamTypes, 746ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool Variadic, unsigned Quals, 74794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun RefQualifierKind RefQualifier, 748ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation Loc, DeclarationName Entity, 749ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FunctionType::ExtInfo Info); 75060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott QualType BuildMemberPointerType(QualType T, QualType Class, 751ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation Loc, 752ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclarationName Entity); 753ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildBlockPointerType(QualType T, 754ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation Loc, DeclarationName Entity); 755ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildParenType(QualType T); 756ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 757ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S, 758ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TagDecl **OwnedDecl = 0, 759ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool AllowAutoInTypeName = false); 760ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeSourceInfo *GetTypeSourceInfoForDeclarator(Declarator &D, QualType T, 761ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeSourceInfo *ReturnTypeInfo); 76294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// \brief Package the given type and TSI into a ParsedType. 763ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo); 764ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclarationNameInfo GetNameForDeclarator(Declarator &D); 765ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name); 766ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo = 0); 767ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckSpecifiedExceptionType(QualType T, const SourceRange &Range); 768ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckDistantExceptionSpec(QualType T); 769ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckEquivalentExceptionSpec(FunctionDecl *Old, FunctionDecl *New); 770ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckEquivalentExceptionSpec( 771ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *Old, SourceLocation OldLoc, 77294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun const FunctionProtoType *New, SourceLocation NewLoc); 773ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckEquivalentExceptionSpec( 774ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, 775ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *Old, SourceLocation OldLoc, 776ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *New, SourceLocation NewLoc, 777ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool *MissingExceptionSpecification = 0, 778ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool *MissingEmptyExceptionSpecification = 0, 779ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool AllowNoexceptAllMatchWithNoSpec = false, 780ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool IsOperatorNew = false); 781ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckExceptionSpecSubset( 782ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const PartialDiagnostic &DiagID, const PartialDiagnostic & NoteID, 783ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *Superset, SourceLocation SuperLoc, 784ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *Subset, SourceLocation SubLoc); 785ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckParamExceptionSpec(const PartialDiagnostic & NoteID, 786ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *Target, SourceLocation TargetLoc, 787ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const FunctionProtoType *Source, SourceLocation SourceLoc); 788ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 789ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeResult ActOnTypeName(Scope *S, Declarator &D); 790ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 791ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool RequireCompleteType(SourceLocation Loc, QualType T, 792ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const PartialDiagnostic &PD, 793ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project std::pair<SourceLocation, PartialDiagnostic> Note); 794ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool RequireCompleteType(SourceLocation Loc, QualType T, 795ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const PartialDiagnostic &PD); 796ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool RequireCompleteType(SourceLocation Loc, QualType T, 797ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned DiagID); 798ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 799ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType getElaboratedType(ElaboratedTypeKeyword Keyword, 800ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const CXXScopeSpec &SS, QualType T); 801ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 802ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildTypeofExprType(Expr *E, SourceLocation Loc); 803ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType BuildDecltypeType(Expr *E, SourceLocation Loc); 804ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 805ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project //===--------------------------------------------------------------------===// 806ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // Symbol table / Decl tracking callbacks: SemaDecl.cpp. 807ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // 808ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 809ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr); 810ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 811ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void DiagnoseUseOfUnimplementedSelectors(); 812ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 813ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParsedType getTypeName(IdentifierInfo &II, SourceLocation NameLoc, 814ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Scope *S, CXXScopeSpec *SS = 0, 815ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool isClassName = false, 816ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool HasTrailingDot = false, 817ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParsedType ObjectType = ParsedType(), 818ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool WantNontrivialTypeSourceInfo = false); 819ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S); 820ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool isMicrosoftMissingTypename(const CXXScopeSpec *SS); 821ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool DiagnoseUnknownTypeName(const IdentifierInfo &II, 822ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation IILoc, 823ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Scope *S, 824ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CXXScopeSpec *SS, 825ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParsedType &SuggestedType); 826ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 827ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Describes the result of the name lookup and resolution performed 828ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// by \c ClassifyName(). 829ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project enum NameClassificationKind { 830ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NC_Unknown, 83194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun NC_Error, 832ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NC_Keyword, 833ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NC_Type, 834ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NC_Expression, 835ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NC_NestedNameSpecifier, 836ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NC_TypeTemplate, 83794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun NC_FunctionTemplate 83894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun }; 83994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 84094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun class NameClassification { 84194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun NameClassificationKind Kind; 84294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun ExprResult Expr; 84394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun TemplateName Template; 844ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParsedType Type; 845ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const IdentifierInfo *Keyword; 846ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 847ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project explicit NameClassification(NameClassificationKind Kind) : Kind(Kind) {} 84894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 849ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project public: 850ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NameClassification(ExprResult Expr) : Kind(NC_Expression), Expr(Expr) {} 851ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 852ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NameClassification(ParsedType Type) : Kind(NC_Type), Type(Type) {} 853ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 854ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NameClassification(const IdentifierInfo *Keyword) 855ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project : Kind(NC_Keyword), Keyword(Keyword) { } 85694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 85794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun static NameClassification Error() { 858ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return NameClassification(NC_Error); 859ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 860ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 86194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun static NameClassification Unknown() { 86294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun return NameClassification(NC_Unknown); 863ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 864ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 865ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project static NameClassification NestedNameSpecifier() { 866ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return NameClassification(NC_NestedNameSpecifier); 867ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 86894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 86994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun static NameClassification TypeTemplate(TemplateName Name) { 870ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NameClassification Result(NC_TypeTemplate); 871ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Result.Template = Name; 872ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return Result; 87394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun } 87494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 875ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project static NameClassification FunctionTemplate(TemplateName Name) { 876ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NameClassification Result(NC_FunctionTemplate); 877ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Result.Template = Name; 878ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return Result; 879ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 88060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 88160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott NameClassificationKind getKind() const { return Kind; } 88260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 88360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ParsedType getType() const { 88460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott assert(Kind == NC_Type); 88560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott return Type; 88660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 88794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 88860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott ExprResult getExpression() const { 88960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott assert(Kind == NC_Expression); 89060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott return Expr; 89160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott } 892ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 893ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TemplateName getTemplateName() const { 894ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate); 895ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return Template; 896ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 897ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 89894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun TemplateNameKind getTemplateNameKind() const { 89994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun assert(Kind == NC_TypeTemplate || Kind == NC_FunctionTemplate); 900ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project return Kind == NC_TypeTemplate? TNK_Type_template : TNK_Function_template; 901ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project } 902ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project}; 90394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 90494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// \brief Perform name lookup on the given name, classifying it based on 905ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// the results of name lookup and the following token. 906ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 907ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// This routine is used by the parser to resolve identifiers and help direct 908ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// parsing. When the identifier cannot be found, this routine will attempt 909ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// to correct the typo and classify based on the resulting name. 91094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// 91194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// \param S The scope in which we're performing name lookup. 912ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 913ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \param SS The nested-name-specifier that precedes the name. 914ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 91594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// \param Name The identifier. If typo correction finds an alternative name, 91694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// this pointer parameter will be updated accordingly. 917ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 918ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \param NameLoc The location of the identifier. 919ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 920ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \param NextToken The token following the identifier. Used to help 921ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// disambiguate the name. 922ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NameClassification ClassifyName(Scope *S, 92394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun CXXScopeSpec &SS, 924ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *&Name, 925ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation NameLoc, 926ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const Token &NextToken); 927ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 928ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnDeclarator(Scope *S, Declarator &D); 929ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 930ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *HandleDeclarator(Scope *S, Declarator &D, 931ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project MultiTemplateParamsArg TemplateParameterLists, 932ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool IsFunctionDefinition); 933ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void RegisterLocallyScopedExternCDecl(NamedDecl *ND, 93494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun const LookupResult &Previous, 935ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Scope *S); 936ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info); 93760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void DiagnoseFunctionSpecifiers(Declarator& D); 938ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R); 939ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void CheckShadow(Scope *S, VarDecl *D); 94094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void CheckCastAlign(Expr *Op, QualType T, SourceRange TRange); 941ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NamedDecl* ActOnTypedefDeclarator(Scope* S, Declarator& D, DeclContext* DC, 942ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType R, TypeSourceInfo *TInfo, 943ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project LookupResult &Previous, bool &Redeclaration); 944ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NamedDecl* ActOnTypedefNameDecl(Scope* S, DeclContext* DC, TypedefNameDecl *D, 945ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project LookupResult &Previous, bool &Redeclaration); 94660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott NamedDecl* ActOnVariableDeclarator(Scope* S, Declarator& D, DeclContext* DC, 94760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott QualType R, TypeSourceInfo *TInfo, 94860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott LookupResult &Previous, 94960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott MultiTemplateParamsArg TemplateParamLists, 950ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool &Redeclaration); 951ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous, 952ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool &Redeclaration); 953ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void CheckCompleteVariableDeclaration(VarDecl *var); 954ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NamedDecl* ActOnFunctionDeclarator(Scope* S, Declarator& D, DeclContext* DC, 955ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType R, TypeSourceInfo *TInfo, 956ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project LookupResult &Previous, 957ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project MultiTemplateParamsArg TemplateParamLists, 958ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool IsFunctionDefinition, 959ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool &Redeclaration); 960ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD); 961ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void DiagnoseHiddenVirtualMethods(CXXRecordDecl *DC, CXXMethodDecl *MD); 962ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void CheckFunctionDeclaration(Scope *S, 963ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FunctionDecl *NewFD, LookupResult &Previous, 964ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool IsExplicitSpecialization, 965ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool &Redeclaration); 966ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void CheckMain(FunctionDecl *FD); 967ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnParamDeclarator(Scope *S, Declarator &D); 968ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParmVarDecl *BuildParmVarDeclForTypedef(DeclContext *DC, 96994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun SourceLocation Loc, 970ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType T); 971ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParmVarDecl *CheckParameter(DeclContext *DC, SourceLocation StartLoc, 972ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation NameLoc, IdentifierInfo *Name, 973ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType T, TypeSourceInfo *TSInfo, 974ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project StorageClass SC, StorageClass SCAsWritten); 97594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void ActOnParamDefaultArgument(Decl *param, 97694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun SourceLocation EqualLoc, 97794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Expr *defarg); 97894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void ActOnParamUnparsedDefaultArgument(Decl *param, 97994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun SourceLocation EqualLoc, 98094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun SourceLocation ArgLoc); 981ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnParamDefaultArgumentError(Decl *param); 982ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, 983ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation EqualLoc); 984ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 98594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, 986ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool TypeMayContainAuto); 987ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto); 988ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnInitializerError(Decl *Dcl); 989ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnCXXForRangeDecl(Decl *D); 990ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void SetDeclDeleted(Decl *dcl, SourceLocation DelLoc); 991ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void FinalizeDeclaration(Decl *D); 992ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, 99394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Decl **Group, 99494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun unsigned NumDecls); 995ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclGroupPtrTy BuildDeclaratorGroup(Decl **Group, unsigned NumDecls, 996ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool TypeMayContainAuto = true); 997ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, 99894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun SourceLocation LocAfterDecls); 99994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void CheckForFunctionRedefinition(FunctionDecl *FD); 1000ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnStartOfFunctionDef(Scope *S, Declarator &D); 1001ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnStartOfFunctionDef(Scope *S, Decl *D); 1002ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnStartOfObjCMethodDef(Scope *S, Decl *D); 1003ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1004ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body); 100594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation); 100694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 1007ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Diagnose any unused parameters in the given sequence of 1008ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// ParmVarDecl pointers. 1009ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void DiagnoseUnusedParameters(ParmVarDecl * const *Begin, 101094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun ParmVarDecl * const *End); 101194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 1012ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \brief Diagnose whether the size of parameters or return value of a 1013ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// function or obj-c method definition is pass-by-value and larger than a 1014ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// specified threshold. 1015ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl * const *Begin, 1016ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ParmVarDecl * const *End, 101760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott QualType ReturnTy, 101860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott NamedDecl *D); 101960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 102060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void DiagnoseInvalidJumps(Stmt *Body); 102160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Decl *ActOnFileScopeAsmDecl(Expr *expr, 102260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SourceLocation AsmLoc, 102360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SourceLocation RParenLoc); 102494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 102560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// Scope actions. 102660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void ActOnPopScope(SourceLocation Loc, Scope *S); 102760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void ActOnTranslationUnitScope(Scope *S); 102860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 1029ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, 1030ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclSpec &DS); 1031ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, 1032ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclSpec &DS, 1033ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project MultiTemplateParamsArg TemplateParams); 1034ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 103594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun StmtResult ActOnVlaStmt(const DeclSpec &DS); 103694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 1037ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, 1038ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project AccessSpecifier AS, 1039ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project RecordDecl *Record); 104094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 104194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Decl *BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, 1042ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project RecordDecl *Record); 1043ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1044ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool isAcceptableTagRedeclaration(const TagDecl *Previous, 1045ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TagTypeKind NewTag, 1046ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation NewTagLoc, 104794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun const IdentifierInfo &Name); 104894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 1049ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project enum TagUseKind { 1050ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TUK_Reference, // Reference to a tag: 'struct foo *X;' 1051ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TUK_Declaration, // Fwd decl of a tag: 'struct foo;' 105294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun TUK_Definition, // Definition of a tag: 'struct foo { int X; } Y;' 105394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun TUK_Friend // Friend declaration: 'friend struct foo;' 1054ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project }; 1055ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1056ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, 1057ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation KWLoc, CXXScopeSpec &SS, 1058ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *Name, SourceLocation NameLoc, 1059ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project AttributeList *Attr, AccessSpecifier AS, 1060ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project MultiTemplateParamsArg TemplateParameterLists, 1061ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool &OwnedDecl, bool &IsDependent, bool ScopedEnum, 1062ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool ScopedEnumUsesClassTag, TypeResult UnderlyingType); 1063ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1064ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnTemplatedFriendTag(Scope *S, SourceLocation FriendLoc, 1065ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned TagSpec, SourceLocation TagLoc, 106660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott CXXScopeSpec &SS, 1067ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *Name, SourceLocation NameLoc, 1068ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project AttributeList *Attr, 1069ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project MultiTemplateParamsArg TempParamLists); 1070ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1071ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeResult ActOnDependentTag(Scope *S, 1072ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project unsigned TagSpec, 1073ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TagUseKind TUK, 1074ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project const CXXScopeSpec &SS, 1075ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *Name, 1076ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation TagLoc, 1077ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation NameLoc); 1078ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 107994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, 1080ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *ClassName, 1081ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVectorImpl<Decl *> &Decls); 1082ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, 108360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Declarator &D, Expr *BitfieldWidth); 108460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 1085ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FieldDecl *HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, 108660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Declarator &D, Expr *BitfieldWidth, 108760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott AccessSpecifier AS); 108860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 1089ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FieldDecl *CheckFieldDecl(DeclarationName Name, QualType T, 1090ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeSourceInfo *TInfo, 1091ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project RecordDecl *Record, SourceLocation Loc, 1092ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool Mutable, Expr *BitfieldWidth, 109360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SourceLocation TSSL, 1094ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project AccessSpecifier AS, NamedDecl *PrevDecl, 1095ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Declarator *D = 0); 1096ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1097ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project enum CXXSpecialMember { 1098ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CXXInvalid = -1, 1099ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CXXConstructor = 0, 110060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott CXXCopyConstructor = 1, 1101ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CXXCopyAssignment = 2, 1102ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CXXDestructor = 3 1103ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project }; 1104ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool CheckNontrivialField(FieldDecl *FD); 110560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void DiagnoseNontrivial(const RecordType* Record, CXXSpecialMember mem); 1106ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD); 1107ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnLastBitfield(SourceLocation DeclStart, Decl *IntfDecl, 1108ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project llvm::SmallVectorImpl<Decl *> &AllIvarDecls); 1109ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnIvar(Scope *S, SourceLocation DeclStart, Decl *IntfDecl, 1110ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Declarator &D, Expr *BitfieldWidth, 111160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott tok::ObjCKeywordKind visibility); 111260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 111360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott // This is used for both record definitions and ObjC interface declarations. 111460a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void ActOnFields(Scope* S, SourceLocation RecLoc, Decl *TagDecl, 111560a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Decl **Fields, unsigned NumFields, 111660a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott SourceLocation LBrac, SourceLocation RBrac, 111760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott AttributeList *AttrList); 111860a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 111960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// ActOnTagStartDefinition - Invoked when we have entered the 112060a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// scope of a tag's definition (e.g., for an enumeration, class, 112160a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// struct, or union). 112260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void ActOnTagStartDefinition(Scope *S, Decl *TagDecl); 1123ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1124ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a 1125ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// C++ record definition's base-specifiers clause and are starting its 1126ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// member declarations. 112760a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, 1128ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation FinalLoc, 1129ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation LBraceLoc); 1130ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1131ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// ActOnTagFinishDefinition - Invoked once we have finished parsing 113260a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott /// the definition of a tag (enumeration, class, struct, or union). 1133ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, 1134ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation RBraceLoc); 1135ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1136ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// ActOnTagDefinitionError - Invoked when there was an unrecoverable 1137ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// error parsing the definition of a tag. 1138ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnTagDefinitionError(Scope *S, Decl *TagDecl); 113960a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott 1140ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project EnumConstantDecl *CheckEnumConstant(EnumDecl *Enum, 1141ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project EnumConstantDecl *LastEnumConst, 1142ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation IdLoc, 1143ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project IdentifierInfo *Id, 1144ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Expr *val); 1145ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1146ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl *ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, 1147ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation IdLoc, IdentifierInfo *Id, 1148ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project AttributeList *Attrs, 1149ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation EqualLoc, Expr *Val); 1150ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, 1151ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project SourceLocation RBraceLoc, Decl *EnumDecl, 1152ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project Decl **Elements, unsigned NumElements, 115360a4c356ee9ce5e9ccb23347c0381f0436192691Patrick Scott Scope *S, AttributeList *Attr); 1154ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 115594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun DeclContext *getContainingDC(DeclContext *DC); 1156ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1157ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Set the current declaration context until it gets popped. 1158ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void PushDeclContext(Scope *S, DeclContext *DC); 1159ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void PopDeclContext(); 1160ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1161ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// EnterDeclaratorContext - Used when we must lookup names in the context 1162ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// of a declarator's nested name specifier. 1163ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void EnterDeclaratorContext(Scope *S, DeclContext *DC); 1164ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void ExitDeclaratorContext(Scope *S); 1165ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1166ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project DeclContext *getFunctionLevelDeclContext(); 1167ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1168ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// getCurFunctionDecl - If inside of a function body, this returns a pointer 1169ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// to the function decl for the function being parsed. If we're currently 1170ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// in a 'block', this returns the containing context. 1171ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project FunctionDecl *getCurFunctionDecl(); 1172ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1173ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// getCurMethodDecl - If inside of a method body, this returns a pointer to 1174ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// the method decl for the method being parsed. If we're currently 1175ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// in a 'block', this returns the containing context. 1176ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project ObjCMethodDecl *getCurMethodDecl(); 1177ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1178ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method 1179ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// or C function we're in, otherwise return null. If we're currently 1180ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// in a 'block', this returns the containing context. 1181ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project NamedDecl *getCurFunctionOrMethodDecl(); 1182ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1183ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Add this decl to the scope shadowed decl chains. 1184ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext = true); 1185ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1186ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true 1187ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope returns 1188ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// true if 'D' belongs to the given declaration context. 1189ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// 1190ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// \param ExplicitInstantiationOrSpecialization When true, we are checking 1191ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// whether the declaration is in scope for the purposes of explicit template 1192ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// instantiation or specialization. The default is false. 1193ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S = 0, 1194ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool ExplicitInstantiationOrSpecialization = false); 1195ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1196ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Finds the scope corresponding to the given decl context, if it 1197ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// happens to be an enclosing scope. Otherwise return NULL. 1198ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project static Scope *getScopeForDeclContext(Scope *S, DeclContext *DC); 1199ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1200ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project /// Subroutines of ActOnDeclarator(). 1201ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypedefDecl *ParseTypedefDecl(Scope *S, Declarator &D, QualType T, 1202ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project TypeSourceInfo *TInfo); 1203ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls); 1204ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool MergeFunctionDecl(FunctionDecl *New, Decl *Old); 1205ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old); 1206ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void mergeObjCMethodDecls(ObjCMethodDecl *New, const ObjCMethodDecl *Old); 1207ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void MergeVarDecl(VarDecl *New, LookupResult &OldDecls); 1208ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void MergeVarDeclTypes(VarDecl *New, VarDecl *Old); 1209ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old); 1210ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old); 1211ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project 1212ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project // AssignmentAction - This is used by all the assignment diagnostic functions 121394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun // to represent what is actually causing the operation 121494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun enum AssignmentAction { 121594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Assigning, 121694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Passing, 121794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Returning, 121894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Converting, 121994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Initializing, 122094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Sending, 122194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun AA_Casting 122294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun }; 122394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 122494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// C++ Overloading. 122594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun enum OverloadKind { 122694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// This is a legitimate overload: the existing declarations are 122794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// functions or function templates with different signatures. 122894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Ovl_Overload, 122994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 123094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// This is not an overload because the signature exactly matches 123194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// an existing declaration. 123294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Ovl_Match, 123394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 123494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// This is not an overload because the lookup results contain a 123594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun /// non-function. 123694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Ovl_NonFunction 123794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun }; 123894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun OverloadKind CheckOverload(Scope *S, 123994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun FunctionDecl *New, 124094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun const LookupResult &OldDecls, 124194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun NamedDecl *&OldDecl, 124294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool IsForUsingDecl); 124394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl); 124494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 124594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool TryImplicitConversion(InitializationSequence &Sequence, 124694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun const InitializedEntity &Entity, 124794442ad4107000e6d49f9b85a46a591495a57632Selim Gurun Expr *From, 124894442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool SuppressUserConversions, 124994442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool AllowExplicit, 125094442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool InOverloadResolution, 125194442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool CStyle); 125294442ad4107000e6d49f9b85a46a591495a57632Selim Gurun 125394442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool IsIntegralPromotion(Expr *From, QualType FromType, QualType ToType); 125494442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool IsFloatingPointPromotion(QualType FromType, QualType ToType); 125594442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool IsComplexPromotion(QualType FromType, QualType ToType); 125694442ad4107000e6d49f9b85a46a591495a57632Selim Gurun bool IsPointerConversion(Expr *From, QualType FromType, QualType ToType, 1257ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool InOverloadResolution, 1258ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project QualType& ConvertedType, bool &IncompatibleObjC); 1259ab4e2e90f63db6b1cd8bb2e453cac899ef43d42bThe Android Open Source Project bool isObjCPointerConversion(QualType FromType, QualType ToType, 1260 QualType& ConvertedType, bool &IncompatibleObjC); 1261 bool IsBlockPointerConversion(QualType FromType, QualType ToType, 1262 QualType& ConvertedType); 1263 bool FunctionArgTypesAreEqual(const FunctionProtoType *OldType, 1264 const FunctionProtoType *NewType); 1265 1266 bool CheckPointerConversion(Expr *From, QualType ToType, 1267 CastKind &Kind, 1268 CXXCastPath& BasePath, 1269 bool IgnoreBaseAccess); 1270 bool IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, 1271 bool InOverloadResolution, 1272 QualType &ConvertedType); 1273 bool CheckMemberPointerConversion(Expr *From, QualType ToType, 1274 CastKind &Kind, 1275 CXXCastPath &BasePath, 1276 bool IgnoreBaseAccess); 1277 bool IsQualificationConversion(QualType FromType, QualType ToType, 1278 bool CStyle); 1279 bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType); 1280 1281 1282 ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, 1283 const VarDecl *NRVOCandidate, 1284 QualType ResultType, 1285 Expr *Value); 1286 1287 ExprResult PerformCopyInitialization(const InitializedEntity &Entity, 1288 SourceLocation EqualLoc, 1289 ExprResult Init); 1290 ExprResult PerformObjectArgumentInitialization(Expr *From, 1291 NestedNameSpecifier *Qualifier, 1292 NamedDecl *FoundDecl, 1293 CXXMethodDecl *Method); 1294 1295 ExprResult PerformContextuallyConvertToBool(Expr *From); 1296 ExprResult PerformContextuallyConvertToObjCId(Expr *From); 1297 1298 ExprResult 1299 ConvertToIntegralOrEnumerationType(SourceLocation Loc, Expr *FromE, 1300 const PartialDiagnostic &NotIntDiag, 1301 const PartialDiagnostic &IncompleteDiag, 1302 const PartialDiagnostic &ExplicitConvDiag, 1303 const PartialDiagnostic &ExplicitConvNote, 1304 const PartialDiagnostic &AmbigDiag, 1305 const PartialDiagnostic &AmbigNote, 1306 const PartialDiagnostic &ConvDiag); 1307 1308 ExprResult PerformObjectMemberConversion(Expr *From, 1309 NestedNameSpecifier *Qualifier, 1310 NamedDecl *FoundDecl, 1311 NamedDecl *Member); 1312 1313 // Members have to be NamespaceDecl* or TranslationUnitDecl*. 1314 // TODO: make this is a typesafe union. 1315 typedef llvm::SmallPtrSet<DeclContext *, 16> AssociatedNamespaceSet; 1316 typedef llvm::SmallPtrSet<CXXRecordDecl *, 16> AssociatedClassSet; 1317 1318 void AddOverloadCandidate(NamedDecl *Function, 1319 DeclAccessPair FoundDecl, 1320 Expr **Args, unsigned NumArgs, 1321 OverloadCandidateSet &CandidateSet); 1322 1323 void AddOverloadCandidate(FunctionDecl *Function, 1324 DeclAccessPair FoundDecl, 1325 Expr **Args, unsigned NumArgs, 1326 OverloadCandidateSet& CandidateSet, 1327 bool SuppressUserConversions = false, 1328 bool PartialOverloading = false); 1329 void AddFunctionCandidates(const UnresolvedSetImpl &Functions, 1330 Expr **Args, unsigned NumArgs, 1331 OverloadCandidateSet& CandidateSet, 1332 bool SuppressUserConversions = false); 1333 void AddMethodCandidate(DeclAccessPair FoundDecl, 1334 QualType ObjectType, 1335 Expr::Classification ObjectClassification, 1336 Expr **Args, unsigned NumArgs, 1337 OverloadCandidateSet& CandidateSet, 1338 bool SuppressUserConversion = false); 1339 void AddMethodCandidate(CXXMethodDecl *Method, 1340 DeclAccessPair FoundDecl, 1341 CXXRecordDecl *ActingContext, QualType ObjectType, 1342 Expr::Classification ObjectClassification, 1343 Expr **Args, unsigned NumArgs, 1344 OverloadCandidateSet& CandidateSet, 1345 bool SuppressUserConversions = false); 1346 void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, 1347 DeclAccessPair FoundDecl, 1348 CXXRecordDecl *ActingContext, 1349 TemplateArgumentListInfo *ExplicitTemplateArgs, 1350 QualType ObjectType, 1351 Expr::Classification ObjectClassification, 1352 Expr **Args, unsigned NumArgs, 1353 OverloadCandidateSet& CandidateSet, 1354 bool SuppressUserConversions = false); 1355 void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, 1356 DeclAccessPair FoundDecl, 1357 TemplateArgumentListInfo *ExplicitTemplateArgs, 1358 Expr **Args, unsigned NumArgs, 1359 OverloadCandidateSet& CandidateSet, 1360 bool SuppressUserConversions = false); 1361 void AddConversionCandidate(CXXConversionDecl *Conversion, 1362 DeclAccessPair FoundDecl, 1363 CXXRecordDecl *ActingContext, 1364 Expr *From, QualType ToType, 1365 OverloadCandidateSet& CandidateSet); 1366 void AddTemplateConversionCandidate(FunctionTemplateDecl *FunctionTemplate, 1367 DeclAccessPair FoundDecl, 1368 CXXRecordDecl *ActingContext, 1369 Expr *From, QualType ToType, 1370 OverloadCandidateSet &CandidateSet); 1371 void AddSurrogateCandidate(CXXConversionDecl *Conversion, 1372 DeclAccessPair FoundDecl, 1373 CXXRecordDecl *ActingContext, 1374 const FunctionProtoType *Proto, 1375 Expr *Object, Expr **Args, unsigned NumArgs, 1376 OverloadCandidateSet& CandidateSet); 1377 void AddMemberOperatorCandidates(OverloadedOperatorKind Op, 1378 SourceLocation OpLoc, 1379 Expr **Args, unsigned NumArgs, 1380 OverloadCandidateSet& CandidateSet, 1381 SourceRange OpRange = SourceRange()); 1382 void AddBuiltinCandidate(QualType ResultTy, QualType *ParamTys, 1383 Expr **Args, unsigned NumArgs, 1384 OverloadCandidateSet& CandidateSet, 1385 bool IsAssignmentOperator = false, 1386 unsigned NumContextualBoolArguments = 0); 1387 void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, 1388 SourceLocation OpLoc, 1389 Expr **Args, unsigned NumArgs, 1390 OverloadCandidateSet& CandidateSet); 1391 void AddArgumentDependentLookupCandidates(DeclarationName Name, 1392 bool Operator, 1393 Expr **Args, unsigned NumArgs, 1394 TemplateArgumentListInfo *ExplicitTemplateArgs, 1395 OverloadCandidateSet& CandidateSet, 1396 bool PartialOverloading = false, 1397 bool StdNamespaceIsAssociated = false); 1398 1399 // Emit as a 'note' the specific overload candidate 1400 void NoteOverloadCandidate(FunctionDecl *Fn); 1401 1402 // Emit as a series of 'note's all template and non-templates 1403 // identified by the expression Expr 1404 void NoteAllOverloadCandidates(Expr* E); 1405 1406 // [PossiblyAFunctionType] --> [Return] 1407 // NonFunctionType --> NonFunctionType 1408 // R (A) --> R(A) 1409 // R (*)(A) --> R (A) 1410 // R (&)(A) --> R (A) 1411 // R (S::*)(A) --> R (A) 1412 QualType ExtractUnqualifiedFunctionType(QualType PossiblyAFunctionType); 1413 1414 FunctionDecl *ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, 1415 bool Complain, 1416 DeclAccessPair &Found); 1417 1418 FunctionDecl *ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, 1419 bool Complain = false, 1420 DeclAccessPair* Found = 0); 1421 1422 ExprResult ResolveAndFixSingleFunctionTemplateSpecialization( 1423 Expr *SrcExpr, bool DoFunctionPointerConverion = false, 1424 bool Complain = false, 1425 const SourceRange& OpRangeForComplaining = SourceRange(), 1426 QualType DestTypeForComplaining = QualType(), 1427 unsigned DiagIDForComplaining = 0); 1428 1429 1430 Expr *FixOverloadedFunctionReference(Expr *E, 1431 DeclAccessPair FoundDecl, 1432 FunctionDecl *Fn); 1433 ExprResult FixOverloadedFunctionReference(ExprResult, 1434 DeclAccessPair FoundDecl, 1435 FunctionDecl *Fn); 1436 1437 void AddOverloadedCallCandidates(UnresolvedLookupExpr *ULE, 1438 Expr **Args, unsigned NumArgs, 1439 OverloadCandidateSet &CandidateSet, 1440 bool PartialOverloading = false); 1441 1442 ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, 1443 UnresolvedLookupExpr *ULE, 1444 SourceLocation LParenLoc, 1445 Expr **Args, unsigned NumArgs, 1446 SourceLocation RParenLoc, 1447 Expr *ExecConfig); 1448 1449 ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, 1450 unsigned Opc, 1451 const UnresolvedSetImpl &Fns, 1452 Expr *input); 1453 1454 ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, 1455 unsigned Opc, 1456 const UnresolvedSetImpl &Fns, 1457 Expr *LHS, Expr *RHS); 1458 1459 ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, 1460 SourceLocation RLoc, 1461 Expr *Base,Expr *Idx); 1462 1463 ExprResult 1464 BuildCallToMemberFunction(Scope *S, Expr *MemExpr, 1465 SourceLocation LParenLoc, Expr **Args, 1466 unsigned NumArgs, SourceLocation RParenLoc); 1467 ExprResult 1468 BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, 1469 Expr **Args, unsigned NumArgs, 1470 SourceLocation RParenLoc); 1471 1472 ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, 1473 SourceLocation OpLoc); 1474 1475 /// CheckCallReturnType - Checks that a call expression's return type is 1476 /// complete. Returns true on failure. The location passed in is the location 1477 /// that best represents the call. 1478 bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, 1479 CallExpr *CE, FunctionDecl *FD); 1480 1481 /// Helpers for dealing with blocks and functions. 1482 bool CheckParmsForFunctionDef(ParmVarDecl **Param, ParmVarDecl **ParamEnd, 1483 bool CheckParameterNames); 1484 void CheckCXXDefaultArguments(FunctionDecl *FD); 1485 void CheckExtraCXXDefaultArguments(Declarator &D); 1486 Scope *getNonFieldDeclScope(Scope *S); 1487 1488 /// \name Name lookup 1489 /// 1490 /// These routines provide name lookup that is used during semantic 1491 /// analysis to resolve the various kinds of names (identifiers, 1492 /// overloaded operator names, constructor names, etc.) into zero or 1493 /// more declarations within a particular scope. The major entry 1494 /// points are LookupName, which performs unqualified name lookup, 1495 /// and LookupQualifiedName, which performs qualified name lookup. 1496 /// 1497 /// All name lookup is performed based on some specific criteria, 1498 /// which specify what names will be visible to name lookup and how 1499 /// far name lookup should work. These criteria are important both 1500 /// for capturing language semantics (certain lookups will ignore 1501 /// certain names, for example) and for performance, since name 1502 /// lookup is often a bottleneck in the compilation of C++. Name 1503 /// lookup criteria is specified via the LookupCriteria enumeration. 1504 /// 1505 /// The results of name lookup can vary based on the kind of name 1506 /// lookup performed, the current language, and the translation 1507 /// unit. In C, for example, name lookup will either return nothing 1508 /// (no entity found) or a single declaration. In C++, name lookup 1509 /// can additionally refer to a set of overloaded functions or 1510 /// result in an ambiguity. All of the possible results of name 1511 /// lookup are captured by the LookupResult class, which provides 1512 /// the ability to distinguish among them. 1513 //@{ 1514 1515 /// @brief Describes the kind of name lookup to perform. 1516 enum LookupNameKind { 1517 /// Ordinary name lookup, which finds ordinary names (functions, 1518 /// variables, typedefs, etc.) in C and most kinds of names 1519 /// (functions, variables, members, types, etc.) in C++. 1520 LookupOrdinaryName = 0, 1521 /// Tag name lookup, which finds the names of enums, classes, 1522 /// structs, and unions. 1523 LookupTagName, 1524 /// Label name lookup. 1525 LookupLabel, 1526 /// Member name lookup, which finds the names of 1527 /// class/struct/union members. 1528 LookupMemberName, 1529 /// Look up of an operator name (e.g., operator+) for use with 1530 /// operator overloading. This lookup is similar to ordinary name 1531 /// lookup, but will ignore any declarations that are class members. 1532 LookupOperatorName, 1533 /// Look up of a name that precedes the '::' scope resolution 1534 /// operator in C++. This lookup completely ignores operator, object, 1535 /// function, and enumerator names (C++ [basic.lookup.qual]p1). 1536 LookupNestedNameSpecifierName, 1537 /// Look up a namespace name within a C++ using directive or 1538 /// namespace alias definition, ignoring non-namespace names (C++ 1539 /// [basic.lookup.udir]p1). 1540 LookupNamespaceName, 1541 /// Look up all declarations in a scope with the given name, 1542 /// including resolved using declarations. This is appropriate 1543 /// for checking redeclarations for a using declaration. 1544 LookupUsingDeclName, 1545 /// Look up an ordinary name that is going to be redeclared as a 1546 /// name with linkage. This lookup ignores any declarations that 1547 /// are outside of the current scope unless they have linkage. See 1548 /// C99 6.2.2p4-5 and C++ [basic.link]p6. 1549 LookupRedeclarationWithLinkage, 1550 /// Look up the name of an Objective-C protocol. 1551 LookupObjCProtocolName, 1552 /// \brief Look up any declaration with any name. 1553 LookupAnyName 1554 }; 1555 1556 /// \brief Specifies whether (or how) name lookup is being performed for a 1557 /// redeclaration (vs. a reference). 1558 enum RedeclarationKind { 1559 /// \brief The lookup is a reference to this name that is not for the 1560 /// purpose of redeclaring the name. 1561 NotForRedeclaration = 0, 1562 /// \brief The lookup results will be used for redeclaration of a name, 1563 /// if an entity by that name already exists. 1564 ForRedeclaration 1565 }; 1566 1567private: 1568 bool CppLookupName(LookupResult &R, Scope *S); 1569 1570public: 1571 /// \brief Look up a name, looking for a single declaration. Return 1572 /// null if the results were absent, ambiguous, or overloaded. 1573 /// 1574 /// It is preferable to use the elaborated form and explicitly handle 1575 /// ambiguity and overloaded. 1576 NamedDecl *LookupSingleName(Scope *S, DeclarationName Name, 1577 SourceLocation Loc, 1578 LookupNameKind NameKind, 1579 RedeclarationKind Redecl 1580 = NotForRedeclaration); 1581 bool LookupName(LookupResult &R, Scope *S, 1582 bool AllowBuiltinCreation = false); 1583 bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, 1584 bool InUnqualifiedLookup = false); 1585 bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, 1586 bool AllowBuiltinCreation = false, 1587 bool EnteringContext = false); 1588 ObjCProtocolDecl *LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc); 1589 1590 void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, 1591 QualType T1, QualType T2, 1592 UnresolvedSetImpl &Functions); 1593 1594 LabelDecl *LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, 1595 SourceLocation GnuLabelLoc = SourceLocation()); 1596 1597 DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class); 1598 CXXDestructorDecl *LookupDestructor(CXXRecordDecl *Class); 1599 1600 void ArgumentDependentLookup(DeclarationName Name, bool Operator, 1601 Expr **Args, unsigned NumArgs, 1602 ADLResult &Functions, 1603 bool StdNamespaceIsAssociated = false); 1604 1605 void LookupVisibleDecls(Scope *S, LookupNameKind Kind, 1606 VisibleDeclConsumer &Consumer, 1607 bool IncludeGlobalScope = true); 1608 void LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind, 1609 VisibleDeclConsumer &Consumer, 1610 bool IncludeGlobalScope = true); 1611 1612 /// \brief The context in which typo-correction occurs. 1613 /// 1614 /// The typo-correction context affects which keywords (if any) are 1615 /// considered when trying to correct for typos. 1616 enum CorrectTypoContext { 1617 /// \brief An unknown context, where any keyword might be valid. 1618 CTC_Unknown, 1619 /// \brief A context where no keywords are used (e.g. we expect an actual 1620 /// name). 1621 CTC_NoKeywords, 1622 /// \brief A context where we're correcting a type name. 1623 CTC_Type, 1624 /// \brief An expression context. 1625 CTC_Expression, 1626 /// \brief A type cast, or anything else that can be followed by a '<'. 1627 CTC_CXXCasts, 1628 /// \brief A member lookup context. 1629 CTC_MemberLookup, 1630 /// \brief An Objective-C ivar lookup context (e.g., self->ivar). 1631 CTC_ObjCIvarLookup, 1632 /// \brief An Objective-C property lookup context (e.g., self.prop). 1633 CTC_ObjCPropertyLookup, 1634 /// \brief The receiver of an Objective-C message send within an 1635 /// Objective-C method where 'super' is a valid keyword. 1636 CTC_ObjCMessageReceiver 1637 }; 1638 1639 DeclarationName CorrectTypo(LookupResult &R, Scope *S, CXXScopeSpec *SS, 1640 DeclContext *MemberContext = 0, 1641 bool EnteringContext = false, 1642 CorrectTypoContext CTC = CTC_Unknown, 1643 const ObjCObjectPointerType *OPT = 0); 1644 1645 void FindAssociatedClassesAndNamespaces(Expr **Args, unsigned NumArgs, 1646 AssociatedNamespaceSet &AssociatedNamespaces, 1647 AssociatedClassSet &AssociatedClasses); 1648 1649 bool DiagnoseAmbiguousLookup(LookupResult &Result); 1650 //@} 1651 1652 ObjCInterfaceDecl *getObjCInterfaceDecl(IdentifierInfo *&Id, 1653 SourceLocation IdLoc, 1654 bool TypoCorrection = false); 1655 NamedDecl *LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, 1656 Scope *S, bool ForRedeclaration, 1657 SourceLocation Loc); 1658 NamedDecl *ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, 1659 Scope *S); 1660 void AddKnownFunctionAttributes(FunctionDecl *FD); 1661 1662 // More parsing and symbol table subroutines. 1663 1664 // Decl attributes - this routine is the top level dispatcher. 1665 void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD, 1666 bool NonInheritable = true, bool Inheritable = true); 1667 void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, 1668 bool NonInheritable = true, bool Inheritable = true); 1669 1670 bool CheckRegparmAttr(const AttributeList &attr, unsigned &value); 1671 bool CheckCallingConvAttr(const AttributeList &attr, CallingConv &CC); 1672 bool CheckNoReturnAttr(const AttributeList &attr); 1673 1674 void WarnUndefinedMethod(SourceLocation ImpLoc, ObjCMethodDecl *method, 1675 bool &IncompleteImpl, unsigned DiagID); 1676 void WarnConflictingTypedMethods(ObjCMethodDecl *ImpMethod, 1677 ObjCMethodDecl *MethodDecl, 1678 bool IsProtocolMethodDecl); 1679 1680 bool isPropertyReadonly(ObjCPropertyDecl *PropertyDecl, 1681 ObjCInterfaceDecl *IDecl); 1682 1683 typedef llvm::DenseSet<Selector, llvm::DenseMapInfo<Selector> > SelectorSet; 1684 1685 /// CheckProtocolMethodDefs - This routine checks unimplemented 1686 /// methods declared in protocol, and those referenced by it. 1687 /// \param IDecl - Used for checking for methods which may have been 1688 /// inherited. 1689 void CheckProtocolMethodDefs(SourceLocation ImpLoc, 1690 ObjCProtocolDecl *PDecl, 1691 bool& IncompleteImpl, 1692 const SelectorSet &InsMap, 1693 const SelectorSet &ClsMap, 1694 ObjCContainerDecl *CDecl); 1695 1696 /// CheckImplementationIvars - This routine checks if the instance variables 1697 /// listed in the implelementation match those listed in the interface. 1698 void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, 1699 ObjCIvarDecl **Fields, unsigned nIvars, 1700 SourceLocation Loc); 1701 1702 /// \brief Determine whether we can synthesize a provisional ivar for the 1703 /// given name. 1704 ObjCPropertyDecl *canSynthesizeProvisionalIvar(IdentifierInfo *II); 1705 1706 /// \brief Determine whether we can synthesize a provisional ivar for the 1707 /// given property. 1708 bool canSynthesizeProvisionalIvar(ObjCPropertyDecl *Property); 1709 1710 /// ImplMethodsVsClassMethods - This is main routine to warn if any method 1711 /// remains unimplemented in the class or category @implementation. 1712 void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, 1713 ObjCContainerDecl* IDecl, 1714 bool IncompleteImpl = false); 1715 1716 /// DiagnoseUnimplementedProperties - This routine warns on those properties 1717 /// which must be implemented by this implementation. 1718 void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl* IMPDecl, 1719 ObjCContainerDecl *CDecl, 1720 const SelectorSet &InsMap); 1721 1722 /// DefaultSynthesizeProperties - This routine default synthesizes all 1723 /// properties which must be synthesized in class's @implementation. 1724 void DefaultSynthesizeProperties (Scope *S, ObjCImplDecl* IMPDecl, 1725 ObjCInterfaceDecl *IDecl); 1726 1727 /// CollectImmediateProperties - This routine collects all properties in 1728 /// the class and its conforming protocols; but not those it its super class. 1729 void CollectImmediateProperties(ObjCContainerDecl *CDecl, 1730 llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& PropMap, 1731 llvm::DenseMap<IdentifierInfo *, ObjCPropertyDecl*>& SuperPropMap); 1732 1733 1734 /// LookupPropertyDecl - Looks up a property in the current class and all 1735 /// its protocols. 1736 ObjCPropertyDecl *LookupPropertyDecl(const ObjCContainerDecl *CDecl, 1737 IdentifierInfo *II); 1738 1739 /// Called by ActOnProperty to handle @property declarations in 1740 //// class extensions. 1741 Decl *HandlePropertyInClassExtension(Scope *S, 1742 ObjCCategoryDecl *CDecl, 1743 SourceLocation AtLoc, 1744 FieldDeclarator &FD, 1745 Selector GetterSel, 1746 Selector SetterSel, 1747 const bool isAssign, 1748 const bool isReadWrite, 1749 const unsigned Attributes, 1750 bool *isOverridingProperty, 1751 TypeSourceInfo *T, 1752 tok::ObjCKeywordKind MethodImplKind); 1753 1754 /// Called by ActOnProperty and HandlePropertyInClassExtension to 1755 /// handle creating the ObjcPropertyDecl for a category or @interface. 1756 ObjCPropertyDecl *CreatePropertyDecl(Scope *S, 1757 ObjCContainerDecl *CDecl, 1758 SourceLocation AtLoc, 1759 FieldDeclarator &FD, 1760 Selector GetterSel, 1761 Selector SetterSel, 1762 const bool isAssign, 1763 const bool isReadWrite, 1764 const unsigned Attributes, 1765 TypeSourceInfo *T, 1766 tok::ObjCKeywordKind MethodImplKind, 1767 DeclContext *lexicalDC = 0); 1768 1769 /// AtomicPropertySetterGetterRules - This routine enforces the rule (via 1770 /// warning) when atomic property has one but not the other user-declared 1771 /// setter or getter. 1772 void AtomicPropertySetterGetterRules(ObjCImplDecl* IMPDecl, 1773 ObjCContainerDecl* IDecl); 1774 1775 void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID); 1776 1777 /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns 1778 /// true, or false, accordingly. 1779 bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, 1780 const ObjCMethodDecl *PrevMethod, 1781 bool matchBasedOnSizeAndAlignment = false, 1782 bool matchBasedOnStrictEqulity = false); 1783 1784 /// MatchAllMethodDeclarations - Check methods declaraed in interface or 1785 /// or protocol against those declared in their implementations. 1786 void MatchAllMethodDeclarations(const SelectorSet &InsMap, 1787 const SelectorSet &ClsMap, 1788 SelectorSet &InsMapSeen, 1789 SelectorSet &ClsMapSeen, 1790 ObjCImplDecl* IMPDecl, 1791 ObjCContainerDecl* IDecl, 1792 bool &IncompleteImpl, 1793 bool ImmediateClass); 1794 1795private: 1796 /// AddMethodToGlobalPool - Add an instance or factory method to the global 1797 /// pool. See descriptoin of AddInstanceMethodToGlobalPool. 1798 void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance); 1799 1800 /// LookupMethodInGlobalPool - Returns the instance or factory method and 1801 /// optionally warns if there are multiple signatures. 1802 ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R, 1803 bool receiverIdOrClass, 1804 bool warn, bool instance); 1805 1806public: 1807 /// AddInstanceMethodToGlobalPool - All instance methods in a translation 1808 /// unit are added to a global pool. This allows us to efficiently associate 1809 /// a selector with a method declaraation for purposes of typechecking 1810 /// messages sent to "id" (where the class of the object is unknown). 1811 void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) { 1812 AddMethodToGlobalPool(Method, impl, /*instance*/true); 1813 } 1814 1815 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods. 1816 void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false) { 1817 AddMethodToGlobalPool(Method, impl, /*instance*/false); 1818 } 1819 1820 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if 1821 /// there are multiple signatures. 1822 ObjCMethodDecl *LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, 1823 bool receiverIdOrClass=false, 1824 bool warn=true) { 1825 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass, 1826 warn, /*instance*/true); 1827 } 1828 1829 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if 1830 /// there are multiple signatures. 1831 ObjCMethodDecl *LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, 1832 bool receiverIdOrClass=false, 1833 bool warn=true) { 1834 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass, 1835 warn, /*instance*/false); 1836 } 1837 1838 /// LookupImplementedMethodInGlobalPool - Returns the method which has an 1839 /// implementation. 1840 ObjCMethodDecl *LookupImplementedMethodInGlobalPool(Selector Sel); 1841 1842 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require 1843 /// initialization. 1844 void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, 1845 llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars); 1846 1847 //===--------------------------------------------------------------------===// 1848 // Statement Parsing Callbacks: SemaStmt.cpp. 1849public: 1850 class FullExprArg { 1851 public: 1852 FullExprArg(Sema &actions) : E(0) { } 1853 1854 // FIXME: The const_cast here is ugly. RValue references would make this 1855 // much nicer (or we could duplicate a bunch of the move semantics 1856 // emulation code from Ownership.h). 1857 FullExprArg(const FullExprArg& Other) : E(Other.E) {} 1858 1859 ExprResult release() { 1860 return move(E); 1861 } 1862 1863 Expr *get() const { return E; } 1864 1865 Expr *operator->() { 1866 return E; 1867 } 1868 1869 private: 1870 // FIXME: No need to make the entire Sema class a friend when it's just 1871 // Sema::MakeFullExpr that needs access to the constructor below. 1872 friend class Sema; 1873 1874 explicit FullExprArg(Expr *expr) : E(expr) {} 1875 1876 Expr *E; 1877 }; 1878 1879 FullExprArg MakeFullExpr(Expr *Arg) { 1880 return FullExprArg(ActOnFinishFullExpr(Arg).release()); 1881 } 1882 1883 StmtResult ActOnExprStmt(FullExprArg Expr); 1884 1885 StmtResult ActOnNullStmt(SourceLocation SemiLoc, 1886 SourceLocation LeadingEmptyMacroLoc = SourceLocation()); 1887 StmtResult ActOnCompoundStmt(SourceLocation L, SourceLocation R, 1888 MultiStmtArg Elts, 1889 bool isStmtExpr); 1890 StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl, 1891 SourceLocation StartLoc, 1892 SourceLocation EndLoc); 1893 void ActOnForEachDeclStmt(DeclGroupPtrTy Decl); 1894 StmtResult ActOnForEachLValueExpr(Expr *E); 1895 StmtResult ActOnCaseStmt(SourceLocation CaseLoc, Expr *LHSVal, 1896 SourceLocation DotDotDotLoc, Expr *RHSVal, 1897 SourceLocation ColonLoc); 1898 void ActOnCaseStmtBody(Stmt *CaseStmt, Stmt *SubStmt); 1899 1900 StmtResult ActOnDefaultStmt(SourceLocation DefaultLoc, 1901 SourceLocation ColonLoc, 1902 Stmt *SubStmt, Scope *CurScope); 1903 StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, 1904 SourceLocation ColonLoc, Stmt *SubStmt); 1905 1906 StmtResult ActOnIfStmt(SourceLocation IfLoc, 1907 FullExprArg CondVal, Decl *CondVar, 1908 Stmt *ThenVal, 1909 SourceLocation ElseLoc, Stmt *ElseVal); 1910 StmtResult ActOnStartOfSwitchStmt(SourceLocation SwitchLoc, 1911 Expr *Cond, 1912 Decl *CondVar); 1913 StmtResult ActOnFinishSwitchStmt(SourceLocation SwitchLoc, 1914 Stmt *Switch, Stmt *Body); 1915 StmtResult ActOnWhileStmt(SourceLocation WhileLoc, 1916 FullExprArg Cond, 1917 Decl *CondVar, Stmt *Body); 1918 StmtResult ActOnDoStmt(SourceLocation DoLoc, Stmt *Body, 1919 SourceLocation WhileLoc, 1920 SourceLocation CondLParen, Expr *Cond, 1921 SourceLocation CondRParen); 1922 1923 StmtResult ActOnForStmt(SourceLocation ForLoc, 1924 SourceLocation LParenLoc, 1925 Stmt *First, FullExprArg Second, 1926 Decl *SecondVar, 1927 FullExprArg Third, 1928 SourceLocation RParenLoc, 1929 Stmt *Body); 1930 StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, 1931 SourceLocation LParenLoc, 1932 Stmt *First, Expr *Second, 1933 SourceLocation RParenLoc, Stmt *Body); 1934 StmtResult ActOnCXXForRangeStmt(SourceLocation ForLoc, 1935 SourceLocation LParenLoc, Stmt *LoopVar, 1936 SourceLocation ColonLoc, Expr *Collection, 1937 SourceLocation RParenLoc); 1938 StmtResult BuildCXXForRangeStmt(SourceLocation ForLoc, 1939 SourceLocation ColonLoc, 1940 Stmt *RangeDecl, Stmt *BeginEndDecl, 1941 Expr *Cond, Expr *Inc, 1942 Stmt *LoopVarDecl, 1943 SourceLocation RParenLoc); 1944 StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body); 1945 1946 StmtResult ActOnGotoStmt(SourceLocation GotoLoc, 1947 SourceLocation LabelLoc, 1948 LabelDecl *TheDecl); 1949 StmtResult ActOnIndirectGotoStmt(SourceLocation GotoLoc, 1950 SourceLocation StarLoc, 1951 Expr *DestExp); 1952 StmtResult ActOnContinueStmt(SourceLocation ContinueLoc, Scope *CurScope); 1953 StmtResult ActOnBreakStmt(SourceLocation GotoLoc, Scope *CurScope); 1954 1955 const VarDecl *getCopyElisionCandidate(QualType ReturnType, Expr *E, 1956 bool AllowFunctionParameters); 1957 1958 StmtResult ActOnReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); 1959 StmtResult ActOnBlockReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp); 1960 1961 StmtResult ActOnAsmStmt(SourceLocation AsmLoc, 1962 bool IsSimple, bool IsVolatile, 1963 unsigned NumOutputs, unsigned NumInputs, 1964 IdentifierInfo **Names, 1965 MultiExprArg Constraints, 1966 MultiExprArg Exprs, 1967 Expr *AsmString, 1968 MultiExprArg Clobbers, 1969 SourceLocation RParenLoc, 1970 bool MSAsm = false); 1971 1972 1973 VarDecl *BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, 1974 SourceLocation StartLoc, 1975 SourceLocation IdLoc, IdentifierInfo *Id, 1976 bool Invalid = false); 1977 1978 Decl *ActOnObjCExceptionDecl(Scope *S, Declarator &D); 1979 1980 StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, 1981 Decl *Parm, Stmt *Body); 1982 1983 StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body); 1984 1985 StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, 1986 MultiStmtArg Catch, Stmt *Finally); 1987 1988 StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw); 1989 StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, 1990 Scope *CurScope); 1991 StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, 1992 Expr *SynchExpr, 1993 Stmt *SynchBody); 1994 1995 VarDecl *BuildExceptionDeclaration(Scope *S, TypeSourceInfo *TInfo, 1996 SourceLocation StartLoc, 1997 SourceLocation IdLoc, 1998 IdentifierInfo *Id); 1999 Decl *ActOnExceptionDeclarator(Scope *S, Declarator &D); 2000 2001 StmtResult ActOnCXXCatchBlock(SourceLocation CatchLoc, 2002 Decl *ExDecl, Stmt *HandlerBlock); 2003 StmtResult ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock, 2004 MultiStmtArg Handlers); 2005 2006 StmtResult ActOnSEHTryBlock(bool IsCXXTry, // try (true) or __try (false) ? 2007 SourceLocation TryLoc, 2008 Stmt *TryBlock, 2009 Stmt *Handler); 2010 2011 StmtResult ActOnSEHExceptBlock(SourceLocation Loc, 2012 Expr *FilterExpr, 2013 Stmt *Block); 2014 2015 StmtResult ActOnSEHFinallyBlock(SourceLocation Loc, 2016 Stmt *Block); 2017 2018 void DiagnoseReturnInConstructorExceptionHandler(CXXTryStmt *TryBlock); 2019 2020 bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const; 2021 2022 /// \brief If it's a file scoped decl that must warn if not used, keep track 2023 /// of it. 2024 void MarkUnusedFileScopedDecl(const DeclaratorDecl *D); 2025 2026 /// DiagnoseUnusedExprResult - If the statement passed in is an expression 2027 /// whose result is unused, warn. 2028 void DiagnoseUnusedExprResult(const Stmt *S); 2029 void DiagnoseUnusedDecl(const NamedDecl *ND); 2030 2031 ParsingDeclState PushParsingDeclaration() { 2032 return DelayedDiagnostics.pushParsingDecl(); 2033 } 2034 void PopParsingDeclaration(ParsingDeclState state, Decl *decl) { 2035 DelayedDiagnostics::popParsingDecl(*this, state, decl); 2036 } 2037 2038 typedef ProcessingContextState ParsingClassState; 2039 ParsingClassState PushParsingClass() { 2040 return DelayedDiagnostics.pushContext(); 2041 } 2042 void PopParsingClass(ParsingClassState state) { 2043 DelayedDiagnostics.popContext(state); 2044 } 2045 2046 void EmitDeprecationWarning(NamedDecl *D, llvm::StringRef Message, 2047 SourceLocation Loc, 2048 const ObjCInterfaceDecl *UnknownObjCClass=0); 2049 2050 void HandleDelayedDeprecationCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); 2051 2052 //===--------------------------------------------------------------------===// 2053 // Expression Parsing Callbacks: SemaExpr.cpp. 2054 2055 bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, 2056 const ObjCInterfaceDecl *UnknownObjCClass=0); 2057 std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD); 2058 bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, 2059 ObjCMethodDecl *Getter, 2060 SourceLocation Loc); 2061 void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, 2062 Expr **Args, unsigned NumArgs); 2063 2064 void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext); 2065 2066 void PopExpressionEvaluationContext(); 2067 2068 void MarkDeclarationReferenced(SourceLocation Loc, Decl *D); 2069 void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T); 2070 void MarkDeclarationsReferencedInExpr(Expr *E); 2071 2072 /// \brief Conditionally issue a diagnostic based on the current 2073 /// evaluation context. 2074 /// 2075 /// \param stmt - If stmt is non-null, delay reporting the diagnostic until 2076 /// the function body is parsed, and then do a basic reachability analysis to 2077 /// determine if the statement is reachable. If it is unreachable, the 2078 /// diagnostic will not be emitted. 2079 bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *stmt, 2080 const PartialDiagnostic &PD); 2081 2082 // Primary Expressions. 2083 SourceRange getExprRange(Expr *E) const; 2084 2085 ObjCIvarDecl *SynthesizeProvisionalIvar(LookupResult &Lookup, 2086 IdentifierInfo *II, 2087 SourceLocation NameLoc); 2088 2089 ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, UnqualifiedId &Name, 2090 bool HasTrailingLParen, bool IsAddressOfOperand); 2091 2092 bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, 2093 CorrectTypoContext CTC = CTC_Unknown); 2094 2095 ExprResult LookupInObjCMethod(LookupResult &R, Scope *S, IdentifierInfo *II, 2096 bool AllowBuiltinCreation=false); 2097 2098 ExprResult ActOnDependentIdExpression(const CXXScopeSpec &SS, 2099 const DeclarationNameInfo &NameInfo, 2100 bool isAddressOfOperand, 2101 const TemplateArgumentListInfo *TemplateArgs); 2102 2103 ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, 2104 ExprValueKind VK, 2105 SourceLocation Loc, 2106 const CXXScopeSpec *SS = 0); 2107 ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, 2108 ExprValueKind VK, 2109 const DeclarationNameInfo &NameInfo, 2110 const CXXScopeSpec *SS = 0); 2111 ExprResult 2112 BuildAnonymousStructUnionMemberReference(const CXXScopeSpec &SS, 2113 SourceLocation nameLoc, 2114 IndirectFieldDecl *indirectField, 2115 Expr *baseObjectExpr = 0, 2116 SourceLocation opLoc = SourceLocation()); 2117 ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, 2118 LookupResult &R, 2119 const TemplateArgumentListInfo *TemplateArgs); 2120 ExprResult BuildImplicitMemberExpr(const CXXScopeSpec &SS, 2121 LookupResult &R, 2122 const TemplateArgumentListInfo *TemplateArgs, 2123 bool IsDefiniteInstance); 2124 bool UseArgumentDependentLookup(const CXXScopeSpec &SS, 2125 const LookupResult &R, 2126 bool HasTrailingLParen); 2127 2128 ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, 2129 const DeclarationNameInfo &NameInfo); 2130 ExprResult BuildDependentDeclRefExpr(const CXXScopeSpec &SS, 2131 const DeclarationNameInfo &NameInfo, 2132 const TemplateArgumentListInfo *TemplateArgs); 2133 2134 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, 2135 LookupResult &R, 2136 bool ADL); 2137 ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, 2138 const DeclarationNameInfo &NameInfo, 2139 NamedDecl *D); 2140 2141 ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind); 2142 ExprResult ActOnNumericConstant(const Token &); 2143 ExprResult ActOnCharacterConstant(const Token &); 2144 ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *Val); 2145 ExprResult ActOnParenOrParenListExpr(SourceLocation L, 2146 SourceLocation R, 2147 MultiExprArg Val, 2148 ParsedType TypeOfCast = ParsedType()); 2149 2150 /// ActOnStringLiteral - The specified tokens were lexed as pasted string 2151 /// fragments (e.g. "foo" "bar" L"baz"). 2152 ExprResult ActOnStringLiteral(const Token *Toks, unsigned NumToks); 2153 2154 ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, 2155 SourceLocation DefaultLoc, 2156 SourceLocation RParenLoc, 2157 Expr *ControllingExpr, 2158 MultiTypeArg Types, 2159 MultiExprArg Exprs); 2160 ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, 2161 SourceLocation DefaultLoc, 2162 SourceLocation RParenLoc, 2163 Expr *ControllingExpr, 2164 TypeSourceInfo **Types, 2165 Expr **Exprs, 2166 unsigned NumAssocs); 2167 2168 // Binary/Unary Operators. 'Tok' is the token for the operator. 2169 ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, 2170 Expr *InputArg); 2171 ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, 2172 UnaryOperatorKind Opc, Expr *input); 2173 ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, 2174 tok::TokenKind Op, Expr *Input); 2175 2176 ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *T, 2177 SourceLocation OpLoc, 2178 UnaryExprOrTypeTrait ExprKind, 2179 SourceRange R); 2180 ExprResult CreateUnaryExprOrTypeTraitExpr(Expr *E, SourceLocation OpLoc, 2181 UnaryExprOrTypeTrait ExprKind, 2182 SourceRange R); 2183 ExprResult 2184 ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, 2185 UnaryExprOrTypeTrait ExprKind, 2186 bool isType, void *TyOrEx, 2187 const SourceRange &ArgRange); 2188 2189 ExprResult CheckPlaceholderExpr(Expr *E); 2190 bool CheckVecStepExpr(Expr *E, SourceLocation OpLoc, SourceRange R); 2191 2192 bool CheckUnaryExprOrTypeTraitOperand(QualType type, SourceLocation OpLoc, 2193 SourceRange R, 2194 UnaryExprOrTypeTrait ExprKind); 2195 ExprResult ActOnSizeofParameterPackExpr(Scope *S, 2196 SourceLocation OpLoc, 2197 IdentifierInfo &Name, 2198 SourceLocation NameLoc, 2199 SourceLocation RParenLoc); 2200 ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, 2201 tok::TokenKind Kind, Expr *Input); 2202 2203 ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, 2204 Expr *Idx, SourceLocation RLoc); 2205 ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, 2206 Expr *Idx, SourceLocation RLoc); 2207 2208 ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, 2209 SourceLocation OpLoc, bool IsArrow, 2210 CXXScopeSpec &SS, 2211 NamedDecl *FirstQualifierInScope, 2212 const DeclarationNameInfo &NameInfo, 2213 const TemplateArgumentListInfo *TemplateArgs); 2214 2215 ExprResult BuildMemberReferenceExpr(Expr *Base, QualType BaseType, 2216 SourceLocation OpLoc, bool IsArrow, 2217 const CXXScopeSpec &SS, 2218 NamedDecl *FirstQualifierInScope, 2219 LookupResult &R, 2220 const TemplateArgumentListInfo *TemplateArgs, 2221 bool SuppressQualifierCheck = false); 2222 2223 ExprResult LookupMemberExpr(LookupResult &R, ExprResult &Base, 2224 bool &IsArrow, SourceLocation OpLoc, 2225 CXXScopeSpec &SS, 2226 Decl *ObjCImpDecl, 2227 bool HasTemplateArgs); 2228 2229 bool CheckQualifiedMemberReference(Expr *BaseExpr, QualType BaseType, 2230 const CXXScopeSpec &SS, 2231 const LookupResult &R); 2232 2233 ExprResult ActOnDependentMemberExpr(Expr *Base, QualType BaseType, 2234 bool IsArrow, SourceLocation OpLoc, 2235 const CXXScopeSpec &SS, 2236 NamedDecl *FirstQualifierInScope, 2237 const DeclarationNameInfo &NameInfo, 2238 const TemplateArgumentListInfo *TemplateArgs); 2239 2240 ExprResult ActOnMemberAccessExpr(Scope *S, Expr *Base, 2241 SourceLocation OpLoc, 2242 tok::TokenKind OpKind, 2243 CXXScopeSpec &SS, 2244 UnqualifiedId &Member, 2245 Decl *ObjCImpDecl, 2246 bool HasTrailingLParen); 2247 2248 void ActOnDefaultCtorInitializers(Decl *CDtorDecl); 2249 bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, 2250 FunctionDecl *FDecl, 2251 const FunctionProtoType *Proto, 2252 Expr **Args, unsigned NumArgs, 2253 SourceLocation RParenLoc); 2254 2255 /// ActOnCallExpr - Handle a call to Fn with the specified array of arguments. 2256 /// This provides the location of the left/right parens and a list of comma 2257 /// locations. 2258 ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, 2259 MultiExprArg Args, SourceLocation RParenLoc, 2260 Expr *ExecConfig = 0); 2261 ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, 2262 SourceLocation LParenLoc, 2263 Expr **Args, unsigned NumArgs, 2264 SourceLocation RParenLoc, 2265 Expr *ExecConfig = 0); 2266 2267 ExprResult ActOnCUDAExecConfigExpr(Scope *S, SourceLocation LLLLoc, 2268 MultiExprArg ExecConfig, SourceLocation GGGLoc); 2269 2270 ExprResult ActOnCastExpr(Scope *S, SourceLocation LParenLoc, 2271 ParsedType Ty, SourceLocation RParenLoc, 2272 Expr *Op); 2273 ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, 2274 TypeSourceInfo *Ty, 2275 SourceLocation RParenLoc, 2276 Expr *Op); 2277 2278 bool TypeIsVectorType(ParsedType Ty) { 2279 return GetTypeFromParser(Ty)->isVectorType(); 2280 } 2281 2282 ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME); 2283 ExprResult ActOnCastOfParenListExpr(Scope *S, SourceLocation LParenLoc, 2284 SourceLocation RParenLoc, Expr *E, 2285 TypeSourceInfo *TInfo); 2286 2287 ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, 2288 ParsedType Ty, 2289 SourceLocation RParenLoc, 2290 Expr *Op); 2291 2292 ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, 2293 TypeSourceInfo *TInfo, 2294 SourceLocation RParenLoc, 2295 Expr *InitExpr); 2296 2297 ExprResult ActOnInitList(SourceLocation LParenLoc, 2298 MultiExprArg InitList, 2299 SourceLocation RParenLoc); 2300 2301 ExprResult ActOnDesignatedInitializer(Designation &Desig, 2302 SourceLocation Loc, 2303 bool GNUSyntax, 2304 ExprResult Init); 2305 2306 ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, 2307 tok::TokenKind Kind, Expr *LHS, Expr *RHS); 2308 ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, 2309 BinaryOperatorKind Opc, Expr *lhs, Expr *rhs); 2310 ExprResult CreateBuiltinBinOp(SourceLocation TokLoc, 2311 BinaryOperatorKind Opc, Expr *lhs, Expr *rhs); 2312 2313 /// ActOnConditionalOp - Parse a ?: operation. Note that 'LHS' may be null 2314 /// in the case of a the GNU conditional expr extension. 2315 ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, 2316 SourceLocation ColonLoc, 2317 Expr *Cond, Expr *LHS, Expr *RHS); 2318 2319 /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". 2320 ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, 2321 LabelDecl *LD); 2322 2323 ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, 2324 SourceLocation RPLoc); // "({..})" 2325 2326 // __builtin_offsetof(type, identifier(.identifier|[expr])*) 2327 struct OffsetOfComponent { 2328 SourceLocation LocStart, LocEnd; 2329 bool isBrackets; // true if [expr], false if .ident 2330 union { 2331 IdentifierInfo *IdentInfo; 2332 ExprTy *E; 2333 } U; 2334 }; 2335 2336 /// __builtin_offsetof(type, a.b[123][456].c) 2337 ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, 2338 TypeSourceInfo *TInfo, 2339 OffsetOfComponent *CompPtr, 2340 unsigned NumComponents, 2341 SourceLocation RParenLoc); 2342 ExprResult ActOnBuiltinOffsetOf(Scope *S, 2343 SourceLocation BuiltinLoc, 2344 SourceLocation TypeLoc, 2345 ParsedType Arg1, 2346 OffsetOfComponent *CompPtr, 2347 unsigned NumComponents, 2348 SourceLocation RParenLoc); 2349 2350 // __builtin_choose_expr(constExpr, expr1, expr2) 2351 ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, 2352 Expr *cond, Expr *expr1, 2353 Expr *expr2, SourceLocation RPLoc); 2354 2355 // __builtin_va_arg(expr, type) 2356 ExprResult ActOnVAArg(SourceLocation BuiltinLoc, 2357 Expr *expr, ParsedType type, 2358 SourceLocation RPLoc); 2359 ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, 2360 Expr *expr, TypeSourceInfo *TInfo, 2361 SourceLocation RPLoc); 2362 2363 // __null 2364 ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc); 2365 2366 bool CheckCaseExpression(Expr *expr); 2367 2368 //===------------------------- "Block" Extension ------------------------===// 2369 2370 /// ActOnBlockStart - This callback is invoked when a block literal is 2371 /// started. 2372 void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope); 2373 2374 /// ActOnBlockArguments - This callback allows processing of block arguments. 2375 /// If there are no arguments, this is still invoked. 2376 void ActOnBlockArguments(Declarator &ParamInfo, Scope *CurScope); 2377 2378 /// ActOnBlockError - If there is an error parsing a block, this callback 2379 /// is invoked to pop the information about the block from the action impl. 2380 void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope); 2381 2382 /// ActOnBlockStmtExpr - This is called when the body of a block statement 2383 /// literal was successfully completed. ^(int x){...} 2384 ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, 2385 Stmt *Body, Scope *CurScope); 2386 2387 //===---------------------------- C++ Features --------------------------===// 2388 2389 // Act on C++ namespaces 2390 Decl *ActOnStartNamespaceDef(Scope *S, SourceLocation InlineLoc, 2391 SourceLocation NamespaceLoc, 2392 SourceLocation IdentLoc, 2393 IdentifierInfo *Ident, 2394 SourceLocation LBrace, 2395 AttributeList *AttrList); 2396 void ActOnFinishNamespaceDef(Decl *Dcl, SourceLocation RBrace); 2397 2398 NamespaceDecl *getStdNamespace() const; 2399 NamespaceDecl *getOrCreateStdNamespace(); 2400 2401 CXXRecordDecl *getStdBadAlloc() const; 2402 2403 Decl *ActOnUsingDirective(Scope *CurScope, 2404 SourceLocation UsingLoc, 2405 SourceLocation NamespcLoc, 2406 CXXScopeSpec &SS, 2407 SourceLocation IdentLoc, 2408 IdentifierInfo *NamespcName, 2409 AttributeList *AttrList); 2410 2411 void PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir); 2412 2413 Decl *ActOnNamespaceAliasDef(Scope *CurScope, 2414 SourceLocation NamespaceLoc, 2415 SourceLocation AliasLoc, 2416 IdentifierInfo *Alias, 2417 CXXScopeSpec &SS, 2418 SourceLocation IdentLoc, 2419 IdentifierInfo *Ident); 2420 2421 void HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow); 2422 bool CheckUsingShadowDecl(UsingDecl *UD, NamedDecl *Target, 2423 const LookupResult &PreviousDecls); 2424 UsingShadowDecl *BuildUsingShadowDecl(Scope *S, UsingDecl *UD, 2425 NamedDecl *Target); 2426 2427 bool CheckUsingDeclRedeclaration(SourceLocation UsingLoc, 2428 bool isTypeName, 2429 const CXXScopeSpec &SS, 2430 SourceLocation NameLoc, 2431 const LookupResult &Previous); 2432 bool CheckUsingDeclQualifier(SourceLocation UsingLoc, 2433 const CXXScopeSpec &SS, 2434 SourceLocation NameLoc); 2435 2436 NamedDecl *BuildUsingDeclaration(Scope *S, AccessSpecifier AS, 2437 SourceLocation UsingLoc, 2438 CXXScopeSpec &SS, 2439 const DeclarationNameInfo &NameInfo, 2440 AttributeList *AttrList, 2441 bool IsInstantiation, 2442 bool IsTypeName, 2443 SourceLocation TypenameLoc); 2444 2445 bool CheckInheritedConstructorUsingDecl(UsingDecl *UD); 2446 2447 Decl *ActOnUsingDeclaration(Scope *CurScope, 2448 AccessSpecifier AS, 2449 bool HasUsingKeyword, 2450 SourceLocation UsingLoc, 2451 CXXScopeSpec &SS, 2452 UnqualifiedId &Name, 2453 AttributeList *AttrList, 2454 bool IsTypeName, 2455 SourceLocation TypenameLoc); 2456 Decl *ActOnAliasDeclaration(Scope *CurScope, 2457 AccessSpecifier AS, 2458 SourceLocation UsingLoc, 2459 UnqualifiedId &Name, 2460 TypeResult Type); 2461 2462 /// AddCXXDirectInitializerToDecl - This action is called immediately after 2463 /// ActOnDeclarator, when a C++ direct initializer is present. 2464 /// e.g: "int x(1);" 2465 void AddCXXDirectInitializerToDecl(Decl *Dcl, 2466 SourceLocation LParenLoc, 2467 MultiExprArg Exprs, 2468 SourceLocation RParenLoc, 2469 bool TypeMayContainAuto); 2470 2471 /// InitializeVarWithConstructor - Creates an CXXConstructExpr 2472 /// and sets it as the initializer for the the passed in VarDecl. 2473 bool InitializeVarWithConstructor(VarDecl *VD, 2474 CXXConstructorDecl *Constructor, 2475 MultiExprArg Exprs); 2476 2477 /// BuildCXXConstructExpr - Creates a complete call to a constructor, 2478 /// including handling of its default argument expressions. 2479 /// 2480 /// \param ConstructKind - a CXXConstructExpr::ConstructionKind 2481 ExprResult 2482 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, 2483 CXXConstructorDecl *Constructor, MultiExprArg Exprs, 2484 bool RequiresZeroInit, unsigned ConstructKind, 2485 SourceRange ParenRange); 2486 2487 // FIXME: Can re remove this and have the above BuildCXXConstructExpr check if 2488 // the constructor can be elidable? 2489 ExprResult 2490 BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, 2491 CXXConstructorDecl *Constructor, bool Elidable, 2492 MultiExprArg Exprs, bool RequiresZeroInit, 2493 unsigned ConstructKind, 2494 SourceRange ParenRange); 2495 2496 /// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating 2497 /// the default expr if needed. 2498 ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, 2499 FunctionDecl *FD, 2500 ParmVarDecl *Param); 2501 2502 /// FinalizeVarWithDestructor - Prepare for calling destructor on the 2503 /// constructed variable. 2504 void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType); 2505 2506 /// \brief Declare the implicit default constructor for the given class. 2507 /// 2508 /// \param ClassDecl The class declaration into which the implicit 2509 /// default constructor will be added. 2510 /// 2511 /// \returns The implicitly-declared default constructor. 2512 CXXConstructorDecl *DeclareImplicitDefaultConstructor( 2513 CXXRecordDecl *ClassDecl); 2514 2515 /// DefineImplicitDefaultConstructor - Checks for feasibility of 2516 /// defining this constructor as the default constructor. 2517 void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, 2518 CXXConstructorDecl *Constructor); 2519 2520 /// \brief Declare the implicit destructor for the given class. 2521 /// 2522 /// \param ClassDecl The class declaration into which the implicit 2523 /// destructor will be added. 2524 /// 2525 /// \returns The implicitly-declared destructor. 2526 CXXDestructorDecl *DeclareImplicitDestructor(CXXRecordDecl *ClassDecl); 2527 2528 /// DefineImplicitDestructor - Checks for feasibility of 2529 /// defining this destructor as the default destructor. 2530 void DefineImplicitDestructor(SourceLocation CurrentLocation, 2531 CXXDestructorDecl *Destructor); 2532 2533 /// \brief Declare all inherited constructors for the given class. 2534 /// 2535 /// \param ClassDecl The class declaration into which the inherited 2536 /// constructors will be added. 2537 void DeclareInheritedConstructors(CXXRecordDecl *ClassDecl); 2538 2539 /// \brief Declare the implicit copy constructor for the given class. 2540 /// 2541 /// \param S The scope of the class, which may be NULL if this is a 2542 /// template instantiation. 2543 /// 2544 /// \param ClassDecl The class declaration into which the implicit 2545 /// copy constructor will be added. 2546 /// 2547 /// \returns The implicitly-declared copy constructor. 2548 CXXConstructorDecl *DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl); 2549 2550 /// DefineImplicitCopyConstructor - Checks for feasibility of 2551 /// defining this constructor as the copy constructor. 2552 void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, 2553 CXXConstructorDecl *Constructor, 2554 unsigned TypeQuals); 2555 2556 /// \brief Declare the implicit copy assignment operator for the given class. 2557 /// 2558 /// \param S The scope of the class, which may be NULL if this is a 2559 /// template instantiation. 2560 /// 2561 /// \param ClassDecl The class declaration into which the implicit 2562 /// copy-assignment operator will be added. 2563 /// 2564 /// \returns The implicitly-declared copy assignment operator. 2565 CXXMethodDecl *DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl); 2566 2567 /// \brief Defined an implicitly-declared copy assignment operator. 2568 void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, 2569 CXXMethodDecl *MethodDecl); 2570 2571 /// \brief Force the declaration of any implicitly-declared members of this 2572 /// class. 2573 void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class); 2574 2575 /// MaybeBindToTemporary - If the passed in expression has a record type with 2576 /// a non-trivial destructor, this will return CXXBindTemporaryExpr. Otherwise 2577 /// it simply returns the passed in expression. 2578 ExprResult MaybeBindToTemporary(Expr *E); 2579 2580 bool CompleteConstructorCall(CXXConstructorDecl *Constructor, 2581 MultiExprArg ArgsPtr, 2582 SourceLocation Loc, 2583 ASTOwningVector<Expr*> &ConvertedArgs); 2584 2585 ParsedType getDestructorName(SourceLocation TildeLoc, 2586 IdentifierInfo &II, SourceLocation NameLoc, 2587 Scope *S, CXXScopeSpec &SS, 2588 ParsedType ObjectType, 2589 bool EnteringContext); 2590 2591 // Checks that reinterpret casts don't have undefined behavior. 2592 void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, 2593 bool IsDereference, SourceRange Range); 2594 2595 /// ActOnCXXNamedCast - Parse {dynamic,static,reinterpret,const}_cast's. 2596 ExprResult ActOnCXXNamedCast(SourceLocation OpLoc, 2597 tok::TokenKind Kind, 2598 SourceLocation LAngleBracketLoc, 2599 ParsedType Ty, 2600 SourceLocation RAngleBracketLoc, 2601 SourceLocation LParenLoc, 2602 Expr *E, 2603 SourceLocation RParenLoc); 2604 2605 ExprResult BuildCXXNamedCast(SourceLocation OpLoc, 2606 tok::TokenKind Kind, 2607 TypeSourceInfo *Ty, 2608 Expr *E, 2609 SourceRange AngleBrackets, 2610 SourceRange Parens); 2611 2612 ExprResult BuildCXXTypeId(QualType TypeInfoType, 2613 SourceLocation TypeidLoc, 2614 TypeSourceInfo *Operand, 2615 SourceLocation RParenLoc); 2616 ExprResult BuildCXXTypeId(QualType TypeInfoType, 2617 SourceLocation TypeidLoc, 2618 Expr *Operand, 2619 SourceLocation RParenLoc); 2620 2621 /// ActOnCXXTypeid - Parse typeid( something ). 2622 ExprResult ActOnCXXTypeid(SourceLocation OpLoc, 2623 SourceLocation LParenLoc, bool isType, 2624 void *TyOrExpr, 2625 SourceLocation RParenLoc); 2626 2627 ExprResult BuildCXXUuidof(QualType TypeInfoType, 2628 SourceLocation TypeidLoc, 2629 TypeSourceInfo *Operand, 2630 SourceLocation RParenLoc); 2631 ExprResult BuildCXXUuidof(QualType TypeInfoType, 2632 SourceLocation TypeidLoc, 2633 Expr *Operand, 2634 SourceLocation RParenLoc); 2635 2636 /// ActOnCXXUuidof - Parse __uuidof( something ). 2637 ExprResult ActOnCXXUuidof(SourceLocation OpLoc, 2638 SourceLocation LParenLoc, bool isType, 2639 void *TyOrExpr, 2640 SourceLocation RParenLoc); 2641 2642 2643 //// ActOnCXXThis - Parse 'this' pointer. 2644 ExprResult ActOnCXXThis(SourceLocation loc); 2645 2646 /// tryCaptureCXXThis - Try to capture a 'this' pointer. Returns a 2647 /// pointer to an instance method whose 'this' pointer is 2648 /// capturable, or null if this is not possible. 2649 CXXMethodDecl *tryCaptureCXXThis(); 2650 2651 /// ActOnCXXBoolLiteral - Parse {true,false} literals. 2652 ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind); 2653 2654 /// ActOnCXXNullPtrLiteral - Parse 'nullptr'. 2655 ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc); 2656 2657 //// ActOnCXXThrow - Parse throw expressions. 2658 ExprResult ActOnCXXThrow(SourceLocation OpLoc, Expr *expr); 2659 ExprResult CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *E); 2660 2661 /// ActOnCXXTypeConstructExpr - Parse construction of a specified type. 2662 /// Can be interpreted either as function-style casting ("int(x)") 2663 /// or class type construction ("ClassType(x,y,z)") 2664 /// or creation of a value-initialized type ("int()"). 2665 ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, 2666 SourceLocation LParenLoc, 2667 MultiExprArg Exprs, 2668 SourceLocation RParenLoc); 2669 2670 ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, 2671 SourceLocation LParenLoc, 2672 MultiExprArg Exprs, 2673 SourceLocation RParenLoc); 2674 2675 /// ActOnCXXNew - Parsed a C++ 'new' expression. 2676 ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, 2677 SourceLocation PlacementLParen, 2678 MultiExprArg PlacementArgs, 2679 SourceLocation PlacementRParen, 2680 SourceRange TypeIdParens, Declarator &D, 2681 SourceLocation ConstructorLParen, 2682 MultiExprArg ConstructorArgs, 2683 SourceLocation ConstructorRParen); 2684 ExprResult BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, 2685 SourceLocation PlacementLParen, 2686 MultiExprArg PlacementArgs, 2687 SourceLocation PlacementRParen, 2688 SourceRange TypeIdParens, 2689 QualType AllocType, 2690 TypeSourceInfo *AllocTypeInfo, 2691 Expr *ArraySize, 2692 SourceLocation ConstructorLParen, 2693 MultiExprArg ConstructorArgs, 2694 SourceLocation ConstructorRParen, 2695 bool TypeMayContainAuto = true); 2696 2697 bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, 2698 SourceRange R); 2699 bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, 2700 bool UseGlobal, QualType AllocType, bool IsArray, 2701 Expr **PlaceArgs, unsigned NumPlaceArgs, 2702 FunctionDecl *&OperatorNew, 2703 FunctionDecl *&OperatorDelete); 2704 bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, 2705 DeclarationName Name, Expr** Args, 2706 unsigned NumArgs, DeclContext *Ctx, 2707 bool AllowMissing, FunctionDecl *&Operator); 2708 void DeclareGlobalNewDelete(); 2709 void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, 2710 QualType Argument, 2711 bool addMallocAttr = false); 2712 2713 bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, 2714 DeclarationName Name, FunctionDecl* &Operator); 2715 2716 /// ActOnCXXDelete - Parsed a C++ 'delete' expression 2717 ExprResult ActOnCXXDelete(SourceLocation StartLoc, 2718 bool UseGlobal, bool ArrayForm, 2719 Expr *Operand); 2720 2721 DeclResult ActOnCXXConditionDeclaration(Scope *S, Declarator &D); 2722 ExprResult CheckConditionVariable(VarDecl *ConditionVar, 2723 SourceLocation StmtLoc, 2724 bool ConvertToBoolean); 2725 2726 ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, 2727 Expr *Operand, SourceLocation RParen); 2728 ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, 2729 SourceLocation RParen); 2730 2731 /// ActOnUnaryTypeTrait - Parsed one of the unary type trait support 2732 /// pseudo-functions. 2733 ExprResult ActOnUnaryTypeTrait(UnaryTypeTrait OTT, 2734 SourceLocation KWLoc, 2735 ParsedType Ty, 2736 SourceLocation RParen); 2737 2738 ExprResult BuildUnaryTypeTrait(UnaryTypeTrait OTT, 2739 SourceLocation KWLoc, 2740 TypeSourceInfo *T, 2741 SourceLocation RParen); 2742 2743 /// ActOnBinaryTypeTrait - Parsed one of the bianry type trait support 2744 /// pseudo-functions. 2745 ExprResult ActOnBinaryTypeTrait(BinaryTypeTrait OTT, 2746 SourceLocation KWLoc, 2747 ParsedType LhsTy, 2748 ParsedType RhsTy, 2749 SourceLocation RParen); 2750 2751 ExprResult BuildBinaryTypeTrait(BinaryTypeTrait BTT, 2752 SourceLocation KWLoc, 2753 TypeSourceInfo *LhsT, 2754 TypeSourceInfo *RhsT, 2755 SourceLocation RParen); 2756 2757 /// ActOnArrayTypeTrait - Parsed one of the bianry type trait support 2758 /// pseudo-functions. 2759 ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, 2760 SourceLocation KWLoc, 2761 ParsedType LhsTy, 2762 Expr *DimExpr, 2763 SourceLocation RParen); 2764 2765 ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, 2766 SourceLocation KWLoc, 2767 TypeSourceInfo *TSInfo, 2768 Expr *DimExpr, 2769 SourceLocation RParen); 2770 2771 /// ActOnExpressionTrait - Parsed one of the unary type trait support 2772 /// pseudo-functions. 2773 ExprResult ActOnExpressionTrait(ExpressionTrait OET, 2774 SourceLocation KWLoc, 2775 Expr *Queried, 2776 SourceLocation RParen); 2777 2778 ExprResult BuildExpressionTrait(ExpressionTrait OET, 2779 SourceLocation KWLoc, 2780 Expr *Queried, 2781 SourceLocation RParen); 2782 2783 ExprResult ActOnStartCXXMemberReference(Scope *S, 2784 Expr *Base, 2785 SourceLocation OpLoc, 2786 tok::TokenKind OpKind, 2787 ParsedType &ObjectType, 2788 bool &MayBePseudoDestructor); 2789 2790 ExprResult DiagnoseDtorReference(SourceLocation NameLoc, Expr *MemExpr); 2791 2792 ExprResult BuildPseudoDestructorExpr(Expr *Base, 2793 SourceLocation OpLoc, 2794 tok::TokenKind OpKind, 2795 const CXXScopeSpec &SS, 2796 TypeSourceInfo *ScopeType, 2797 SourceLocation CCLoc, 2798 SourceLocation TildeLoc, 2799 PseudoDestructorTypeStorage DestroyedType, 2800 bool HasTrailingLParen); 2801 2802 ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, 2803 SourceLocation OpLoc, 2804 tok::TokenKind OpKind, 2805 CXXScopeSpec &SS, 2806 UnqualifiedId &FirstTypeName, 2807 SourceLocation CCLoc, 2808 SourceLocation TildeLoc, 2809 UnqualifiedId &SecondTypeName, 2810 bool HasTrailingLParen); 2811 2812 /// MaybeCreateExprWithCleanups - If the current full-expression 2813 /// requires any cleanups, surround it with a ExprWithCleanups node. 2814 /// Otherwise, just returns the passed-in expression. 2815 Expr *MaybeCreateExprWithCleanups(Expr *SubExpr); 2816 Stmt *MaybeCreateStmtWithCleanups(Stmt *SubStmt); 2817 ExprResult MaybeCreateExprWithCleanups(ExprResult SubExpr); 2818 2819 ExprResult ActOnFinishFullExpr(Expr *Expr); 2820 StmtResult ActOnFinishFullStmt(Stmt *Stmt); 2821 2822 // Marks SS invalid if it represents an incomplete type. 2823 bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC); 2824 2825 DeclContext *computeDeclContext(QualType T); 2826 DeclContext *computeDeclContext(const CXXScopeSpec &SS, 2827 bool EnteringContext = false); 2828 bool isDependentScopeSpecifier(const CXXScopeSpec &SS); 2829 CXXRecordDecl *getCurrentInstantiationOf(NestedNameSpecifier *NNS); 2830 bool isUnknownSpecialization(const CXXScopeSpec &SS); 2831 2832 /// \brief The parser has parsed a global nested-name-specifier '::'. 2833 /// 2834 /// \param S The scope in which this nested-name-specifier occurs. 2835 /// 2836 /// \param CCLoc The location of the '::'. 2837 /// 2838 /// \param SS The nested-name-specifier, which will be updated in-place 2839 /// to reflect the parsed nested-name-specifier. 2840 /// 2841 /// \returns true if an error occurred, false otherwise. 2842 bool ActOnCXXGlobalScopeSpecifier(Scope *S, SourceLocation CCLoc, 2843 CXXScopeSpec &SS); 2844 2845 bool isAcceptableNestedNameSpecifier(NamedDecl *SD); 2846 NamedDecl *FindFirstQualifierInScope(Scope *S, NestedNameSpecifier *NNS); 2847 2848 bool isNonTypeNestedNameSpecifier(Scope *S, CXXScopeSpec &SS, 2849 SourceLocation IdLoc, 2850 IdentifierInfo &II, 2851 ParsedType ObjectType); 2852 2853 bool BuildCXXNestedNameSpecifier(Scope *S, 2854 IdentifierInfo &Identifier, 2855 SourceLocation IdentifierLoc, 2856 SourceLocation CCLoc, 2857 QualType ObjectType, 2858 bool EnteringContext, 2859 CXXScopeSpec &SS, 2860 NamedDecl *ScopeLookupResult, 2861 bool ErrorRecoveryLookup); 2862 2863 /// \brief The parser has parsed a nested-name-specifier 'identifier::'. 2864 /// 2865 /// \param S The scope in which this nested-name-specifier occurs. 2866 /// 2867 /// \param Identifier The identifier preceding the '::'. 2868 /// 2869 /// \param IdentifierLoc The location of the identifier. 2870 /// 2871 /// \param CCLoc The location of the '::'. 2872 /// 2873 /// \param ObjectType The type of the object, if we're parsing 2874 /// nested-name-specifier in a member access expression. 2875 /// 2876 /// \param EnteringContext Whether we're entering the context nominated by 2877 /// this nested-name-specifier. 2878 /// 2879 /// \param SS The nested-name-specifier, which is both an input 2880 /// parameter (the nested-name-specifier before this type) and an 2881 /// output parameter (containing the full nested-name-specifier, 2882 /// including this new type). 2883 /// 2884 /// \returns true if an error occurred, false otherwise. 2885 bool ActOnCXXNestedNameSpecifier(Scope *S, 2886 IdentifierInfo &Identifier, 2887 SourceLocation IdentifierLoc, 2888 SourceLocation CCLoc, 2889 ParsedType ObjectType, 2890 bool EnteringContext, 2891 CXXScopeSpec &SS); 2892 2893 bool IsInvalidUnlessNestedName(Scope *S, CXXScopeSpec &SS, 2894 IdentifierInfo &Identifier, 2895 SourceLocation IdentifierLoc, 2896 SourceLocation ColonLoc, 2897 ParsedType ObjectType, 2898 bool EnteringContext); 2899 2900 /// \brief The parser has parsed a nested-name-specifier 2901 /// 'template[opt] template-name < template-args >::'. 2902 /// 2903 /// \param S The scope in which this nested-name-specifier occurs. 2904 /// 2905 /// \param TemplateLoc The location of the 'template' keyword, if any. 2906 /// 2907 /// \param SS The nested-name-specifier, which is both an input 2908 /// parameter (the nested-name-specifier before this type) and an 2909 /// output parameter (containing the full nested-name-specifier, 2910 /// including this new type). 2911 /// 2912 /// \param TemplateLoc the location of the 'template' keyword, if any. 2913 /// \param TemplateName The template name. 2914 /// \param TemplateNameLoc The location of the template name. 2915 /// \param LAngleLoc The location of the opening angle bracket ('<'). 2916 /// \param TemplateArgs The template arguments. 2917 /// \param RAngleLoc The location of the closing angle bracket ('>'). 2918 /// \param CCLoc The location of the '::'. 2919 2920 /// \param EnteringContext Whether we're entering the context of the 2921 /// nested-name-specifier. 2922 /// 2923 /// 2924 /// \returns true if an error occurred, false otherwise. 2925 bool ActOnCXXNestedNameSpecifier(Scope *S, 2926 SourceLocation TemplateLoc, 2927 CXXScopeSpec &SS, 2928 TemplateTy Template, 2929 SourceLocation TemplateNameLoc, 2930 SourceLocation LAngleLoc, 2931 ASTTemplateArgsPtr TemplateArgs, 2932 SourceLocation RAngleLoc, 2933 SourceLocation CCLoc, 2934 bool EnteringContext); 2935 2936 /// \brief Given a C++ nested-name-specifier, produce an annotation value 2937 /// that the parser can use later to reconstruct the given 2938 /// nested-name-specifier. 2939 /// 2940 /// \param SS A nested-name-specifier. 2941 /// 2942 /// \returns A pointer containing all of the information in the 2943 /// nested-name-specifier \p SS. 2944 void *SaveNestedNameSpecifierAnnotation(CXXScopeSpec &SS); 2945 2946 /// \brief Given an annotation pointer for a nested-name-specifier, restore 2947 /// the nested-name-specifier structure. 2948 /// 2949 /// \param Annotation The annotation pointer, produced by 2950 /// \c SaveNestedNameSpecifierAnnotation(). 2951 /// 2952 /// \param AnnotationRange The source range corresponding to the annotation. 2953 /// 2954 /// \param SS The nested-name-specifier that will be updated with the contents 2955 /// of the annotation pointer. 2956 void RestoreNestedNameSpecifierAnnotation(void *Annotation, 2957 SourceRange AnnotationRange, 2958 CXXScopeSpec &SS); 2959 2960 bool ShouldEnterDeclaratorScope(Scope *S, const CXXScopeSpec &SS); 2961 2962 /// ActOnCXXEnterDeclaratorScope - Called when a C++ scope specifier (global 2963 /// scope or nested-name-specifier) is parsed, part of a declarator-id. 2964 /// After this method is called, according to [C++ 3.4.3p3], names should be 2965 /// looked up in the declarator-id's scope, until the declarator is parsed and 2966 /// ActOnCXXExitDeclaratorScope is called. 2967 /// The 'SS' should be a non-empty valid CXXScopeSpec. 2968 bool ActOnCXXEnterDeclaratorScope(Scope *S, CXXScopeSpec &SS); 2969 2970 /// ActOnCXXExitDeclaratorScope - Called when a declarator that previously 2971 /// invoked ActOnCXXEnterDeclaratorScope(), is finished. 'SS' is the same 2972 /// CXXScopeSpec that was passed to ActOnCXXEnterDeclaratorScope as well. 2973 /// Used to indicate that names should revert to being looked up in the 2974 /// defining scope. 2975 void ActOnCXXExitDeclaratorScope(Scope *S, const CXXScopeSpec &SS); 2976 2977 /// ActOnCXXEnterDeclInitializer - Invoked when we are about to parse an 2978 /// initializer for the declaration 'Dcl'. 2979 /// After this method is called, according to [C++ 3.4.1p13], if 'Dcl' is a 2980 /// static data member of class X, names should be looked up in the scope of 2981 /// class X. 2982 void ActOnCXXEnterDeclInitializer(Scope *S, Decl *Dcl); 2983 2984 /// ActOnCXXExitDeclInitializer - Invoked after we are finished parsing an 2985 /// initializer for the declaration 'Dcl'. 2986 void ActOnCXXExitDeclInitializer(Scope *S, Decl *Dcl); 2987 2988 // ParseObjCStringLiteral - Parse Objective-C string literals. 2989 ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, 2990 Expr **Strings, 2991 unsigned NumStrings); 2992 2993 Expr *BuildObjCEncodeExpression(SourceLocation AtLoc, 2994 TypeSourceInfo *EncodedTypeInfo, 2995 SourceLocation RParenLoc); 2996 ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, 2997 CXXMethodDecl *Method); 2998 2999 ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, 3000 SourceLocation EncodeLoc, 3001 SourceLocation LParenLoc, 3002 ParsedType Ty, 3003 SourceLocation RParenLoc); 3004 3005 // ParseObjCSelectorExpression - Build selector expression for @selector 3006 ExprResult ParseObjCSelectorExpression(Selector Sel, 3007 SourceLocation AtLoc, 3008 SourceLocation SelLoc, 3009 SourceLocation LParenLoc, 3010 SourceLocation RParenLoc); 3011 3012 // ParseObjCProtocolExpression - Build protocol expression for @protocol 3013 ExprResult ParseObjCProtocolExpression(IdentifierInfo * ProtocolName, 3014 SourceLocation AtLoc, 3015 SourceLocation ProtoLoc, 3016 SourceLocation LParenLoc, 3017 SourceLocation RParenLoc); 3018 3019 //===--------------------------------------------------------------------===// 3020 // C++ Declarations 3021 // 3022 Decl *ActOnStartLinkageSpecification(Scope *S, 3023 SourceLocation ExternLoc, 3024 SourceLocation LangLoc, 3025 llvm::StringRef Lang, 3026 SourceLocation LBraceLoc); 3027 Decl *ActOnFinishLinkageSpecification(Scope *S, 3028 Decl *LinkageSpec, 3029 SourceLocation RBraceLoc); 3030 3031 3032 //===--------------------------------------------------------------------===// 3033 // C++ Classes 3034 // 3035 bool isCurrentClassName(const IdentifierInfo &II, Scope *S, 3036 const CXXScopeSpec *SS = 0); 3037 3038 Decl *ActOnAccessSpecifier(AccessSpecifier Access, 3039 SourceLocation ASLoc, 3040 SourceLocation ColonLoc); 3041 3042 Decl *ActOnCXXMemberDeclarator(Scope *S, AccessSpecifier AS, 3043 Declarator &D, 3044 MultiTemplateParamsArg TemplateParameterLists, 3045 Expr *BitfieldWidth, const VirtSpecifiers &VS, 3046 Expr *Init, bool IsDefinition, 3047 bool Deleted = false); 3048 3049 MemInitResult ActOnMemInitializer(Decl *ConstructorD, 3050 Scope *S, 3051 CXXScopeSpec &SS, 3052 IdentifierInfo *MemberOrBase, 3053 ParsedType TemplateTypeTy, 3054 SourceLocation IdLoc, 3055 SourceLocation LParenLoc, 3056 Expr **Args, unsigned NumArgs, 3057 SourceLocation RParenLoc, 3058 SourceLocation EllipsisLoc); 3059 3060 MemInitResult BuildMemberInitializer(ValueDecl *Member, Expr **Args, 3061 unsigned NumArgs, SourceLocation IdLoc, 3062 SourceLocation LParenLoc, 3063 SourceLocation RParenLoc); 3064 3065 MemInitResult BuildBaseInitializer(QualType BaseType, 3066 TypeSourceInfo *BaseTInfo, 3067 Expr **Args, unsigned NumArgs, 3068 SourceLocation LParenLoc, 3069 SourceLocation RParenLoc, 3070 CXXRecordDecl *ClassDecl, 3071 SourceLocation EllipsisLoc); 3072 3073 MemInitResult BuildDelegatingInitializer(TypeSourceInfo *TInfo, 3074 Expr **Args, unsigned NumArgs, 3075 SourceLocation BaseLoc, 3076 SourceLocation RParenLoc, 3077 SourceLocation LParenLoc, 3078 CXXRecordDecl *ClassDecl); 3079 3080 bool SetDelegatingInitializer(CXXConstructorDecl *Constructor, 3081 CXXCtorInitializer *Initializer); 3082 3083 bool SetCtorInitializers(CXXConstructorDecl *Constructor, 3084 CXXCtorInitializer **Initializers, 3085 unsigned NumInitializers, bool AnyErrors); 3086 3087 void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation); 3088 3089 3090 /// MarkBaseAndMemberDestructorsReferenced - Given a record decl, 3091 /// mark all the non-trivial destructors of its members and bases as 3092 /// referenced. 3093 void MarkBaseAndMemberDestructorsReferenced(SourceLocation Loc, 3094 CXXRecordDecl *Record); 3095 3096 /// \brief The list of classes whose vtables have been used within 3097 /// this translation unit, and the source locations at which the 3098 /// first use occurred. 3099 typedef std::pair<CXXRecordDecl*, SourceLocation> VTableUse; 3100 3101 /// \brief The list of vtables that are required but have not yet been 3102 /// materialized. 3103 llvm::SmallVector<VTableUse, 16> VTableUses; 3104 3105 /// \brief The set of classes whose vtables have been used within 3106 /// this translation unit, and a bit that will be true if the vtable is 3107 /// required to be emitted (otherwise, it should be emitted only if needed 3108 /// by code generation). 3109 llvm::DenseMap<CXXRecordDecl *, bool> VTablesUsed; 3110 3111 /// \brief A list of all of the dynamic classes in this translation 3112 /// unit. 3113 llvm::SmallVector<CXXRecordDecl *, 16> DynamicClasses; 3114 3115 /// \brief Note that the vtable for the given class was used at the 3116 /// given location. 3117 void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, 3118 bool DefinitionRequired = false); 3119 3120 /// MarkVirtualMembersReferenced - Will mark all members of the given 3121 /// CXXRecordDecl referenced. 3122 void MarkVirtualMembersReferenced(SourceLocation Loc, 3123 const CXXRecordDecl *RD); 3124 3125 /// \brief Define all of the vtables that have been used in this 3126 /// translation unit and reference any virtual members used by those 3127 /// vtables. 3128 /// 3129 /// \returns true if any work was done, false otherwise. 3130 bool DefineUsedVTables(); 3131 3132 void AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl); 3133 3134 void ActOnMemInitializers(Decl *ConstructorDecl, 3135 SourceLocation ColonLoc, 3136 MemInitTy **MemInits, unsigned NumMemInits, 3137 bool AnyErrors); 3138 3139 void CheckCompletedCXXClass(CXXRecordDecl *Record); 3140 void ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, 3141 Decl *TagDecl, 3142 SourceLocation LBrac, 3143 SourceLocation RBrac, 3144 AttributeList *AttrList); 3145 3146 void ActOnReenterTemplateScope(Scope *S, Decl *Template); 3147 void ActOnReenterDeclaratorTemplateScope(Scope *S, DeclaratorDecl *D); 3148 void ActOnStartDelayedMemberDeclarations(Scope *S, Decl *Record); 3149 void ActOnStartDelayedCXXMethodDeclaration(Scope *S, Decl *Method); 3150 void ActOnDelayedCXXMethodParameter(Scope *S, Decl *Param); 3151 void ActOnFinishDelayedCXXMethodDeclaration(Scope *S, Decl *Method); 3152 void ActOnFinishDelayedMemberDeclarations(Scope *S, Decl *Record); 3153 void MarkAsLateParsedTemplate(FunctionDecl *FD, bool Flag = true); 3154 bool IsInsideALocalClassWithinATemplateFunction(); 3155 3156 Decl *ActOnStaticAssertDeclaration(SourceLocation StaticAssertLoc, 3157 Expr *AssertExpr, 3158 Expr *AssertMessageExpr, 3159 SourceLocation RParenLoc); 3160 3161 FriendDecl *CheckFriendTypeDecl(SourceLocation FriendLoc, 3162 TypeSourceInfo *TSInfo); 3163 Decl *ActOnFriendTypeDecl(Scope *S, const DeclSpec &DS, 3164 MultiTemplateParamsArg TemplateParams); 3165 Decl *ActOnFriendFunctionDecl(Scope *S, Declarator &D, bool IsDefinition, 3166 MultiTemplateParamsArg TemplateParams); 3167 3168 QualType CheckConstructorDeclarator(Declarator &D, QualType R, 3169 StorageClass& SC); 3170 void CheckConstructor(CXXConstructorDecl *Constructor); 3171 QualType CheckDestructorDeclarator(Declarator &D, QualType R, 3172 StorageClass& SC); 3173 bool CheckDestructor(CXXDestructorDecl *Destructor); 3174 void CheckConversionDeclarator(Declarator &D, QualType &R, 3175 StorageClass& SC); 3176 Decl *ActOnConversionDeclarator(CXXConversionDecl *Conversion); 3177 3178 //===--------------------------------------------------------------------===// 3179 // C++ Derived Classes 3180 // 3181 3182 /// ActOnBaseSpecifier - Parsed a base specifier 3183 CXXBaseSpecifier *CheckBaseSpecifier(CXXRecordDecl *Class, 3184 SourceRange SpecifierRange, 3185 bool Virtual, AccessSpecifier Access, 3186 TypeSourceInfo *TInfo, 3187 SourceLocation EllipsisLoc); 3188 3189 BaseResult ActOnBaseSpecifier(Decl *classdecl, 3190 SourceRange SpecifierRange, 3191 bool Virtual, AccessSpecifier Access, 3192 ParsedType basetype, 3193 SourceLocation BaseLoc, 3194 SourceLocation EllipsisLoc); 3195 3196 bool AttachBaseSpecifiers(CXXRecordDecl *Class, CXXBaseSpecifier **Bases, 3197 unsigned NumBases); 3198 void ActOnBaseSpecifiers(Decl *ClassDecl, BaseTy **Bases, unsigned NumBases); 3199 3200 bool IsDerivedFrom(QualType Derived, QualType Base); 3201 bool IsDerivedFrom(QualType Derived, QualType Base, CXXBasePaths &Paths); 3202 3203 // FIXME: I don't like this name. 3204 void BuildBasePathArray(const CXXBasePaths &Paths, CXXCastPath &BasePath); 3205 3206 bool BasePathInvolvesVirtualBase(const CXXCastPath &BasePath); 3207 3208 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, 3209 SourceLocation Loc, SourceRange Range, 3210 CXXCastPath *BasePath = 0, 3211 bool IgnoreAccess = false); 3212 bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, 3213 unsigned InaccessibleBaseID, 3214 unsigned AmbigiousBaseConvID, 3215 SourceLocation Loc, SourceRange Range, 3216 DeclarationName Name, 3217 CXXCastPath *BasePath); 3218 3219 std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths); 3220 3221 /// CheckOverridingFunctionReturnType - Checks whether the return types are 3222 /// covariant, according to C++ [class.virtual]p5. 3223 bool CheckOverridingFunctionReturnType(const CXXMethodDecl *New, 3224 const CXXMethodDecl *Old); 3225 3226 /// CheckOverridingFunctionExceptionSpec - Checks whether the exception 3227 /// spec is a subset of base spec. 3228 bool CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New, 3229 const CXXMethodDecl *Old); 3230 3231 bool CheckPureMethod(CXXMethodDecl *Method, SourceRange InitRange); 3232 3233 /// CheckOverrideControl - Check C++0x override control semantics. 3234 void CheckOverrideControl(const Decl *D); 3235 3236 /// CheckForFunctionMarkedFinal - Checks whether a virtual member function 3237 /// overrides a virtual member function marked 'final', according to 3238 /// C++0x [class.virtual]p3. 3239 bool CheckIfOverriddenFunctionIsMarkedFinal(const CXXMethodDecl *New, 3240 const CXXMethodDecl *Old); 3241 3242 3243 //===--------------------------------------------------------------------===// 3244 // C++ Access Control 3245 // 3246 3247 enum AccessResult { 3248 AR_accessible, 3249 AR_inaccessible, 3250 AR_dependent, 3251 AR_delayed 3252 }; 3253 3254 bool SetMemberAccessSpecifier(NamedDecl *MemberDecl, 3255 NamedDecl *PrevMemberDecl, 3256 AccessSpecifier LexicalAS); 3257 3258 AccessResult CheckUnresolvedMemberAccess(UnresolvedMemberExpr *E, 3259 DeclAccessPair FoundDecl); 3260 AccessResult CheckUnresolvedLookupAccess(UnresolvedLookupExpr *E, 3261 DeclAccessPair FoundDecl); 3262 AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, 3263 SourceRange PlacementRange, 3264 CXXRecordDecl *NamingClass, 3265 DeclAccessPair FoundDecl); 3266 AccessResult CheckConstructorAccess(SourceLocation Loc, 3267 CXXConstructorDecl *D, 3268 const InitializedEntity &Entity, 3269 AccessSpecifier Access, 3270 bool IsCopyBindingRefToTemp = false); 3271 AccessResult CheckDestructorAccess(SourceLocation Loc, 3272 CXXDestructorDecl *Dtor, 3273 const PartialDiagnostic &PDiag); 3274 AccessResult CheckDirectMemberAccess(SourceLocation Loc, 3275 NamedDecl *D, 3276 const PartialDiagnostic &PDiag); 3277 AccessResult CheckMemberOperatorAccess(SourceLocation Loc, 3278 Expr *ObjectExpr, 3279 Expr *ArgExpr, 3280 DeclAccessPair FoundDecl); 3281 AccessResult CheckAddressOfMemberAccess(Expr *OvlExpr, 3282 DeclAccessPair FoundDecl); 3283 AccessResult CheckBaseClassAccess(SourceLocation AccessLoc, 3284 QualType Base, QualType Derived, 3285 const CXXBasePath &Path, 3286 unsigned DiagID, 3287 bool ForceCheck = false, 3288 bool ForceUnprivileged = false); 3289 void CheckLookupAccess(const LookupResult &R); 3290 3291 void HandleDependentAccessCheck(const DependentDiagnostic &DD, 3292 const MultiLevelTemplateArgumentList &TemplateArgs); 3293 void PerformDependentDiagnostics(const DeclContext *Pattern, 3294 const MultiLevelTemplateArgumentList &TemplateArgs); 3295 3296 void HandleDelayedAccessCheck(sema::DelayedDiagnostic &DD, Decl *Ctx); 3297 3298 /// A flag to suppress access checking. 3299 bool SuppressAccessChecking; 3300 3301 /// \brief When true, access checking violations are treated as SFINAE 3302 /// failures rather than hard errors. 3303 bool AccessCheckingSFINAE; 3304 3305 void ActOnStartSuppressingAccessChecks(); 3306 void ActOnStopSuppressingAccessChecks(); 3307 3308 enum AbstractDiagSelID { 3309 AbstractNone = -1, 3310 AbstractReturnType, 3311 AbstractParamType, 3312 AbstractVariableType, 3313 AbstractFieldType, 3314 AbstractArrayType 3315 }; 3316 3317 bool RequireNonAbstractType(SourceLocation Loc, QualType T, 3318 const PartialDiagnostic &PD); 3319 void DiagnoseAbstractType(const CXXRecordDecl *RD); 3320 3321 bool RequireNonAbstractType(SourceLocation Loc, QualType T, unsigned DiagID, 3322 AbstractDiagSelID SelID = AbstractNone); 3323 3324 //===--------------------------------------------------------------------===// 3325 // C++ Overloaded Operators [C++ 13.5] 3326 // 3327 3328 bool CheckOverloadedOperatorDeclaration(FunctionDecl *FnDecl); 3329 3330 bool CheckLiteralOperatorDeclaration(FunctionDecl *FnDecl); 3331 3332 //===--------------------------------------------------------------------===// 3333 // C++ Templates [C++ 14] 3334 // 3335 void FilterAcceptableTemplateNames(LookupResult &R); 3336 bool hasAnyAcceptableTemplateNames(LookupResult &R); 3337 3338 void LookupTemplateName(LookupResult &R, Scope *S, CXXScopeSpec &SS, 3339 QualType ObjectType, bool EnteringContext, 3340 bool &MemberOfUnknownSpecialization); 3341 3342 TemplateNameKind isTemplateName(Scope *S, 3343 CXXScopeSpec &SS, 3344 bool hasTemplateKeyword, 3345 UnqualifiedId &Name, 3346 ParsedType ObjectType, 3347 bool EnteringContext, 3348 TemplateTy &Template, 3349 bool &MemberOfUnknownSpecialization); 3350 3351 bool DiagnoseUnknownTemplateName(const IdentifierInfo &II, 3352 SourceLocation IILoc, 3353 Scope *S, 3354 const CXXScopeSpec *SS, 3355 TemplateTy &SuggestedTemplate, 3356 TemplateNameKind &SuggestedKind); 3357 3358 bool DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl); 3359 TemplateDecl *AdjustDeclIfTemplate(Decl *&Decl); 3360 3361 Decl *ActOnTypeParameter(Scope *S, bool Typename, bool Ellipsis, 3362 SourceLocation EllipsisLoc, 3363 SourceLocation KeyLoc, 3364 IdentifierInfo *ParamName, 3365 SourceLocation ParamNameLoc, 3366 unsigned Depth, unsigned Position, 3367 SourceLocation EqualLoc, 3368 ParsedType DefaultArg); 3369 3370 QualType CheckNonTypeTemplateParameterType(QualType T, SourceLocation Loc); 3371 Decl *ActOnNonTypeTemplateParameter(Scope *S, Declarator &D, 3372 unsigned Depth, 3373 unsigned Position, 3374 SourceLocation EqualLoc, 3375 Expr *DefaultArg); 3376 Decl *ActOnTemplateTemplateParameter(Scope *S, 3377 SourceLocation TmpLoc, 3378 TemplateParamsTy *Params, 3379 SourceLocation EllipsisLoc, 3380 IdentifierInfo *ParamName, 3381 SourceLocation ParamNameLoc, 3382 unsigned Depth, 3383 unsigned Position, 3384 SourceLocation EqualLoc, 3385 ParsedTemplateArgument DefaultArg); 3386 3387 TemplateParamsTy * 3388 ActOnTemplateParameterList(unsigned Depth, 3389 SourceLocation ExportLoc, 3390 SourceLocation TemplateLoc, 3391 SourceLocation LAngleLoc, 3392 Decl **Params, unsigned NumParams, 3393 SourceLocation RAngleLoc); 3394 3395 /// \brief The context in which we are checking a template parameter 3396 /// list. 3397 enum TemplateParamListContext { 3398 TPC_ClassTemplate, 3399 TPC_FunctionTemplate, 3400 TPC_ClassTemplateMember, 3401 TPC_FriendFunctionTemplate, 3402 TPC_FriendFunctionTemplateDefinition 3403 }; 3404 3405 bool CheckTemplateParameterList(TemplateParameterList *NewParams, 3406 TemplateParameterList *OldParams, 3407 TemplateParamListContext TPC); 3408 TemplateParameterList * 3409 MatchTemplateParametersToScopeSpecifier(SourceLocation DeclStartLoc, 3410 const CXXScopeSpec &SS, 3411 TemplateParameterList **ParamLists, 3412 unsigned NumParamLists, 3413 bool IsFriend, 3414 bool &IsExplicitSpecialization, 3415 bool &Invalid); 3416 3417 DeclResult CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK, 3418 SourceLocation KWLoc, CXXScopeSpec &SS, 3419 IdentifierInfo *Name, SourceLocation NameLoc, 3420 AttributeList *Attr, 3421 TemplateParameterList *TemplateParams, 3422 AccessSpecifier AS, 3423 unsigned NumOuterTemplateParamLists, 3424 TemplateParameterList **OuterTemplateParamLists); 3425 3426 void translateTemplateArguments(const ASTTemplateArgsPtr &In, 3427 TemplateArgumentListInfo &Out); 3428 3429 void NoteAllFoundTemplates(TemplateName Name); 3430 3431 QualType CheckTemplateIdType(TemplateName Template, 3432 SourceLocation TemplateLoc, 3433 TemplateArgumentListInfo &TemplateArgs); 3434 3435 TypeResult 3436 ActOnTemplateIdType(CXXScopeSpec &SS, 3437 TemplateTy Template, SourceLocation TemplateLoc, 3438 SourceLocation LAngleLoc, 3439 ASTTemplateArgsPtr TemplateArgs, 3440 SourceLocation RAngleLoc); 3441 3442 /// \brief Parsed an elaborated-type-specifier that refers to a template-id, 3443 /// such as \c class T::template apply<U>. 3444 /// 3445 /// \param TUK 3446 TypeResult ActOnTagTemplateIdType(TagUseKind TUK, 3447 TypeSpecifierType TagSpec, 3448 SourceLocation TagLoc, 3449 CXXScopeSpec &SS, 3450 TemplateTy TemplateD, 3451 SourceLocation TemplateLoc, 3452 SourceLocation LAngleLoc, 3453 ASTTemplateArgsPtr TemplateArgsIn, 3454 SourceLocation RAngleLoc); 3455 3456 3457 ExprResult BuildTemplateIdExpr(const CXXScopeSpec &SS, 3458 LookupResult &R, 3459 bool RequiresADL, 3460 const TemplateArgumentListInfo &TemplateArgs); 3461 ExprResult BuildQualifiedTemplateIdExpr(CXXScopeSpec &SS, 3462 const DeclarationNameInfo &NameInfo, 3463 const TemplateArgumentListInfo &TemplateArgs); 3464 3465 TemplateNameKind ActOnDependentTemplateName(Scope *S, 3466 SourceLocation TemplateKWLoc, 3467 CXXScopeSpec &SS, 3468 UnqualifiedId &Name, 3469 ParsedType ObjectType, 3470 bool EnteringContext, 3471 TemplateTy &Template); 3472 3473 DeclResult 3474 ActOnClassTemplateSpecialization(Scope *S, unsigned TagSpec, TagUseKind TUK, 3475 SourceLocation KWLoc, 3476 CXXScopeSpec &SS, 3477 TemplateTy Template, 3478 SourceLocation TemplateNameLoc, 3479 SourceLocation LAngleLoc, 3480 ASTTemplateArgsPtr TemplateArgs, 3481 SourceLocation RAngleLoc, 3482 AttributeList *Attr, 3483 MultiTemplateParamsArg TemplateParameterLists); 3484 3485 Decl *ActOnTemplateDeclarator(Scope *S, 3486 MultiTemplateParamsArg TemplateParameterLists, 3487 Declarator &D); 3488 3489 Decl *ActOnStartOfFunctionTemplateDef(Scope *FnBodyScope, 3490 MultiTemplateParamsArg TemplateParameterLists, 3491 Declarator &D); 3492 3493 bool 3494 CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, 3495 TemplateSpecializationKind NewTSK, 3496 NamedDecl *PrevDecl, 3497 TemplateSpecializationKind PrevTSK, 3498 SourceLocation PrevPtOfInstantiation, 3499 bool &SuppressNew); 3500 3501 bool CheckDependentFunctionTemplateSpecialization(FunctionDecl *FD, 3502 const TemplateArgumentListInfo &ExplicitTemplateArgs, 3503 LookupResult &Previous); 3504 3505 bool CheckFunctionTemplateSpecialization(FunctionDecl *FD, 3506 TemplateArgumentListInfo *ExplicitTemplateArgs, 3507 LookupResult &Previous); 3508 bool CheckMemberSpecialization(NamedDecl *Member, LookupResult &Previous); 3509 3510 DeclResult 3511 ActOnExplicitInstantiation(Scope *S, 3512 SourceLocation ExternLoc, 3513 SourceLocation TemplateLoc, 3514 unsigned TagSpec, 3515 SourceLocation KWLoc, 3516 const CXXScopeSpec &SS, 3517 TemplateTy Template, 3518 SourceLocation TemplateNameLoc, 3519 SourceLocation LAngleLoc, 3520 ASTTemplateArgsPtr TemplateArgs, 3521 SourceLocation RAngleLoc, 3522 AttributeList *Attr); 3523 3524 DeclResult 3525 ActOnExplicitInstantiation(Scope *S, 3526 SourceLocation ExternLoc, 3527 SourceLocation TemplateLoc, 3528 unsigned TagSpec, 3529 SourceLocation KWLoc, 3530 CXXScopeSpec &SS, 3531 IdentifierInfo *Name, 3532 SourceLocation NameLoc, 3533 AttributeList *Attr); 3534 3535 DeclResult ActOnExplicitInstantiation(Scope *S, 3536 SourceLocation ExternLoc, 3537 SourceLocation TemplateLoc, 3538 Declarator &D); 3539 3540 TemplateArgumentLoc 3541 SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, 3542 SourceLocation TemplateLoc, 3543 SourceLocation RAngleLoc, 3544 Decl *Param, 3545 llvm::SmallVectorImpl<TemplateArgument> &Converted); 3546 3547 /// \brief Specifies the context in which a particular template 3548 /// argument is being checked. 3549 enum CheckTemplateArgumentKind { 3550 /// \brief The template argument was specified in the code or was 3551 /// instantiated with some deduced template arguments. 3552 CTAK_Specified, 3553 3554 /// \brief The template argument was deduced via template argument 3555 /// deduction. 3556 CTAK_Deduced, 3557 3558 /// \brief The template argument was deduced from an array bound 3559 /// via template argument deduction. 3560 CTAK_DeducedFromArrayBound 3561 }; 3562 3563 bool CheckTemplateArgument(NamedDecl *Param, 3564 const TemplateArgumentLoc &Arg, 3565 NamedDecl *Template, 3566 SourceLocation TemplateLoc, 3567 SourceLocation RAngleLoc, 3568 unsigned ArgumentPackIndex, 3569 llvm::SmallVectorImpl<TemplateArgument> &Converted, 3570 CheckTemplateArgumentKind CTAK = CTAK_Specified); 3571 3572 /// \brief Check that the given template arguments can be be provided to 3573 /// the given template, converting the arguments along the way. 3574 /// 3575 /// \param Template The template to which the template arguments are being 3576 /// provided. 3577 /// 3578 /// \param TemplateLoc The location of the template name in the source. 3579 /// 3580 /// \param TemplateArgs The list of template arguments. If the template is 3581 /// a template template parameter, this function may extend the set of 3582 /// template arguments to also include substituted, defaulted template 3583 /// arguments. 3584 /// 3585 /// \param PartialTemplateArgs True if the list of template arguments is 3586 /// intentionally partial, e.g., because we're checking just the initial 3587 /// set of template arguments. 3588 /// 3589 /// \param Converted Will receive the converted, canonicalized template 3590 /// arguments. 3591 /// 3592 /// \returns True if an error occurred, false otherwise. 3593 bool CheckTemplateArgumentList(TemplateDecl *Template, 3594 SourceLocation TemplateLoc, 3595 TemplateArgumentListInfo &TemplateArgs, 3596 bool PartialTemplateArgs, 3597 llvm::SmallVectorImpl<TemplateArgument> &Converted); 3598 3599 bool CheckTemplateTypeArgument(TemplateTypeParmDecl *Param, 3600 const TemplateArgumentLoc &Arg, 3601 llvm::SmallVectorImpl<TemplateArgument> &Converted); 3602 3603 bool CheckTemplateArgument(TemplateTypeParmDecl *Param, 3604 TypeSourceInfo *Arg); 3605 bool CheckTemplateArgumentPointerToMember(Expr *Arg, 3606 TemplateArgument &Converted); 3607 ExprResult CheckTemplateArgument(NonTypeTemplateParmDecl *Param, 3608 QualType InstantiatedParamType, Expr *Arg, 3609 TemplateArgument &Converted, 3610 CheckTemplateArgumentKind CTAK = CTAK_Specified); 3611 bool CheckTemplateArgument(TemplateTemplateParmDecl *Param, 3612 const TemplateArgumentLoc &Arg); 3613 3614 ExprResult 3615 BuildExpressionFromDeclTemplateArgument(const TemplateArgument &Arg, 3616 QualType ParamType, 3617 SourceLocation Loc); 3618 ExprResult 3619 BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, 3620 SourceLocation Loc); 3621 3622 /// \brief Enumeration describing how template parameter lists are compared 3623 /// for equality. 3624 enum TemplateParameterListEqualKind { 3625 /// \brief We are matching the template parameter lists of two templates 3626 /// that might be redeclarations. 3627 /// 3628 /// \code 3629 /// template<typename T> struct X; 3630 /// template<typename T> struct X; 3631 /// \endcode 3632 TPL_TemplateMatch, 3633 3634 /// \brief We are matching the template parameter lists of two template 3635 /// template parameters as part of matching the template parameter lists 3636 /// of two templates that might be redeclarations. 3637 /// 3638 /// \code 3639 /// template<template<int I> class TT> struct X; 3640 /// template<template<int Value> class Other> struct X; 3641 /// \endcode 3642 TPL_TemplateTemplateParmMatch, 3643 3644 /// \brief We are matching the template parameter lists of a template 3645 /// template argument against the template parameter lists of a template 3646 /// template parameter. 3647 /// 3648 /// \code 3649 /// template<template<int Value> class Metafun> struct X; 3650 /// template<int Value> struct integer_c; 3651 /// X<integer_c> xic; 3652 /// \endcode 3653 TPL_TemplateTemplateArgumentMatch 3654 }; 3655 3656 bool TemplateParameterListsAreEqual(TemplateParameterList *New, 3657 TemplateParameterList *Old, 3658 bool Complain, 3659 TemplateParameterListEqualKind Kind, 3660 SourceLocation TemplateArgLoc 3661 = SourceLocation()); 3662 3663 bool CheckTemplateDeclScope(Scope *S, TemplateParameterList *TemplateParams); 3664 3665 /// \brief Called when the parser has parsed a C++ typename 3666 /// specifier, e.g., "typename T::type". 3667 /// 3668 /// \param S The scope in which this typename type occurs. 3669 /// \param TypenameLoc the location of the 'typename' keyword 3670 /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). 3671 /// \param II the identifier we're retrieving (e.g., 'type' in the example). 3672 /// \param IdLoc the location of the identifier. 3673 TypeResult 3674 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 3675 const CXXScopeSpec &SS, const IdentifierInfo &II, 3676 SourceLocation IdLoc); 3677 3678 /// \brief Called when the parser has parsed a C++ typename 3679 /// specifier that ends in a template-id, e.g., 3680 /// "typename MetaFun::template apply<T1, T2>". 3681 /// 3682 /// \param S The scope in which this typename type occurs. 3683 /// \param TypenameLoc the location of the 'typename' keyword 3684 /// \param SS the nested-name-specifier following the typename (e.g., 'T::'). 3685 /// \param TemplateLoc the location of the 'template' keyword, if any. 3686 /// \param TemplateName The template name. 3687 /// \param TemplateNameLoc The location of the template name. 3688 /// \param LAngleLoc The location of the opening angle bracket ('<'). 3689 /// \param TemplateArgs The template arguments. 3690 /// \param RAngleLoc The location of the closing angle bracket ('>'). 3691 TypeResult 3692 ActOnTypenameType(Scope *S, SourceLocation TypenameLoc, 3693 const CXXScopeSpec &SS, 3694 SourceLocation TemplateLoc, 3695 TemplateTy Template, 3696 SourceLocation TemplateNameLoc, 3697 SourceLocation LAngleLoc, 3698 ASTTemplateArgsPtr TemplateArgs, 3699 SourceLocation RAngleLoc); 3700 3701 QualType CheckTypenameType(ElaboratedTypeKeyword Keyword, 3702 SourceLocation KeywordLoc, 3703 NestedNameSpecifierLoc QualifierLoc, 3704 const IdentifierInfo &II, 3705 SourceLocation IILoc); 3706 3707 TypeSourceInfo *RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, 3708 SourceLocation Loc, 3709 DeclarationName Name); 3710 bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS); 3711 3712 ExprResult RebuildExprInCurrentInstantiation(Expr *E); 3713 3714 std::string 3715 getTemplateArgumentBindingsText(const TemplateParameterList *Params, 3716 const TemplateArgumentList &Args); 3717 3718 std::string 3719 getTemplateArgumentBindingsText(const TemplateParameterList *Params, 3720 const TemplateArgument *Args, 3721 unsigned NumArgs); 3722 3723 //===--------------------------------------------------------------------===// 3724 // C++ Variadic Templates (C++0x [temp.variadic]) 3725 //===--------------------------------------------------------------------===// 3726 3727 /// \brief The context in which an unexpanded parameter pack is 3728 /// being diagnosed. 3729 /// 3730 /// Note that the values of this enumeration line up with the first 3731 /// argument to the \c err_unexpanded_parameter_pack diagnostic. 3732 enum UnexpandedParameterPackContext { 3733 /// \brief An arbitrary expression. 3734 UPPC_Expression = 0, 3735 3736 /// \brief The base type of a class type. 3737 UPPC_BaseType, 3738 3739 /// \brief The type of an arbitrary declaration. 3740 UPPC_DeclarationType, 3741 3742 /// \brief The type of a data member. 3743 UPPC_DataMemberType, 3744 3745 /// \brief The size of a bit-field. 3746 UPPC_BitFieldWidth, 3747 3748 /// \brief The expression in a static assertion. 3749 UPPC_StaticAssertExpression, 3750 3751 /// \brief The fixed underlying type of an enumeration. 3752 UPPC_FixedUnderlyingType, 3753 3754 /// \brief The enumerator value. 3755 UPPC_EnumeratorValue, 3756 3757 /// \brief A using declaration. 3758 UPPC_UsingDeclaration, 3759 3760 /// \brief A friend declaration. 3761 UPPC_FriendDeclaration, 3762 3763 /// \brief A declaration qualifier. 3764 UPPC_DeclarationQualifier, 3765 3766 /// \brief An initializer. 3767 UPPC_Initializer, 3768 3769 /// \brief A default argument. 3770 UPPC_DefaultArgument, 3771 3772 /// \brief The type of a non-type template parameter. 3773 UPPC_NonTypeTemplateParameterType, 3774 3775 /// \brief The type of an exception. 3776 UPPC_ExceptionType, 3777 3778 /// \brief Partial specialization. 3779 UPPC_PartialSpecialization 3780 }; 3781 3782 /// \brief If the given type contains an unexpanded parameter pack, 3783 /// diagnose the error. 3784 /// 3785 /// \param Loc The source location where a diagnostc should be emitted. 3786 /// 3787 /// \param T The type that is being checked for unexpanded parameter 3788 /// packs. 3789 /// 3790 /// \returns true if an error occurred, false otherwise. 3791 bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, 3792 UnexpandedParameterPackContext UPPC); 3793 3794 /// \brief If the given expression contains an unexpanded parameter 3795 /// pack, diagnose the error. 3796 /// 3797 /// \param E The expression that is being checked for unexpanded 3798 /// parameter packs. 3799 /// 3800 /// \returns true if an error occurred, false otherwise. 3801 bool DiagnoseUnexpandedParameterPack(Expr *E, 3802 UnexpandedParameterPackContext UPPC = UPPC_Expression); 3803 3804 /// \brief If the given nested-name-specifier contains an unexpanded 3805 /// parameter pack, diagnose the error. 3806 /// 3807 /// \param SS The nested-name-specifier that is being checked for 3808 /// unexpanded parameter packs. 3809 /// 3810 /// \returns true if an error occurred, false otherwise. 3811 bool DiagnoseUnexpandedParameterPack(const CXXScopeSpec &SS, 3812 UnexpandedParameterPackContext UPPC); 3813 3814 /// \brief If the given name contains an unexpanded parameter pack, 3815 /// diagnose the error. 3816 /// 3817 /// \param NameInfo The name (with source location information) that 3818 /// is being checked for unexpanded parameter packs. 3819 /// 3820 /// \returns true if an error occurred, false otherwise. 3821 bool DiagnoseUnexpandedParameterPack(const DeclarationNameInfo &NameInfo, 3822 UnexpandedParameterPackContext UPPC); 3823 3824 /// \brief If the given template name contains an unexpanded parameter pack, 3825 /// diagnose the error. 3826 /// 3827 /// \param Loc The location of the template name. 3828 /// 3829 /// \param Template The template name that is being checked for unexpanded 3830 /// parameter packs. 3831 /// 3832 /// \returns true if an error occurred, false otherwise. 3833 bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, 3834 TemplateName Template, 3835 UnexpandedParameterPackContext UPPC); 3836 3837 /// \brief If the given template argument contains an unexpanded parameter 3838 /// pack, diagnose the error. 3839 /// 3840 /// \param Arg The template argument that is being checked for unexpanded 3841 /// parameter packs. 3842 /// 3843 /// \returns true if an error occurred, false otherwise. 3844 bool DiagnoseUnexpandedParameterPack(TemplateArgumentLoc Arg, 3845 UnexpandedParameterPackContext UPPC); 3846 3847 /// \brief Collect the set of unexpanded parameter packs within the given 3848 /// template argument. 3849 /// 3850 /// \param Arg The template argument that will be traversed to find 3851 /// unexpanded parameter packs. 3852 void collectUnexpandedParameterPacks(TemplateArgument Arg, 3853 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded); 3854 3855 /// \brief Collect the set of unexpanded parameter packs within the given 3856 /// template argument. 3857 /// 3858 /// \param Arg The template argument that will be traversed to find 3859 /// unexpanded parameter packs. 3860 void collectUnexpandedParameterPacks(TemplateArgumentLoc Arg, 3861 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded); 3862 3863 /// \brief Collect the set of unexpanded parameter packs within the given 3864 /// type. 3865 /// 3866 /// \param T The type that will be traversed to find 3867 /// unexpanded parameter packs. 3868 void collectUnexpandedParameterPacks(QualType T, 3869 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded); 3870 3871 /// \brief Collect the set of unexpanded parameter packs within the given 3872 /// type. 3873 /// 3874 /// \param TL The type that will be traversed to find 3875 /// unexpanded parameter packs. 3876 void collectUnexpandedParameterPacks(TypeLoc TL, 3877 llvm::SmallVectorImpl<UnexpandedParameterPack> &Unexpanded); 3878 3879 /// \brief Invoked when parsing a template argument followed by an 3880 /// ellipsis, which creates a pack expansion. 3881 /// 3882 /// \param Arg The template argument preceding the ellipsis, which 3883 /// may already be invalid. 3884 /// 3885 /// \param EllipsisLoc The location of the ellipsis. 3886 ParsedTemplateArgument ActOnPackExpansion(const ParsedTemplateArgument &Arg, 3887 SourceLocation EllipsisLoc); 3888 3889 /// \brief Invoked when parsing a type followed by an ellipsis, which 3890 /// creates a pack expansion. 3891 /// 3892 /// \param Type The type preceding the ellipsis, which will become 3893 /// the pattern of the pack expansion. 3894 /// 3895 /// \param EllipsisLoc The location of the ellipsis. 3896 TypeResult ActOnPackExpansion(ParsedType Type, SourceLocation EllipsisLoc); 3897 3898 /// \brief Construct a pack expansion type from the pattern of the pack 3899 /// expansion. 3900 TypeSourceInfo *CheckPackExpansion(TypeSourceInfo *Pattern, 3901 SourceLocation EllipsisLoc, 3902 llvm::Optional<unsigned> NumExpansions); 3903 3904 /// \brief Construct a pack expansion type from the pattern of the pack 3905 /// expansion. 3906 QualType CheckPackExpansion(QualType Pattern, 3907 SourceRange PatternRange, 3908 SourceLocation EllipsisLoc, 3909 llvm::Optional<unsigned> NumExpansions); 3910 3911 /// \brief Invoked when parsing an expression followed by an ellipsis, which 3912 /// creates a pack expansion. 3913 /// 3914 /// \param Pattern The expression preceding the ellipsis, which will become 3915 /// the pattern of the pack expansion. 3916 /// 3917 /// \param EllipsisLoc The location of the ellipsis. 3918 ExprResult ActOnPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc); 3919 3920 /// \brief Invoked when parsing an expression followed by an ellipsis, which 3921 /// creates a pack expansion. 3922 /// 3923 /// \param Pattern The expression preceding the ellipsis, which will become 3924 /// the pattern of the pack expansion. 3925 /// 3926 /// \param EllipsisLoc The location of the ellipsis. 3927 ExprResult CheckPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc, 3928 llvm::Optional<unsigned> NumExpansions); 3929 3930 /// \brief Determine whether we could expand a pack expansion with the 3931 /// given set of parameter packs into separate arguments by repeatedly 3932 /// transforming the pattern. 3933 /// 3934 /// \param EllipsisLoc The location of the ellipsis that identifies the 3935 /// pack expansion. 3936 /// 3937 /// \param PatternRange The source range that covers the entire pattern of 3938 /// the pack expansion. 3939 /// 3940 /// \param Unexpanded The set of unexpanded parameter packs within the 3941 /// pattern. 3942 /// 3943 /// \param NumUnexpanded The number of unexpanded parameter packs in 3944 /// \p Unexpanded. 3945 /// 3946 /// \param ShouldExpand Will be set to \c true if the transformer should 3947 /// expand the corresponding pack expansions into separate arguments. When 3948 /// set, \c NumExpansions must also be set. 3949 /// 3950 /// \param RetainExpansion Whether the caller should add an unexpanded 3951 /// pack expansion after all of the expanded arguments. This is used 3952 /// when extending explicitly-specified template argument packs per 3953 /// C++0x [temp.arg.explicit]p9. 3954 /// 3955 /// \param NumExpansions The number of separate arguments that will be in 3956 /// the expanded form of the corresponding pack expansion. This is both an 3957 /// input and an output parameter, which can be set by the caller if the 3958 /// number of expansions is known a priori (e.g., due to a prior substitution) 3959 /// and will be set by the callee when the number of expansions is known. 3960 /// The callee must set this value when \c ShouldExpand is \c true; it may 3961 /// set this value in other cases. 3962 /// 3963 /// \returns true if an error occurred (e.g., because the parameter packs 3964 /// are to be instantiated with arguments of different lengths), false 3965 /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions) 3966 /// must be set. 3967 bool CheckParameterPacksForExpansion(SourceLocation EllipsisLoc, 3968 SourceRange PatternRange, 3969 const UnexpandedParameterPack *Unexpanded, 3970 unsigned NumUnexpanded, 3971 const MultiLevelTemplateArgumentList &TemplateArgs, 3972 bool &ShouldExpand, 3973 bool &RetainExpansion, 3974 llvm::Optional<unsigned> &NumExpansions); 3975 3976 /// \brief Determine the number of arguments in the given pack expansion 3977 /// type. 3978 /// 3979 /// This routine already assumes that the pack expansion type can be 3980 /// expanded and that the number of arguments in the expansion is 3981 /// consistent across all of the unexpanded parameter packs in its pattern. 3982 unsigned getNumArgumentsInExpansion(QualType T, 3983 const MultiLevelTemplateArgumentList &TemplateArgs); 3984 3985 /// \brief Determine whether the given declarator contains any unexpanded 3986 /// parameter packs. 3987 /// 3988 /// This routine is used by the parser to disambiguate function declarators 3989 /// with an ellipsis prior to the ')', e.g., 3990 /// 3991 /// \code 3992 /// void f(T...); 3993 /// \endcode 3994 /// 3995 /// To determine whether we have an (unnamed) function parameter pack or 3996 /// a variadic function. 3997 /// 3998 /// \returns true if the declarator contains any unexpanded parameter packs, 3999 /// false otherwise. 4000 bool containsUnexpandedParameterPacks(Declarator &D); 4001 4002 //===--------------------------------------------------------------------===// 4003 // C++ Template Argument Deduction (C++ [temp.deduct]) 4004 //===--------------------------------------------------------------------===// 4005 4006 /// \brief Describes the result of template argument deduction. 4007 /// 4008 /// The TemplateDeductionResult enumeration describes the result of 4009 /// template argument deduction, as returned from 4010 /// DeduceTemplateArguments(). The separate TemplateDeductionInfo 4011 /// structure provides additional information about the results of 4012 /// template argument deduction, e.g., the deduced template argument 4013 /// list (if successful) or the specific template parameters or 4014 /// deduced arguments that were involved in the failure. 4015 enum TemplateDeductionResult { 4016 /// \brief Template argument deduction was successful. 4017 TDK_Success = 0, 4018 /// \brief Template argument deduction exceeded the maximum template 4019 /// instantiation depth (which has already been diagnosed). 4020 TDK_InstantiationDepth, 4021 /// \brief Template argument deduction did not deduce a value 4022 /// for every template parameter. 4023 TDK_Incomplete, 4024 /// \brief Template argument deduction produced inconsistent 4025 /// deduced values for the given template parameter. 4026 TDK_Inconsistent, 4027 /// \brief Template argument deduction failed due to inconsistent 4028 /// cv-qualifiers on a template parameter type that would 4029 /// otherwise be deduced, e.g., we tried to deduce T in "const T" 4030 /// but were given a non-const "X". 4031 TDK_Underqualified, 4032 /// \brief Substitution of the deduced template argument values 4033 /// resulted in an error. 4034 TDK_SubstitutionFailure, 4035 /// \brief Substitution of the deduced template argument values 4036 /// into a non-deduced context produced a type or value that 4037 /// produces a type that does not match the original template 4038 /// arguments provided. 4039 TDK_NonDeducedMismatch, 4040 /// \brief When performing template argument deduction for a function 4041 /// template, there were too many call arguments. 4042 TDK_TooManyArguments, 4043 /// \brief When performing template argument deduction for a function 4044 /// template, there were too few call arguments. 4045 TDK_TooFewArguments, 4046 /// \brief The explicitly-specified template arguments were not valid 4047 /// template arguments for the given template. 4048 TDK_InvalidExplicitArguments, 4049 /// \brief The arguments included an overloaded function name that could 4050 /// not be resolved to a suitable function. 4051 TDK_FailedOverloadResolution 4052 }; 4053 4054 TemplateDeductionResult 4055 DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, 4056 const TemplateArgumentList &TemplateArgs, 4057 sema::TemplateDeductionInfo &Info); 4058 4059 TemplateDeductionResult 4060 SubstituteExplicitTemplateArguments(FunctionTemplateDecl *FunctionTemplate, 4061 TemplateArgumentListInfo &ExplicitTemplateArgs, 4062 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced, 4063 llvm::SmallVectorImpl<QualType> &ParamTypes, 4064 QualType *FunctionType, 4065 sema::TemplateDeductionInfo &Info); 4066 4067 TemplateDeductionResult 4068 FinishTemplateArgumentDeduction(FunctionTemplateDecl *FunctionTemplate, 4069 llvm::SmallVectorImpl<DeducedTemplateArgument> &Deduced, 4070 unsigned NumExplicitlySpecified, 4071 FunctionDecl *&Specialization, 4072 sema::TemplateDeductionInfo &Info); 4073 4074 TemplateDeductionResult 4075 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, 4076 TemplateArgumentListInfo *ExplicitTemplateArgs, 4077 Expr **Args, unsigned NumArgs, 4078 FunctionDecl *&Specialization, 4079 sema::TemplateDeductionInfo &Info); 4080 4081 TemplateDeductionResult 4082 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, 4083 TemplateArgumentListInfo *ExplicitTemplateArgs, 4084 QualType ArgFunctionType, 4085 FunctionDecl *&Specialization, 4086 sema::TemplateDeductionInfo &Info); 4087 4088 TemplateDeductionResult 4089 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, 4090 QualType ToType, 4091 CXXConversionDecl *&Specialization, 4092 sema::TemplateDeductionInfo &Info); 4093 4094 TemplateDeductionResult 4095 DeduceTemplateArguments(FunctionTemplateDecl *FunctionTemplate, 4096 TemplateArgumentListInfo *ExplicitTemplateArgs, 4097 FunctionDecl *&Specialization, 4098 sema::TemplateDeductionInfo &Info); 4099 4100 bool DeduceAutoType(TypeSourceInfo *AutoType, Expr *Initializer, 4101 TypeSourceInfo *&Result); 4102 4103 FunctionTemplateDecl *getMoreSpecializedTemplate(FunctionTemplateDecl *FT1, 4104 FunctionTemplateDecl *FT2, 4105 SourceLocation Loc, 4106 TemplatePartialOrderingContext TPOC, 4107 unsigned NumCallArguments); 4108 UnresolvedSetIterator getMostSpecialized(UnresolvedSetIterator SBegin, 4109 UnresolvedSetIterator SEnd, 4110 TemplatePartialOrderingContext TPOC, 4111 unsigned NumCallArguments, 4112 SourceLocation Loc, 4113 const PartialDiagnostic &NoneDiag, 4114 const PartialDiagnostic &AmbigDiag, 4115 const PartialDiagnostic &CandidateDiag, 4116 bool Complain = true); 4117 4118 ClassTemplatePartialSpecializationDecl * 4119 getMoreSpecializedPartialSpecialization( 4120 ClassTemplatePartialSpecializationDecl *PS1, 4121 ClassTemplatePartialSpecializationDecl *PS2, 4122 SourceLocation Loc); 4123 4124 void MarkUsedTemplateParameters(const TemplateArgumentList &TemplateArgs, 4125 bool OnlyDeduced, 4126 unsigned Depth, 4127 llvm::SmallVectorImpl<bool> &Used); 4128 void MarkDeducedTemplateParameters(FunctionTemplateDecl *FunctionTemplate, 4129 llvm::SmallVectorImpl<bool> &Deduced); 4130 4131 //===--------------------------------------------------------------------===// 4132 // C++ Template Instantiation 4133 // 4134 4135 MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, 4136 const TemplateArgumentList *Innermost = 0, 4137 bool RelativeToPrimary = false, 4138 const FunctionDecl *Pattern = 0); 4139 4140 /// \brief A template instantiation that is currently in progress. 4141 struct ActiveTemplateInstantiation { 4142 /// \brief The kind of template instantiation we are performing 4143 enum InstantiationKind { 4144 /// We are instantiating a template declaration. The entity is 4145 /// the declaration we're instantiating (e.g., a CXXRecordDecl). 4146 TemplateInstantiation, 4147 4148 /// We are instantiating a default argument for a template 4149 /// parameter. The Entity is the template, and 4150 /// TemplateArgs/NumTemplateArguments provides the template 4151 /// arguments as specified. 4152 /// FIXME: Use a TemplateArgumentList 4153 DefaultTemplateArgumentInstantiation, 4154 4155 /// We are instantiating a default argument for a function. 4156 /// The Entity is the ParmVarDecl, and TemplateArgs/NumTemplateArgs 4157 /// provides the template arguments as specified. 4158 DefaultFunctionArgumentInstantiation, 4159 4160 /// We are substituting explicit template arguments provided for 4161 /// a function template. The entity is a FunctionTemplateDecl. 4162 ExplicitTemplateArgumentSubstitution, 4163 4164 /// We are substituting template argument determined as part of 4165 /// template argument deduction for either a class template 4166 /// partial specialization or a function template. The 4167 /// Entity is either a ClassTemplatePartialSpecializationDecl or 4168 /// a FunctionTemplateDecl. 4169 DeducedTemplateArgumentSubstitution, 4170 4171 /// We are substituting prior template arguments into a new 4172 /// template parameter. The template parameter itself is either a 4173 /// NonTypeTemplateParmDecl or a TemplateTemplateParmDecl. 4174 PriorTemplateArgumentSubstitution, 4175 4176 /// We are checking the validity of a default template argument that 4177 /// has been used when naming a template-id. 4178 DefaultTemplateArgumentChecking 4179 } Kind; 4180 4181 /// \brief The point of instantiation within the source code. 4182 SourceLocation PointOfInstantiation; 4183 4184 /// \brief The template (or partial specialization) in which we are 4185 /// performing the instantiation, for substitutions of prior template 4186 /// arguments. 4187 NamedDecl *Template; 4188 4189 /// \brief The entity that is being instantiated. 4190 uintptr_t Entity; 4191 4192 /// \brief The list of template arguments we are substituting, if they 4193 /// are not part of the entity. 4194 const TemplateArgument *TemplateArgs; 4195 4196 /// \brief The number of template arguments in TemplateArgs. 4197 unsigned NumTemplateArgs; 4198 4199 /// \brief The template deduction info object associated with the 4200 /// substitution or checking of explicit or deduced template arguments. 4201 sema::TemplateDeductionInfo *DeductionInfo; 4202 4203 /// \brief The source range that covers the construct that cause 4204 /// the instantiation, e.g., the template-id that causes a class 4205 /// template instantiation. 4206 SourceRange InstantiationRange; 4207 4208 ActiveTemplateInstantiation() 4209 : Kind(TemplateInstantiation), Template(0), Entity(0), TemplateArgs(0), 4210 NumTemplateArgs(0), DeductionInfo(0) {} 4211 4212 /// \brief Determines whether this template is an actual instantiation 4213 /// that should be counted toward the maximum instantiation depth. 4214 bool isInstantiationRecord() const; 4215 4216 friend bool operator==(const ActiveTemplateInstantiation &X, 4217 const ActiveTemplateInstantiation &Y) { 4218 if (X.Kind != Y.Kind) 4219 return false; 4220 4221 if (X.Entity != Y.Entity) 4222 return false; 4223 4224 switch (X.Kind) { 4225 case TemplateInstantiation: 4226 return true; 4227 4228 case PriorTemplateArgumentSubstitution: 4229 case DefaultTemplateArgumentChecking: 4230 if (X.Template != Y.Template) 4231 return false; 4232 4233 // Fall through 4234 4235 case DefaultTemplateArgumentInstantiation: 4236 case ExplicitTemplateArgumentSubstitution: 4237 case DeducedTemplateArgumentSubstitution: 4238 case DefaultFunctionArgumentInstantiation: 4239 return X.TemplateArgs == Y.TemplateArgs; 4240 4241 } 4242 4243 return true; 4244 } 4245 4246 friend bool operator!=(const ActiveTemplateInstantiation &X, 4247 const ActiveTemplateInstantiation &Y) { 4248 return !(X == Y); 4249 } 4250 }; 4251 4252 /// \brief List of active template instantiations. 4253 /// 4254 /// This vector is treated as a stack. As one template instantiation 4255 /// requires another template instantiation, additional 4256 /// instantiations are pushed onto the stack up to a 4257 /// user-configurable limit LangOptions::InstantiationDepth. 4258 llvm::SmallVector<ActiveTemplateInstantiation, 16> 4259 ActiveTemplateInstantiations; 4260 4261 /// \brief Whether we are in a SFINAE context that is not associated with 4262 /// template instantiation. 4263 /// 4264 /// This is used when setting up a SFINAE trap (\c see SFINAETrap) outside 4265 /// of a template instantiation or template argument deduction. 4266 bool InNonInstantiationSFINAEContext; 4267 4268 /// \brief The number of ActiveTemplateInstantiation entries in 4269 /// \c ActiveTemplateInstantiations that are not actual instantiations and, 4270 /// therefore, should not be counted as part of the instantiation depth. 4271 unsigned NonInstantiationEntries; 4272 4273 /// \brief The last template from which a template instantiation 4274 /// error or warning was produced. 4275 /// 4276 /// This value is used to suppress printing of redundant template 4277 /// instantiation backtraces when there are multiple errors in the 4278 /// same instantiation. FIXME: Does this belong in Sema? It's tough 4279 /// to implement it anywhere else. 4280 ActiveTemplateInstantiation LastTemplateInstantiationErrorContext; 4281 4282 /// \brief The current index into pack expansion arguments that will be 4283 /// used for substitution of parameter packs. 4284 /// 4285 /// The pack expansion index will be -1 to indicate that parameter packs 4286 /// should be instantiated as themselves. Otherwise, the index specifies 4287 /// which argument within the parameter pack will be used for substitution. 4288 int ArgumentPackSubstitutionIndex; 4289 4290 /// \brief RAII object used to change the argument pack substitution index 4291 /// within a \c Sema object. 4292 /// 4293 /// See \c ArgumentPackSubstitutionIndex for more information. 4294 class ArgumentPackSubstitutionIndexRAII { 4295 Sema &Self; 4296 int OldSubstitutionIndex; 4297 4298 public: 4299 ArgumentPackSubstitutionIndexRAII(Sema &Self, int NewSubstitutionIndex) 4300 : Self(Self), OldSubstitutionIndex(Self.ArgumentPackSubstitutionIndex) { 4301 Self.ArgumentPackSubstitutionIndex = NewSubstitutionIndex; 4302 } 4303 4304 ~ArgumentPackSubstitutionIndexRAII() { 4305 Self.ArgumentPackSubstitutionIndex = OldSubstitutionIndex; 4306 } 4307 }; 4308 4309 friend class ArgumentPackSubstitutionRAII; 4310 4311 /// \brief The stack of calls expression undergoing template instantiation. 4312 /// 4313 /// The top of this stack is used by a fixit instantiating unresolved 4314 /// function calls to fix the AST to match the textual change it prints. 4315 llvm::SmallVector<CallExpr *, 8> CallsUndergoingInstantiation; 4316 4317 /// \brief For each declaration that involved template argument deduction, the 4318 /// set of diagnostics that were suppressed during that template argument 4319 /// deduction. 4320 /// 4321 /// FIXME: Serialize this structure to the AST file. 4322 llvm::DenseMap<Decl *, llvm::SmallVector<PartialDiagnosticAt, 1> > 4323 SuppressedDiagnostics; 4324 4325 /// \brief A stack object to be created when performing template 4326 /// instantiation. 4327 /// 4328 /// Construction of an object of type \c InstantiatingTemplate 4329 /// pushes the current instantiation onto the stack of active 4330 /// instantiations. If the size of this stack exceeds the maximum 4331 /// number of recursive template instantiations, construction 4332 /// produces an error and evaluates true. 4333 /// 4334 /// Destruction of this object will pop the named instantiation off 4335 /// the stack. 4336 struct InstantiatingTemplate { 4337 /// \brief Note that we are instantiating a class template, 4338 /// function template, or a member thereof. 4339 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4340 Decl *Entity, 4341 SourceRange InstantiationRange = SourceRange()); 4342 4343 /// \brief Note that we are instantiating a default argument in a 4344 /// template-id. 4345 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4346 TemplateDecl *Template, 4347 const TemplateArgument *TemplateArgs, 4348 unsigned NumTemplateArgs, 4349 SourceRange InstantiationRange = SourceRange()); 4350 4351 /// \brief Note that we are instantiating a default argument in a 4352 /// template-id. 4353 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4354 FunctionTemplateDecl *FunctionTemplate, 4355 const TemplateArgument *TemplateArgs, 4356 unsigned NumTemplateArgs, 4357 ActiveTemplateInstantiation::InstantiationKind Kind, 4358 sema::TemplateDeductionInfo &DeductionInfo, 4359 SourceRange InstantiationRange = SourceRange()); 4360 4361 /// \brief Note that we are instantiating as part of template 4362 /// argument deduction for a class template partial 4363 /// specialization. 4364 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4365 ClassTemplatePartialSpecializationDecl *PartialSpec, 4366 const TemplateArgument *TemplateArgs, 4367 unsigned NumTemplateArgs, 4368 sema::TemplateDeductionInfo &DeductionInfo, 4369 SourceRange InstantiationRange = SourceRange()); 4370 4371 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4372 ParmVarDecl *Param, 4373 const TemplateArgument *TemplateArgs, 4374 unsigned NumTemplateArgs, 4375 SourceRange InstantiationRange = SourceRange()); 4376 4377 /// \brief Note that we are substituting prior template arguments into a 4378 /// non-type or template template parameter. 4379 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4380 NamedDecl *Template, 4381 NonTypeTemplateParmDecl *Param, 4382 const TemplateArgument *TemplateArgs, 4383 unsigned NumTemplateArgs, 4384 SourceRange InstantiationRange); 4385 4386 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4387 NamedDecl *Template, 4388 TemplateTemplateParmDecl *Param, 4389 const TemplateArgument *TemplateArgs, 4390 unsigned NumTemplateArgs, 4391 SourceRange InstantiationRange); 4392 4393 /// \brief Note that we are checking the default template argument 4394 /// against the template parameter for a given template-id. 4395 InstantiatingTemplate(Sema &SemaRef, SourceLocation PointOfInstantiation, 4396 TemplateDecl *Template, 4397 NamedDecl *Param, 4398 const TemplateArgument *TemplateArgs, 4399 unsigned NumTemplateArgs, 4400 SourceRange InstantiationRange); 4401 4402 4403 /// \brief Note that we have finished instantiating this template. 4404 void Clear(); 4405 4406 ~InstantiatingTemplate() { Clear(); } 4407 4408 /// \brief Determines whether we have exceeded the maximum 4409 /// recursive template instantiations. 4410 operator bool() const { return Invalid; } 4411 4412 private: 4413 Sema &SemaRef; 4414 bool Invalid; 4415 bool SavedInNonInstantiationSFINAEContext; 4416 bool CheckInstantiationDepth(SourceLocation PointOfInstantiation, 4417 SourceRange InstantiationRange); 4418 4419 InstantiatingTemplate(const InstantiatingTemplate&); // not implemented 4420 4421 InstantiatingTemplate& 4422 operator=(const InstantiatingTemplate&); // not implemented 4423 }; 4424 4425 void PrintInstantiationStack(); 4426 4427 /// \brief Determines whether we are currently in a context where 4428 /// template argument substitution failures are not considered 4429 /// errors. 4430 /// 4431 /// \returns An empty \c llvm::Optional if we're not in a SFINAE context. 4432 /// Otherwise, contains a pointer that, if non-NULL, contains the nearest 4433 /// template-deduction context object, which can be used to capture 4434 /// diagnostics that will be suppressed. 4435 llvm::Optional<sema::TemplateDeductionInfo *> isSFINAEContext() const; 4436 4437 /// \brief RAII class used to determine whether SFINAE has 4438 /// trapped any errors that occur during template argument 4439 /// deduction.` 4440 class SFINAETrap { 4441 Sema &SemaRef; 4442 unsigned PrevSFINAEErrors; 4443 bool PrevInNonInstantiationSFINAEContext; 4444 bool PrevAccessCheckingSFINAE; 4445 4446 public: 4447 explicit SFINAETrap(Sema &SemaRef, bool AccessCheckingSFINAE = false) 4448 : SemaRef(SemaRef), PrevSFINAEErrors(SemaRef.NumSFINAEErrors), 4449 PrevInNonInstantiationSFINAEContext( 4450 SemaRef.InNonInstantiationSFINAEContext), 4451 PrevAccessCheckingSFINAE(SemaRef.AccessCheckingSFINAE) 4452 { 4453 if (!SemaRef.isSFINAEContext()) 4454 SemaRef.InNonInstantiationSFINAEContext = true; 4455 SemaRef.AccessCheckingSFINAE = AccessCheckingSFINAE; 4456 } 4457 4458 ~SFINAETrap() { 4459 SemaRef.NumSFINAEErrors = PrevSFINAEErrors; 4460 SemaRef.InNonInstantiationSFINAEContext 4461 = PrevInNonInstantiationSFINAEContext; 4462 SemaRef.AccessCheckingSFINAE = PrevAccessCheckingSFINAE; 4463 } 4464 4465 /// \brief Determine whether any SFINAE errors have been trapped. 4466 bool hasErrorOccurred() const { 4467 return SemaRef.NumSFINAEErrors > PrevSFINAEErrors; 4468 } 4469 }; 4470 4471 /// \brief The current instantiation scope used to store local 4472 /// variables. 4473 LocalInstantiationScope *CurrentInstantiationScope; 4474 4475 /// \brief The number of typos corrected by CorrectTypo. 4476 unsigned TyposCorrected; 4477 4478 typedef llvm::DenseMap<IdentifierInfo *, std::pair<llvm::StringRef, bool> > 4479 UnqualifiedTyposCorrectedMap; 4480 4481 /// \brief A cache containing the results of typo correction for unqualified 4482 /// name lookup. 4483 /// 4484 /// The string is the string that we corrected to (which may be empty, if 4485 /// there was no correction), while the boolean will be true when the 4486 /// string represents a keyword. 4487 UnqualifiedTyposCorrectedMap UnqualifiedTyposCorrected; 4488 4489 /// \brief Worker object for performing CFG-based warnings. 4490 sema::AnalysisBasedWarnings AnalysisWarnings; 4491 4492 /// \brief An entity for which implicit template instantiation is required. 4493 /// 4494 /// The source location associated with the declaration is the first place in 4495 /// the source code where the declaration was "used". It is not necessarily 4496 /// the point of instantiation (which will be either before or after the 4497 /// namespace-scope declaration that triggered this implicit instantiation), 4498 /// However, it is the location that diagnostics should generally refer to, 4499 /// because users will need to know what code triggered the instantiation. 4500 typedef std::pair<ValueDecl *, SourceLocation> PendingImplicitInstantiation; 4501 4502 /// \brief The queue of implicit template instantiations that are required 4503 /// but have not yet been performed. 4504 std::deque<PendingImplicitInstantiation> PendingInstantiations; 4505 4506 /// \brief The queue of implicit template instantiations that are required 4507 /// and must be performed within the current local scope. 4508 /// 4509 /// This queue is only used for member functions of local classes in 4510 /// templates, which must be instantiated in the same scope as their 4511 /// enclosing function, so that they can reference function-local 4512 /// types, static variables, enumerators, etc. 4513 std::deque<PendingImplicitInstantiation> PendingLocalImplicitInstantiations; 4514 4515 bool PerformPendingInstantiations(bool LocalOnly = false); 4516 4517 TypeSourceInfo *SubstType(TypeSourceInfo *T, 4518 const MultiLevelTemplateArgumentList &TemplateArgs, 4519 SourceLocation Loc, DeclarationName Entity); 4520 4521 QualType SubstType(QualType T, 4522 const MultiLevelTemplateArgumentList &TemplateArgs, 4523 SourceLocation Loc, DeclarationName Entity); 4524 4525 TypeSourceInfo *SubstType(TypeLoc TL, 4526 const MultiLevelTemplateArgumentList &TemplateArgs, 4527 SourceLocation Loc, DeclarationName Entity); 4528 4529 TypeSourceInfo *SubstFunctionDeclType(TypeSourceInfo *T, 4530 const MultiLevelTemplateArgumentList &TemplateArgs, 4531 SourceLocation Loc, 4532 DeclarationName Entity); 4533 ParmVarDecl *SubstParmVarDecl(ParmVarDecl *D, 4534 const MultiLevelTemplateArgumentList &TemplateArgs, 4535 int indexAdjustment, 4536 llvm::Optional<unsigned> NumExpansions); 4537 bool SubstParmTypes(SourceLocation Loc, 4538 ParmVarDecl **Params, unsigned NumParams, 4539 const MultiLevelTemplateArgumentList &TemplateArgs, 4540 llvm::SmallVectorImpl<QualType> &ParamTypes, 4541 llvm::SmallVectorImpl<ParmVarDecl *> *OutParams = 0); 4542 ExprResult SubstExpr(Expr *E, 4543 const MultiLevelTemplateArgumentList &TemplateArgs); 4544 4545 /// \brief Substitute the given template arguments into a list of 4546 /// expressions, expanding pack expansions if required. 4547 /// 4548 /// \param Exprs The list of expressions to substitute into. 4549 /// 4550 /// \param NumExprs The number of expressions in \p Exprs. 4551 /// 4552 /// \param IsCall Whether this is some form of call, in which case 4553 /// default arguments will be dropped. 4554 /// 4555 /// \param TemplateArgs The set of template arguments to substitute. 4556 /// 4557 /// \param Outputs Will receive all of the substituted arguments. 4558 /// 4559 /// \returns true if an error occurred, false otherwise. 4560 bool SubstExprs(Expr **Exprs, unsigned NumExprs, bool IsCall, 4561 const MultiLevelTemplateArgumentList &TemplateArgs, 4562 llvm::SmallVectorImpl<Expr *> &Outputs); 4563 4564 StmtResult SubstStmt(Stmt *S, 4565 const MultiLevelTemplateArgumentList &TemplateArgs); 4566 4567 Decl *SubstDecl(Decl *D, DeclContext *Owner, 4568 const MultiLevelTemplateArgumentList &TemplateArgs); 4569 4570 bool 4571 SubstBaseSpecifiers(CXXRecordDecl *Instantiation, 4572 CXXRecordDecl *Pattern, 4573 const MultiLevelTemplateArgumentList &TemplateArgs); 4574 4575 bool 4576 InstantiateClass(SourceLocation PointOfInstantiation, 4577 CXXRecordDecl *Instantiation, CXXRecordDecl *Pattern, 4578 const MultiLevelTemplateArgumentList &TemplateArgs, 4579 TemplateSpecializationKind TSK, 4580 bool Complain = true); 4581 4582 void InstantiateAttrs(const MultiLevelTemplateArgumentList &TemplateArgs, 4583 Decl *Pattern, Decl *Inst); 4584 4585 bool 4586 InstantiateClassTemplateSpecialization(SourceLocation PointOfInstantiation, 4587 ClassTemplateSpecializationDecl *ClassTemplateSpec, 4588 TemplateSpecializationKind TSK, 4589 bool Complain = true); 4590 4591 void InstantiateClassMembers(SourceLocation PointOfInstantiation, 4592 CXXRecordDecl *Instantiation, 4593 const MultiLevelTemplateArgumentList &TemplateArgs, 4594 TemplateSpecializationKind TSK); 4595 4596 void InstantiateClassTemplateSpecializationMembers( 4597 SourceLocation PointOfInstantiation, 4598 ClassTemplateSpecializationDecl *ClassTemplateSpec, 4599 TemplateSpecializationKind TSK); 4600 4601 NestedNameSpecifierLoc 4602 SubstNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS, 4603 const MultiLevelTemplateArgumentList &TemplateArgs); 4604 4605 DeclarationNameInfo 4606 SubstDeclarationNameInfo(const DeclarationNameInfo &NameInfo, 4607 const MultiLevelTemplateArgumentList &TemplateArgs); 4608 TemplateName 4609 SubstTemplateName(NestedNameSpecifierLoc QualifierLoc, TemplateName Name, 4610 SourceLocation Loc, 4611 const MultiLevelTemplateArgumentList &TemplateArgs); 4612 bool Subst(const TemplateArgumentLoc *Args, unsigned NumArgs, 4613 TemplateArgumentListInfo &Result, 4614 const MultiLevelTemplateArgumentList &TemplateArgs); 4615 4616 void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, 4617 FunctionDecl *Function, 4618 bool Recursive = false, 4619 bool DefinitionRequired = false); 4620 void InstantiateStaticDataMemberDefinition( 4621 SourceLocation PointOfInstantiation, 4622 VarDecl *Var, 4623 bool Recursive = false, 4624 bool DefinitionRequired = false); 4625 4626 void InstantiateMemInitializers(CXXConstructorDecl *New, 4627 const CXXConstructorDecl *Tmpl, 4628 const MultiLevelTemplateArgumentList &TemplateArgs); 4629 4630 NamedDecl *FindInstantiatedDecl(SourceLocation Loc, NamedDecl *D, 4631 const MultiLevelTemplateArgumentList &TemplateArgs); 4632 DeclContext *FindInstantiatedContext(SourceLocation Loc, DeclContext *DC, 4633 const MultiLevelTemplateArgumentList &TemplateArgs); 4634 4635 // Objective-C declarations. 4636 Decl *ActOnStartClassInterface(SourceLocation AtInterfaceLoc, 4637 IdentifierInfo *ClassName, 4638 SourceLocation ClassLoc, 4639 IdentifierInfo *SuperName, 4640 SourceLocation SuperLoc, 4641 Decl * const *ProtoRefs, 4642 unsigned NumProtoRefs, 4643 const SourceLocation *ProtoLocs, 4644 SourceLocation EndProtoLoc, 4645 AttributeList *AttrList); 4646 4647 Decl *ActOnCompatiblityAlias( 4648 SourceLocation AtCompatibilityAliasLoc, 4649 IdentifierInfo *AliasName, SourceLocation AliasLocation, 4650 IdentifierInfo *ClassName, SourceLocation ClassLocation); 4651 4652 void CheckForwardProtocolDeclarationForCircularDependency( 4653 IdentifierInfo *PName, 4654 SourceLocation &PLoc, SourceLocation PrevLoc, 4655 const ObjCList<ObjCProtocolDecl> &PList); 4656 4657 Decl *ActOnStartProtocolInterface( 4658 SourceLocation AtProtoInterfaceLoc, 4659 IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, 4660 Decl * const *ProtoRefNames, unsigned NumProtoRefs, 4661 const SourceLocation *ProtoLocs, 4662 SourceLocation EndProtoLoc, 4663 AttributeList *AttrList); 4664 4665 Decl *ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, 4666 IdentifierInfo *ClassName, 4667 SourceLocation ClassLoc, 4668 IdentifierInfo *CategoryName, 4669 SourceLocation CategoryLoc, 4670 Decl * const *ProtoRefs, 4671 unsigned NumProtoRefs, 4672 const SourceLocation *ProtoLocs, 4673 SourceLocation EndProtoLoc); 4674 4675 Decl *ActOnStartClassImplementation( 4676 SourceLocation AtClassImplLoc, 4677 IdentifierInfo *ClassName, SourceLocation ClassLoc, 4678 IdentifierInfo *SuperClassname, 4679 SourceLocation SuperClassLoc); 4680 4681 Decl *ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, 4682 IdentifierInfo *ClassName, 4683 SourceLocation ClassLoc, 4684 IdentifierInfo *CatName, 4685 SourceLocation CatLoc); 4686 4687 Decl *ActOnForwardClassDeclaration(SourceLocation Loc, 4688 IdentifierInfo **IdentList, 4689 SourceLocation *IdentLocs, 4690 unsigned NumElts); 4691 4692 Decl *ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, 4693 const IdentifierLocPair *IdentList, 4694 unsigned NumElts, 4695 AttributeList *attrList); 4696 4697 void FindProtocolDeclaration(bool WarnOnDeclarations, 4698 const IdentifierLocPair *ProtocolId, 4699 unsigned NumProtocols, 4700 llvm::SmallVectorImpl<Decl *> &Protocols); 4701 4702 /// Ensure attributes are consistent with type. 4703 /// \param [in, out] Attributes The attributes to check; they will 4704 /// be modified to be consistent with \arg PropertyTy. 4705 void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, 4706 SourceLocation Loc, 4707 unsigned &Attributes); 4708 4709 /// Process the specified property declaration and create decls for the 4710 /// setters and getters as needed. 4711 /// \param property The property declaration being processed 4712 /// \param DC The semantic container for the property 4713 /// \param redeclaredProperty Declaration for property if redeclared 4714 /// in class extension. 4715 /// \param lexicalDC Container for redeclaredProperty. 4716 void ProcessPropertyDecl(ObjCPropertyDecl *property, 4717 ObjCContainerDecl *DC, 4718 ObjCPropertyDecl *redeclaredProperty = 0, 4719 ObjCContainerDecl *lexicalDC = 0); 4720 4721 void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, 4722 ObjCPropertyDecl *SuperProperty, 4723 const IdentifierInfo *Name); 4724 void ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl); 4725 4726 void CompareMethodParamsInBaseAndSuper(Decl *IDecl, 4727 ObjCMethodDecl *MethodDecl, 4728 bool IsInstance); 4729 4730 void CompareProperties(Decl *CDecl, Decl *MergeProtocols); 4731 4732 void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, 4733 ObjCInterfaceDecl *ID); 4734 4735 void MatchOneProtocolPropertiesInClass(Decl *CDecl, 4736 ObjCProtocolDecl *PDecl); 4737 4738 void ActOnAtEnd(Scope *S, SourceRange AtEnd, Decl *classDecl, 4739 Decl **allMethods = 0, unsigned allNum = 0, 4740 Decl **allProperties = 0, unsigned pNum = 0, 4741 DeclGroupPtrTy *allTUVars = 0, unsigned tuvNum = 0); 4742 4743 Decl *ActOnProperty(Scope *S, SourceLocation AtLoc, 4744 FieldDeclarator &FD, ObjCDeclSpec &ODS, 4745 Selector GetterSel, Selector SetterSel, 4746 Decl *ClassCategory, 4747 bool *OverridingProperty, 4748 tok::ObjCKeywordKind MethodImplKind, 4749 DeclContext *lexicalDC = 0); 4750 4751 Decl *ActOnPropertyImplDecl(Scope *S, 4752 SourceLocation AtLoc, 4753 SourceLocation PropertyLoc, 4754 bool ImplKind,Decl *ClassImplDecl, 4755 IdentifierInfo *PropertyId, 4756 IdentifierInfo *PropertyIvar, 4757 SourceLocation PropertyIvarLoc); 4758 4759 struct ObjCArgInfo { 4760 IdentifierInfo *Name; 4761 SourceLocation NameLoc; 4762 // The Type is null if no type was specified, and the DeclSpec is invalid 4763 // in this case. 4764 ParsedType Type; 4765 ObjCDeclSpec DeclSpec; 4766 4767 /// ArgAttrs - Attribute list for this argument. 4768 AttributeList *ArgAttrs; 4769 }; 4770 4771 Decl *ActOnMethodDeclaration( 4772 Scope *S, 4773 SourceLocation BeginLoc, // location of the + or -. 4774 SourceLocation EndLoc, // location of the ; or {. 4775 tok::TokenKind MethodType, 4776 Decl *ClassDecl, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, 4777 Selector Sel, 4778 // optional arguments. The number of types/arguments is obtained 4779 // from the Sel.getNumArgs(). 4780 ObjCArgInfo *ArgInfo, 4781 DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, // c-style args 4782 AttributeList *AttrList, tok::ObjCKeywordKind MethodImplKind, 4783 bool isVariadic, bool MethodDefinition); 4784 4785 // Helper method for ActOnClassMethod/ActOnInstanceMethod. 4786 // Will search "local" class/category implementations for a method decl. 4787 // Will also search in class's root looking for instance method. 4788 // Returns 0 if no method is found. 4789 ObjCMethodDecl *LookupPrivateClassMethod(Selector Sel, 4790 ObjCInterfaceDecl *CDecl); 4791 ObjCMethodDecl *LookupPrivateInstanceMethod(Selector Sel, 4792 ObjCInterfaceDecl *ClassDecl); 4793 ObjCMethodDecl *LookupMethodInQualifiedType(Selector Sel, 4794 const ObjCObjectPointerType *OPT, 4795 bool IsInstance); 4796 4797 ExprResult 4798 HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, 4799 Expr *BaseExpr, 4800 DeclarationName MemberName, 4801 SourceLocation MemberLoc, 4802 SourceLocation SuperLoc, QualType SuperType, 4803 bool Super); 4804 4805 ExprResult 4806 ActOnClassPropertyRefExpr(IdentifierInfo &receiverName, 4807 IdentifierInfo &propertyName, 4808 SourceLocation receiverNameLoc, 4809 SourceLocation propertyNameLoc); 4810 4811 ObjCMethodDecl *tryCaptureObjCSelf(); 4812 4813 /// \brief Describes the kind of message expression indicated by a message 4814 /// send that starts with an identifier. 4815 enum ObjCMessageKind { 4816 /// \brief The message is sent to 'super'. 4817 ObjCSuperMessage, 4818 /// \brief The message is an instance message. 4819 ObjCInstanceMessage, 4820 /// \brief The message is a class message, and the identifier is a type 4821 /// name. 4822 ObjCClassMessage 4823 }; 4824 4825 ObjCMessageKind getObjCMessageKind(Scope *S, 4826 IdentifierInfo *Name, 4827 SourceLocation NameLoc, 4828 bool IsSuper, 4829 bool HasTrailingDot, 4830 ParsedType &ReceiverType); 4831 4832 ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, 4833 Selector Sel, 4834 SourceLocation LBracLoc, 4835 SourceLocation SelectorLoc, 4836 SourceLocation RBracLoc, 4837 MultiExprArg Args); 4838 4839 ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, 4840 QualType ReceiverType, 4841 SourceLocation SuperLoc, 4842 Selector Sel, 4843 ObjCMethodDecl *Method, 4844 SourceLocation LBracLoc, 4845 SourceLocation SelectorLoc, 4846 SourceLocation RBracLoc, 4847 MultiExprArg Args); 4848 4849 ExprResult ActOnClassMessage(Scope *S, 4850 ParsedType Receiver, 4851 Selector Sel, 4852 SourceLocation LBracLoc, 4853 SourceLocation SelectorLoc, 4854 SourceLocation RBracLoc, 4855 MultiExprArg Args); 4856 4857 ExprResult BuildInstanceMessage(Expr *Receiver, 4858 QualType ReceiverType, 4859 SourceLocation SuperLoc, 4860 Selector Sel, 4861 ObjCMethodDecl *Method, 4862 SourceLocation LBracLoc, 4863 SourceLocation SelectorLoc, 4864 SourceLocation RBracLoc, 4865 MultiExprArg Args); 4866 4867 ExprResult ActOnInstanceMessage(Scope *S, 4868 Expr *Receiver, 4869 Selector Sel, 4870 SourceLocation LBracLoc, 4871 SourceLocation SelectorLoc, 4872 SourceLocation RBracLoc, 4873 MultiExprArg Args); 4874 4875 4876 enum PragmaOptionsAlignKind { 4877 POAK_Native, // #pragma options align=native 4878 POAK_Natural, // #pragma options align=natural 4879 POAK_Packed, // #pragma options align=packed 4880 POAK_Power, // #pragma options align=power 4881 POAK_Mac68k, // #pragma options align=mac68k 4882 POAK_Reset // #pragma options align=reset 4883 }; 4884 4885 /// ActOnPragmaOptionsAlign - Called on well formed #pragma options align. 4886 void ActOnPragmaOptionsAlign(PragmaOptionsAlignKind Kind, 4887 SourceLocation PragmaLoc, 4888 SourceLocation KindLoc); 4889 4890 enum PragmaPackKind { 4891 PPK_Default, // #pragma pack([n]) 4892 PPK_Show, // #pragma pack(show), only supported by MSVC. 4893 PPK_Push, // #pragma pack(push, [identifier], [n]) 4894 PPK_Pop // #pragma pack(pop, [identifier], [n]) 4895 }; 4896 4897 enum PragmaMSStructKind { 4898 PMSST_OFF, // #pragms ms_struct off 4899 PMSST_ON // #pragms ms_struct on 4900 }; 4901 4902 /// ActOnPragmaPack - Called on well formed #pragma pack(...). 4903 void ActOnPragmaPack(PragmaPackKind Kind, 4904 IdentifierInfo *Name, 4905 Expr *Alignment, 4906 SourceLocation PragmaLoc, 4907 SourceLocation LParenLoc, 4908 SourceLocation RParenLoc); 4909 4910 /// ActOnPragmaMSStruct - Called on well formed #pragms ms_struct [on|off]. 4911 void ActOnPragmaMSStruct(PragmaMSStructKind Kind); 4912 4913 /// ActOnPragmaUnused - Called on well-formed '#pragma unused'. 4914 void ActOnPragmaUnused(const Token &Identifier, 4915 Scope *curScope, 4916 SourceLocation PragmaLoc); 4917 4918 /// ActOnPragmaVisibility - Called on well formed #pragma GCC visibility... . 4919 void ActOnPragmaVisibility(bool IsPush, const IdentifierInfo* VisType, 4920 SourceLocation PragmaLoc); 4921 4922 NamedDecl *DeclClonePragmaWeak(NamedDecl *ND, IdentifierInfo *II); 4923 void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W); 4924 4925 /// ActOnPragmaWeakID - Called on well formed #pragma weak ident. 4926 void ActOnPragmaWeakID(IdentifierInfo* WeakName, 4927 SourceLocation PragmaLoc, 4928 SourceLocation WeakNameLoc); 4929 4930 /// ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident. 4931 void ActOnPragmaWeakAlias(IdentifierInfo* WeakName, 4932 IdentifierInfo* AliasName, 4933 SourceLocation PragmaLoc, 4934 SourceLocation WeakNameLoc, 4935 SourceLocation AliasNameLoc); 4936 4937 /// ActOnPragmaFPContract - Called on well formed 4938 /// #pragma {STDC,OPENCL} FP_CONTRACT 4939 void ActOnPragmaFPContract(tok::OnOffSwitch OOS); 4940 4941 /// AddAlignmentAttributesForRecord - Adds any needed alignment attributes to 4942 /// a the record decl, to handle '#pragma pack' and '#pragma options align'. 4943 void AddAlignmentAttributesForRecord(RecordDecl *RD); 4944 4945 /// AddMsStructLayoutForRecord - Adds ms_struct layout attribute to record. 4946 void AddMsStructLayoutForRecord(RecordDecl *RD); 4947 4948 /// FreePackedContext - Deallocate and null out PackContext. 4949 void FreePackedContext(); 4950 4951 /// PushNamespaceVisibilityAttr - Note that we've entered a 4952 /// namespace with a visibility attribute. 4953 void PushNamespaceVisibilityAttr(const VisibilityAttr *Attr); 4954 4955 /// AddPushedVisibilityAttribute - If '#pragma GCC visibility' was used, 4956 /// add an appropriate visibility attribute. 4957 void AddPushedVisibilityAttribute(Decl *RD); 4958 4959 /// PopPragmaVisibility - Pop the top element of the visibility stack; used 4960 /// for '#pragma GCC visibility' and visibility attributes on namespaces. 4961 void PopPragmaVisibility(); 4962 4963 /// FreeVisContext - Deallocate and null out VisContext. 4964 void FreeVisContext(); 4965 4966 /// AddAlignedAttr - Adds an aligned attribute to a particular declaration. 4967 void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, Expr *E); 4968 void AddAlignedAttr(SourceLocation AttrLoc, Decl *D, TypeSourceInfo *T); 4969 4970 /// CastCategory - Get the correct forwarded implicit cast result category 4971 /// from the inner expression. 4972 ExprValueKind CastCategory(Expr *E); 4973 4974 /// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit 4975 /// cast. If there is already an implicit cast, merge into the existing one. 4976 /// If isLvalue, the result of the cast is an lvalue. 4977 ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, 4978 ExprValueKind VK = VK_RValue, 4979 const CXXCastPath *BasePath = 0); 4980 4981 /// ScalarTypeToBooleanCastKind - Returns the cast kind corresponding 4982 /// to the conversion from scalar type ScalarTy to the Boolean type. 4983 static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy); 4984 4985 /// IgnoredValueConversions - Given that an expression's result is 4986 /// syntactically ignored, perform any conversions that are 4987 /// required. 4988 ExprResult IgnoredValueConversions(Expr *E); 4989 4990 // UsualUnaryConversions - promotes integers (C99 6.3.1.1p2) and converts 4991 // functions and arrays to their respective pointers (C99 6.3.2.1). 4992 ExprResult UsualUnaryConversions(Expr *E); 4993 4994 // DefaultFunctionArrayConversion - converts functions and arrays 4995 // to their respective pointers (C99 6.3.2.1). 4996 ExprResult DefaultFunctionArrayConversion(Expr *E); 4997 4998 // DefaultFunctionArrayLvalueConversion - converts functions and 4999 // arrays to their respective pointers and performs the 5000 // lvalue-to-rvalue conversion. 5001 ExprResult DefaultFunctionArrayLvalueConversion(Expr *E); 5002 5003 // DefaultLvalueConversion - performs lvalue-to-rvalue conversion on 5004 // the operand. This is DefaultFunctionArrayLvalueConversion, 5005 // except that it assumes the operand isn't of function or array 5006 // type. 5007 ExprResult DefaultLvalueConversion(Expr *E); 5008 5009 // DefaultArgumentPromotion (C99 6.5.2.2p6). Used for function calls that 5010 // do not have a prototype. Integer promotions are performed on each 5011 // argument, and arguments that have type float are promoted to double. 5012 ExprResult DefaultArgumentPromotion(Expr *E); 5013 5014 // Used for emitting the right warning by DefaultVariadicArgumentPromotion 5015 enum VariadicCallType { 5016 VariadicFunction, 5017 VariadicBlock, 5018 VariadicMethod, 5019 VariadicConstructor, 5020 VariadicDoesNotApply 5021 }; 5022 5023 /// GatherArgumentsForCall - Collector argument expressions for various 5024 /// form of call prototypes. 5025 bool GatherArgumentsForCall(SourceLocation CallLoc, 5026 FunctionDecl *FDecl, 5027 const FunctionProtoType *Proto, 5028 unsigned FirstProtoArg, 5029 Expr **Args, unsigned NumArgs, 5030 llvm::SmallVector<Expr *, 8> &AllArgs, 5031 VariadicCallType CallType = VariadicDoesNotApply); 5032 5033 // DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but 5034 // will warn if the resulting type is not a POD type. 5035 ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, 5036 FunctionDecl *FDecl); 5037 5038 // UsualArithmeticConversions - performs the UsualUnaryConversions on it's 5039 // operands and then handles various conversions that are common to binary 5040 // operators (C99 6.3.1.8). If both operands aren't arithmetic, this 5041 // routine returns the first non-arithmetic type found. The client is 5042 // responsible for emitting appropriate error diagnostics. 5043 QualType UsualArithmeticConversions(ExprResult &lExpr, ExprResult &rExpr, 5044 bool isCompAssign = false); 5045 5046 /// AssignConvertType - All of the 'assignment' semantic checks return this 5047 /// enum to indicate whether the assignment was allowed. These checks are 5048 /// done for simple assignments, as well as initialization, return from 5049 /// function, argument passing, etc. The query is phrased in terms of a 5050 /// source and destination type. 5051 enum AssignConvertType { 5052 /// Compatible - the types are compatible according to the standard. 5053 Compatible, 5054 5055 /// PointerToInt - The assignment converts a pointer to an int, which we 5056 /// accept as an extension. 5057 PointerToInt, 5058 5059 /// IntToPointer - The assignment converts an int to a pointer, which we 5060 /// accept as an extension. 5061 IntToPointer, 5062 5063 /// FunctionVoidPointer - The assignment is between a function pointer and 5064 /// void*, which the standard doesn't allow, but we accept as an extension. 5065 FunctionVoidPointer, 5066 5067 /// IncompatiblePointer - The assignment is between two pointers types that 5068 /// are not compatible, but we accept them as an extension. 5069 IncompatiblePointer, 5070 5071 /// IncompatiblePointer - The assignment is between two pointers types which 5072 /// point to integers which have a different sign, but are otherwise identical. 5073 /// This is a subset of the above, but broken out because it's by far the most 5074 /// common case of incompatible pointers. 5075 IncompatiblePointerSign, 5076 5077 /// CompatiblePointerDiscardsQualifiers - The assignment discards 5078 /// c/v/r qualifiers, which we accept as an extension. 5079 CompatiblePointerDiscardsQualifiers, 5080 5081 /// IncompatiblePointerDiscardsQualifiers - The assignment 5082 /// discards qualifiers that we don't permit to be discarded, 5083 /// like address spaces. 5084 IncompatiblePointerDiscardsQualifiers, 5085 5086 /// IncompatibleNestedPointerQualifiers - The assignment is between two 5087 /// nested pointer types, and the qualifiers other than the first two 5088 /// levels differ e.g. char ** -> const char **, but we accept them as an 5089 /// extension. 5090 IncompatibleNestedPointerQualifiers, 5091 5092 /// IncompatibleVectors - The assignment is between two vector types that 5093 /// have the same size, which we accept as an extension. 5094 IncompatibleVectors, 5095 5096 /// IntToBlockPointer - The assignment converts an int to a block 5097 /// pointer. We disallow this. 5098 IntToBlockPointer, 5099 5100 /// IncompatibleBlockPointer - The assignment is between two block 5101 /// pointers types that are not compatible. 5102 IncompatibleBlockPointer, 5103 5104 /// IncompatibleObjCQualifiedId - The assignment is between a qualified 5105 /// id type and something else (that is incompatible with it). For example, 5106 /// "id <XXX>" = "Foo *", where "Foo *" doesn't implement the XXX protocol. 5107 IncompatibleObjCQualifiedId, 5108 5109 /// Incompatible - We reject this conversion outright, it is invalid to 5110 /// represent it in the AST. 5111 Incompatible 5112 }; 5113 5114 /// DiagnoseAssignmentResult - Emit a diagnostic, if required, for the 5115 /// assignment conversion type specified by ConvTy. This returns true if the 5116 /// conversion was invalid or false if the conversion was accepted. 5117 bool DiagnoseAssignmentResult(AssignConvertType ConvTy, 5118 SourceLocation Loc, 5119 QualType DstType, QualType SrcType, 5120 Expr *SrcExpr, AssignmentAction Action, 5121 bool *Complained = 0); 5122 5123 /// CheckAssignmentConstraints - Perform type checking for assignment, 5124 /// argument passing, variable initialization, and function return values. 5125 /// C99 6.5.16. 5126 AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, 5127 QualType lhs, QualType rhs); 5128 5129 /// Check assignment constraints and prepare for a conversion of the 5130 /// RHS to the LHS type. 5131 AssignConvertType CheckAssignmentConstraints(QualType lhs, ExprResult &rhs, 5132 CastKind &Kind); 5133 5134 // CheckSingleAssignmentConstraints - Currently used by 5135 // CheckAssignmentOperands, and ActOnReturnStmt. Prior to type checking, 5136 // this routine performs the default function/array converions. 5137 AssignConvertType CheckSingleAssignmentConstraints(QualType lhs, 5138 ExprResult &rExprRes); 5139 5140 // \brief If the lhs type is a transparent union, check whether we 5141 // can initialize the transparent union with the given expression. 5142 AssignConvertType CheckTransparentUnionArgumentConstraints(QualType lhs, 5143 ExprResult &rExpr); 5144 5145 bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType); 5146 5147 bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType); 5148 5149 ExprResult PerformImplicitConversion(Expr *From, QualType ToType, 5150 AssignmentAction Action, 5151 bool AllowExplicit = false); 5152 ExprResult PerformImplicitConversion(Expr *From, QualType ToType, 5153 AssignmentAction Action, 5154 bool AllowExplicit, 5155 ImplicitConversionSequence& ICS); 5156 ExprResult PerformImplicitConversion(Expr *From, QualType ToType, 5157 const ImplicitConversionSequence& ICS, 5158 AssignmentAction Action, 5159 bool CStyle = false); 5160 ExprResult PerformImplicitConversion(Expr *From, QualType ToType, 5161 const StandardConversionSequence& SCS, 5162 AssignmentAction Action, 5163 bool CStyle); 5164 5165 /// the following "Check" methods will return a valid/converted QualType 5166 /// or a null QualType (indicating an error diagnostic was issued). 5167 5168 /// type checking binary operators (subroutines of CreateBuiltinBinOp). 5169 QualType InvalidOperands(SourceLocation l, ExprResult &lex, ExprResult &rex); 5170 QualType CheckPointerToMemberOperands( // C++ 5.5 5171 ExprResult &lex, ExprResult &rex, ExprValueKind &VK, 5172 SourceLocation OpLoc, bool isIndirect); 5173 QualType CheckMultiplyDivideOperands( // C99 6.5.5 5174 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, bool isCompAssign, 5175 bool isDivide); 5176 QualType CheckRemainderOperands( // C99 6.5.5 5177 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, bool isCompAssign = false); 5178 QualType CheckAdditionOperands( // C99 6.5.6 5179 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, QualType* CompLHSTy = 0); 5180 QualType CheckSubtractionOperands( // C99 6.5.6 5181 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, QualType* CompLHSTy = 0); 5182 QualType CheckShiftOperands( // C99 6.5.7 5183 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, unsigned Opc, 5184 bool isCompAssign = false); 5185 QualType CheckCompareOperands( // C99 6.5.8/9 5186 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, unsigned Opc, 5187 bool isRelational); 5188 QualType CheckBitwiseOperands( // C99 6.5.[10...12] 5189 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, bool isCompAssign = false); 5190 QualType CheckLogicalOperands( // C99 6.5.[13,14] 5191 ExprResult &lex, ExprResult &rex, SourceLocation OpLoc, unsigned Opc); 5192 // CheckAssignmentOperands is used for both simple and compound assignment. 5193 // For simple assignment, pass both expressions and a null converted type. 5194 // For compound assignment, pass both expressions and the converted type. 5195 QualType CheckAssignmentOperands( // C99 6.5.16.[1,2] 5196 Expr *lex, ExprResult &rex, SourceLocation OpLoc, QualType convertedType); 5197 5198 void ConvertPropertyForLValue(ExprResult &LHS, ExprResult &RHS, QualType& LHSTy); 5199 ExprResult ConvertPropertyForRValue(Expr *E); 5200 5201 QualType CheckConditionalOperands( // C99 6.5.15 5202 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, 5203 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc); 5204 QualType CXXCheckConditionalOperands( // C++ 5.16 5205 ExprResult &cond, ExprResult &lhs, ExprResult &rhs, 5206 ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc); 5207 QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, 5208 bool *NonStandardCompositeType = 0); 5209 QualType FindCompositePointerType(SourceLocation Loc, ExprResult &E1, ExprResult &E2, 5210 bool *NonStandardCompositeType = 0) { 5211 Expr *E1Tmp = E1.take(), *E2Tmp = E2.take(); 5212 QualType Composite = FindCompositePointerType(Loc, E1Tmp, E2Tmp, NonStandardCompositeType); 5213 E1 = Owned(E1Tmp); 5214 E2 = Owned(E2Tmp); 5215 return Composite; 5216 } 5217 5218 QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, 5219 SourceLocation questionLoc); 5220 5221 bool DiagnoseConditionalForNull(Expr *LHS, Expr *RHS, 5222 SourceLocation QuestionLoc); 5223 5224 /// type checking for vector binary operators. 5225 QualType CheckVectorOperands(SourceLocation l, ExprResult &lex, ExprResult &rex); 5226 QualType CheckVectorCompareOperands(ExprResult &lex, ExprResult &rx, 5227 SourceLocation l, bool isRel); 5228 5229 /// type checking declaration initializers (C99 6.7.8) 5230 bool CheckInitList(const InitializedEntity &Entity, 5231 InitListExpr *&InitList, QualType &DeclType); 5232 bool CheckForConstantInitializer(Expr *e, QualType t); 5233 5234 // type checking C++ declaration initializers (C++ [dcl.init]). 5235 5236 /// ReferenceCompareResult - Expresses the result of comparing two 5237 /// types (cv1 T1 and cv2 T2) to determine their compatibility for the 5238 /// purposes of initialization by reference (C++ [dcl.init.ref]p4). 5239 enum ReferenceCompareResult { 5240 /// Ref_Incompatible - The two types are incompatible, so direct 5241 /// reference binding is not possible. 5242 Ref_Incompatible = 0, 5243 /// Ref_Related - The two types are reference-related, which means 5244 /// that their unqualified forms (T1 and T2) are either the same 5245 /// or T1 is a base class of T2. 5246 Ref_Related, 5247 /// Ref_Compatible_With_Added_Qualification - The two types are 5248 /// reference-compatible with added qualification, meaning that 5249 /// they are reference-compatible and the qualifiers on T1 (cv1) 5250 /// are greater than the qualifiers on T2 (cv2). 5251 Ref_Compatible_With_Added_Qualification, 5252 /// Ref_Compatible - The two types are reference-compatible and 5253 /// have equivalent qualifiers (cv1 == cv2). 5254 Ref_Compatible 5255 }; 5256 5257 ReferenceCompareResult CompareReferenceRelationship(SourceLocation Loc, 5258 QualType T1, QualType T2, 5259 bool &DerivedToBase, 5260 bool &ObjCConversion); 5261 5262 /// CheckCastTypes - Check type constraints for casting between types under 5263 /// C semantics, or forward to CXXCheckCStyleCast in C++. 5264 ExprResult CheckCastTypes(SourceRange TyRange, QualType CastTy, Expr *CastExpr, 5265 CastKind &Kind, ExprValueKind &VK, CXXCastPath &BasePath, 5266 bool FunctionalStyle = false); 5267 5268 ExprResult checkUnknownAnyCast(SourceRange TyRange, QualType castType, 5269 Expr *castExpr, CastKind &castKind, 5270 ExprValueKind &valueKind, CXXCastPath &BasePath); 5271 5272 // CheckVectorCast - check type constraints for vectors. 5273 // Since vectors are an extension, there are no C standard reference for this. 5274 // We allow casting between vectors and integer datatypes of the same size. 5275 // returns true if the cast is invalid 5276 bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, 5277 CastKind &Kind); 5278 5279 // CheckExtVectorCast - check type constraints for extended vectors. 5280 // Since vectors are an extension, there are no C standard reference for this. 5281 // We allow casting between vectors and integer datatypes of the same size, 5282 // or vectors and the element type of that vector. 5283 // returns the cast expr 5284 ExprResult CheckExtVectorCast(SourceRange R, QualType VectorTy, Expr *CastExpr, 5285 CastKind &Kind); 5286 5287 /// CXXCheckCStyleCast - Check constraints of a C-style or function-style 5288 /// cast under C++ semantics. 5289 ExprResult CXXCheckCStyleCast(SourceRange R, QualType CastTy, ExprValueKind &VK, 5290 Expr *CastExpr, CastKind &Kind, 5291 CXXCastPath &BasePath, bool FunctionalStyle); 5292 5293 /// CheckMessageArgumentTypes - Check types in an Obj-C message send. 5294 /// \param Method - May be null. 5295 /// \param [out] ReturnType - The return type of the send. 5296 /// \return true iff there were any incompatible types. 5297 bool CheckMessageArgumentTypes(Expr **Args, unsigned NumArgs, Selector Sel, 5298 ObjCMethodDecl *Method, bool isClassMessage, 5299 SourceLocation lbrac, SourceLocation rbrac, 5300 QualType &ReturnType, ExprValueKind &VK); 5301 5302 /// CheckBooleanCondition - Diagnose problems involving the use of 5303 /// the given expression as a boolean condition (e.g. in an if 5304 /// statement). Also performs the standard function and array 5305 /// decays, possibly changing the input variable. 5306 /// 5307 /// \param Loc - A location associated with the condition, e.g. the 5308 /// 'if' keyword. 5309 /// \return true iff there were any errors 5310 ExprResult CheckBooleanCondition(Expr *CondExpr, SourceLocation Loc); 5311 5312 ExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc, 5313 Expr *SubExpr); 5314 5315 /// DiagnoseAssignmentAsCondition - Given that an expression is 5316 /// being used as a boolean condition, warn if it's an assignment. 5317 void DiagnoseAssignmentAsCondition(Expr *E); 5318 5319 /// \brief Redundant parentheses over an equality comparison can indicate 5320 /// that the user intended an assignment used as condition. 5321 void DiagnoseEqualityWithExtraParens(ParenExpr *parenE); 5322 5323 /// CheckCXXBooleanCondition - Returns true if conversion to bool is invalid. 5324 ExprResult CheckCXXBooleanCondition(Expr *CondExpr); 5325 5326 /// ConvertIntegerToTypeWarnOnOverflow - Convert the specified APInt to have 5327 /// the specified width and sign. If an overflow occurs, detect it and emit 5328 /// the specified diagnostic. 5329 void ConvertIntegerToTypeWarnOnOverflow(llvm::APSInt &OldVal, 5330 unsigned NewWidth, bool NewSign, 5331 SourceLocation Loc, unsigned DiagID); 5332 5333 /// Checks that the Objective-C declaration is declared in the global scope. 5334 /// Emits an error and marks the declaration as invalid if it's not declared 5335 /// in the global scope. 5336 bool CheckObjCDeclScope(Decl *D); 5337 5338 /// VerifyIntegerConstantExpression - verifies that an expression is an ICE, 5339 /// and reports the appropriate diagnostics. Returns false on success. 5340 /// Can optionally return the value of the expression. 5341 bool VerifyIntegerConstantExpression(const Expr *E, llvm::APSInt *Result = 0); 5342 5343 /// VerifyBitField - verifies that a bit field expression is an ICE and has 5344 /// the correct width, and that the field type is valid. 5345 /// Returns false on success. 5346 /// Can optionally return whether the bit-field is of width 0 5347 bool VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, 5348 QualType FieldTy, const Expr *BitWidth, 5349 bool *ZeroWidth = 0); 5350 5351 /// \name Code completion 5352 //@{ 5353 /// \brief Describes the context in which code completion occurs. 5354 enum ParserCompletionContext { 5355 /// \brief Code completion occurs at top-level or namespace context. 5356 PCC_Namespace, 5357 /// \brief Code completion occurs within a class, struct, or union. 5358 PCC_Class, 5359 /// \brief Code completion occurs within an Objective-C interface, protocol, 5360 /// or category. 5361 PCC_ObjCInterface, 5362 /// \brief Code completion occurs within an Objective-C implementation or 5363 /// category implementation 5364 PCC_ObjCImplementation, 5365 /// \brief Code completion occurs within the list of instance variables 5366 /// in an Objective-C interface, protocol, category, or implementation. 5367 PCC_ObjCInstanceVariableList, 5368 /// \brief Code completion occurs following one or more template 5369 /// headers. 5370 PCC_Template, 5371 /// \brief Code completion occurs following one or more template 5372 /// headers within a class. 5373 PCC_MemberTemplate, 5374 /// \brief Code completion occurs within an expression. 5375 PCC_Expression, 5376 /// \brief Code completion occurs within a statement, which may 5377 /// also be an expression or a declaration. 5378 PCC_Statement, 5379 /// \brief Code completion occurs at the beginning of the 5380 /// initialization statement (or expression) in a for loop. 5381 PCC_ForInit, 5382 /// \brief Code completion occurs within the condition of an if, 5383 /// while, switch, or for statement. 5384 PCC_Condition, 5385 /// \brief Code completion occurs within the body of a function on a 5386 /// recovery path, where we do not have a specific handle on our position 5387 /// in the grammar. 5388 PCC_RecoveryInFunction, 5389 /// \brief Code completion occurs where only a type is permitted. 5390 PCC_Type, 5391 /// \brief Code completion occurs in a parenthesized expression, which 5392 /// might also be a type cast. 5393 PCC_ParenthesizedExpression, 5394 /// \brief Code completion occurs within a sequence of declaration 5395 /// specifiers within a function, method, or block. 5396 PCC_LocalDeclarationSpecifiers 5397 }; 5398 5399 void CodeCompleteOrdinaryName(Scope *S, 5400 ParserCompletionContext CompletionContext); 5401 void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, 5402 bool AllowNonIdentifiers, 5403 bool AllowNestedNameSpecifiers); 5404 5405 struct CodeCompleteExpressionData; 5406 void CodeCompleteExpression(Scope *S, 5407 const CodeCompleteExpressionData &Data); 5408 void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, 5409 SourceLocation OpLoc, 5410 bool IsArrow); 5411 void CodeCompletePostfixExpression(Scope *S, ExprResult LHS); 5412 void CodeCompleteTag(Scope *S, unsigned TagSpec); 5413 void CodeCompleteTypeQualifiers(DeclSpec &DS); 5414 void CodeCompleteCase(Scope *S); 5415 void CodeCompleteCall(Scope *S, Expr *Fn, Expr **Args, unsigned NumArgs); 5416 void CodeCompleteInitializer(Scope *S, Decl *D); 5417 void CodeCompleteReturn(Scope *S); 5418 void CodeCompleteAssignmentRHS(Scope *S, Expr *LHS); 5419 5420 void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, 5421 bool EnteringContext); 5422 void CodeCompleteUsing(Scope *S); 5423 void CodeCompleteUsingDirective(Scope *S); 5424 void CodeCompleteNamespaceDecl(Scope *S); 5425 void CodeCompleteNamespaceAliasDecl(Scope *S); 5426 void CodeCompleteOperatorName(Scope *S); 5427 void CodeCompleteConstructorInitializer(Decl *Constructor, 5428 CXXCtorInitializer** Initializers, 5429 unsigned NumInitializers); 5430 5431 void CodeCompleteObjCAtDirective(Scope *S, Decl *ObjCImpDecl, 5432 bool InInterface); 5433 void CodeCompleteObjCAtVisibility(Scope *S); 5434 void CodeCompleteObjCAtStatement(Scope *S); 5435 void CodeCompleteObjCAtExpression(Scope *S); 5436 void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS); 5437 void CodeCompleteObjCPropertyGetter(Scope *S, Decl *ClassDecl); 5438 void CodeCompleteObjCPropertySetter(Scope *S, Decl *ClassDecl); 5439 void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS, 5440 bool IsParameter); 5441 void CodeCompleteObjCMessageReceiver(Scope *S); 5442 void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc, 5443 IdentifierInfo **SelIdents, 5444 unsigned NumSelIdents, 5445 bool AtArgumentExpression); 5446 void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver, 5447 IdentifierInfo **SelIdents, 5448 unsigned NumSelIdents, 5449 bool AtArgumentExpression, 5450 bool IsSuper = false); 5451 void CodeCompleteObjCInstanceMessage(Scope *S, ExprTy *Receiver, 5452 IdentifierInfo **SelIdents, 5453 unsigned NumSelIdents, 5454 bool AtArgumentExpression, 5455 ObjCInterfaceDecl *Super = 0); 5456 void CodeCompleteObjCForCollection(Scope *S, 5457 DeclGroupPtrTy IterationVar); 5458 void CodeCompleteObjCSelector(Scope *S, 5459 IdentifierInfo **SelIdents, 5460 unsigned NumSelIdents); 5461 void CodeCompleteObjCProtocolReferences(IdentifierLocPair *Protocols, 5462 unsigned NumProtocols); 5463 void CodeCompleteObjCProtocolDecl(Scope *S); 5464 void CodeCompleteObjCInterfaceDecl(Scope *S); 5465 void CodeCompleteObjCSuperclass(Scope *S, 5466 IdentifierInfo *ClassName, 5467 SourceLocation ClassNameLoc); 5468 void CodeCompleteObjCImplementationDecl(Scope *S); 5469 void CodeCompleteObjCInterfaceCategory(Scope *S, 5470 IdentifierInfo *ClassName, 5471 SourceLocation ClassNameLoc); 5472 void CodeCompleteObjCImplementationCategory(Scope *S, 5473 IdentifierInfo *ClassName, 5474 SourceLocation ClassNameLoc); 5475 void CodeCompleteObjCPropertyDefinition(Scope *S, Decl *ObjCImpDecl); 5476 void CodeCompleteObjCPropertySynthesizeIvar(Scope *S, 5477 IdentifierInfo *PropertyName, 5478 Decl *ObjCImpDecl); 5479 void CodeCompleteObjCMethodDecl(Scope *S, 5480 bool IsInstanceMethod, 5481 ParsedType ReturnType, 5482 Decl *IDecl); 5483 void CodeCompleteObjCMethodDeclSelector(Scope *S, 5484 bool IsInstanceMethod, 5485 bool AtParameterName, 5486 ParsedType ReturnType, 5487 IdentifierInfo **SelIdents, 5488 unsigned NumSelIdents); 5489 void CodeCompletePreprocessorDirective(bool InConditional); 5490 void CodeCompleteInPreprocessorConditionalExclusion(Scope *S); 5491 void CodeCompletePreprocessorMacroName(bool IsDefinition); 5492 void CodeCompletePreprocessorExpression(); 5493 void CodeCompletePreprocessorMacroArgument(Scope *S, 5494 IdentifierInfo *Macro, 5495 MacroInfo *MacroInfo, 5496 unsigned Argument); 5497 void CodeCompleteNaturalLanguage(); 5498 void GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator, 5499 llvm::SmallVectorImpl<CodeCompletionResult> &Results); 5500 //@} 5501 5502 void PrintStats() const {} 5503 5504 //===--------------------------------------------------------------------===// 5505 // Extra semantic analysis beyond the C type system 5506 5507public: 5508 SourceLocation getLocationOfStringLiteralByte(const StringLiteral *SL, 5509 unsigned ByteNo) const; 5510 5511private: 5512 void CheckArrayAccess(const Expr *E); 5513 bool CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall); 5514 bool CheckBlockCall(NamedDecl *NDecl, CallExpr *TheCall); 5515 5516 bool CheckablePrintfAttr(const FormatAttr *Format, CallExpr *TheCall); 5517 bool CheckObjCString(Expr *Arg); 5518 5519 ExprResult CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); 5520 bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall); 5521 5522 bool SemaBuiltinVAStart(CallExpr *TheCall); 5523 bool SemaBuiltinUnorderedCompare(CallExpr *TheCall); 5524 bool SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs); 5525 5526public: 5527 // Used by C++ template instantiation. 5528 ExprResult SemaBuiltinShuffleVector(CallExpr *TheCall); 5529 5530private: 5531 bool SemaBuiltinPrefetch(CallExpr *TheCall); 5532 bool SemaBuiltinObjectSize(CallExpr *TheCall); 5533 bool SemaBuiltinLongjmp(CallExpr *TheCall); 5534 ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult); 5535 bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum, 5536 llvm::APSInt &Result); 5537 5538 bool SemaCheckStringLiteral(const Expr *E, const CallExpr *TheCall, 5539 bool HasVAListArg, unsigned format_idx, 5540 unsigned firstDataArg, bool isPrintf); 5541 5542 void CheckFormatString(const StringLiteral *FExpr, const Expr *OrigFormatExpr, 5543 const CallExpr *TheCall, bool HasVAListArg, 5544 unsigned format_idx, unsigned firstDataArg, 5545 bool isPrintf); 5546 5547 void CheckNonNullArguments(const NonNullAttr *NonNull, 5548 const Expr * const *ExprArgs, 5549 SourceLocation CallSiteLoc); 5550 5551 void CheckPrintfScanfArguments(const CallExpr *TheCall, bool HasVAListArg, 5552 unsigned format_idx, unsigned firstDataArg, 5553 bool isPrintf); 5554 5555 void CheckMemsetArguments(const CallExpr *Call); 5556 5557 void CheckReturnStackAddr(Expr *RetValExp, QualType lhsType, 5558 SourceLocation ReturnLoc); 5559 void CheckFloatComparison(SourceLocation loc, Expr* lex, Expr* rex); 5560 void CheckImplicitConversions(Expr *E, SourceLocation CC = SourceLocation()); 5561 5562 void CheckBitFieldInitialization(SourceLocation InitLoc, FieldDecl *Field, 5563 Expr *Init); 5564 5565 /// \brief The parser's current scope. 5566 /// 5567 /// The parser maintains this state here. 5568 Scope *CurScope; 5569 5570protected: 5571 friend class Parser; 5572 friend class InitializationSequence; 5573 5574 /// \brief Retrieve the parser's current scope. 5575 Scope *getCurScope() const { return CurScope; } 5576}; 5577 5578/// \brief RAII object that enters a new expression evaluation context. 5579class EnterExpressionEvaluationContext { 5580 Sema &Actions; 5581 5582public: 5583 EnterExpressionEvaluationContext(Sema &Actions, 5584 Sema::ExpressionEvaluationContext NewContext) 5585 : Actions(Actions) { 5586 Actions.PushExpressionEvaluationContext(NewContext); 5587 } 5588 5589 ~EnterExpressionEvaluationContext() { 5590 Actions.PopExpressionEvaluationContext(); 5591 } 5592}; 5593 5594} // end namespace clang 5595 5596#endif 5597