Template.h revision d3731198193eee92796ddeb493973b7a598b003e
1d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor//===------- SemaTemplate.h - C++ Templates ---------------------*- C++ -*-===/ 2d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// 3d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// The LLVM Compiler Infrastructure 4d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// 5d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// This file is distributed under the University of Illinois Open Source 6d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// License. See LICENSE.TXT for details. 7d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor//===----------------------------------------------------------------------===/ 8d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// 9d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// This file provides types used in the semantic analysis of C++ templates. 10d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor// 11d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor//===----------------------------------------------------------------------===/ 12d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor#ifndef LLVM_CLANG_SEMA_TEMPLATE_H 13d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor#define LLVM_CLANG_SEMA_TEMPLATE_H 14d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 15d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor#include "clang/AST/DeclTemplate.h" 16d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor#include "clang/AST/DeclVisitor.h" 17d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor#include "llvm/ADT/SmallVector.h" 18d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor#include <cassert> 19d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor#include <utility> 20d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 21d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregornamespace clang { 22d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief Data structure that captures multiple levels of template argument 23d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// lists for use in template instantiation. 24d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// 25d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// Multiple levels of template arguments occur when instantiating the 26d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// definitions of member templates. For example: 27d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// 28d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \code 29d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// template<typename T> 30d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// struct X { 31d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// template<T Value> 32d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// struct Y { 33d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// void f(); 34d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// }; 35d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// }; 36d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \endcode 37d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// 38d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// When instantiating X<int>::Y<17>::f, the multi-level template argument 39d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// list will contain a template argument list (int) at depth 0 and a 40d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// template argument list (17) at depth 1. 4124bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor class MultiLevelTemplateArgumentList { 4224bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor public: 4324bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor typedef std::pair<const TemplateArgument *, unsigned> ArgList; 4424bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor 4524bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor private: 46d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief The template argument lists, stored from the innermost template 47357bbd022c1d340c8e255aea7a684ddb34bc76e5Douglas Gregor /// argument list (first) to the outermost template argument list (last). 4824bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor llvm::SmallVector<ArgList, 4> TemplateArgumentLists; 49d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 50d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor public: 51d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief Construct an empty set of template argument lists. 52d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor MultiLevelTemplateArgumentList() { } 53d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 54d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief Construct a single-level template argument list. 55357bbd022c1d340c8e255aea7a684ddb34bc76e5Douglas Gregor explicit 56d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor MultiLevelTemplateArgumentList(const TemplateArgumentList &TemplateArgs) { 5724bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor addOuterTemplateArguments(&TemplateArgs); 58d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor } 59d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 60d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief Determine the number of levels in this template argument 61d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// list. 62d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor unsigned getNumLevels() const { return TemplateArgumentLists.size(); } 63d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 64d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief Retrieve the template argument at a given depth and index. 65d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor const TemplateArgument &operator()(unsigned Depth, unsigned Index) const { 66d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor assert(Depth < TemplateArgumentLists.size()); 6724bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].second); 6824bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor return TemplateArgumentLists[getNumLevels() - Depth - 1].first[Index]; 69d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor } 70d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor 71d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor /// \brief Determine whether there is a non-NULL template argument at the 72d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor /// given depth and index. 73d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor /// 74d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor /// There must exist a template argument list at the given depth. 75d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor bool hasTemplateArgument(unsigned Depth, unsigned Index) const { 76d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor assert(Depth < TemplateArgumentLists.size()); 77d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor 7824bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor if (Index >= TemplateArgumentLists[getNumLevels() - Depth - 1].second) 79d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor return false; 80d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor 81d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor return !(*this)(Depth, Index).isNull(); 82d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor } 83d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 84d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief Clear out a specific template argument. 85d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor void setArgument(unsigned Depth, unsigned Index, 86d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor TemplateArgument Arg) { 87d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor assert(Depth < TemplateArgumentLists.size()); 88d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor assert(Index < TemplateArgumentLists[getNumLevels() - Depth - 1].second); 89d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor const_cast<TemplateArgument&>( 90d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor TemplateArgumentLists[getNumLevels() - Depth - 1].first[Index]) 91d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor = Arg; 92d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor } 93d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 94d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// \brief Add a new outermost level to the multi-level template argument 95d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor /// list. 96d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor void addOuterTemplateArguments(const TemplateArgumentList *TemplateArgs) { 97910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor TemplateArgumentLists.push_back(ArgList(TemplateArgs->data(), 98910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor TemplateArgs->size())); 9924bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor } 10024bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor 10124bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor /// \brief Add a new outmost level to the multi-level template argument 10224bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor /// list. 10324bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor void addOuterTemplateArguments(const TemplateArgument *Args, 10424bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor unsigned NumArgs) { 10524bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor TemplateArgumentLists.push_back(ArgList(Args, NumArgs)); 106d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor } 107d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 108d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor /// \brief Retrieve the innermost template argument list. 10924bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor const ArgList &getInnermost() const { 11024bae92f08ae098cc50a602d8cf1273b423e14daDouglas Gregor return TemplateArgumentLists.front(); 111d6350aefb1396b299e199c7f1fe51bb40c12e75eDouglas Gregor } 112d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor }; 1138a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor 1148a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// \brief The context in which partial ordering of function templates occurs. 1157cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall enum TPOC { 1168a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// \brief Partial ordering of function templates for a function call. 1178a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor TPOC_Call, 1188a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// \brief Partial ordering of function templates for a call to a 1198a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// conversion function. 1208a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor TPOC_Conversion, 1218a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// \brief Partial ordering of function templates in other contexts, e.g., 1228a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// taking the address of a function template or matching a function 1238a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor /// template specialization to a function template. 1248a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor TPOC_Other 1258a51491d936d8c50480f3c3ca6647be12a7ad51fDouglas Gregor }; 12602024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor 1277cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall // This is lame but unavoidable in a world without forward 1287cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall // declarations of enums. The alternatives are to either pollute 1297cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall // Sema.h (by including this file) or sacrifice type safety (by 1307cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall // making Sema.h declare things as enums). 1317cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall class TemplatePartialOrderingContext { 1327cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall TPOC Value; 1337cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall public: 1347cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall TemplatePartialOrderingContext(TPOC Value) : Value(Value) {} 1357cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall operator TPOC() const { return Value; } 1367cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall }; 1377cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall 13802024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// \brief Captures a template argument whose value has been deduced 13902024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// via c++ template argument deduction. 14002024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor class DeducedTemplateArgument : public TemplateArgument { 14102024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// \brief For a non-type template argument, whether the value was 14202024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// deduced from an array bound. 14302024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor bool DeducedFromArrayBound; 14402024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor 14502024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor public: 14602024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor DeducedTemplateArgument() 14702024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor : TemplateArgument(), DeducedFromArrayBound(false) { } 14802024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor 14902024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor DeducedTemplateArgument(const TemplateArgument &Arg, 15002024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor bool DeducedFromArrayBound = false) 15102024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor : TemplateArgument(Arg), DeducedFromArrayBound(DeducedFromArrayBound) { } 15202024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor 15302024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// \brief Construct an integral non-type template argument that 154d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// has been deduced, possibly from an array bound. 15502024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor DeducedTemplateArgument(const llvm::APSInt &Value, 15602024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor QualType ValueType, 15702024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor bool DeducedFromArrayBound) 15802024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor : TemplateArgument(Value, ValueType), 15902024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor DeducedFromArrayBound(DeducedFromArrayBound) { } 16002024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor 16102024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// \brief For a non-type template argument, determine whether the 16202024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// template argument was deduced from an array bound. 16302024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor bool wasDeducedFromArrayBound() const { return DeducedFromArrayBound; } 16402024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor 16502024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// \brief Specify whether the given non-type template argument 16602024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor /// was deduced from an array bound. 16702024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor void setDeducedFromArrayBound(bool Deduced) { 16802024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor DeducedFromArrayBound = Deduced; 16902024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor } 17002024a9f0d8e6c898de276193af604c42ee41269Douglas Gregor }; 1712a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 1722a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief A stack-allocated class that identifies which local 1732a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// variable declaration instantiations are present in this scope. 1742a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// 1752a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// A new instance of this class type will be created whenever we 1762a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// instantiate a new function declaration, which will have its own 1772a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// set of parameter declarations. 1782a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall class LocalInstantiationScope { 17912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor public: 18012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// \brief A set of declarations. 18112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor typedef llvm::SmallVector<Decl *, 4> DeclArgumentPack; 18212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor 18312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor private: 1842a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief Reference to the semantic analysis that is performing 1852a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// this template instantiation. 1862a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall Sema &SemaRef; 1872a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 18812c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor typedef llvm::DenseMap<const Decl *, 18912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor llvm::PointerUnion<Decl *, DeclArgumentPack *> > 19012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor LocalDeclsMap; 19112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor 1922a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief A mapping from local declarations that occur 1932a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// within a template to their instantiations. 1942a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// 1952a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// This mapping is used during instantiation to keep track of, 1962a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// e.g., function parameter and variable declarations. For example, 1972a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// given: 1982a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// 1992a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \code 2002a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// template<typename T> T add(T x, T y) { return x + y; } 2012a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \endcode 2022a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// 2032a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// when we instantiate add<int>, we will introduce a mapping from 2042a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// the ParmVarDecl for 'x' that occurs in the template to the 2052a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// instantiated ParmVarDecl for 'x'. 20612c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// 20712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// For a parameter pack, the local instantiation scope may contain a 20812c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// set of instantiated parameters. This is stored as a DeclArgumentPack 20912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// pointer. 21012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor LocalDeclsMap LocalDecls; 2112a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 21212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// \brief The set of argument packs we've allocated. 21312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor llvm::SmallVector<DeclArgumentPack *, 1> ArgumentPacks; 21412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor 2152a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief The outer scope, which contains local variable 2162a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// definitions from some other instantiation (that may not be 2172a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// relevant to this particular scope). 2182a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall LocalInstantiationScope *Outer; 2192a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2202a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief Whether we have already exited this scope. 2212a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall bool Exited; 2222a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2232a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief Whether to combine this scope with the outer scope, such that 2242a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// lookup will search our outer scope. 2252a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall bool CombineWithOuterScope; 2262a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 227d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief If non-NULL, the template parameter pack that has been 228d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// partially substituted per C++0x [temp.arg.explicit]p9. 229d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NamedDecl *PartiallySubstitutedPack; 230d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 231d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief If \c PartiallySubstitutedPack is non-null, the set of 232d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// explicitly-specified template arguments in that pack. 233d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor const TemplateArgument *ArgsInPartiallySubstitutedPack; 234d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 235d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief If \c PartiallySubstitutedPack, the number of 236d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// explicitly-specified template arguments in 237d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// ArgsInPartiallySubstitutedPack. 238d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor unsigned NumArgsInPartiallySubstitutedPack; 239d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 2402a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall // This class is non-copyable 2412a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall LocalInstantiationScope(const LocalInstantiationScope &); 2422a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall LocalInstantiationScope &operator=(const LocalInstantiationScope &); 2432a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2442a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall public: 2452a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall LocalInstantiationScope(Sema &SemaRef, bool CombineWithOuterScope = false) 2462a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall : SemaRef(SemaRef), Outer(SemaRef.CurrentInstantiationScope), 247d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor Exited(false), CombineWithOuterScope(CombineWithOuterScope), 248d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor PartiallySubstitutedPack(0) 2492a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall { 2502a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall SemaRef.CurrentInstantiationScope = this; 2512a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall } 2522a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2532a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall ~LocalInstantiationScope() { 2542a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall Exit(); 2552a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall } 2562a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2572a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall /// \brief Exit this local instantiation scope early. 2582a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall void Exit() { 2592a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall if (Exited) 2602a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall return; 2612a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 26212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor for (unsigned I = 0, N = ArgumentPacks.size(); I != N; ++I) 26312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor delete ArgumentPacks[I]; 26412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor 2652a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall SemaRef.CurrentInstantiationScope = Outer; 2662a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall Exited = true; 2672a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall } 2682a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2692a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall Decl *getInstantiationOf(const Decl *D); 2702a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 27112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// \brief Find the instantiation of the declaration D within the current 27212c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// instantiation scope. 27312c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// 27412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// \param D The declaration whose instantiation we are searching for. 27512c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// 27612c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// \returns A pointer to the declaration or argument pack of declarations 27712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// to which the declaration \c D is instantiataed, if found. Otherwise, 27812c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// returns NULL. 27912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor llvm::PointerUnion<Decl *, DeclArgumentPack *> * 28012c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor findInstantiationOf(const Decl *D); 28112c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor 2822a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall VarDecl *getInstantiationOf(const VarDecl *Var) { 2832a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall return cast<VarDecl>(getInstantiationOf(cast<Decl>(Var))); 2842a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall } 2852a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2862a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall ParmVarDecl *getInstantiationOf(const ParmVarDecl *Var) { 2872a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall return cast<ParmVarDecl>(getInstantiationOf(cast<Decl>(Var))); 2882a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall } 2892a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2902a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall NonTypeTemplateParmDecl *getInstantiationOf( 2912a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall const NonTypeTemplateParmDecl *Var) { 2922a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall return cast<NonTypeTemplateParmDecl>(getInstantiationOf(cast<Decl>(Var))); 2932a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall } 2942a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall 2952a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall void InstantiatedLocal(const Decl *D, Decl *Inst); 29612c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor void InstantiatedLocalPackArg(const Decl *D, Decl *Inst); 29712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor void MakeInstantiatedLocalArgPack(const Decl *D); 298d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 299d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief Note that the given parameter pack has been partially substituted 300d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// via explicit specification of template arguments 301d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// (C++0x [temp.arg.explicit]p9). 302d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 303d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \param Pack The parameter pack, which will always be a template 304d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// parameter pack. 305d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 306d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \param ExplicitArgs The explicitly-specified template arguments provided 307d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// for this parameter pack. 308d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 309d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \param NumExplicitArgs The number of explicitly-specified template 310d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// arguments provided for this parameter pack. 311d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor void SetPartiallySubstitutedPack(NamedDecl *Pack, 312d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor const TemplateArgument *ExplicitArgs, 313d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor unsigned NumExplicitArgs); 314d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 315d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief Retrieve the partially-substitued template parameter pack. 316d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 317d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// If there is no partially-substituted parameter pack, returns NULL. 318d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NamedDecl *getPartiallySubstitutedPack( 319d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor const TemplateArgument **ExplicitArgs = 0, 320d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor unsigned *NumExplicitArgs = 0) const; 3212a7fb27913999d132cf9e10e03dc5271faa2e9d3John McCall }; 322d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 323d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor class TemplateDeclInstantiator 3248491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor : public DeclVisitor<TemplateDeclInstantiator, Decl *> 3258491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor { 326d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Sema &SemaRef; 3278491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex; 328d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor DeclContext *Owner; 329d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor const MultiLevelTemplateArgumentList &TemplateArgs; 330d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 331d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// \brief A list of out-of-line class template partial 332d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// specializations that will need to be instantiated after the 333d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// enclosing class's instantiation is complete. 334d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor llvm::SmallVector<std::pair<ClassTemplateDecl *, 335d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ClassTemplatePartialSpecializationDecl *>, 4> 336d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor OutOfLinePartialSpecs; 337d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 338d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor public: 339d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner, 340d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor const MultiLevelTemplateArgumentList &TemplateArgs) 3418491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor : SemaRef(SemaRef), SubstIndex(SemaRef, -1), Owner(Owner), 3428491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor TemplateArgs(TemplateArgs) { } 343d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 344d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor // FIXME: Once we get closer to completion, replace these manually-written 345d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor // declarations with automatically-generated ones from 346d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor // clang/AST/DeclNodes.inc. 347d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitTranslationUnitDecl(TranslationUnitDecl *D); 348d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitNamespaceDecl(NamespaceDecl *D); 349d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitNamespaceAliasDecl(NamespaceAliasDecl *D); 350d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitTypedefDecl(TypedefDecl *D); 351d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitVarDecl(VarDecl *D); 352d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitAccessSpecDecl(AccessSpecDecl *D); 353d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitFieldDecl(FieldDecl *D); 35487c2e121cf0522fc266efe2922b58091cd2e0182Francois Pichet Decl *VisitIndirectFieldDecl(IndirectFieldDecl *D); 355d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitStaticAssertDecl(StaticAssertDecl *D); 356d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitEnumDecl(EnumDecl *D); 357d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitEnumConstantDecl(EnumConstantDecl *D); 358d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitFriendDecl(FriendDecl *D); 359d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitFunctionDecl(FunctionDecl *D, 360d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor TemplateParameterList *TemplateParams = 0); 361d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitCXXRecordDecl(CXXRecordDecl *D); 362d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitCXXMethodDecl(CXXMethodDecl *D, 363d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor TemplateParameterList *TemplateParams = 0); 364d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitCXXConstructorDecl(CXXConstructorDecl *D); 365d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitCXXDestructorDecl(CXXDestructorDecl *D); 366d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitCXXConversionDecl(CXXConversionDecl *D); 367d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ParmVarDecl *VisitParmVarDecl(ParmVarDecl *D); 368d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitClassTemplateDecl(ClassTemplateDecl *D); 369d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitClassTemplatePartialSpecializationDecl( 370d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ClassTemplatePartialSpecializationDecl *D); 371d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitFunctionTemplateDecl(FunctionTemplateDecl *D); 372d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D); 373d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D); 374d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D); 375d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitUsingDirectiveDecl(UsingDirectiveDecl *D); 376d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitUsingDecl(UsingDecl *D); 377d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitUsingShadowDecl(UsingShadowDecl *D); 378d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D); 379d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitUnresolvedUsingTypenameDecl(UnresolvedUsingTypenameDecl *D); 380d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 381d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor // Base case. FIXME: Remove once we can instantiate everything. 382d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Decl *VisitDecl(Decl *D) { 383d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor unsigned DiagID = SemaRef.getDiagnostics().getCustomDiagID( 384d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor Diagnostic::Error, 385d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor "cannot instantiate %0 yet"); 386d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor SemaRef.Diag(D->getLocation(), DiagID) 387d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor << D->getDeclKindName(); 388d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 389d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor return 0; 390d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor } 391d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 392d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor typedef 393d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor llvm::SmallVectorImpl<std::pair<ClassTemplateDecl *, 394d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ClassTemplatePartialSpecializationDecl *> > 395d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ::iterator 396d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor delayed_partial_spec_iterator; 397d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 398d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// \brief Return an iterator to the beginning of the set of 399d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// "delayed" partial specializations, which must be passed to 400d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// InstantiateClassTemplatePartialSpecialization once the class 401d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// definition has been completed. 402d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor delayed_partial_spec_iterator delayed_partial_spec_begin() { 403d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor return OutOfLinePartialSpecs.begin(); 404d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor } 405d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 406d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// \brief Return an iterator to the end of the set of 407d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// "delayed" partial specializations, which must be passed to 408d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// InstantiateClassTemplatePartialSpecialization once the class 409d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor /// definition has been completed. 410d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor delayed_partial_spec_iterator delayed_partial_spec_end() { 411d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor return OutOfLinePartialSpecs.end(); 412d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor } 413d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 414d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor // Helper functions for instantiating methods. 415d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor TypeSourceInfo *SubstFunctionType(FunctionDecl *D, 416d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor llvm::SmallVectorImpl<ParmVarDecl *> &Params); 417d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor bool InitFunctionInstantiation(FunctionDecl *New, FunctionDecl *Tmpl); 418d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor bool InitMethodInstantiation(CXXMethodDecl *New, CXXMethodDecl *Tmpl); 419d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 420d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor TemplateParameterList * 421d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor SubstTemplateParams(TemplateParameterList *List); 422d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 423d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor bool SubstQualifier(const DeclaratorDecl *OldDecl, 424d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor DeclaratorDecl *NewDecl); 425d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor bool SubstQualifier(const TagDecl *OldDecl, 426d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor TagDecl *NewDecl); 427d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor 428d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ClassTemplatePartialSpecializationDecl * 429d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor InstantiateClassTemplatePartialSpecialization( 430d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ClassTemplateDecl *ClassTemplate, 431d65587f7a6d38965fa37158d3f57990a7faf3836Douglas Gregor ClassTemplatePartialSpecializationDecl *PartialSpec); 4328491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor }; 433d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor} 434d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor 435d1102433214bd33b5bef5b493944292a1e82c2fbDouglas Gregor#endif // LLVM_CLANG_SEMA_TEMPLATE_H 436