TreeTransform.h revision d3731198193eee92796ddeb493973b7a598b003e
1a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall//===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===/ 2577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// 3577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// The LLVM Compiler Infrastructure 4577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// 5577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// This file is distributed under the University of Illinois Open Source 6577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// License. See LICENSE.TXT for details. 7577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor//===----------------------------------------------------------------------===/ 8577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// 9577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// This file implements a semantic tree transformation that takes a given 10577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// AST and rebuilds it, possibly transforming some nodes in the process. 11577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// 12577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor//===----------------------------------------------------------------------===/ 13577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor#ifndef LLVM_CLANG_SEMA_TREETRANSFORM_H 14577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor#define LLVM_CLANG_SEMA_TREETRANSFORM_H 15577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 162d88708cbe4e4ec5e04e4acb6bd7f5be68557379John McCall#include "clang/Sema/SemaInternal.h" 17e737f5041a36d0befb39ffeed8d50ba15916d3daDouglas Gregor#include "clang/Sema/Lookup.h" 188491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor#include "clang/Sema/ParsedTemplate.h" 19dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor#include "clang/Sema/SemaDiagnostic.h" 20781472fe99a120098c631b0cbe33c89f8cef5e70John McCall#include "clang/Sema/ScopeInfo.h" 21c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor#include "clang/AST/Decl.h" 227cd088e519d7e6caa4c4c12db52e0e4ae35d25c2John McCall#include "clang/AST/DeclObjC.h" 23657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregor#include "clang/AST/Expr.h" 24b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor#include "clang/AST/ExprCXX.h" 25b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor#include "clang/AST/ExprObjC.h" 2643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#include "clang/AST/Stmt.h" 2743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#include "clang/AST/StmtCXX.h" 2843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#include "clang/AST/StmtObjC.h" 2919510856727e0e14a3696b2a72c35163bff2a71fJohn McCall#include "clang/Sema/Ownership.h" 3019510856727e0e14a3696b2a72c35163bff2a71fJohn McCall#include "clang/Sema/Designator.h" 31b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor#include "clang/Lex/Preprocessor.h" 32a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#include "llvm/Support/ErrorHandling.h" 337e44e3fcd75147f229f42e6912898ce62d6b4d08Douglas Gregor#include "TypeLocBuilder.h" 34577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor#include <algorithm> 35577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 36577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregornamespace clang { 37781472fe99a120098c631b0cbe33c89f8cef5e70John McCallusing namespace sema; 381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 39577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// \brief A semantic tree transformation that allows one to transform one 40577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// abstract syntax tree into another. 41577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// 421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// A new tree transformation is defined by creating a new subclass \c X of 431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// \c TreeTransform<X> and then overriding certain operations to provide 441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// behavior specific to that transformation. For example, template 45577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// instantiation is implemented as a tree transformation where the 46577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// transformation of TemplateTypeParmType nodes involves substituting the 47577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// template arguments for their corresponding template parameters; a similar 48577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// transformation is performed for non-type template parameters and 49577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// template template parameters. 50577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// 51577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// This tree-transformation template uses static polymorphism to allow 521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// subclasses to customize any of its operations. Thus, a subclass can 53577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// override any of the transformation or rebuild operators by providing an 54577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// operation with the same signature as the default implementation. The 55577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// overridding function should not be virtual. 56577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// 57577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// Semantic tree transformations are split into two stages, either of which 58577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// can be replaced by a subclass. The "transform" step transforms an AST node 59577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// or the parts of an AST node using the various transformation functions, 60577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// then passes the pieces on to the "rebuild" step, which constructs a new AST 61577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// node of the appropriate kind from the pieces. The default transformation 62577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// routines recursively transform the operands to composite AST nodes (e.g., 63577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// the pointee type of a PointerType node) and, if any of those operand nodes 64577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// were changed by the transformation, invokes the rebuild operation to create 65577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// a new AST node. 66577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// 671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// Subclasses can customize the transformation at various levels. The 68670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor/// most coarse-grained transformations involve replacing TransformType(), 69577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifier(), 70577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// TransformTemplateName(), or TransformTemplateArgument() with entirely 71577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// new implementations. 72577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// 73577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// For more fine-grained transformations, subclasses can replace any of the 74577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// \c TransformXXX functions (where XXX is the name of an AST node, e.g., 7543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor/// PointerType, StmtExpr) to alter the transformation. As mentioned previously, 76577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// replacing TransformTemplateTypeParmType() allows template instantiation 771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// to substitute template arguments for their corresponding template 78577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// parameters. Additionally, subclasses can override the \c RebuildXXX 79577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// functions to control how AST nodes are rebuilt when their operands change. 80577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// By default, \c TreeTransform will invoke semantic analysis to rebuild 81577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// AST nodes. However, certain other tree transformations (e.g, cloning) may 82577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// be able to use more efficient rebuild steps. 83577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// 84577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// There are a handful of other functions that can be overridden, allowing one 851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump/// to avoid traversing nodes that don't need any transformation 86577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their 87577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// operands have not changed (\c AlwaysRebuild()), and customize the 88577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// default locations and entity names used for type-checking 89577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor/// (\c getBaseLocation(), \c getBaseEntity()). 90577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 91577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregorclass TreeTransform { 92d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief Private RAII object that helps us forget and then re-remember 93d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// the template argument corresponding to a partially-substituted parameter 94d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// pack. 95d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor class ForgetPartiallySubstitutedPackRAII { 96d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor Derived &Self; 97d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor TemplateArgument Old; 98d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 99d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor public: 100d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) { 101d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor Old = Self.ForgetPartiallySubstitutedPack(); 102d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor } 103d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 104d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ~ForgetPartiallySubstitutedPackRAII() { 105d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor Self.RememberPartiallySubstitutedPack(Old); 106d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor } 107d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor }; 108d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 109577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregorprotected: 110577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor Sema &SemaRef; 1118491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 1121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumppublic: 113577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Initializes a new tree transformer. 114b99268b3083c882103bd1bd08bdcc9a76a2b4795Douglas Gregor TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { } 1151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 116577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Retrieves a reference to the derived class. 117577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor Derived &getDerived() { return static_cast<Derived&>(*this); } 118577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 119577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Retrieves a reference to the derived class. 1201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump const Derived &getDerived() const { 1211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return static_cast<const Derived&>(*this); 122577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 123577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 12460d7b3a319d84d688752be3870615ac0f111fb16John McCall static inline ExprResult Owned(Expr *E) { return E; } 12560d7b3a319d84d688752be3870615ac0f111fb16John McCall static inline StmtResult Owned(Stmt *S) { return S; } 1269ae2f076ca5ab1feb3ba95629099ec2319833701John McCall 127577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Retrieves a reference to the semantic analysis object used for 128577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// this tree transform. 129577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor Sema &getSema() const { return SemaRef; } 1301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 131577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Whether the transformation should always rebuild AST nodes, even 132577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// if none of the children have changed. 133577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 134577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this function to specify when the transformation 135577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// should rebuild all AST nodes. 136577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor bool AlwaysRebuild() { return false; } 1371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 138577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Returns the location of the entity being transformed, if that 139577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// information was not available elsewhere in the AST. 140577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 1411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, returns no source-location information. Subclasses can 142577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// provide an alternative implementation that provides better location 143577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// information. 144577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceLocation getBaseLocation() { return SourceLocation(); } 1451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 146577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Returns the name of the entity being transformed, if that 147577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// information was not available elsewhere in the AST. 148577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 149577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, returns an empty name. Subclasses can provide an alternative 150577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// implementation with a more precise name. 151577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor DeclarationName getBaseEntity() { return DeclarationName(); } 152577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 153b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Sets the "base" location and entity when that 154b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// information is known based on another transformation. 155b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 156b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, the source location and entity are ignored. Subclasses can 157b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// override this function to provide a customized implementation. 158b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor void setBase(SourceLocation Loc, DeclarationName Entity) { } 1591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 160b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief RAII object that temporarily sets the base location and entity 161b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// used for reporting diagnostics in types. 162b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor class TemporaryBase { 163b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor TreeTransform &Self; 164b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation OldLocation; 165b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor DeclarationName OldEntity; 1661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 167b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor public: 168b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor TemporaryBase(TreeTransform &Self, SourceLocation Location, 1691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump DeclarationName Entity) : Self(Self) { 170b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor OldLocation = Self.getDerived().getBaseLocation(); 171b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor OldEntity = Self.getDerived().getBaseEntity(); 172b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Self.getDerived().setBase(Location, Entity); 173b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 175b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ~TemporaryBase() { 176b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Self.getDerived().setBase(OldLocation, OldEntity); 177b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 178b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor }; 1791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Determine whether the given type \p T has already been 181577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// transformed. 182577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 183577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses can provide an alternative implementation of this routine 1841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// to short-circuit evaluation when it is known that a given type will 185577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// not change. For example, template instantiation need not traverse 186577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// non-dependent types. 187577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor bool AlreadyTransformed(QualType T) { 188577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return T.isNull(); 189577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 190577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 1916eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor /// \brief Determine whether the given call argument should be dropped, e.g., 1926eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor /// because it is a default argument. 1936eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor /// 1946eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor /// Subclasses can provide an alternative implementation of this routine to 1956eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor /// determine which kinds of call arguments get dropped. By default, 1966eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor /// CXXDefaultArgument nodes are dropped (prior to transformation). 1976eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor bool DropCallArgument(Expr *E) { 1986eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor return E->isDefaultArgument(); 1996eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor } 200c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2018491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \brief Determine whether we should expand a pack expansion with the 2028491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// given set of parameter packs into separate arguments by repeatedly 2038491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// transforming the pattern. 2048491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 205b99268b3083c882103bd1bd08bdcc9a76a2b4795Douglas Gregor /// By default, the transformer never tries to expand pack expansions. 2068491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// Subclasses can override this routine to provide different behavior. 2078491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 2088491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \param EllipsisLoc The location of the ellipsis that identifies the 2098491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// pack expansion. 2108491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 2118491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \param PatternRange The source range that covers the entire pattern of 2128491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// the pack expansion. 2138491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 2148491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \param Unexpanded The set of unexpanded parameter packs within the 2158491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// pattern. 2168491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 2178491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \param NumUnexpanded The number of unexpanded parameter packs in 2188491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \p Unexpanded. 2198491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 2208491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \param ShouldExpand Will be set to \c true if the transformer should 2218491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// expand the corresponding pack expansions into separate arguments. When 2228491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// set, \c NumExpansions must also be set. 2238491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 224d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \param RetainExpansion Whether the caller should add an unexpanded 225d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// pack expansion after all of the expanded arguments. This is used 226d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// when extending explicitly-specified template argument packs per 227d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// C++0x [temp.arg.explicit]p9. 228d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 2298491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \param NumExpansions The number of separate arguments that will be in 2308491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// the expanded form of the corresponding pack expansion. Must be set when 2318491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \c ShouldExpand is \c true. 2328491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 2338491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \returns true if an error occurred (e.g., because the parameter packs 2348491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// are to be instantiated with arguments of different lengths), false 2358491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions) 2368491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// must be set. 2378491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor bool TryExpandParameterPacks(SourceLocation EllipsisLoc, 2388491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor SourceRange PatternRange, 2398491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor const UnexpandedParameterPack *Unexpanded, 2408491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor unsigned NumUnexpanded, 2418491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor bool &ShouldExpand, 242d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor bool &RetainExpansion, 2438491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor unsigned &NumExpansions) { 2448491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor ShouldExpand = false; 2458491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return false; 2468491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 2478491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 248d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief "Forget" about the partially-substituted pack template argument, 249d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// when performing an instantiation that must preserve the parameter pack 250d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// use. 251d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 252d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// This routine is meant to be overridden by the template instantiator. 253d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor TemplateArgument ForgetPartiallySubstitutedPack() { 254d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor return TemplateArgument(); 255d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor } 256d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 257d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// \brief "Remember" the partially-substituted pack template argument 258d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// after performing an instantiation that must preserve the parameter pack 259d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// use. 260d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// 261d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor /// This routine is meant to be overridden by the template instantiator. 262d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor void RememberPartiallySubstitutedPack(TemplateArgument Arg) { } 263d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 26412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// \brief Note to the derived class when a function parameter pack is 26512c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor /// being expanded. 26612c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { } 26712c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor 268577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Transforms the given type into another type. 269577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 270a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// By default, this routine transforms a type by creating a 271a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall /// TypeSourceInfo for it and delegating to the appropriate 272a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// function. This is expensive, but we don't mind, because 273a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// this method is deprecated anyway; all users should be 274a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall /// switched to storing TypeSourceInfos. 275577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 276577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \returns the transformed type. 27743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType TransformType(QualType T); 2781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 279a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// \brief Transforms the given type-with-location into a new 280a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// type-with-location. 281a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// 282a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// By default, this routine transforms a type by delegating to the 283a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// appropriate TransformXXXType to build a new type. Subclasses 284a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// may override this function (to take over all type 285a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// transformations) or some set of the TransformXXXType functions 286a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// to alter the transformation. 28743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeSourceInfo *TransformType(TypeSourceInfo *DI); 288a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 289a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// \brief Transform the given type-with-location into a new 290a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// type, collecting location information in the given builder 291a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// as necessary. 292577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 29343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL); 2941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 295657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregor /// \brief Transform the given statement. 296577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 2971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, this routine transforms a statement by delegating to the 29843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// appropriate TransformXXXStmt function to transform a specific kind of 29943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// statement or the TransformExpr() function to transform an expression. 30043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this function to transform statements using some 30143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// other mechanism. 30243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 30343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \returns the transformed statement. 30460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult TransformStmt(Stmt *S); 3051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 306657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregor /// \brief Transform the given expression. 307657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregor /// 308b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, this routine transforms an expression by delegating to the 309b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// appropriate TransformXXXExpr function to build a new expression. 310b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this function to transform expressions using some 311b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// other mechanism. 312b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 313b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \returns the transformed expression. 31460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult TransformExpr(Expr *E); 3151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 316aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \brief Transform the given list of expressions. 317aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 318aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// This routine transforms a list of expressions by invoking 319aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \c TransformExpr() for each subexpression. However, it also provides 320aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// support for variadic templates by expanding any pack expansions (if the 321aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// derived class permits such expansion) along the way. When pack expansions 322aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// are present, the number of outputs may not equal the number of inputs. 323aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 324aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \param Inputs The set of expressions to be transformed. 325aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 326aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \param NumInputs The number of expressions in \c Inputs. 327aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 328aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \param IsCall If \c true, then this transform is being performed on 329aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// function-call arguments, and any arguments that should be dropped, will 330aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// be. 331aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 332aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \param Outputs The transformed input expressions will be added to this 333aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// vector. 334aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 335aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \param ArgChanged If non-NULL, will be set \c true if any argument changed 336aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// due to transformation. 337aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// 338aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor /// \returns true if an error occurred, false otherwise. 339aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor bool TransformExprs(Expr **Inputs, unsigned NumInputs, bool IsCall, 340aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor llvm::SmallVectorImpl<Expr *> &Outputs, 341aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor bool *ArgChanged = 0); 342aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 343577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Transform the given declaration, which is referenced from a type 344577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// or expression. 345577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 346dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// By default, acts as the identity function on declarations. Subclasses 347dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// may override this function to provide alternate behavior. 3487c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor Decl *TransformDecl(SourceLocation Loc, Decl *D) { return D; } 34943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 35043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Transform the definition of the given declaration. 35143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 3521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, invokes TransformDecl() to transform the declaration. 35343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this function to provide alternate behavior. 354c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt Decl *TransformDefinition(SourceLocation Loc, Decl *D) { 355c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getDerived().TransformDecl(Loc, D); 3567c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor } 3571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3586cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// \brief Transform the given declaration, which was the first part of a 3596cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// nested-name-specifier in a member access expression. 3606cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// 361c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt /// This specific declaration transformation only applies to the first 3626cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// identifier in a nested-name-specifier of a member access expression, e.g., 3636cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// the \c T in \c x->T::member 3646cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// 3656cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// By default, invokes TransformDecl() to transform the declaration. 3666cd219879ffce00920189ec1dcea927a42602961Douglas Gregor /// Subclasses may override this function to provide alternate behavior. 367c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) { 368c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D)); 3696cd219879ffce00920189ec1dcea927a42602961Douglas Gregor } 370c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 371577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Transform the given nested-name-specifier. 372577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 3731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, transforms all of the types and declarations within the 374dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// nested-name-specifier. Subclasses may override this function to provide 375dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// alternate behavior. 376577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor NestedNameSpecifier *TransformNestedNameSpecifier(NestedNameSpecifier *NNS, 377a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange Range, 378c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor QualType ObjectType = QualType(), 379c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierInScope = 0); 3801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 38181499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor /// \brief Transform the given declaration name. 38281499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor /// 38381499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor /// By default, transforms the types of conversion function, constructor, 38481499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor /// and destructor names and then (if needed) rebuilds the declaration name. 38581499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor /// Identifiers and selectors are returned unmodified. Sublcasses may 38681499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor /// override this function to provide alternate behavior. 3872577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo 38843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo); 3891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 390577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Transform the given template name. 3911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 392d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// By default, transforms the template name by transforming the declarations 3931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// and nested-name-specifiers that occur within the template name. 394d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// Subclasses may override this function to provide alternate behavior. 3953b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor TemplateName TransformTemplateName(TemplateName Name, 39643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType = QualType(), 39743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *FirstQualifierInScope = 0); 3981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 399577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Transform the given template argument. 400577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 4011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, this operation transforms the type, expression, or 4021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// declaration stored within the template argument and constructs a 403670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor /// new template argument from the transformed result. Subclasses may 404670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor /// override this function to provide alternate behavior. 405833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// 406833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// Returns true if there was an error. 407833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall bool TransformTemplateArgument(const TemplateArgumentLoc &Input, 408833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc &Output); 409833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 410fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// \brief Transform the given set of template arguments. 411fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// 412fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// By default, this operation transforms all of the template arguments 413fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// in the input set using \c TransformTemplateArgument(), and appends 414fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// the transformed arguments to the output list. 415fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// 4167ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// Note that this overload of \c TransformTemplateArguments() is merely 4177ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// a convenience function. Subclasses that wish to override this behavior 4187ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// should override the iterator-based member template version. 4197ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// 420fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// \param Inputs The set of template arguments to be transformed. 421fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// 422fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// \param NumInputs The number of template arguments in \p Inputs. 423fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// 424fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// \param Outputs The set of transformed template arguments output by this 425fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// routine. 426fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// 427fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor /// Returns true if an error occurred. 428fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs, 429fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor unsigned NumInputs, 4307ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentListInfo &Outputs) { 4317ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs); 4327ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 4337f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor 4347f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// \brief Transform the given set of template arguments. 4357f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// 4367f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// By default, this operation transforms all of the template arguments 4377f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// in the input set using \c TransformTemplateArgument(), and appends 4387f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// the transformed arguments to the output list. 4397f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// 4407ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// \param First An iterator to the first template argument. 4417ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// 4427ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// \param Last An iterator one step past the last template argument. 4437f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// 4447f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// \param Outputs The set of transformed template arguments output by this 4457f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// routine. 4467f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// 4477f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor /// Returns true if an error occurred. 4487ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor template<typename InputIterator> 4497ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor bool TransformTemplateArguments(InputIterator First, 4507ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor InputIterator Last, 4517ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentListInfo &Outputs); 4527f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor 453833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall /// \brief Fakes up a TemplateArgumentLoc for a given TemplateArgument. 454833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall void InventTemplateArgumentLoc(const TemplateArgument &Arg, 455833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc &ArgLoc); 456833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 457a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall /// \brief Fakes up a TypeSourceInfo for a type. 458a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *InventTypeSourceInfo(QualType T) { 459a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall return SemaRef.Context.getTrivialTypeSourceInfo(T, 460833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getDerived().getBaseLocation()); 461833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 4621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 463a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#define ABSTRACT_TYPELOC(CLASS, PARENT) 464a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#define TYPELOC(CLASS, PARENT) \ 46543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T); 466a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#include "clang/AST/TypeLocNodes.def" 467577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 46843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType 46943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TransformTemplateSpecializationType(TypeLocBuilder &TLB, 47043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateSpecializationTypeLoc TL, 47143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateName Template); 47243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 47343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType 47443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, 47543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentTemplateSpecializationTypeLoc TL, 47643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Prefix); 47743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 47821ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// \brief Transforms the parameters of a function type into the 47921ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// given vectors. 48021ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// 48121ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// The result vectors should be kept in sync; null entries in the 48221ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// variables vector are acceptable. 48321ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// 48421ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// Return true on error. 485a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor bool TransformFunctionTypeParams(SourceLocation Loc, 486a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParmVarDecl **Params, unsigned NumParams, 487a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor const QualType *ParamTypes, 48821ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall llvm::SmallVectorImpl<QualType> &PTypes, 489a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor llvm::SmallVectorImpl<ParmVarDecl*> *PVars); 49021ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall 49121ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// \brief Transforms a single function-type parameter. Return null 49221ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /// on error. 49321ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm); 49421ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall 49543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL); 496833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 49760d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr); 49860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E); 4991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 50043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#define STMT(Node, Parent) \ 50160d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Transform##Node(Node *S); 502b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor#define EXPR(Node, Parent) \ 50360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Transform##Node(Node *E); 5047381d5cfbd599fa2b9e215011ad7cbd449de231aSean Hunt#define ABSTRACT_STMT(Stmt) 5054bfe1968410ea8ffe3b4f629addd7c4bcf484765Sean Hunt#include "clang/AST/StmtNodes.inc" 5061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 507577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new pointer type given its pointee type. 508577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 509577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the pointer type. 510577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 51185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil); 512577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 513577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new block pointer type given its pointee type. 514577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 5151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, performs semantic analysis when building the block pointer 516577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// type. Subclasses may override this routine to provide different behavior. 51785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil); 518577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 51985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall /// \brief Build a new reference type given the type it references. 520577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 52185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall /// By default, performs semantic analysis when building the 52285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall /// reference type. Subclasses may override this routine to provide 52385737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall /// different behavior. 524577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 52585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall /// \param LValue whether the type was written with an lvalue sigil 52685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall /// or an rvalue sigil. 52785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType RebuildReferenceType(QualType ReferentType, 52885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall bool LValue, 52985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceLocation Sigil); 5301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 531577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new member pointer type given the pointee type and the 532577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// class type it refers into. 533577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 534577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the member pointer 535577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// type. Subclasses may override this routine to provide different behavior. 53685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType, 53785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceLocation Sigil); 5381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 539577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new array type given the element type, size 540577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// modifier, size of the array (if known), size expression, and index type 541577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// qualifiers. 542577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 543577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the array type. 544577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 5451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// Also by default, all of the other Rebuild*Array 546577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildArrayType(QualType ElementType, 547577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 548577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor const llvm::APInt *Size, 549577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor Expr *SizeExpr, 550577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned IndexTypeQuals, 551577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceRange BracketsRange); 5521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 553577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new constant array type given the element type, size 554577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// modifier, (known) size of the array, and index type qualifiers. 555577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 556577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the array type. 557577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 5581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType RebuildConstantArrayType(QualType ElementType, 559577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 560577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor const llvm::APInt &Size, 56185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall unsigned IndexTypeQuals, 56285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange BracketsRange); 563577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 564577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new incomplete array type given the element type, size 565577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// modifier, and index type qualifiers. 566577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 567577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the array type. 568577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 5691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType RebuildIncompleteArrayType(QualType ElementType, 570577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 57185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall unsigned IndexTypeQuals, 57285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange BracketsRange); 573577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 5741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new variable-length array type given the element type, 575577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// size modifier, size expression, and index type qualifiers. 576577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 577577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the array type. 578577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 5791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType RebuildVariableArrayType(QualType ElementType, 580577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 5819ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SizeExpr, 582577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned IndexTypeQuals, 583577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceRange BracketsRange); 584577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 5851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new dependent-sized array type given the element type, 586577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// size modifier, size expression, and index type qualifiers. 587577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 588577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the array type. 589577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 5901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType RebuildDependentSizedArrayType(QualType ElementType, 591577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 5929ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SizeExpr, 593577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned IndexTypeQuals, 594577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceRange BracketsRange); 595577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 596577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new vector type given the element type and 597577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// number of elements. 598577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 599577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the vector type. 600577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 60182287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson QualType RebuildVectorType(QualType ElementType, unsigned NumElements, 602e86d78cf4754a6aef2cf9a33d847aa15338e276fBob Wilson VectorType::VectorKind VecKind); 6031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 604577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new extended vector type given the element type and 605577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// number of elements. 606577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 607577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the vector type. 608577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 609577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements, 610577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceLocation AttributeLoc); 6111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new potentially dependently-sized extended vector type 613577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// given the element type and number of elements. 614577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 615577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the vector type. 616577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 6171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType RebuildDependentSizedExtVectorType(QualType ElementType, 6189ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SizeExpr, 619577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceLocation AttributeLoc); 6201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 621577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new function type. 622577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 623577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the function type. 624577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 625577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildFunctionProtoType(QualType T, 6261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType *ParamTypes, 627577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned NumParamTypes, 628fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman bool Variadic, unsigned Quals, 629fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman const FunctionType::ExtInfo &Info); 6301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 631a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /// \brief Build a new unprototyped function type. 632a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType RebuildFunctionNoProtoType(QualType ResultType); 633a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 634ed97649e9574b9d854fa4d6109c9333ae0993554John McCall /// \brief Rebuild an unresolved typename type, given the decl that 635ed97649e9574b9d854fa4d6109c9333ae0993554John McCall /// the UnresolvedUsingTypenameDecl was transformed to. 636ed97649e9574b9d854fa4d6109c9333ae0993554John McCall QualType RebuildUnresolvedUsingType(Decl *D); 637ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 638577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new typedef type. 639577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildTypedefType(TypedefDecl *Typedef) { 640577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return SemaRef.Context.getTypeDeclType(Typedef); 641577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 642577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 643577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new class/struct/union type. 644577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildRecordType(RecordDecl *Record) { 645577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return SemaRef.Context.getTypeDeclType(Record); 646577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 647577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 648577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new Enum type. 649577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildEnumType(EnumDecl *Enum) { 650577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return SemaRef.Context.getTypeDeclType(Enum); 651577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 6527da2431c23ef1ee8acb114e39692246e1801afc2John McCall 6531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new typeof(expr) type. 654577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 655577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the typeof type. 656577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 6572a984cad5ac3fdceeff2bd99daa7b90979313475John McCall QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc); 658577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 6591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new typeof(type) type. 660577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 661577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, builds a new TypeOfType with the given underlying type. 662577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildTypeOfType(QualType Underlying); 663577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 6641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new C++0x decltype type. 665577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 666577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the decltype type. 667577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// Subclasses may override this routine to provide different behavior. 6682a984cad5ac3fdceeff2bd99daa7b90979313475John McCall QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc); 6691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 670577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new template specialization type. 671577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 672577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the template 673577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// specialization type. Subclasses may override this routine to provide 674577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// different behavior. 675577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType RebuildTemplateSpecializationType(TemplateName Template, 676833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation TemplateLoc, 677d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo &Args); 6781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 679075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara /// \brief Build a new parenthesized type. 680075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara /// 681075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara /// By default, builds a new ParenType type from the inner type. 682075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara /// Subclasses may override this routine to provide different behavior. 683075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType RebuildParenType(QualType InnerType) { 684075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return SemaRef.Context.getParenType(InnerType); 685075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 686075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 687577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new qualified name type. 688577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 689465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara /// By default, builds a new ElaboratedType type from the keyword, 690465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara /// the nested-name-specifier and the named type. 691465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara /// Subclasses may override this routine to provide different behavior. 69221e413fe6305a198564d436ac515497716c47844John McCall QualType RebuildElaboratedType(SourceLocation KeywordLoc, 69321e413fe6305a198564d436ac515497716c47844John McCall ElaboratedTypeKeyword Keyword, 694465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara NestedNameSpecifier *NNS, QualType Named) { 695465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara return SemaRef.Context.getElaboratedType(Keyword, NNS, Named); 6961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 697577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 698577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new typename type that refers to a template-id. 699577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 700e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara /// By default, builds a new DependentNameType type from the 701e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara /// nested-name-specifier and the given type. Subclasses may override 702e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara /// this routine to provide different behavior. 70333500955d731c73717af52088b7fc0e7a85681e7John McCall QualType RebuildDependentTemplateSpecializationType( 70433500955d731c73717af52088b7fc0e7a85681e7John McCall ElaboratedTypeKeyword Keyword, 7051efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor NestedNameSpecifier *Qualifier, 7061efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor SourceRange QualifierRange, 70733500955d731c73717af52088b7fc0e7a85681e7John McCall const IdentifierInfo *Name, 70833500955d731c73717af52088b7fc0e7a85681e7John McCall SourceLocation NameLoc, 70933500955d731c73717af52088b7fc0e7a85681e7John McCall const TemplateArgumentListInfo &Args) { 71033500955d731c73717af52088b7fc0e7a85681e7John McCall // Rebuild the template name. 71133500955d731c73717af52088b7fc0e7a85681e7John McCall // TODO: avoid TemplateName abstraction 71233500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateName InstName = 7131efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor getDerived().RebuildTemplateName(Qualifier, QualifierRange, *Name, 71443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType(), 0); 71533500955d731c73717af52088b7fc0e7a85681e7John McCall 71696fb42ea29253cf2b34848dfdb3e40ef14ca8ebcDouglas Gregor if (InstName.isNull()) 71796fb42ea29253cf2b34848dfdb3e40ef14ca8ebcDouglas Gregor return QualType(); 71896fb42ea29253cf2b34848dfdb3e40ef14ca8ebcDouglas Gregor 71933500955d731c73717af52088b7fc0e7a85681e7John McCall // If it's still dependent, make a dependent specialization. 72033500955d731c73717af52088b7fc0e7a85681e7John McCall if (InstName.getAsDependentTemplateName()) 72133500955d731c73717af52088b7fc0e7a85681e7John McCall return SemaRef.Context.getDependentTemplateSpecializationType( 7221efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor Keyword, Qualifier, Name, Args); 72333500955d731c73717af52088b7fc0e7a85681e7John McCall 72433500955d731c73717af52088b7fc0e7a85681e7John McCall // Otherwise, make an elaborated type wrapping a non-dependent 72533500955d731c73717af52088b7fc0e7a85681e7John McCall // specialization. 72633500955d731c73717af52088b7fc0e7a85681e7John McCall QualType T = 72733500955d731c73717af52088b7fc0e7a85681e7John McCall getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args); 72833500955d731c73717af52088b7fc0e7a85681e7John McCall if (T.isNull()) return QualType(); 729465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara 73022f638a58ed05579c51ee6a35a1d16a7c2157f90Abramo Bagnara // NOTE: NNS is already recorded in template specialization type T. 73122f638a58ed05579c51ee6a35a1d16a7c2157f90Abramo Bagnara return SemaRef.Context.getElaboratedType(Keyword, /*NNS=*/0, T); 7321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 733577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 734577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// \brief Build a new typename type that refers to an identifier. 735577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// 736577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// By default, performs semantic analysis when building the typename type 737e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara /// (or elaborated type). Subclasses may override this routine to provide 738577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor /// different behavior. 739e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, 7404a2023f5014e82389d5980d307b89c545dbbac81Douglas Gregor NestedNameSpecifier *NNS, 7414a2023f5014e82389d5980d307b89c545dbbac81Douglas Gregor const IdentifierInfo *Id, 742e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation KeywordLoc, 743e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceRange NNSRange, 744e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SourceLocation IdLoc) { 7454033642464e8ba0982f88f34cffad808d247b393Douglas Gregor CXXScopeSpec SS; 7464033642464e8ba0982f88f34cffad808d247b393Douglas Gregor SS.setScopeRep(NNS); 747e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SS.setRange(NNSRange); 748e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara 7494033642464e8ba0982f88f34cffad808d247b393Douglas Gregor if (NNS->isDependent()) { 7504033642464e8ba0982f88f34cffad808d247b393Douglas Gregor // If the name is still dependent, just build a new dependent name type. 7514033642464e8ba0982f88f34cffad808d247b393Douglas Gregor if (!SemaRef.computeDeclContext(SS)) 7524033642464e8ba0982f88f34cffad808d247b393Douglas Gregor return SemaRef.Context.getDependentNameType(Keyword, NNS, Id); 7534033642464e8ba0982f88f34cffad808d247b393Douglas Gregor } 7544033642464e8ba0982f88f34cffad808d247b393Douglas Gregor 755465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara if (Keyword == ETK_None || Keyword == ETK_Typename) 756e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara return SemaRef.CheckTypenameType(Keyword, NNS, *Id, 757e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara KeywordLoc, NNSRange, IdLoc); 758465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara 759465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForKeyword(Keyword); 760465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara 761e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara // We had a dependent elaborated-type-specifier that has been transformed 7624033642464e8ba0982f88f34cffad808d247b393Douglas Gregor // into a non-dependent elaborated-type-specifier. Find the tag we're 7634033642464e8ba0982f88f34cffad808d247b393Douglas Gregor // referring to. 764e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName); 7654033642464e8ba0982f88f34cffad808d247b393Douglas Gregor DeclContext *DC = SemaRef.computeDeclContext(SS, false); 7664033642464e8ba0982f88f34cffad808d247b393Douglas Gregor if (!DC) 7674033642464e8ba0982f88f34cffad808d247b393Douglas Gregor return QualType(); 7684033642464e8ba0982f88f34cffad808d247b393Douglas Gregor 7695613876991c80a684595fe8de1f039296a0657ffJohn McCall if (SemaRef.RequireCompleteDeclContext(SS, DC)) 7705613876991c80a684595fe8de1f039296a0657ffJohn McCall return QualType(); 7715613876991c80a684595fe8de1f039296a0657ffJohn McCall 7724033642464e8ba0982f88f34cffad808d247b393Douglas Gregor TagDecl *Tag = 0; 7734033642464e8ba0982f88f34cffad808d247b393Douglas Gregor SemaRef.LookupQualifiedName(Result, DC); 7744033642464e8ba0982f88f34cffad808d247b393Douglas Gregor switch (Result.getResultKind()) { 7754033642464e8ba0982f88f34cffad808d247b393Douglas Gregor case LookupResult::NotFound: 7764033642464e8ba0982f88f34cffad808d247b393Douglas Gregor case LookupResult::NotFoundInCurrentInstantiation: 7774033642464e8ba0982f88f34cffad808d247b393Douglas Gregor break; 778c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 7794033642464e8ba0982f88f34cffad808d247b393Douglas Gregor case LookupResult::Found: 7804033642464e8ba0982f88f34cffad808d247b393Douglas Gregor Tag = Result.getAsSingle<TagDecl>(); 7814033642464e8ba0982f88f34cffad808d247b393Douglas Gregor break; 782c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 7834033642464e8ba0982f88f34cffad808d247b393Douglas Gregor case LookupResult::FoundOverloaded: 7844033642464e8ba0982f88f34cffad808d247b393Douglas Gregor case LookupResult::FoundUnresolvedValue: 7854033642464e8ba0982f88f34cffad808d247b393Douglas Gregor llvm_unreachable("Tag lookup cannot find non-tags"); 7864033642464e8ba0982f88f34cffad808d247b393Douglas Gregor return QualType(); 787c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 7884033642464e8ba0982f88f34cffad808d247b393Douglas Gregor case LookupResult::Ambiguous: 7894033642464e8ba0982f88f34cffad808d247b393Douglas Gregor // Let the LookupResult structure handle ambiguities. 7904033642464e8ba0982f88f34cffad808d247b393Douglas Gregor return QualType(); 7914033642464e8ba0982f88f34cffad808d247b393Douglas Gregor } 7924033642464e8ba0982f88f34cffad808d247b393Douglas Gregor 7934033642464e8ba0982f88f34cffad808d247b393Douglas Gregor if (!Tag) { 7941eabb7d0c30f6a876b0fd03ad4656c096c26b8d0Douglas Gregor // FIXME: Would be nice to highlight just the source range. 795e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope) 7961eabb7d0c30f6a876b0fd03ad4656c096c26b8d0Douglas Gregor << Kind << Id << DC; 7974033642464e8ba0982f88f34cffad808d247b393Douglas Gregor return QualType(); 7984033642464e8ba0982f88f34cffad808d247b393Douglas Gregor } 799465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara 800e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, IdLoc, *Id)) { 801e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id; 8024033642464e8ba0982f88f34cffad808d247b393Douglas Gregor SemaRef.Diag(Tag->getLocation(), diag::note_previous_use); 8034033642464e8ba0982f88f34cffad808d247b393Douglas Gregor return QualType(); 8044033642464e8ba0982f88f34cffad808d247b393Douglas Gregor } 8054033642464e8ba0982f88f34cffad808d247b393Douglas Gregor 8064033642464e8ba0982f88f34cffad808d247b393Douglas Gregor // Build the elaborated-type-specifier type. 8074033642464e8ba0982f88f34cffad808d247b393Douglas Gregor QualType T = SemaRef.Context.getTypeDeclType(Tag); 808465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara return SemaRef.Context.getElaboratedType(Keyword, NNS, T); 809dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor } 8101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 811dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// \brief Build a new nested-name-specifier given the prefix and an 812dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// identifier that names the next step in the nested-name-specifier. 813dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// 814dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// By default, performs semantic analysis when building the new 815dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// nested-name-specifier. Subclasses may override this routine to provide 816dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// different behavior. 817dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix, 818dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SourceRange Range, 819a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor IdentifierInfo &II, 820c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor QualType ObjectType, 821c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierInScope); 822dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor 823dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// \brief Build a new nested-name-specifier given the prefix and the 824dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// namespace named in the next step in the nested-name-specifier. 825dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// 826dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// By default, performs semantic analysis when building the new 827dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// nested-name-specifier. Subclasses may override this routine to provide 828dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// different behavior. 829dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix, 830dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SourceRange Range, 831dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor NamespaceDecl *NS); 832dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor 833dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// \brief Build a new nested-name-specifier given the prefix and the 834dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// type named in the next step in the nested-name-specifier. 835dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// 836dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// By default, performs semantic analysis when building the new 837dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// nested-name-specifier. Subclasses may override this routine to provide 838dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor /// different behavior. 839dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix, 840dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SourceRange Range, 841dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor bool TemplateKW, 842edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor QualType T); 843d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor 844d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// \brief Build a new template name given a nested name specifier, a flag 845d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// indicating whether the "template" keyword was provided, and the template 846d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// that the template name refers to. 847d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// 848d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// By default, builds the new template name directly. Subclasses may override 849d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// this routine to provide different behavior. 850d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier, 851d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor bool TemplateKW, 852d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TemplateDecl *Template); 853d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor 854d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// \brief Build a new template name given a nested name specifier and the 855d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// name that is referred to as a template. 856d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// 857d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// By default, performs semantic analysis to determine whether the name can 858d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// be resolved to a specific template, then builds the appropriate kind of 859d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// template name. Subclasses may override this routine to provide different 860d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor /// behavior. 861d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier, 8621efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor SourceRange QualifierRange, 8633b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor const IdentifierInfo &II, 86443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 86543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *FirstQualifierInScope); 8661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 867ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// \brief Build a new template name given a nested name specifier and the 868ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// overloaded operator name that is referred to as a template. 869ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// 870ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// By default, performs semantic analysis to determine whether the name can 871ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// be resolved to a specific template, then builds the appropriate kind of 872ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// template name. Subclasses may override this routine to provide different 873ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /// behavior. 874ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier, 875ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor OverloadedOperatorKind Operator, 876ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor QualType ObjectType); 877c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 87843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new compound statement. 87943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 88043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 88143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 88260d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, 88343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor MultiStmtArg Statements, 88443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation RBraceLoc, 88543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor bool IsStmtExpr) { 8869ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements, 88743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor IsStmtExpr); 88843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 88943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 89043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new case statement. 89143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 89243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 89343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 89460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildCaseStmt(SourceLocation CaseLoc, 8959ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *LHS, 89643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation EllipsisLoc, 8979ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *RHS, 89843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation ColonLoc) { 8999ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS, 90043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor ColonLoc); 90143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 90343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Attach the body to a new case statement. 90443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 90543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 90643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 90760d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body) { 9089ae2f076ca5ab1feb3ba95629099ec2319833701John McCall getSema().ActOnCaseStmtBody(S, Body); 9099ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return S; 91043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 91243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new default statement. 91343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 91443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 91543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 91660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc, 91743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation ColonLoc, 9189ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *SubStmt) { 9199ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt, 92043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /*CurScope=*/0); 92143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 92343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new label statement. 92443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 92543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 92643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 92760d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildLabelStmt(SourceLocation IdentLoc, 92843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor IdentifierInfo *Id, 92943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation ColonLoc, 9301a18600b85aaa691122983dd8dcf4225cfc9ef68Argyrios Kyrtzidis Stmt *SubStmt, bool HasUnusedAttr) { 9311a18600b85aaa691122983dd8dcf4225cfc9ef68Argyrios Kyrtzidis return SemaRef.ActOnLabelStmt(IdentLoc, Id, ColonLoc, SubStmt, 9321a18600b85aaa691122983dd8dcf4225cfc9ef68Argyrios Kyrtzidis HasUnusedAttr); 93343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 93543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new "if" statement. 93643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 93743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 93843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 93960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildIfStmt(SourceLocation IfLoc, Sema::FullExprArg Cond, 94044aa1f397855f130e88e62ffc1029f7f83bb5d2eArgyrios Kyrtzidis VarDecl *CondVar, Stmt *Then, 9419ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SourceLocation ElseLoc, Stmt *Else) { 94244aa1f397855f130e88e62ffc1029f7f83bb5d2eArgyrios Kyrtzidis return getSema().ActOnIfStmt(IfLoc, Cond, CondVar, Then, ElseLoc, Else); 94343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 94543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Start building a new switch statement. 94643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 94743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 94843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 94960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, 9509ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Cond, VarDecl *CondVar) { 9519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Cond, 952d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall CondVar); 95343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 95543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Attach the body to the switch statement. 95643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 95743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 95843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 95960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, 9609ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Switch, Stmt *Body) { 9619ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body); 96243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 96343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 96443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new while statement. 96543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 96643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 96743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 96860d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildWhileStmt(SourceLocation WhileLoc, 969eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor Sema::FullExprArg Cond, 97099e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor VarDecl *CondVar, 9719ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Body) { 9729ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnWhileStmt(WhileLoc, Cond, CondVar, Body); 97343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 9741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 97543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new do-while statement. 97643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 97743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 97843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 97960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body, 98043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation WhileLoc, 98143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation LParenLoc, 9829ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Cond, 98343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation RParenLoc) { 9849ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc, 9859ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Cond, RParenLoc); 98643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 98743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 98843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new for statement. 98943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 99043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 99143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 99260d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildForStmt(SourceLocation ForLoc, 99343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation LParenLoc, 9949ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Init, Sema::FullExprArg Cond, 99599e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor VarDecl *CondVar, Sema::FullExprArg Inc, 9969ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SourceLocation RParenLoc, Stmt *Body) { 9979ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond, 998d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall CondVar, 9999ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Inc, RParenLoc, Body); 100043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 10011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 100243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new goto statement. 100343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 100443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 100543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 100660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildGotoStmt(SourceLocation GotoLoc, 100743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation LabelLoc, 100843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor LabelStmt *Label) { 100943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label->getID()); 101043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 101143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 101243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new indirect goto statement. 101343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 101443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 101543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 101660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc, 101743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation StarLoc, 10189ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Target) { 10199ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target); 102043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 10211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 102243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new return statement. 102343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 102443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 102543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 102660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, 10279ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Result) { 10281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 10299ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnReturnStmt(ReturnLoc, Result); 103043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 10311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 103243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new declaration statement. 103343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 103443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 103543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 103660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildDeclStmt(Decl **Decls, unsigned NumDecls, 10371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation StartLoc, 103843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation EndLoc) { 103943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getSema().Owned( 104043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor new (getSema().Context) DeclStmt( 104143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor DeclGroupRef::Create(getSema().Context, 104243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Decls, NumDecls), 104343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor StartLoc, EndLoc)); 104443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 10451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1046703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson /// \brief Build a new inline asm statement. 1047703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson /// 1048703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson /// By default, performs semantic analysis to build the new statement. 1049703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson /// Subclasses may override this routine to provide different behavior. 105060d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildAsmStmt(SourceLocation AsmLoc, 1051703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson bool IsSimple, 1052703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson bool IsVolatile, 1053703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson unsigned NumOutputs, 1054703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson unsigned NumInputs, 1055ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson IdentifierInfo **Names, 1056703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson MultiExprArg Constraints, 1057703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson MultiExprArg Exprs, 10589ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *AsmString, 1059703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson MultiExprArg Clobbers, 1060703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson SourceLocation RParenLoc, 1061703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson bool MSAsm) { 1062c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getSema().ActOnAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs, 1063703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson NumInputs, Names, move(Constraints), 10649ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Exprs, AsmString, Clobbers, 1065703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson RParenLoc, MSAsm); 1066703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson } 10674dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor 10684dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// \brief Build a new Objective-C @try statement. 10694dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// 10704dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// By default, performs semantic analysis to build the new statement. 10714dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// Subclasses may override this routine to provide different behavior. 107260d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc, 10739ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *TryBody, 10748f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor MultiStmtArg CatchStmts, 10759ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Finally) { 10769ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, move(CatchStmts), 10779ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Finally); 10784dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor } 10794dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor 1080be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// \brief Rebuild an Objective-C exception declaration. 1081be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// 1082be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// By default, performs semantic analysis to build the new declaration. 1083be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// Subclasses may override this routine to provide different behavior. 1084be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, 1085be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor TypeSourceInfo *TInfo, QualType T) { 1086c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getSema().BuildObjCExceptionDecl(TInfo, T, 1087c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt ExceptionDecl->getIdentifier(), 1088be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor ExceptionDecl->getLocation()); 1089be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor } 1090c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 1091be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// \brief Build a new Objective-C @catch statement. 1092be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// 1093be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// By default, performs semantic analysis to build the new statement. 1094be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor /// Subclasses may override this routine to provide different behavior. 109560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc, 1096be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor SourceLocation RParenLoc, 1097be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor VarDecl *Var, 10989ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Body) { 1099be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc, 11009ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Var, Body); 1101be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor } 1102c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 11034dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// \brief Build a new Objective-C @finally statement. 11044dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// 11054dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// By default, performs semantic analysis to build the new statement. 11064dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor /// Subclasses may override this routine to provide different behavior. 110760d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc, 11089ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Body) { 11099ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body); 11104dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor } 1111c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 11128fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor /// \brief Build a new Objective-C @throw statement. 1113d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor /// 1114d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor /// By default, performs semantic analysis to build the new statement. 1115d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor /// Subclasses may override this routine to provide different behavior. 111660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc, 11179ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Operand) { 11189ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildObjCAtThrowStmt(AtLoc, Operand); 1119d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor } 1120c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 11218fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor /// \brief Build a new Objective-C @synchronized statement. 11228fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor /// 11238fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor /// By default, performs semantic analysis to build the new statement. 11248fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor /// Subclasses may override this routine to provide different behavior. 112560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, 11269ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Object, 11279ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *Body) { 11289ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, 11299ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Body); 11308fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor } 1131c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor 1132c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor /// \brief Build a new Objective-C fast enumeration statement. 1133c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor /// 1134c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor /// By default, performs semantic analysis to build the new statement. 1135c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor /// Subclasses may override this routine to provide different behavior. 113660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc, 1137f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall SourceLocation LParenLoc, 1138f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Stmt *Element, 1139f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Expr *Collection, 1140f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall SourceLocation RParenLoc, 1141f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Stmt *Body) { 1142c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor return getSema().ActOnObjCForCollectionStmt(ForLoc, LParenLoc, 11439ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Element, 11449ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Collection, 1145c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor RParenLoc, 11469ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Body); 1147c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor } 1148c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 114943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new C++ exception declaration. 115043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 115143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new decaration. 115243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 115383cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, 1154a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *Declarator, 115543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor IdentifierInfo *Name, 115683cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor SourceLocation Loc) { 115783cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor return getSema().BuildExceptionDeclaration(0, Declarator, Name, Loc); 115843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 115943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 116043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new C++ catch statement. 116143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 116243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 116343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 116460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, 1165f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall VarDecl *ExceptionDecl, 1166f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Stmt *Handler) { 11679ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl, 11689ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Handler)); 116943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 11701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 117143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// \brief Build a new C++ try statement. 117243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// 117343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// By default, performs semantic analysis to build the new statement. 117443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor /// Subclasses may override this routine to provide different behavior. 117560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, 1176f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Stmt *TryBlock, 1177f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall MultiStmtArg Handlers) { 11789ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, move(Handlers)); 117943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 11801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1181b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new expression that references a declaration. 1182b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1183b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1184b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 118560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, 1186f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall LookupResult &R, 1187f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall bool RequiresADL) { 1188f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL); 1189f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 1190f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1191f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1192f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// \brief Build a new expression that references a declaration. 1193f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// 1194f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// By default, performs semantic analysis to build the new expression. 1195f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /// Subclasses may override this routine to provide different behavior. 119660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildDeclRefExpr(NestedNameSpecifier *Qualifier, 1197f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall SourceRange QualifierRange, 1198f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall ValueDecl *VD, 1199f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall const DeclarationNameInfo &NameInfo, 1200f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall TemplateArgumentListInfo *TemplateArgs) { 1201a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor CXXScopeSpec SS; 1202a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor SS.setScopeRep(Qualifier); 1203a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor SS.setRange(QualifierRange); 1204dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall 1205dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall // FIXME: loses template args. 12062577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 12072577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD); 1208b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 12091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1210b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new expression in parentheses. 12111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1212b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1213b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 121460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen, 1215b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParen) { 12169ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnParenExpr(LParen, RParen, SubExpr); 1217b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1218b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1219a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// \brief Build a new pseudo-destructor expression. 12201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1221a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1222a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor /// Subclasses may override this routine to provide different behavior. 122360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base, 1224a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor SourceLocation OperatorLoc, 1225a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor bool isArrow, 1226a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor NestedNameSpecifier *Qualifier, 122726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SourceRange QualifierRange, 122826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *ScopeType, 122926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SourceLocation CCLoc, 1230fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 1231a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage Destroyed); 12321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1233b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new unary operator expression. 12341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1235b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1236b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 123760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildUnaryOperator(SourceLocation OpLoc, 12382de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall UnaryOperatorKind Opc, 12399ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr) { 12409ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildUnaryOp(/*Scope=*/0, OpLoc, Opc, SubExpr); 1241b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 12421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 12438ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor /// \brief Build a new builtin offsetof expression. 12448ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor /// 12458ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor /// By default, performs semantic analysis to build the new expression. 12468ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor /// Subclasses may override this routine to provide different behavior. 124760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc, 12488ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor TypeSourceInfo *Type, 1249f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema::OffsetOfComponent *Components, 12508ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor unsigned NumComponents, 12518ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor SourceLocation RParenLoc) { 12528ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components, 12538ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor NumComponents, RParenLoc); 12548ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor } 1255c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 1256b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new sizeof or alignof expression with a type argument. 12571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1258b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1259b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 126060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildSizeOfAlignOf(TypeSourceInfo *TInfo, 12615ab75172051a6d2ea71a80a79e81c65519fd3462John McCall SourceLocation OpLoc, 1262b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool isSizeOf, SourceRange R) { 1263a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall return getSema().CreateSizeOfAlignOfExpr(TInfo, OpLoc, isSizeOf, R); 1264b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1265b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 12661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new sizeof or alignof expression with an expression 1267b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// argument. 12681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1269b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1270b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 127160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildSizeOfAlignOf(Expr *SubExpr, SourceLocation OpLoc, 1272b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool isSizeOf, SourceRange R) { 127360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result 12749ae2f076ca5ab1feb3ba95629099ec2319833701John McCall = getSema().CreateSizeOfAlignOfExpr(SubExpr, OpLoc, isSizeOf, R); 1275b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Result.isInvalid()) 1276f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 12771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1278b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return move(Result); 1279b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 12801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1281b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new array subscript expression. 12821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1283b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1284b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 128560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildArraySubscriptExpr(Expr *LHS, 1286b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LBracketLoc, 12879ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *RHS, 1288b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RBracketLoc) { 12899ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnArraySubscriptExpr(/*Scope=*/0, LHS, 12909ae2f076ca5ab1feb3ba95629099ec2319833701John McCall LBracketLoc, RHS, 1291b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RBracketLoc); 1292b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1293b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1294b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new call expression. 12951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1296b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1297b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 129860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, 1299b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor MultiExprArg Args, 1300b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 13019ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnCallExpr(/*Scope=*/0, Callee, LParenLoc, 1302a1a04786cea2445759026edacd096abd1fbf4a05Douglas Gregor move(Args), RParenLoc); 1303b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1304b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1305b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new member access expression. 13061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1307b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1308b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 130960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, 1310f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall bool isArrow, 1311f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall NestedNameSpecifier *Qualifier, 1312f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall SourceRange QualifierRange, 1313f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall const DeclarationNameInfo &MemberNameInfo, 1314f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ValueDecl *Member, 1315f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall NamedDecl *FoundDecl, 1316d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo *ExplicitTemplateArgs, 1317f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall NamedDecl *FirstQualifierInScope) { 1318d8b285fee4471f393da8ee30f552ceacdc362afaAnders Carlsson if (!Member->getDeclName()) { 1319f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall // We have a reference to an unnamed field. This is always the 1320f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall // base of an anonymous struct/union member access, i.e. the 1321f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall // field is always of record type. 1322d8b285fee4471f393da8ee30f552ceacdc362afaAnders Carlsson assert(!Qualifier && "Can't have an unnamed field with a qualifier!"); 1323f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall assert(Member->getType()->isRecordType() && 1324f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall "unnamed member not of record type?"); 13251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 13269ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (getSema().PerformObjectMemberConversion(Base, Qualifier, 13276bb8017bb9e828d118e15e59d71c66bba323c364John McCall FoundDecl, Member)) 1328f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 13298aa5f407d9e4787ff08bd66e1a2fe39be174fddcDouglas Gregor 1330f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind(); 13311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump MemberExpr *ME = 13329ae2f076ca5ab1feb3ba95629099ec2319833701John McCall new (getSema().Context) MemberExpr(Base, isArrow, 13332577743c5650c646fb705df01403707e94f2df04Abramo Bagnara Member, MemberNameInfo, 1334f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall cast<FieldDecl>(Member)->getType(), 1335f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall VK, OK_Ordinary); 1336d8b285fee4471f393da8ee30f552ceacdc362afaAnders Carlsson return getSema().Owned(ME); 1337d8b285fee4471f393da8ee30f552ceacdc362afaAnders Carlsson } 13381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 133983f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor CXXScopeSpec SS; 134083f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor if (Qualifier) { 134183f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor SS.setRange(QualifierRange); 134283f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor SS.setScopeRep(Qualifier); 134383f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor } 134483f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor 13459ae2f076ca5ab1feb3ba95629099ec2319833701John McCall getSema().DefaultFunctionArrayConversion(Base); 13469ae2f076ca5ab1feb3ba95629099ec2319833701John McCall QualType BaseType = Base->getType(); 1347aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 13486bb8017bb9e828d118e15e59d71c66bba323c364John McCall // FIXME: this involves duplicating earlier analysis in a lot of 13496bb8017bb9e828d118e15e59d71c66bba323c364John McCall // cases; we should avoid this when possible. 13502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName); 13516bb8017bb9e828d118e15e59d71c66bba323c364John McCall R.addDecl(FoundDecl); 1352c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall R.resolveKind(); 1353c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall 13549ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow, 1355129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SS, FirstQualifierInScope, 1356c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall R, ExplicitTemplateArgs); 1357b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 13581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1359b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new binary operator expression. 13601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1361b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1362b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 136360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildBinaryOperator(SourceLocation OpLoc, 13642de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall BinaryOperatorKind Opc, 13659ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *LHS, Expr *RHS) { 13669ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc, LHS, RHS); 1367b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1368b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1369b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new conditional operator expression. 13701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1371b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1372b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 137360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildConditionalOperator(Expr *Cond, 1374b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation QuestionLoc, 13759ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *LHS, 1376b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation ColonLoc, 13779ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *RHS) { 13789ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond, 13799ae2f076ca5ab1feb3ba95629099ec2319833701John McCall LHS, RHS); 1380b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1381b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1382b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C-style cast expression. 13831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1384b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1385b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 138660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc, 13879d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *TInfo, 1388b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc, 13899ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr) { 1390b042fdfc9460e0018276412257e3c3226f9ea96eJohn McCall return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, 13919ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr); 1392b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 13931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1394b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new compound literal expression. 13951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1396b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1397b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 139860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc, 139942f56b50062cd3b3c6b23fdb9053578ae9145664John McCall TypeSourceInfo *TInfo, 1400b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc, 14019ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Init) { 140242f56b50062cd3b3c6b23fdb9053578ae9145664John McCall return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, 14039ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Init); 1404b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 14051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1406b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new extended vector element access expression. 14071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1408b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1409b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 141060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildExtVectorElementExpr(Expr *Base, 1411b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation OpLoc, 1412b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation AccessorLoc, 1413b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor IdentifierInfo &Accessor) { 1414aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 1415129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall CXXScopeSpec SS; 14162577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo(&Accessor, AccessorLoc); 14179ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildMemberReferenceExpr(Base, Base->getType(), 1418129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall OpLoc, /*IsArrow*/ false, 1419129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SS, /*FirstQualifierInScope*/ 0, 14202577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo, 1421129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /* TemplateArgs */ 0); 1422b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 14231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1424b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new initializer list expression. 14251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1426b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1427b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 142860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildInitList(SourceLocation LBraceLoc, 1429b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor MultiExprArg Inits, 1430e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor SourceLocation RBraceLoc, 1431e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor QualType ResultTy) { 143260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result 1433e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor = SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc); 1434e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor if (Result.isInvalid() || ResultTy->isDependentType()) 1435e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor return move(Result); 1436c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 1437e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor // Patch in the result type we were given, which may have been computed 1438e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor // when the initial InitListExpr was built. 1439e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor InitListExpr *ILE = cast<InitListExpr>((Expr *)Result.get()); 1440e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor ILE->setType(ResultTy); 1441e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor return move(Result); 1442b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 14431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1444b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new designated initializer expression. 14451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1446b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1447b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 144860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildDesignatedInitExpr(Designation &Desig, 1449b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor MultiExprArg ArrayExprs, 1450b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation EqualOrColonLoc, 1451b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool GNUSyntax, 14529ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Init) { 145360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result 1454b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax, 14559ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Init); 1456b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Result.isInvalid()) 1457f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 14581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1459b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ArrayExprs.release(); 1460b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return move(Result); 1461b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 14621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1463b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new value-initialized expression. 14641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1465b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, builds the implicit value initialization without performing 1466b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// any semantic analysis. Subclasses may override this routine to provide 1467b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// different behavior. 146860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildImplicitValueInitExpr(QualType T) { 1469b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return SemaRef.Owned(new (SemaRef.Context) ImplicitValueInitExpr(T)); 1470b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 14711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1472b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new \c va_arg expression. 14731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1474b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1475b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 147660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, 14779ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr, TypeSourceInfo *TInfo, 14782cad900202561cdda18ea6cc51ddbf3e20e3c23aAbramo Bagnara SourceLocation RParenLoc) { 14792cad900202561cdda18ea6cc51ddbf3e20e3c23aAbramo Bagnara return getSema().BuildVAArgExpr(BuiltinLoc, 14809ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr, TInfo, 14812cad900202561cdda18ea6cc51ddbf3e20e3c23aAbramo Bagnara RParenLoc); 1482b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1483b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1484b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new expression list in parentheses. 14851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1486b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1487b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 148860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildParenListExpr(SourceLocation LParenLoc, 1489b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor MultiExprArg SubExprs, 1490b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1491c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getSema().ActOnParenOrParenListExpr(LParenLoc, RParenLoc, 1492f88f7ab5adaa11d050270ffee6aa871e855f83b8Fariborz Jahanian move(SubExprs)); 1493b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 14941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1495b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new address-of-label expression. 14961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 14971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// By default, performs semantic analysis, using the name of the label 1498b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// rather than attempting to map the label statement itself. 1499b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 150060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc, 1501b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LabelLoc, 1502b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LabelStmt *Label) { 1503b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label->getID()); 1504b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 15051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1506b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new GNU statement expression. 15071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// 1508b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1509b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 151060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildStmtExpr(SourceLocation LParenLoc, 15119ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Stmt *SubStmt, 1512b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 15139ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc); 1514b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 15151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1516b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new __builtin_choose_expr expression. 1517b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1518b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1519b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 152060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc, 15219ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Cond, Expr *LHS, Expr *RHS, 1522b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1523b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return SemaRef.ActOnChooseExpr(BuiltinLoc, 15249ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Cond, LHS, RHS, 1525b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc); 1526b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 15271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1528b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new overloaded operator call expression. 1529b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1530b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1531b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// The semantic analysis provides the behavior of template instantiation, 1532b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// copying with transformations that turn what looks like an overloaded 15331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// operator call into a use of a builtin operator, performing 1534b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// argument-dependent lookup, etc. Subclasses may override this routine to 1535b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// provide different behavior. 153660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, 1537b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation OpLoc, 15389ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Callee, 15399ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *First, 15409ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Second); 15411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 15421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new C++ "named" cast expression, such as static_cast or 1543b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// reinterpret_cast. 1544b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1545b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, this routine dispatches to one of the more-specific routines 15461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// for a particular named case, e.g., RebuildCXXStaticCastExpr(). 1547b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 154860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc, 1549b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Stmt::StmtClass Class, 1550b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LAngleLoc, 15519d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *TInfo, 1552b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RAngleLoc, 1553b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LParenLoc, 15549ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr, 1555b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1556b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor switch (Class) { 1557b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor case Stmt::CXXStaticCastExprClass: 15589d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo, 15591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump RAngleLoc, LParenLoc, 15609ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr, RParenLoc); 1561b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1562b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor case Stmt::CXXDynamicCastExprClass: 15639d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo, 15641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump RAngleLoc, LParenLoc, 15659ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr, RParenLoc); 15661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1567b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor case Stmt::CXXReinterpretCastExprClass: 15689d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo, 15691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump RAngleLoc, LParenLoc, 15709ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr, 1571b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc); 15721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1573b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor case Stmt::CXXConstCastExprClass: 15749d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo, 15751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump RAngleLoc, LParenLoc, 15769ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr, RParenLoc); 15771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1578b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor default: 1579b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor assert(false && "Invalid C++ named cast"); 1580b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor break; 1581b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 15821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1583f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 1584b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 15851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1586b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ static_cast expression. 1587b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1588b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1589b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 159060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc, 1591b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LAngleLoc, 15929d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *TInfo, 1593b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RAngleLoc, 1594b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LParenLoc, 15959ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr, 1596b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1597c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast, 15989ae2f076ca5ab1feb3ba95629099ec2319833701John McCall TInfo, SubExpr, 1599c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LAngleLoc, RAngleLoc), 1600c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LParenLoc, RParenLoc)); 1601b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1602b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1603b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ dynamic_cast expression. 1604b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1605b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1606b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 160760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc, 1608b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LAngleLoc, 16099d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *TInfo, 1610b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RAngleLoc, 1611b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LParenLoc, 16129ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr, 1613b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1614c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast, 16159ae2f076ca5ab1feb3ba95629099ec2319833701John McCall TInfo, SubExpr, 1616c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LAngleLoc, RAngleLoc), 1617c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LParenLoc, RParenLoc)); 1618b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1619b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1620b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ reinterpret_cast expression. 1621b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1622b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1623b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 162460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc, 1625b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LAngleLoc, 16269d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *TInfo, 1627b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RAngleLoc, 1628b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LParenLoc, 16299ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr, 1630b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1631c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast, 16329ae2f076ca5ab1feb3ba95629099ec2319833701John McCall TInfo, SubExpr, 1633c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LAngleLoc, RAngleLoc), 1634c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LParenLoc, RParenLoc)); 1635b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1636b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1637b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ const_cast expression. 1638b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1639b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1640b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 164160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, 1642b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LAngleLoc, 16439d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall TypeSourceInfo *TInfo, 1644b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RAngleLoc, 1645b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation LParenLoc, 16469ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SubExpr, 1647b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1648c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast, 16499ae2f076ca5ab1feb3ba95629099ec2319833701John McCall TInfo, SubExpr, 1650c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LAngleLoc, RAngleLoc), 1651c89724cc6dcb178ec79c76d7e629d9a7b5d83418John McCall SourceRange(LParenLoc, RParenLoc)); 1652b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 16531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1654b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ functional-style cast expression. 1655b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1656b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1657b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 1658ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, 1659ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation LParenLoc, 1660ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor Expr *Sub, 1661ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation RParenLoc) { 1662ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc, 1663f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall MultiExprArg(&Sub, 1), 1664b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc); 1665b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 16661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1667b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ typeid(type) expression. 1668b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1669b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1670b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 167160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, 167257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor SourceLocation TypeidLoc, 167357fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *Operand, 1674b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 1675c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, 167657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor RParenLoc); 1677b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 16781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 167901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 1680b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ typeid(expr) expression. 1681b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1682b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1683b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 168460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, 168557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor SourceLocation TypeidLoc, 16869ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Operand, 1687b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 16889ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand, 168957fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor RParenLoc); 16901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 16911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 169201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Build a new C++ __uuidof(type) expression. 169301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// 169401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// By default, performs semantic analysis to build the new expression. 169501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// Subclasses may override this routine to provide different behavior. 169601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, 169701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceLocation TypeidLoc, 169801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TypeSourceInfo *Operand, 169901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceLocation RParenLoc) { 170001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand, 170101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet RParenLoc); 170201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 170301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 170401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// \brief Build a new C++ __uuidof(expr) expression. 170501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// 170601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// By default, performs semantic analysis to build the new expression. 170701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet /// Subclasses may override this routine to provide different behavior. 170801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType, 170901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceLocation TypeidLoc, 171001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet Expr *Operand, 171101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SourceLocation RParenLoc) { 171201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand, 171301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet RParenLoc); 171401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 171501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 1716b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ "this" expression. 1717b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1718b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, builds a new "this" expression without performing any 17191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// semantic analysis. Subclasses may override this routine to provide 1720b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// different behavior. 172160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc, 1722ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor QualType ThisType, 1723ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor bool isImplicit) { 1724b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getSema().Owned( 1725828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor new (getSema().Context) CXXThisExpr(ThisLoc, ThisType, 1726828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor isImplicit)); 1727b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1728b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1729b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ throw expression. 1730b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1731b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1732b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 173360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub) { 17349ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnCXXThrow(ThrowLoc, Sub); 1735b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1736b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1737b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ default-argument expression. 1738b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1739b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, builds a new default-argument expression, which does not 1740b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// require any semantic analysis. Subclasses may override this routine to 1741b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// provide different behavior. 174260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc, 1743036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor ParmVarDecl *Param) { 1744036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return getSema().Owned(CXXDefaultArgExpr::Create(getSema().Context, Loc, 1745036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor Param)); 1746b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1747b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1748b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ zero-initialization expression. 1749b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1750b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1751b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 1752ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo, 1753ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation LParenLoc, 1754ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation RParenLoc) { 1755ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, 17561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump MultiExprArg(getSema(), 0, 0), 1757ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor RParenLoc); 1758b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 17591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1760b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ "new" expression. 1761b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1762b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1763b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 176460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, 17651bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor bool UseGlobal, 17661bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor SourceLocation PlacementLParen, 17671bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor MultiExprArg PlacementArgs, 17681bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor SourceLocation PlacementRParen, 17691bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor SourceRange TypeIdParens, 17701bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor QualType AllocatedType, 17711bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocatedTypeInfo, 17721bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor Expr *ArraySize, 17731bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor SourceLocation ConstructorLParen, 17741bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor MultiExprArg ConstructorArgs, 17751bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor SourceLocation ConstructorRParen) { 17761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getSema().BuildCXXNew(StartLoc, UseGlobal, 1777b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor PlacementLParen, 1778b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move(PlacementArgs), 1779b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor PlacementRParen, 17804bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor TypeIdParens, 17811bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor AllocatedType, 17821bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor AllocatedTypeInfo, 17839ae2f076ca5ab1feb3ba95629099ec2319833701John McCall ArraySize, 1784b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ConstructorLParen, 1785b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move(ConstructorArgs), 1786b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ConstructorRParen); 1787b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 17881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1789b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new C++ "delete" expression. 1790b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1791b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1792b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 179360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc, 1794b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool IsGlobalDelete, 1795b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool IsArrayForm, 17969ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Operand) { 1797b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm, 17989ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Operand); 1799b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 18001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1801b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new unary type trait expression. 1802b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1803b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1804b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 180560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildUnaryTypeTrait(UnaryTypeTrait Trait, 18063d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor SourceLocation StartLoc, 18073d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *T, 18083d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor SourceLocation RParenLoc) { 18093d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor return getSema().BuildUnaryTypeTrait(Trait, StartLoc, T, RParenLoc); 1810b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1811b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 18126ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// \brief Build a new binary type trait expression. 18136ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// 18146ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// By default, performs semantic analysis to build the new expression. 18156ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet /// Subclasses may override this routine to provide different behavior. 18166ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet ExprResult RebuildBinaryTypeTrait(BinaryTypeTrait Trait, 18176ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation StartLoc, 18186ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *LhsT, 18196ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *RhsT, 18206ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet SourceLocation RParenLoc) { 18216ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return getSema().BuildBinaryTypeTrait(Trait, StartLoc, LhsT, RhsT, RParenLoc); 18226ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet } 18236ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 18241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump /// \brief Build a new (previously unresolved) declaration reference 1825b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// expression. 1826b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1827b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1828b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 182960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifier *NNS, 1830b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceRange QualifierRange, 18312577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &NameInfo, 1832f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall const TemplateArgumentListInfo *TemplateArgs) { 1833b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor CXXScopeSpec SS; 1834b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SS.setRange(QualifierRange); 1835b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SS.setScopeRep(NNS); 1836f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 1837f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (TemplateArgs) 18382577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return getSema().BuildQualifiedTemplateIdExpr(SS, NameInfo, 1839f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall *TemplateArgs); 1840f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 18412577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return getSema().BuildQualifiedDeclarationNameExpr(SS, NameInfo); 1842b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1843b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1844b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new template-id expression. 1845b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1846b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1847b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 184860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, 1849f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall LookupResult &R, 1850f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall bool RequiresADL, 1851d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo &TemplateArgs) { 1852f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getSema().BuildTemplateIdExpr(SS, R, RequiresADL, TemplateArgs); 1853b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1854b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1855b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new object-construction expression. 1856b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1857b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1858b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 185960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXConstructExpr(QualType T, 18604411d2e674b0119f682ac472c3a377f14fa9fa30Douglas Gregor SourceLocation Loc, 1861b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor CXXConstructorDecl *Constructor, 1862b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool IsElidable, 18638c3e554d00d456d5093c21ce8a0c205461279aabDouglas Gregor MultiExprArg Args, 18648c3e554d00d456d5093c21ce8a0c205461279aabDouglas Gregor bool RequiresZeroInit, 1865428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth CXXConstructExpr::ConstructionKind ConstructKind, 1866428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth SourceRange ParenRange) { 1867ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> ConvertedArgs(SemaRef); 1868c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc, 18694411d2e674b0119f682ac472c3a377f14fa9fa30Douglas Gregor ConvertedArgs)) 1870f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 1871c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 18724411d2e674b0119f682ac472c3a377f14fa9fa30Douglas Gregor return getSema().BuildCXXConstructExpr(Loc, T, Constructor, IsElidable, 18738c3e554d00d456d5093c21ce8a0c205461279aabDouglas Gregor move_arg(ConvertedArgs), 1874428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth RequiresZeroInit, ConstructKind, 1875428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth ParenRange); 1876b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1877b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1878b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new object-construction expression. 1879b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1880b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1881b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 1882ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, 1883ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation LParenLoc, 1884ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor MultiExprArg Args, 1885ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation RParenLoc) { 1886ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getSema().BuildCXXTypeConstructExpr(TSInfo, 1887b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LParenLoc, 1888b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move(Args), 1889b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc); 1890b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1891b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1892b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new object-construction expression. 1893b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1894b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1895b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 1896ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, 1897ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation LParenLoc, 1898ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor MultiExprArg Args, 1899ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SourceLocation RParenLoc) { 1900ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getSema().BuildCXXTypeConstructExpr(TSInfo, 1901b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LParenLoc, 1902b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move(Args), 1903b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc); 1904b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 19051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 1906b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new member reference expression. 1907b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1908b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1909b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 191060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE, 1911aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType, 1912b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool IsArrow, 1913b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation OperatorLoc, 1914a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier, 1915a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange QualifierRange, 1916129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NamedDecl *FirstQualifierInScope, 19172577743c5650c646fb705df01403707e94f2df04Abramo Bagnara const DeclarationNameInfo &MemberNameInfo, 1918129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentListInfo *TemplateArgs) { 1919b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor CXXScopeSpec SS; 1920a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SS.setRange(QualifierRange); 1921a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SS.setScopeRep(Qualifier); 19221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19239ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType, 1924aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall OperatorLoc, IsArrow, 1925129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SS, FirstQualifierInScope, 19262577743c5650c646fb705df01403707e94f2df04Abramo Bagnara MemberNameInfo, 19272577743c5650c646fb705df01403707e94f2df04Abramo Bagnara TemplateArgs); 1928b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 1929b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 1930129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /// \brief Build a new member reference expression. 19313b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// 19323b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// By default, performs semantic analysis to build the new expression. 19333b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor /// Subclasses may override this routine to provide different behavior. 193460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, 1935aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType, 1936129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceLocation OperatorLoc, 1937129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall bool IsArrow, 1938129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NestedNameSpecifier *Qualifier, 1939129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall SourceRange QualifierRange, 1940c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall NamedDecl *FirstQualifierInScope, 1941129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall LookupResult &R, 1942129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall const TemplateArgumentListInfo *TemplateArgs) { 19433b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor CXXScopeSpec SS; 19443b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SS.setRange(QualifierRange); 19453b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor SS.setScopeRep(Qualifier); 19461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19479ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType, 1948aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall OperatorLoc, IsArrow, 1949c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall SS, FirstQualifierInScope, 1950c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall R, TemplateArgs); 19513b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 19521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 19532e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl /// \brief Build a new noexcept expression. 19542e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl /// 19552e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl /// By default, performs semantic analysis to build the new expression. 19562e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl /// Subclasses may override this routine to provide different behavior. 19572e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg) { 19582e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd()); 19592e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl } 19602e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 1961ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor /// \brief Build a new expression to compute the length of a parameter pack. 1962ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack, 1963ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation PackLoc, 1964ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor SourceLocation RParenLoc, 1965ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned Length) { 1966ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return new (SemaRef.Context) SizeOfPackExpr(SemaRef.Context.getSizeType(), 1967ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor OperatorLoc, Pack, PackLoc, 1968ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor RParenLoc, Length); 1969ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor } 1970ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 1971b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new Objective-C @encode expression. 1972b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 1973b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 1974b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 197560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc, 197681d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor TypeSourceInfo *EncodeTypeInfo, 1977b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation RParenLoc) { 197881d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, 1979b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc)); 19801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 1981b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 198292e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor /// \brief Build a new Objective-C class message. 198360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo, 198492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor Selector Sel, 1985f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis SourceLocation SelectorLoc, 198692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor ObjCMethodDecl *Method, 1987c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt SourceLocation LBracLoc, 198892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor MultiExprArg Args, 198992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor SourceLocation RBracLoc) { 199092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor return SemaRef.BuildClassMessage(ReceiverTypeInfo, 199192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor ReceiverTypeInfo->getType(), 199292e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor /*SuperLoc=*/SourceLocation(), 1993f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis Sel, Method, LBracLoc, SelectorLoc, 1994f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis RBracLoc, move(Args)); 199592e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor } 199692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor 199792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor /// \brief Build a new Objective-C instance message. 199860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildObjCMessageExpr(Expr *Receiver, 199992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor Selector Sel, 2000f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis SourceLocation SelectorLoc, 200192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor ObjCMethodDecl *Method, 2002c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt SourceLocation LBracLoc, 200392e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor MultiExprArg Args, 200492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor SourceLocation RBracLoc) { 20059ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildInstanceMessage(Receiver, 20069ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Receiver->getType(), 200792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor /*SuperLoc=*/SourceLocation(), 2008f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis Sel, Method, LBracLoc, SelectorLoc, 2009f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis RBracLoc, move(Args)); 201092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor } 201192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor 2012f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// \brief Build a new Objective-C ivar reference expression. 2013f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// 2014f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// By default, performs semantic analysis to build the new expression. 2015f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// Subclasses may override this routine to provide different behavior. 201660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar, 2017f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor SourceLocation IvarLoc, 2018f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor bool IsArrow, bool IsFreeIvar) { 2019f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor // FIXME: We lose track of the IsFreeIvar bit. 2020f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor CXXScopeSpec SS; 20219ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Base = BaseArg; 2022f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor LookupResult R(getSema(), Ivar->getDeclName(), IvarLoc, 2023f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor Sema::LookupMemberName); 202460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, 2025f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /*FIME:*/IvarLoc, 2026d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall SS, 0, 2027ad00b7705f9bbee81beeac428e7c6587734ab5a6John McCall false); 2028f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (Result.isInvalid()) 2029f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 2030c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2031f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (Result.get()) 2032f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor return move(Result); 2033c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 20349ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildMemberReferenceExpr(Base, Base->getType(), 2035c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt /*FIXME:*/IvarLoc, IsArrow, SS, 2036f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /*FirstQualifierInScope=*/0, 2037c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt R, 2038f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /*TemplateArgs=*/0); 2039f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor } 2040e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor 2041e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /// \brief Build a new Objective-C property reference expression. 2042e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /// 2043e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /// By default, performs semantic analysis to build the new expression. 2044e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /// Subclasses may override this routine to provide different behavior. 204560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg, 2046e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor ObjCPropertyDecl *Property, 2047e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor SourceLocation PropertyLoc) { 2048e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor CXXScopeSpec SS; 20499ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Base = BaseArg; 2050e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor LookupResult R(getSema(), Property->getDeclName(), PropertyLoc, 2051e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor Sema::LookupMemberName); 2052e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor bool IsArrow = false; 205360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, 2054e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /*FIME:*/PropertyLoc, 2055d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall SS, 0, false); 2056e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor if (Result.isInvalid()) 2057f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 2058c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2059e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor if (Result.get()) 2060e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor return move(Result); 2061c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 20629ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildMemberReferenceExpr(Base, Base->getType(), 2063c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt /*FIXME:*/PropertyLoc, IsArrow, 2064c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt SS, 2065e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /*FirstQualifierInScope=*/0, 2066c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt R, 2067e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor /*TemplateArgs=*/0); 2068e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor } 2069c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 207012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall /// \brief Build a new Objective-C property reference expression. 20719cbfdd212ee0167f2487363d6fac7faaf7c65b64Douglas Gregor /// 20729cbfdd212ee0167f2487363d6fac7faaf7c65b64Douglas Gregor /// By default, performs semantic analysis to build the new expression. 207312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall /// Subclasses may override this routine to provide different behavior. 207412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T, 207512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall ObjCMethodDecl *Getter, 207612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall ObjCMethodDecl *Setter, 207712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall SourceLocation PropertyLoc) { 207812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall // Since these expressions can only be value-dependent, we do not 207912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall // need to perform semantic analysis again. 208012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall return Owned( 208112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T, 208212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall VK_LValue, OK_ObjCProperty, 208312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall PropertyLoc, Base)); 20849cbfdd212ee0167f2487363d6fac7faaf7c65b64Douglas Gregor } 20859cbfdd212ee0167f2487363d6fac7faaf7c65b64Douglas Gregor 2086f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// \brief Build a new Objective-C "isa" expression. 2087f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// 2088f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// By default, performs semantic analysis to build the new expression. 2089f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /// Subclasses may override this routine to provide different behavior. 209060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc, 2091f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor bool IsArrow) { 2092f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor CXXScopeSpec SS; 20939ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Base = BaseArg; 2094f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor LookupResult R(getSema(), &getSema().Context.Idents.get("isa"), IsaLoc, 2095f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor Sema::LookupMemberName); 209660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow, 2097f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /*FIME:*/IsaLoc, 2098d226f65006733ed7f709c3174f22ce33391cb58fJohn McCall SS, 0, false); 2099f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (Result.isInvalid()) 2100f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 2101c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2102f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (Result.get()) 2103f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor return move(Result); 2104c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 21059ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildMemberReferenceExpr(Base, Base->getType(), 2106c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt /*FIXME:*/IsaLoc, IsArrow, SS, 2107f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /*FirstQualifierInScope=*/0, 2108c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt R, 2109f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor /*TemplateArgs=*/0); 2110f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor } 2111c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2112b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// \brief Build a new shuffle vector expression. 2113b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// 2114b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// By default, performs semantic analysis to build the new expression. 2115b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /// Subclasses may override this routine to provide different behavior. 211660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, 2117f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall MultiExprArg SubExprs, 2118f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall SourceLocation RParenLoc) { 2119b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Find the declaration for __builtin_shufflevector 21201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump const IdentifierInfo &Name 2121b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.Context.Idents.get("__builtin_shufflevector"); 2122b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl(); 2123b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name)); 2124b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor assert(Lookup.first != Lookup.second && "No __builtin_shufflevector?"); 21251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2126b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Build a reference to the __builtin_shufflevector builtin 2127b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor FunctionDecl *Builtin = cast<FunctionDecl>(*Lookup.first); 21281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Expr *Callee 2129b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = new (SemaRef.Context) DeclRefExpr(Builtin, Builtin->getType(), 2130f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall VK_LValue, BuiltinLoc); 2131b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SemaRef.UsualUnaryConversions(Callee); 21321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 21331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump // Build the CallExpr 2134b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor unsigned NumSubExprs = SubExprs.size(); 2135b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Expr **Subs = (Expr **)SubExprs.release(); 2136b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor CallExpr *TheCall = new (SemaRef.Context) CallExpr(SemaRef.Context, Callee, 2137b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Subs, NumSubExprs, 21385291c3cec0dbe8ad1d8e7e67e93af2b1586d5400Douglas Gregor Builtin->getCallResultType(), 2139f89e55ab1bfb3ea997f8b02997c611a02254eb2dJohn McCall Expr::getValueKindForType(Builtin->getResultType()), 2140b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RParenLoc); 214160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult OwnedCall(SemaRef.Owned(TheCall)); 21421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2143b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Type-check the __builtin_shufflevector expression. 214460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = SemaRef.SemaBuiltinShuffleVector(TheCall); 2145b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Result.isInvalid()) 2146f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 21471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2148b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor OwnedCall.release(); 21491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return move(Result); 2150b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 215143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 21528491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// \brief Build a new template argument pack expansion. 21538491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// 21548491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// By default, performs semantic analysis to build a new pack expansion 21558491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// for a template argument. Subclasses may override this routine to provide 21568491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor /// different behavior. 21578491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern, 21588491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor SourceLocation EllipsisLoc) { 21598491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor switch (Pattern.getArgument().getKind()) { 21607a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor case TemplateArgument::Expression: { 21617a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor ExprResult Result 21627a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor = getSema().ActOnPackExpansion(Pattern.getSourceExpression(), 21637a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor EllipsisLoc); 21647a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor if (Result.isInvalid()) 21657a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor return TemplateArgumentLoc(); 21667a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor 21677a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor return TemplateArgumentLoc(Result.get(), Result.get()); 21687a21fd45d4f04643cbfb5df96a01f84bc6d3dd14Douglas Gregor } 2169dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 21708491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor case TemplateArgument::Template: 2171a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor return TemplateArgumentLoc(TemplateArgument( 2172a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor Pattern.getArgument().getAsTemplate(), 2173a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor true), 2174a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor Pattern.getTemplateQualifierRange(), 2175a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor Pattern.getTemplateNameLoc(), 2176a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor EllipsisLoc); 21778491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 21788491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor case TemplateArgument::Null: 21798491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor case TemplateArgument::Integral: 21808491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor case TemplateArgument::Declaration: 21818491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor case TemplateArgument::Pack: 2182a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor case TemplateArgument::TemplateExpansion: 21838491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor llvm_unreachable("Pack expansion pattern has no parameter packs"); 21848491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 21858491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor case TemplateArgument::Type: 21868491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (TypeSourceInfo *Expansion 21878491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(), 21888491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor EllipsisLoc)) 21898491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return TemplateArgumentLoc(TemplateArgument(Expansion->getType()), 21908491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Expansion); 21918491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor break; 21928491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 21938491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 21948491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return TemplateArgumentLoc(); 21958491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 21968491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 2197dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor /// \brief Build a new expression pack expansion. 2198dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor /// 2199dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor /// By default, performs semantic analysis to build a new pack expansion 2200dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor /// for an expression. Subclasses may override this routine to provide 2201dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor /// different behavior. 2202dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc) { 2203dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor return getSema().ActOnPackExpansion(Pattern, EllipsisLoc); 2204dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor } 2205dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 220643fed0de4f5bc189e45562491f83d5193eb8dac0John McCallprivate: 220743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType TransformTypeInObjectScope(QualType T, 220843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 220943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *FirstQualifierInScope, 221043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Prefix); 221143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 221243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *T, 221343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 221443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *FirstQualifierInScope, 221543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Prefix); 2216577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor}; 2217b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 221843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 221960d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) { 222043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!S) 222143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return SemaRef.Owned(S); 22221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 222343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor switch (S->getStmtClass()) { 222443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor case Stmt::NoStmtClass: break; 22251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 222643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform individual statement nodes 222743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#define STMT(Node, Parent) \ 222843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S)); 222943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#define EXPR(Node, Parent) 22304bfe1968410ea8ffe3b4f629addd7c4bcf484765Sean Hunt#include "clang/AST/StmtNodes.inc" 22311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 223243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform expressions by calling TransformExpr. 223343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#define STMT(Node, Parent) 22347381d5cfbd599fa2b9e215011ad7cbd449de231aSean Hunt#define ABSTRACT_STMT(Stmt) 223543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor#define EXPR(Node, Parent) case Stmt::Node##Class: 22364bfe1968410ea8ffe3b4f629addd7c4bcf484765Sean Hunt#include "clang/AST/StmtNodes.inc" 223743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor { 223860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult E = getDerived().TransformExpr(cast<Expr>(S)); 223943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (E.isInvalid()) 2240f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 22411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22429ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().ActOnExprStmt(getSema().MakeFullExpr(E.take())); 224343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 22441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 22451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22463fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 224743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 22481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2250670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregortemplate<typename Derived> 225160d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult TreeTransform<Derived>::TransformExpr(Expr *E) { 2252b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!E) 2253b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return SemaRef.Owned(E); 2254b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 2255b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor switch (E->getStmtClass()) { 2256b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor case Stmt::NoStmtClass: break; 2257b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor#define STMT(Node, Parent) case Stmt::Node##Class: break; 22587381d5cfbd599fa2b9e215011ad7cbd449de231aSean Hunt#define ABSTRACT_STMT(Stmt) 2259b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor#define EXPR(Node, Parent) \ 2260454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E)); 22614bfe1968410ea8ffe3b4f629addd7c4bcf484765Sean Hunt#include "clang/AST/StmtNodes.inc" 22621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 22631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 22643fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 2265657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregor} 2266657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregor 2267657c1acfc47d5c315ce864f2089b692262532a17Douglas Gregortemplate<typename Derived> 2268aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregorbool TreeTransform<Derived>::TransformExprs(Expr **Inputs, 2269aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor unsigned NumInputs, 2270aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor bool IsCall, 2271aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor llvm::SmallVectorImpl<Expr *> &Outputs, 2272aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor bool *ArgChanged) { 2273aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor for (unsigned I = 0; I != NumInputs; ++I) { 2274aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor // If requested, drop call arguments that need to be dropped. 2275aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (IsCall && getDerived().DropCallArgument(Inputs[I])) { 2276aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (ArgChanged) 2277aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor *ArgChanged = true; 2278aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 2279aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor break; 2280aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 2281aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 2282dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) { 2283dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Expr *Pattern = Expansion->getPattern(); 2284dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2285dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded; 2286dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); 2287dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); 2288dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2289dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // Determine whether the set of unexpanded parameter packs can and should 2290dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // be expanded. 2291dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor bool Expand = true; 2292d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor bool RetainExpansion = false; 2293dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor unsigned NumExpansions = 0; 2294dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(), 2295dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Pattern->getSourceRange(), 2296dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Unexpanded.data(), 2297dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Unexpanded.size(), 2298d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor Expand, RetainExpansion, 2299d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NumExpansions)) 2300dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor return true; 2301dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2302dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (!Expand) { 2303dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // The transform has determined that we should perform a simple 2304dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // transformation on the pack expansion, producing another pack 2305dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // expansion. 2306dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); 2307dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor ExprResult OutPattern = getDerived().TransformExpr(Pattern); 2308dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (OutPattern.isInvalid()) 2309dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor return true; 2310dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2311dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(), 2312dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Expansion->getEllipsisLoc()); 2313dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (Out.isInvalid()) 2314dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor return true; 2315dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2316dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (ArgChanged) 2317dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor *ArgChanged = true; 2318dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Outputs.push_back(Out.get()); 2319dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor continue; 2320dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor } 2321dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2322dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // The transform has determined that we should perform an elementwise 2323dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor // expansion of the pattern. Do so. 2324dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor for (unsigned I = 0; I != NumExpansions; ++I) { 2325dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); 2326dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor ExprResult Out = getDerived().TransformExpr(Pattern); 2327dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (Out.isInvalid()) 2328dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor return true; 2329dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2330dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor if (ArgChanged) 2331dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor *ArgChanged = true; 2332dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor Outputs.push_back(Out.get()); 2333dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor } 2334dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2335dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor continue; 2336dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor } 2337dcaa1ca0b475dfa887e1d061678a1e3501288510Douglas Gregor 2338aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor ExprResult Result = getDerived().TransformExpr(Inputs[I]); 2339aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (Result.isInvalid()) 2340aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return true; 2341aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 2342aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (Result.get() != Inputs[I] && ArgChanged) 2343aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor *ArgChanged = true; 2344aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 2345aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Outputs.push_back(Result.get()); 2346aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor } 2347aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 2348aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return false; 2349aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor} 2350aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 2351aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregortemplate<typename Derived> 2352dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorNestedNameSpecifier * 2353dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorTreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS, 2354a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor SourceRange Range, 2355c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor QualType ObjectType, 2356c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierInScope) { 235743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Prefix = NNS->getPrefix(); 23581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 235943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the prefix of this nested name specifier. 2360dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor if (Prefix) { 23611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Prefix = getDerived().TransformNestedNameSpecifier(Prefix, Range, 2362c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor ObjectType, 2363c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor FirstQualifierInScope); 2364dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor if (!Prefix) 2365dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return 0; 2366dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor } 23671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2368dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor switch (NNS->getKind()) { 2369dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor case NestedNameSpecifier::Identifier: 237043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (Prefix) { 237143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // The object type and qualifier-in-scope really apply to the 237243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // leftmost entity. 237343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType = QualType(); 237443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FirstQualifierInScope = 0; 237543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall } 237643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 23771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump assert((Prefix || !ObjectType.isNull()) && 2378a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor "Identifier nested-name-specifier with no prefix or object type"); 2379a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor if (!getDerived().AlwaysRebuild() && Prefix == NNS->getPrefix() && 2380a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor ObjectType.isNull()) 2381dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return NNS; 23821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 23831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildNestedNameSpecifier(Prefix, Range, 2384a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor *NNS->getAsIdentifier(), 2385c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor ObjectType, 2386c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor FirstQualifierInScope); 23871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2388dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor case NestedNameSpecifier::Namespace: { 23891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NamespaceDecl *NS 2390dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor = cast_or_null<NamespaceDecl>( 23917c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(Range.getBegin(), 23927c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor NNS->getAsNamespace())); 23931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump if (!getDerived().AlwaysRebuild() && 2394dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor Prefix == NNS->getPrefix() && 2395dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor NS == NNS->getAsNamespace()) 2396dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return NNS; 23971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2398dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return getDerived().RebuildNestedNameSpecifier(Prefix, Range, NS); 2399dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor } 24001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2401dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor case NestedNameSpecifier::Global: 2402dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor // There is no meaningful transformation that one could perform on the 2403dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor // global scope. 2404dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return NNS; 24051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2406dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor case NestedNameSpecifier::TypeSpecWithTemplate: 2407dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor case NestedNameSpecifier::TypeSpec: { 2408fbf2c945f8f8bbfe0459d45c03f9ff34bb445c81Douglas Gregor TemporaryBase Rebase(*this, Range.getBegin(), DeclarationName()); 240943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType T = TransformTypeInObjectScope(QualType(NNS->getAsType(), 0), 241043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType, 241143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FirstQualifierInScope, 241243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall Prefix); 2413d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (T.isNull()) 2414d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return 0; 24151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2416dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor if (!getDerived().AlwaysRebuild() && 2417dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor Prefix == NNS->getPrefix() && 2418dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor T == QualType(NNS->getAsType(), 0)) 2419dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return NNS; 24201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildNestedNameSpecifier(Prefix, Range, 24221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate, 2423edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor T); 2424dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor } 2425dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor } 24261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2427dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor // Required to silence a GCC warning 24281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return 0; 2429dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor} 2430dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor 2431dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregortemplate<typename Derived> 24322577743c5650c646fb705df01403707e94f2df04Abramo BagnaraDeclarationNameInfo 24332577743c5650c646fb705df01403707e94f2df04Abramo BagnaraTreeTransform<Derived> 243443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall::TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo) { 24352577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName Name = NameInfo.getName(); 243681499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor if (!Name) 24372577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return DeclarationNameInfo(); 243881499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor 243981499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor switch (Name.getNameKind()) { 244081499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::Identifier: 244181499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::ObjCZeroArgSelector: 244281499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::ObjCOneArgSelector: 244381499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::ObjCMultiArgSelector: 244481499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::CXXOperatorName: 24453e518bda00d710754ca077cf9be8dd821e16a854Sean Hunt case DeclarationName::CXXLiteralOperatorName: 244681499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::CXXUsingDirective: 24472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return NameInfo; 24481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 244981499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::CXXConstructorName: 245081499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::CXXDestructorName: 245181499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor case DeclarationName::CXXConversionFunctionName: { 24522577743c5650c646fb705df01403707e94f2df04Abramo Bagnara TypeSourceInfo *NewTInfo; 24532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara CanQualType NewCanTy; 24542577743c5650c646fb705df01403707e94f2df04Abramo Bagnara if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) { 245543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NewTInfo = getDerived().TransformType(OldTInfo); 245643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (!NewTInfo) 245743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return DeclarationNameInfo(); 245843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType()); 24592577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 24602577743c5650c646fb705df01403707e94f2df04Abramo Bagnara else { 24612577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NewTInfo = 0; 24622577743c5650c646fb705df01403707e94f2df04Abramo Bagnara TemporaryBase Rebase(*this, NameInfo.getLoc(), Name); 246343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType NewT = getDerived().TransformType(Name.getCXXNameType()); 24642577743c5650c646fb705df01403707e94f2df04Abramo Bagnara if (NewT.isNull()) 24652577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return DeclarationNameInfo(); 24662577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NewCanTy = SemaRef.Context.getCanonicalType(NewT); 24672577743c5650c646fb705df01403707e94f2df04Abramo Bagnara } 24681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24692577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName NewName 24702577743c5650c646fb705df01403707e94f2df04Abramo Bagnara = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(), 24712577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NewCanTy); 24722577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NewNameInfo(NameInfo); 24732577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NewNameInfo.setName(NewName); 24742577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NewNameInfo.setNamedTypeInfo(NewTInfo); 24752577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return NewNameInfo; 247681499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor } 24771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump } 24781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 24792577743c5650c646fb705df01403707e94f2df04Abramo Bagnara assert(0 && "Unknown name kind."); 24802577743c5650c646fb705df01403707e94f2df04Abramo Bagnara return DeclarationNameInfo(); 248181499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor} 248281499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregor 248381499bbeb2bd157a77b60364676ac434aca7a4dfDouglas Gregortemplate<typename Derived> 24841eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTemplateName 24853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas GregorTreeTransform<Derived>::TransformTemplateName(TemplateName Name, 248643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 248743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *FirstQualifierInScope) { 24887c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor SourceLocation Loc = getDerived().getBaseLocation(); 24897c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor 2490d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) { 24911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump NestedNameSpecifier *NNS 2492d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor = getDerived().TransformNestedNameSpecifier(QTN->getQualifier(), 249343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall /*FIXME*/ SourceRange(Loc), 249443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType, 249543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FirstQualifierInScope); 2496d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (!NNS) 2497d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return TemplateName(); 24981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2499d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (TemplateDecl *Template = QTN->getTemplateDecl()) { 25001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump TemplateDecl *TransTemplate 25017c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<TemplateDecl>(getDerived().TransformDecl(Loc, Template)); 2502d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (!TransTemplate) 2503d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return TemplateName(); 25041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2505d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (!getDerived().AlwaysRebuild() && 2506d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor NNS == QTN->getQualifier() && 2507d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TransTemplate == Template) 2508d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return Name; 25091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2510d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return getDerived().RebuildTemplateName(NNS, QTN->hasTemplateKeyword(), 2511d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TransTemplate); 2512d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor } 25131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2514f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // These should be getting filtered out before they make it into the AST. 251543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall llvm_unreachable("overloaded template name survived to here"); 2516d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor } 25171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2518d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) { 251943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *NNS = DTN->getQualifier(); 252043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (NNS) { 252143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NNS = getDerived().TransformNestedNameSpecifier(NNS, 252243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall /*FIXME:*/SourceRange(Loc), 252343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType, 252443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FirstQualifierInScope); 252543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (!NNS) return TemplateName(); 252643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 252743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // These apply to the scope specifier, not the template. 252843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType = QualType(); 252943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FirstQualifierInScope = 0; 253043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall } 25311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2532d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (!getDerived().AlwaysRebuild() && 2533dd62b15665a4144c45c1f7c53665414ad5f7f4f2Douglas Gregor NNS == DTN->getQualifier() && 2534dd62b15665a4144c45c1f7c53665414ad5f7f4f2Douglas Gregor ObjectType.isNull()) 2535d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return Name; 25361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 25371efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor if (DTN->isIdentifier()) { 25381efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor // FIXME: Bad range 25391efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor SourceRange QualifierRange(getDerived().getBaseLocation()); 25401efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor return getDerived().RebuildTemplateName(NNS, QualifierRange, 25411efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor *DTN->getIdentifier(), 254243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType, 254343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FirstQualifierInScope); 25441efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor } 2545c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2546c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getDerived().RebuildTemplateName(NNS, DTN->getOperator(), 2547ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor ObjectType); 2548d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor } 25491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2550d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (TemplateDecl *Template = Name.getAsTemplateDecl()) { 25511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump TemplateDecl *TransTemplate 25527c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<TemplateDecl>(getDerived().TransformDecl(Loc, Template)); 2553d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (!TransTemplate) 2554d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return TemplateName(); 25551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2556d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor if (!getDerived().AlwaysRebuild() && 2557d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TransTemplate == Template) 2558d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return Name; 25591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2560d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor return TemplateName(TransTemplate); 2561d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor } 25621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2563f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // These should be getting filtered out before they reach the AST. 256443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall llvm_unreachable("overloaded function decl survived to here"); 2565f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return TemplateName(); 2566d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor} 2567d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor 2568d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregortemplate<typename Derived> 2569833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallvoid TreeTransform<Derived>::InventTemplateArgumentLoc( 2570833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgument &Arg, 2571833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc &Output) { 2572833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation Loc = getDerived().getBaseLocation(); 2573670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor switch (Arg.getKind()) { 2574670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor case TemplateArgument::Null: 25759f61aa9e280adea9fbf3365f0e4f6ed568c9885aJeffrey Yasskin llvm_unreachable("null template argument in TreeTransform"); 2576833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall break; 2577833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2578833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall case TemplateArgument::Type: 2579833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall Output = TemplateArgumentLoc(Arg, 2580a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc)); 2581c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2582833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall break; 2583833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2584788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor case TemplateArgument::Template: 2585788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor Output = TemplateArgumentLoc(Arg, SourceRange(), Loc); 2586788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor break; 2587a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor 2588a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor case TemplateArgument::TemplateExpansion: 2589a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor Output = TemplateArgumentLoc(Arg, SourceRange(), Loc, Loc); 2590a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor break; 2591a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor 2592833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall case TemplateArgument::Expression: 2593833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall Output = TemplateArgumentLoc(Arg, Arg.getAsExpr()); 2594833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall break; 2595833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2596833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall case TemplateArgument::Declaration: 2597670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor case TemplateArgument::Integral: 2598833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall case TemplateArgument::Pack: 2599828bff2079b6a91ecd7ed5b842c59527d7682789John McCall Output = TemplateArgumentLoc(Arg, TemplateArgumentLocInfo()); 2600833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall break; 2601833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 2602833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall} 2603833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2604833ca991c1bfc967f0995974ca86f66ba1f666b5John McCalltemplate<typename Derived> 2605833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallbool TreeTransform<Derived>::TransformTemplateArgument( 2606833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgumentLoc &Input, 2607833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateArgumentLoc &Output) { 2608833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall const TemplateArgument &Arg = Input.getArgument(); 2609833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall switch (Arg.getKind()) { 2610833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall case TemplateArgument::Null: 2611833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall case TemplateArgument::Integral: 2612833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall Output = Input; 2613833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return false; 26141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2615670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor case TemplateArgument::Type: { 2616a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *DI = Input.getTypeSourceInfo(); 2617833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall if (DI == NULL) 2618a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall DI = InventTypeSourceInfo(Input.getArgument().getAsType()); 2619833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2620833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall DI = getDerived().TransformType(DI); 2621833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall if (!DI) return true; 2622833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2623833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI); 2624833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return false; 2625670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor } 26261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2627670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor case TemplateArgument::Declaration: { 2628833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // FIXME: we should never have to transform one of these. 2629972e6ce33c7e307f4b0da12bd6079bbd6ef76948Douglas Gregor DeclarationName Name; 2630972e6ce33c7e307f4b0da12bd6079bbd6ef76948Douglas Gregor if (NamedDecl *ND = dyn_cast<NamedDecl>(Arg.getAsDecl())) 2631972e6ce33c7e307f4b0da12bd6079bbd6ef76948Douglas Gregor Name = ND->getDeclName(); 2632788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor TemporaryBase Rebase(*this, Input.getLocation(), Name); 26337c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor Decl *D = getDerived().TransformDecl(Input.getLocation(), Arg.getAsDecl()); 2634833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall if (!D) return true; 2635833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2636828bff2079b6a91ecd7ed5b842c59527d7682789John McCall Expr *SourceExpr = Input.getSourceDeclExpression(); 2637828bff2079b6a91ecd7ed5b842c59527d7682789John McCall if (SourceExpr) { 2638828bff2079b6a91ecd7ed5b842c59527d7682789John McCall EnterExpressionEvaluationContext Unevaluated(getSema(), 2639f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema::Unevaluated); 264060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult E = getDerived().TransformExpr(SourceExpr); 26419ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SourceExpr = (E.isInvalid() ? 0 : E.take()); 2642828bff2079b6a91ecd7ed5b842c59527d7682789John McCall } 2643828bff2079b6a91ecd7ed5b842c59527d7682789John McCall 2644828bff2079b6a91ecd7ed5b842c59527d7682789John McCall Output = TemplateArgumentLoc(TemplateArgument(D), SourceExpr); 2645833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return false; 2646670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor } 26471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2648788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor case TemplateArgument::Template: { 2649c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt TemporaryBase Rebase(*this, Input.getLocation(), DeclarationName()); 2650788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor TemplateName Template 2651788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor = getDerived().TransformTemplateName(Arg.getAsTemplate()); 2652788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor if (Template.isNull()) 2653788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor return true; 2654c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 2655788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor Output = TemplateArgumentLoc(TemplateArgument(Template), 2656788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor Input.getTemplateQualifierRange(), 2657788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor Input.getTemplateNameLoc()); 2658788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor return false; 2659788cd06cf8e868a67158aafec5de3a1f408d14f3Douglas Gregor } 2660a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor 2661a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor case TemplateArgument::TemplateExpansion: 2662a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor llvm_unreachable("Caller should expand pack expansions"); 2663a7fc901a2e39bfe55bfcff5934b2d9fdf9656491Douglas Gregor 2664670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor case TemplateArgument::Expression: { 2665670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // Template argument expressions are not potentially evaluated. 26661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump EnterExpressionEvaluationContext Unevaluated(getSema(), 2667f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema::Unevaluated); 26681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2669833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall Expr *InputExpr = Input.getSourceExpression(); 2670833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall if (!InputExpr) InputExpr = Input.getArgument().getAsExpr(); 2671833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 267260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult E 2673833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall = getDerived().TransformExpr(InputExpr); 2674833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall if (E.isInvalid()) return true; 26759ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Output = TemplateArgumentLoc(TemplateArgument(E.take()), E.take()); 2676833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return false; 2677670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor } 26781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2679670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor case TemplateArgument::Pack: { 2680670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor llvm::SmallVector<TemplateArgument, 4> TransformedArgs; 2681670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor TransformedArgs.reserve(Arg.pack_size()); 26821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump for (TemplateArgument::pack_iterator A = Arg.pack_begin(), 2683670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor AEnd = Arg.pack_end(); 2684670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor A != AEnd; ++A) { 26851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2686833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // FIXME: preserve source information here when we start 2687833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // caring about parameter packs. 2688833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2689828bff2079b6a91ecd7ed5b842c59527d7682789John McCall TemplateArgumentLoc InputArg; 2690828bff2079b6a91ecd7ed5b842c59527d7682789John McCall TemplateArgumentLoc OutputArg; 2691828bff2079b6a91ecd7ed5b842c59527d7682789John McCall getDerived().InventTemplateArgumentLoc(*A, InputArg); 2692828bff2079b6a91ecd7ed5b842c59527d7682789John McCall if (getDerived().TransformTemplateArgument(InputArg, OutputArg)) 2693833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return true; 2694833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 2695828bff2079b6a91ecd7ed5b842c59527d7682789John McCall TransformedArgs.push_back(OutputArg.getArgument()); 2696670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor } 2697910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor 2698910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor TemplateArgument *TransformedArgsPtr 2699910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor = new (getSema().Context) TemplateArgument[TransformedArgs.size()]; 2700910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor std::copy(TransformedArgs.begin(), TransformedArgs.end(), 2701910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor TransformedArgsPtr); 2702910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor Output = TemplateArgumentLoc(TemplateArgument(TransformedArgsPtr, 2703910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor TransformedArgs.size()), 2704910f8008fea79120489a53593fe971b0b8a4a740Douglas Gregor Input.getLocInfo()); 2705833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return false; 2706670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor } 2707670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor } 27081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2709670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // Work around bogus GCC warning 2710833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return true; 2711670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor} 2712670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor 27137ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor/// \brief Iterator adaptor that invents template argument location information 27147ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor/// for each of the template arguments in its underlying iterator. 27157ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregortemplate<typename Derived, typename InputIterator> 27167ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregorclass TemplateArgumentLocInventIterator { 27177ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TreeTransform<Derived> &Self; 27187ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor InputIterator Iter; 27197ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27207ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregorpublic: 27217ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLoc value_type; 27227ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLoc reference; 27237ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef typename std::iterator_traits<InputIterator>::difference_type 27247ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor difference_type; 27257ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef std::input_iterator_tag iterator_category; 27267ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27277ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor class pointer { 27287ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLoc Arg; 2729fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor 27307ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor public: 27317ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { } 27327ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27337ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor const TemplateArgumentLoc *operator->() const { return &Arg; } 27347ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor }; 27357ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27367ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocInventIterator() { } 27377ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27387ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor explicit TemplateArgumentLocInventIterator(TreeTransform<Derived> &Self, 27397ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor InputIterator Iter) 27407ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor : Self(Self), Iter(Iter) { } 27417ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27427ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocInventIterator &operator++() { 27437ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ++Iter; 27447ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return *this; 2745fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor } 2746fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor 27477ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocInventIterator operator++(int) { 27487ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocInventIterator Old(*this); 27497ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ++(*this); 27507ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return Old; 27517ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 27527ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27537ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor reference operator*() const { 27547ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLoc Result; 27557ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor Self.InventTemplateArgumentLoc(*Iter, Result); 27567ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return Result; 27577ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 27587ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27597ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor pointer operator->() const { return pointer(**this); } 27607ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27617ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor friend bool operator==(const TemplateArgumentLocInventIterator &X, 27627ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor const TemplateArgumentLocInventIterator &Y) { 27637ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return X.Iter == Y.Iter; 27647ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 2765fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor 27667ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor friend bool operator!=(const TemplateArgumentLocInventIterator &X, 27677ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor const TemplateArgumentLocInventIterator &Y) { 27687ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return X.Iter != Y.Iter; 27697ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 27707ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor}; 27717ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 27727f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregortemplate<typename Derived> 27737ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregortemplate<typename InputIterator> 27747ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregorbool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First, 27757ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor InputIterator Last, 27767f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor TemplateArgumentListInfo &Outputs) { 27777ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor for (; First != Last; ++First) { 27787f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor TemplateArgumentLoc Out; 27797ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLoc In = *First; 27808491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 27818491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (In.getArgument().getKind() == TemplateArgument::Pack) { 27828491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // Unpack argument packs, which we translate them into separate 27838491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // arguments. 27847ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor // FIXME: We could do much better if we could guarantee that the 27857ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor // TemplateArgumentLocInfo for the pack expansion would be usable for 27867ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor // all of the template arguments in the argument pack. 27877ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLocInventIterator<Derived, 27887ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgument::pack_iterator> 27897ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor PackLocIterator; 27907ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor if (TransformTemplateArguments(PackLocIterator(*this, 27917ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor In.getArgument().pack_begin()), 27927ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor PackLocIterator(*this, 27937ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor In.getArgument().pack_end()), 27947ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor Outputs)) 27957ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return true; 27968491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 27978491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor continue; 27988491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 27998491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28008491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (In.getArgument().isPackExpansion()) { 28018491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // We have a pack expansion, for which we will be substituting into 28028491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // the pattern. 28038491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor SourceLocation Ellipsis; 28048491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor TemplateArgumentLoc Pattern 28058491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor = In.getPackExpansionPattern(Ellipsis, getSema().Context); 28068491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28078491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded; 28088491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); 28098491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor assert(!Unexpanded.empty() && "Pack expansion without parameter packs?"); 28108491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28118491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // Determine whether the set of unexpanded parameter packs can and should 28128491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // be expanded. 28138491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor bool Expand = true; 2814d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor bool RetainExpansion = false; 28158491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor unsigned NumExpansions = 0; 28168491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (getDerived().TryExpandParameterPacks(Ellipsis, 28178491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Pattern.getSourceRange(), 28188491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Unexpanded.data(), 28198491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Unexpanded.size(), 2820d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor Expand, 2821d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor RetainExpansion, 2822d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NumExpansions)) 28238491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return true; 28248491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28258491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (!Expand) { 28268491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // The transform has determined that we should perform a simple 28278491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // transformation on the pack expansion, producing another pack 28288491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // expansion. 28298491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor TemplateArgumentLoc OutPattern; 28308491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); 28318491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (getDerived().TransformTemplateArgument(Pattern, OutPattern)) 28328491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return true; 28338491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28348491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis); 28358491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (Out.getArgument().isNull()) 28368491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return true; 28378491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28388491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Outputs.addArgument(Out); 28398491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor continue; 28408491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 28418491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28428491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // The transform has determined that we should perform an elementwise 28438491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // expansion of the pattern. Do so. 28448491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor for (unsigned I = 0; I != NumExpansions; ++I) { 28458491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); 28468491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28478491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (getDerived().TransformTemplateArgument(Pattern, Out)) 28488491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor return true; 28498491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28508491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Outputs.addArgument(Out); 28518491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 28528491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 2853d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor // FIXME: Variadic templates retain expansion! 2854d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 28558491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor continue; 28568491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor } 28578491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor 28588491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor // The simple case: 28598491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor if (getDerived().TransformTemplateArgument(In, Out)) 28607f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor return true; 28617f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor 28627f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor Outputs.addArgument(Out); 28637f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor } 28647f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor 28657f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor return false; 28667f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor 28677f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor} 28687f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor 2869577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor//===----------------------------------------------------------------------===// 2870577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor// Type transformation 2871577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor//===----------------------------------------------------------------------===// 2872577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 2873577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 287443fed0de4f5bc189e45562491f83d5193eb8dac0John McCallQualType TreeTransform<Derived>::TransformType(QualType T) { 2875577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (getDerived().AlreadyTransformed(T)) 2876577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return T; 28771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2878a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // Temporary workaround. All of these transformations should 2879a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // eventually turn into transformations on TypeLocs. 2880a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *DI = getSema().Context.CreateTypeSourceInfo(T); 28814802a311f402836f1f226a3d7a87e6a3088f9704John McCall DI->getTypeLoc().initialize(getDerived().getBaseLocation()); 2882c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 288343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeSourceInfo *NewDI = getDerived().TransformType(DI); 28841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2885a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (!NewDI) 2886a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 28871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2888a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return NewDI->getType(); 2889577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 28901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2891577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 289243fed0de4f5bc189e45562491f83d5193eb8dac0John McCallTypeSourceInfo *TreeTransform<Derived>::TransformType(TypeSourceInfo *DI) { 2893a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlreadyTransformed(DI->getType())) 2894a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return DI; 28951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2896a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLocBuilder TLB; 28971bb8a45f7386a23871598d05141a07af03067925Argyrios Kyrtzidis 2898a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLoc TL = DI->getTypeLoc(); 2899a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TLB.reserve(TL.getFullDataSize()); 29001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 290143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType Result = getDerived().TransformType(TLB, TL); 2902a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 2903a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return 0; 29041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2905a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall return TLB.getTypeSourceInfo(SemaRef.Context, Result); 2906577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 29071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 29081eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 2909a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 291043fed0de4f5bc189e45562491f83d5193eb8dac0John McCallTreeTransform<Derived>::TransformType(TypeLocBuilder &TLB, TypeLoc T) { 2911a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall switch (T.getTypeLocClass()) { 2912a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#define ABSTRACT_TYPELOC(CLASS, PARENT) 2913a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#define TYPELOC(CLASS, PARENT) \ 2914a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall case TypeLoc::CLASS: \ 291543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return getDerived().Transform##CLASS##Type(TLB, cast<CLASS##TypeLoc>(T)); 2916a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall#include "clang/AST/TypeLocNodes.def" 2917a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 2918577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 29199f61aa9e280adea9fbf3365f0e4f6ed568c9885aJeffrey Yasskin llvm_unreachable("unhandled type loc!"); 2920a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 2921577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 29221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2923a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall/// FIXME: By default, this routine adds type qualifiers only to types 2924a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall/// that can have qualifiers, and silently suppresses those qualifiers 2925a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall/// that are not permitted (e.g., qualifiers on reference or function 2926a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall/// types). This is the right thing for template instantiation, but 2927a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall/// probably not for other clients. 29281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 29291eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 2930a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB, 293143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualifiedTypeLoc T) { 2932a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor Qualifiers Quals = T.getType().getLocalQualifiers(); 2933a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 293443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc()); 2935a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 2936577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 29371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 2938a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // Silently suppress qualifiers if the result type can't be qualified. 2939a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // FIXME: this is the right thing for template instantiation, but 2940a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // probably not for other clients. 2941a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result->isFunctionType() || Result->isReferenceType()) 2942a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 29431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 29442865474261a608c7873b87ba4af110d17907896dJohn McCall if (!Quals.empty()) { 29452865474261a608c7873b87ba4af110d17907896dJohn McCall Result = SemaRef.BuildQualifiedType(Result, T.getBeginLoc(), Quals); 29462865474261a608c7873b87ba4af110d17907896dJohn McCall TLB.push<QualifiedTypeLoc>(Result); 29472865474261a608c7873b87ba4af110d17907896dJohn McCall // No location information to preserve. 29482865474261a608c7873b87ba4af110d17907896dJohn McCall } 2949a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 2950a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 2951a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall} 2952a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 295343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// \brief Transforms a type that was written in a scope specifier, 295443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// given an object type, the results of unqualified lookup, and 295543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// an already-instantiated prefix. 295643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// 295743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// The object type is provided iff the scope specifier qualifies the 295843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// member of a dependent member-access expression. The prefix is 295943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// provided iff the the scope specifier in which this appears has a 296043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// prefix. 296143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// 296243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall/// This is private to TreeTransform. 296343fed0de4f5bc189e45562491f83d5193eb8dac0John McCalltemplate<typename Derived> 296443fed0de4f5bc189e45562491f83d5193eb8dac0John McCallQualType 296543fed0de4f5bc189e45562491f83d5193eb8dac0John McCallTreeTransform<Derived>::TransformTypeInObjectScope(QualType T, 296643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 296743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *UnqualLookup, 296843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Prefix) { 296943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (getDerived().AlreadyTransformed(T)) 297043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return T; 297143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 297243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeSourceInfo *TSI = 297343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall SemaRef.Context.getTrivialTypeSourceInfo(T, getBaseLocation()); 297443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 297543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TSI = getDerived().TransformTypeInObjectScope(TSI, ObjectType, 297643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall UnqualLookup, Prefix); 297743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (!TSI) return QualType(); 297843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return TSI->getType(); 297943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall} 298043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 298143fed0de4f5bc189e45562491f83d5193eb8dac0John McCalltemplate<typename Derived> 298243fed0de4f5bc189e45562491f83d5193eb8dac0John McCallTypeSourceInfo * 298343fed0de4f5bc189e45562491f83d5193eb8dac0John McCallTreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSI, 298443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 298543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *UnqualLookup, 298643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Prefix) { 298743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // TODO: in some cases, we might be some verification to do here. 298843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (ObjectType.isNull()) 298943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return getDerived().TransformType(TSI); 299043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 299143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType T = TSI->getType(); 299243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (getDerived().AlreadyTransformed(T)) 299343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return TSI; 299443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 299543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeLocBuilder TLB; 299643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType Result; 299743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 299843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (isa<TemplateSpecializationType>(T)) { 299943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateSpecializationTypeLoc TL 300043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall = cast<TemplateSpecializationTypeLoc>(TSI->getTypeLoc()); 300143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 300243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateName Template = 300343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall getDerived().TransformTemplateName(TL.getTypePtr()->getTemplateName(), 300443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType, UnqualLookup); 300543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (Template.isNull()) return 0; 300643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 300743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall Result = getDerived() 300843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall .TransformTemplateSpecializationType(TLB, TL, Template); 300943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall } else if (isa<DependentTemplateSpecializationType>(T)) { 301043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentTemplateSpecializationTypeLoc TL 301143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall = cast<DependentTemplateSpecializationTypeLoc>(TSI->getTypeLoc()); 301243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 301343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall Result = getDerived() 301443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall .TransformDependentTemplateSpecializationType(TLB, TL, Prefix); 301543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall } else { 301643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // Nothing special needs to be done for these. 301743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall Result = getDerived().TransformType(TLB, TSI->getTypeLoc()); 301843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall } 301943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 302043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (Result.isNull()) return 0; 302143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return TLB.getTypeSourceInfo(SemaRef.Context, Result); 302243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall} 302343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 3024a2becad14a0eb19cde2f441ced588b975433d2edJohn McCalltemplate <class TyLoc> static inline 3025a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T) { 3026a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TyLoc NewT = TLB.push<TyLoc>(T.getType()); 3027a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewT.setNameLoc(T.getNameLoc()); 3028a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return T.getType(); 3029a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall} 3030a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3031a2becad14a0eb19cde2f441ced588b975433d2edJohn McCalltemplate<typename Derived> 3032a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB, 303343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall BuiltinTypeLoc T) { 3034ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType()); 3035ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor NewT.setBuiltinLoc(T.getBuiltinLoc()); 3036ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor if (T.needsExtraLocalData()) 3037ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs(); 3038ddf889a2ad2888f1dea573987bbe952d9912c1a0Douglas Gregor return T.getType(); 3039577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 3040577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 30411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3042a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB, 304343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ComplexTypeLoc T) { 3044a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // FIXME: recurse? 3045a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return TransformTypeSpecType(TLB, T); 3046a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall} 30471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3048a2becad14a0eb19cde2f441ced588b975433d2edJohn McCalltemplate<typename Derived> 3049a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB, 305043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall PointerTypeLoc TL) { 3051c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt QualType PointeeType 3052c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt = getDerived().TransformType(TLB, TL.getPointeeLoc()); 305392e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (PointeeType.isNull()) 305492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor return QualType(); 305592e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor 305692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor QualType Result = TL.getType(); 3057c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall if (PointeeType->getAs<ObjCObjectType>()) { 305892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // A dependent pointer type 'T *' has is being transformed such 305992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // that an Objective-C class type is being replaced for 'T'. The 306092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // resulting pointer type is an ObjCObjectPointerType, not a 306192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // PointerType. 3062c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall Result = SemaRef.Context.getObjCObjectPointerType(PointeeType); 3063c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3064c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result); 3065c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall NewT.setStarLoc(TL.getStarLoc()); 306692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor return Result; 306792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor } 306843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 306992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (getDerived().AlwaysRebuild() || 307092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor PointeeType != TL.getPointeeLoc().getType()) { 307192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc()); 307292e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (Result.isNull()) 307392e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor return QualType(); 307492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor } 3075c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 307692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result); 307792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor NewT.setSigilLoc(TL.getSigilLoc()); 3078c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return Result; 3079577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 3080577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 30811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 30821eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 3083a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB, 308443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall BlockPointerTypeLoc TL) { 3085db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor QualType PointeeType 3086c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt = getDerived().TransformType(TLB, TL.getPointeeLoc()); 3087c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt if (PointeeType.isNull()) 3088c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return QualType(); 3089c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3090c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt QualType Result = TL.getType(); 3091c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt if (getDerived().AlwaysRebuild() || 3092c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt PointeeType != TL.getPointeeLoc().getType()) { 3093c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt Result = getDerived().RebuildBlockPointerType(PointeeType, 3094db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor TL.getSigilLoc()); 3095db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor if (Result.isNull()) 3096db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor return QualType(); 3097db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor } 3098db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor 309939968adc66ab02275d2f561e372a20ae454bd4e7Douglas Gregor BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result); 3100db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor NewT.setSigilLoc(TL.getSigilLoc()); 3101db93c4a8f839b2f46bfea66531aa014242f4da2cDouglas Gregor return Result; 3102a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall} 31031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 310485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall/// Transforms a reference type. Note that somewhat paradoxically we 310585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall/// don't care whether the type itself is an l-value type or an r-value 310685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall/// type; we only care if the type was *written* as an l-value type 310785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall/// or an r-value type. 310885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCalltemplate<typename Derived> 310985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCallQualType 311085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCallTreeTransform<Derived>::TransformReferenceType(TypeLocBuilder &TLB, 311143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ReferenceTypeLoc TL) { 311285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall const ReferenceType *T = TL.getTypePtr(); 311385737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 311485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall // Note that this works with the pointee-as-written. 311585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc()); 311685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall if (PointeeType.isNull()) 311785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return QualType(); 311885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 311985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType Result = TL.getType(); 312085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall if (getDerived().AlwaysRebuild() || 312185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall PointeeType != T->getPointeeTypeAsWritten()) { 312285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall Result = getDerived().RebuildReferenceType(PointeeType, 312385737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall T->isSpelledAsLValue(), 312485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall TL.getSigilLoc()); 312585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall if (Result.isNull()) 312685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return QualType(); 312785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall } 312885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 312985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall // r-value references can be rebuilt as l-value references. 313085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall ReferenceTypeLoc NewTL; 313185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall if (isa<LValueReferenceType>(Result)) 313285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall NewTL = TLB.push<LValueReferenceTypeLoc>(Result); 313385737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall else 313485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall NewTL = TLB.push<RValueReferenceTypeLoc>(Result); 313585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall NewTL.setSigilLoc(TL.getSigilLoc()); 313685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 313785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall return Result; 313885737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall} 313985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall 3140a2becad14a0eb19cde2f441ced588b975433d2edJohn McCalltemplate<typename Derived> 3141a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 3142a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformLValueReferenceType(TypeLocBuilder &TLB, 314343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall LValueReferenceTypeLoc TL) { 314443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return TransformReferenceType(TLB, TL); 3145a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall} 31461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3147a2becad14a0eb19cde2f441ced588b975433d2edJohn McCalltemplate<typename Derived> 3148a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 3149a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB, 315043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall RValueReferenceTypeLoc TL) { 315143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return TransformReferenceType(TLB, TL); 3152577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 31531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3154577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 31551eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 3156a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB, 315743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall MemberPointerTypeLoc TL) { 3158a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall MemberPointerType *T = TL.getTypePtr(); 3159a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3160a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc()); 3161577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (PointeeType.isNull()) 3162577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 31631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3164a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // TODO: preserve source information for this. 3165a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType ClassType 3166a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall = getDerived().TransformType(QualType(T->getClass(), 0)); 3167577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ClassType.isNull()) 3168577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 31691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3170a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3171a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3172a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall PointeeType != T->getPointeeType() || 3173a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ClassType != QualType(T->getClass(), 0)) { 317485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall Result = getDerived().RebuildMemberPointerType(PointeeType, ClassType, 317585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall TL.getStarLoc()); 3176a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3177a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3178a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3179577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 3180a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result); 3181a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setSigilLoc(TL.getSigilLoc()); 3182a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3183a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3184577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 3185577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 31861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 31871eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 3188a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB, 318943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ConstantArrayTypeLoc TL) { 3190a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ConstantArrayType *T = TL.getTypePtr(); 3191a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); 3192577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3193577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 31941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3195a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3196a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3197a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ElementType != T->getElementType()) { 3198a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildConstantArrayType(ElementType, 3199a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getSizeModifier(), 3200a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getSize(), 320185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall T->getIndexTypeCVRQualifiers(), 320285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall TL.getBracketsRange()); 3203a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3204a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3205a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3206c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3207a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ConstantArrayTypeLoc NewTL = TLB.push<ConstantArrayTypeLoc>(Result); 3208a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setLBracketLoc(TL.getLBracketLoc()); 3209a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setRBracketLoc(TL.getRBracketLoc()); 32101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3211a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Expr *Size = TL.getSizeExpr(); 3212a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Size) { 3213f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 3214a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Size = getDerived().TransformExpr(Size).template takeAs<Expr>(); 3215a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3216a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setSizeExpr(Size); 3217a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3218a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3219577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 32201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3221577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3222577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::TransformIncompleteArrayType( 3223a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLocBuilder &TLB, 322443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall IncompleteArrayTypeLoc TL) { 3225a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall IncompleteArrayType *T = TL.getTypePtr(); 3226a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); 3227577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3228577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 32291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3230a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3231a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3232a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ElementType != T->getElementType()) { 3233a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildIncompleteArrayType(ElementType, 3234a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getSizeModifier(), 323585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall T->getIndexTypeCVRQualifiers(), 323685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall TL.getBracketsRange()); 3237a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3238a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3239a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3240c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3241a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result); 3242a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setLBracketLoc(TL.getLBracketLoc()); 3243a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setRBracketLoc(TL.getRBracketLoc()); 3244a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setSizeExpr(0); 3245577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 3246a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3247577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 32481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3249577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3250a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 3251a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB, 325243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall VariableArrayTypeLoc TL) { 3253a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall VariableArrayType *T = TL.getTypePtr(); 3254a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); 3255577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3256577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 32571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3258670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // Array bounds are not potentially evaluated contexts 3259f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 3260670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor 326160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SizeResult 3262a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall = getDerived().TransformExpr(T->getSizeExpr()); 3263a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (SizeResult.isInvalid()) 3264577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 32651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 32669ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Size = SizeResult.take(); 3267a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3268a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3269a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3270a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ElementType != T->getElementType() || 3271a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Size != T->getSizeExpr()) { 3272a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildVariableArrayType(ElementType, 3273a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getSizeModifier(), 32749ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Size, 3275a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getIndexTypeCVRQualifiers(), 327685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall TL.getBracketsRange()); 3277a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3278a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3279577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 3280c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3281a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall VariableArrayTypeLoc NewTL = TLB.push<VariableArrayTypeLoc>(Result); 3282a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setLBracketLoc(TL.getLBracketLoc()); 3283a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setRBracketLoc(TL.getRBracketLoc()); 3284a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setSizeExpr(Size); 32851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3286a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3287577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 32881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 32891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3290a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 3291a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB, 329243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentSizedArrayTypeLoc TL) { 3293a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall DependentSizedArrayType *T = TL.getTypePtr(); 3294a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc()); 3295577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3296577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 32971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3298670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // Array bounds are not potentially evaluated contexts 3299f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 33001eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 330160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SizeResult 3302a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall = getDerived().TransformExpr(T->getSizeExpr()); 3303a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (SizeResult.isInvalid()) 3304577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 33051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3306a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Expr *Size = static_cast<Expr*>(SizeResult.get()); 3307a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3308a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3309a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3310a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ElementType != T->getElementType() || 3311a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Size != T->getSizeExpr()) { 3312a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildDependentSizedArrayType(ElementType, 3313a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getSizeModifier(), 33149ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Size, 3315a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getIndexTypeCVRQualifiers(), 331685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall TL.getBracketsRange()); 3317a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3318a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3319577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 3320a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall else SizeResult.take(); 33211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3322a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // We might have any sort of array type now, but fortunately they 3323a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // all have the same location layout. 3324a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result); 3325a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setLBracketLoc(TL.getLBracketLoc()); 3326a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setRBracketLoc(TL.getRBracketLoc()); 3327a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setSizeExpr(Size); 3328a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3329a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3330577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 33311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 33321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3333577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::TransformDependentSizedExtVectorType( 3334a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLocBuilder &TLB, 333543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentSizedExtVectorTypeLoc TL) { 3336a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall DependentSizedExtVectorType *T = TL.getTypePtr(); 3337a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3338a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // FIXME: ext vector locs should be nested 3339577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType ElementType = getDerived().TransformType(T->getElementType()); 3340577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3341577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 33421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3343670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // Vector sizes are not potentially evaluated contexts 3344f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 3345670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor 334660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Size = getDerived().TransformExpr(T->getSizeExpr()); 3347577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (Size.isInvalid()) 3348577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 33491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3350a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3351a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3352eee91c3efbfc6a1509b42f39beb5533a9636fd70John McCall ElementType != T->getElementType() || 3353eee91c3efbfc6a1509b42f39beb5533a9636fd70John McCall Size.get() != T->getSizeExpr()) { 3354a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildDependentSizedExtVectorType(ElementType, 33559ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Size.take(), 3356577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor T->getAttributeLoc()); 3357a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3358a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3359a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3360a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3361a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // Result might be dependent or not. 3362a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (isa<DependentSizedExtVectorType>(Result)) { 3363a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall DependentSizedExtVectorTypeLoc NewTL 3364a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall = TLB.push<DependentSizedExtVectorTypeLoc>(Result); 3365a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 3366a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } else { 3367a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result); 3368a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 3369a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3370a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3371a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3372577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 33731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 33741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3375a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB, 337643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall VectorTypeLoc TL) { 3377a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall VectorType *T = TL.getTypePtr(); 3378577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType ElementType = getDerived().TransformType(T->getElementType()); 3379577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3380577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 3381577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 3382a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3383a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3384a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ElementType != T->getElementType()) { 338582287d19ded35248c4ce6a425ce74116a13ce44eJohn Thompson Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(), 3386e86d78cf4754a6aef2cf9a33d847aa15338e276fBob Wilson T->getVectorKind()); 3387a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3388a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3389a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3390c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3391a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result); 3392a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 33931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3394a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3395577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 33961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 33971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3398a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB, 339943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ExtVectorTypeLoc TL) { 3400a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall VectorType *T = TL.getTypePtr(); 3401577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType ElementType = getDerived().TransformType(T->getElementType()); 3402577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (ElementType.isNull()) 3403577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 34041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3405a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3406a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3407a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ElementType != T->getElementType()) { 3408a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildExtVectorType(ElementType, 3409a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->getNumElements(), 3410a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall /*FIXME*/ SourceLocation()); 3411a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3412a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3413a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3414c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 3415a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result); 3416a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 34171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3418a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3419577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 3420577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 34211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 342221ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCallParmVarDecl * 342321ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCallTreeTransform<Derived>::TransformFunctionTypeParam(ParmVarDecl *OldParm) { 342421ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo(); 342521ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall TypeSourceInfo *NewDI = getDerived().TransformType(OldDI); 342621ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall if (!NewDI) 342721ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall return 0; 342821ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall 342921ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall if (NewDI == OldDI) 343021ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall return OldParm; 343121ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall else 343221ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall return ParmVarDecl::Create(SemaRef.Context, 343321ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall OldParm->getDeclContext(), 343421ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall OldParm->getLocation(), 343521ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall OldParm->getIdentifier(), 343621ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall NewDI->getType(), 343721ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall NewDI, 343821ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall OldParm->getStorageClass(), 343916573fa9705b546b7597c273b25b85d6321e2b33Douglas Gregor OldParm->getStorageClassAsWritten(), 344021ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall /* DefArg */ NULL); 344121ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall} 344221ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall 344321ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCalltemplate<typename Derived> 344421ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCallbool TreeTransform<Derived>:: 3445a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TransformFunctionTypeParams(SourceLocation Loc, 3446a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParmVarDecl **Params, unsigned NumParams, 3447a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor const QualType *ParamTypes, 3448a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor llvm::SmallVectorImpl<QualType> &OutParamTypes, 3449a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor llvm::SmallVectorImpl<ParmVarDecl*> *PVars) { 3450a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor for (unsigned i = 0; i != NumParams; ++i) { 3451a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (ParmVarDecl *OldParm = Params[i]) { 3452603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (OldParm->isParameterPack()) { 3453603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // We have a function parameter pack that may need to be expanded. 3454603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded; 3455603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3456603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // Find the parameter packs that could be expanded. 3457c8a16fbb78c0e0ae2d2ebdb00bd6761d9d6714d2Douglas Gregor TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc(); 3458c8a16fbb78c0e0ae2d2ebdb00bd6761d9d6714d2Douglas Gregor PackExpansionTypeLoc ExpansionTL = cast<PackExpansionTypeLoc>(TL); 3459c8a16fbb78c0e0ae2d2ebdb00bd6761d9d6714d2Douglas Gregor TypeLoc Pattern = ExpansionTL.getPatternLoc(); 3460c8a16fbb78c0e0ae2d2ebdb00bd6761d9d6714d2Douglas Gregor SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded); 3461603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3462603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // Determine whether we should expand the parameter packs. 3463603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor bool ShouldExpand = false; 3464d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor bool RetainExpansion = false; 3465603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor unsigned NumExpansions = 0; 3466c8a16fbb78c0e0ae2d2ebdb00bd6761d9d6714d2Douglas Gregor if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(), 3467c8a16fbb78c0e0ae2d2ebdb00bd6761d9d6714d2Douglas Gregor Pattern.getSourceRange(), 3468603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Unexpanded.data(), 3469603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Unexpanded.size(), 3470d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ShouldExpand, 3471d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor RetainExpansion, 3472d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NumExpansions)) { 3473603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor return true; 3474603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3475603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3476603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (ShouldExpand) { 3477603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // Expand the function parameter pack into multiple, separate 3478603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // parameters. 347912c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor getDerived().ExpandingFunctionParameterPack(OldParm); 3480603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor for (unsigned I = 0; I != NumExpansions; ++I) { 3481603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); 3482603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor ParmVarDecl *NewParm 3483603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor = getDerived().TransformFunctionTypeParam(OldParm); 3484603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (!NewParm) 3485603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor return true; 3486603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3487a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor OutParamTypes.push_back(NewParm->getType()); 3488a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (PVars) 3489a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor PVars->push_back(NewParm); 3490603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3491d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 3492d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor // If we're supposed to retain a pack expansion, do so by temporarily 3493d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor // forgetting the partially-substituted parameter pack. 3494d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor if (RetainExpansion) { 3495d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ForgetPartiallySubstitutedPackRAII Forget(getDerived()); 3496d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ParmVarDecl *NewParm 3497d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor = getDerived().TransformFunctionTypeParam(OldParm); 3498d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor if (!NewParm) 3499d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor return true; 3500d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 3501d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor OutParamTypes.push_back(NewParm->getType()); 3502d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor if (PVars) 3503d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor PVars->push_back(NewParm); 3504d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor } 3505d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 3506603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // We're done with the pack expansion. 3507603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor continue; 3508603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3509603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3510603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // We'll substitute the parameter now without expanding the pack 3511603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // expansion. 3512603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3513603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3514603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); 3515603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor ParmVarDecl *NewParm = getDerived().TransformFunctionTypeParam(OldParm); 351621ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall if (!NewParm) 351721ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall return true; 3518603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3519a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor OutParamTypes.push_back(NewParm->getType()); 3520a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (PVars) 3521a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor PVars->push_back(NewParm); 3522603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor continue; 3523603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3524a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3525a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // Deal with the possibility that we don't have a parameter 3526a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall // declaration for this parameter. 3527a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor QualType OldType = ParamTypes[i]; 3528603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor bool IsPackExpansion = false; 3529603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (const PackExpansionType *Expansion 3530603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor = dyn_cast<PackExpansionType>(OldType)) { 3531603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // We have a function parameter pack that may need to be expanded. 3532603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor QualType Pattern = Expansion->getPattern(); 3533603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor llvm::SmallVector<UnexpandedParameterPack, 2> Unexpanded; 3534603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded); 3535603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3536603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // Determine whether we should expand the parameter packs. 3537603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor bool ShouldExpand = false; 3538d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor bool RetainExpansion = false; 3539603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor unsigned NumExpansions = 0; 3540a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (getDerived().TryExpandParameterPacks(Loc, SourceRange(), 3541603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Unexpanded.data(), 3542603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Unexpanded.size(), 3543d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ShouldExpand, 3544d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor RetainExpansion, 3545d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NumExpansions)) { 354621ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall return true; 3547603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3548603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3549603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (ShouldExpand) { 3550603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // Expand the function parameter pack into multiple, separate 3551603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // parameters. 3552603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor for (unsigned I = 0; I != NumExpansions; ++I) { 3553603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I); 3554603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor QualType NewType = getDerived().TransformType(Pattern); 3555603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (NewType.isNull()) 3556603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor return true; 3557603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3558a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor OutParamTypes.push_back(NewType); 3559a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (PVars) 3560a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor PVars->push_back(0); 3561603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3562603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3563603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // We're done with the pack expansion. 3564603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor continue; 3565603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 3566603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3567d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor // FIXME: Variadic templates retain pack expansion! 3568d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor 3569603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // We'll substitute the parameter now without expanding the pack 3570603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor // expansion. 3571603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor OldType = Expansion->getPattern(); 3572603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor IsPackExpansion = true; 3573a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3574603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3575603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1); 3576603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor QualType NewType = getDerived().TransformType(OldType); 3577603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (NewType.isNull()) 3578603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor return true; 35791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3580603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor if (IsPackExpansion) 3581603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor NewType = getSema().Context.getPackExpansionType(NewType); 3582603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor 3583a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor OutParamTypes.push_back(NewType); 3584a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (PVars) 3585a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor PVars->push_back(0); 3586577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 35871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 358821ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall return false; 3589603cfb4da2f7ba08a1c3452c2fbf70585b8e7621Douglas Gregor } 359021ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall 359121ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCalltemplate<typename Derived> 359221ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCallQualType 359321ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCallTreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB, 359443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FunctionProtoTypeLoc TL) { 35957e010a04fef171049291d8cb3047f118566da090Douglas Gregor // Transform the parameters and return type. 35967e010a04fef171049291d8cb3047f118566da090Douglas Gregor // 35977e010a04fef171049291d8cb3047f118566da090Douglas Gregor // We instantiate in source order, with the return type first followed by 35987e010a04fef171049291d8cb3047f118566da090Douglas Gregor // the parameters, because users tend to expect this (even if they shouldn't 35997e010a04fef171049291d8cb3047f118566da090Douglas Gregor // rely on it!). 36007e010a04fef171049291d8cb3047f118566da090Douglas Gregor // 3601dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor // When the function has a trailing return type, we instantiate the 3602dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor // parameters before the return type, since the return type can then refer 3603dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor // to the parameters themselves (via decltype, sizeof, etc.). 3604dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor // 360521ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall llvm::SmallVector<QualType, 4> ParamTypes; 360621ef0fa27b0783ec0bc6aa5b524feb2ec840f952John McCall llvm::SmallVector<ParmVarDecl*, 4> ParamDecls; 3607895162da2d52f4243f61081d7436de66af4503fcDouglas Gregor FunctionProtoType *T = TL.getTypePtr(); 36087e010a04fef171049291d8cb3047f118566da090Douglas Gregor 3609dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor QualType ResultType; 3610dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 3611dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor if (TL.getTrailingReturn()) { 3612a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (getDerived().TransformFunctionTypeParams(TL.getBeginLoc(), 3613a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TL.getParmArray(), 3614a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TL.getNumArgs(), 3615a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TL.getTypePtr()->arg_type_begin(), 3616a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParamTypes, &ParamDecls)) 3617dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor return QualType(); 3618dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 3619dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor ResultType = getDerived().TransformType(TLB, TL.getResultLoc()); 3620dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor if (ResultType.isNull()) 3621dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor return QualType(); 3622dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor } 3623dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor else { 3624dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor ResultType = getDerived().TransformType(TLB, TL.getResultLoc()); 3625dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor if (ResultType.isNull()) 3626dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor return QualType(); 3627dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 3628a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor if (getDerived().TransformFunctionTypeParams(TL.getBeginLoc(), 3629a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TL.getParmArray(), 3630a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TL.getNumArgs(), 3631a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor TL.getTypePtr()->arg_type_begin(), 3632a009b59fc2c550a229b9146aabda8e33fe3a7771Douglas Gregor ParamTypes, &ParamDecls)) 3633dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor return QualType(); 3634dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor } 3635dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor 3636a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3637a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3638a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ResultType != T->getResultType() || 3639bd5f9f708aa31920d3bd73aa10fcb5de424c657aDouglas Gregor T->getNumArgs() != ParamTypes.size() || 3640a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall !std::equal(T->arg_type_begin(), T->arg_type_end(), ParamTypes.begin())) { 3641a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildFunctionProtoType(ResultType, 3642a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ParamTypes.data(), 3643a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ParamTypes.size(), 3644a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall T->isVariadic(), 3645fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman T->getTypeQuals(), 3646fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman T->getExtInfo()); 3647a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3648a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3649a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 36501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3651a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result); 3652a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setLParenLoc(TL.getLParenLoc()); 3653a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setRParenLoc(TL.getRParenLoc()); 3654dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor NewTL.setTrailingReturn(TL.getTrailingReturn()); 3655a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i) 3656a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setArg(i, ParamDecls[i]); 3657a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3658a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3659577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 36601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3661577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3662577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::TransformFunctionNoProtoType( 3663a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLocBuilder &TLB, 366443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall FunctionNoProtoTypeLoc TL) { 3665a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall FunctionNoProtoType *T = TL.getTypePtr(); 3666a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc()); 3667a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (ResultType.isNull()) 3668a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3669a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3670a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3671a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3672a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall ResultType != T->getResultType()) 3673a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildFunctionNoProtoType(ResultType); 3674a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3675a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result); 3676a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setLParenLoc(TL.getLParenLoc()); 3677a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setRParenLoc(TL.getRParenLoc()); 3678dab60ad68a3a98d687305941a3852e793705f945Douglas Gregor NewTL.setTrailingReturn(false); 3679a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3680a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3681577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 36821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3683ed97649e9574b9d854fa4d6109c9333ae0993554John McCalltemplate<typename Derived> QualType 3684ed97649e9574b9d854fa4d6109c9333ae0993554John McCallTreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB, 368543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall UnresolvedUsingTypeLoc TL) { 3686ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UnresolvedUsingType *T = TL.getTypePtr(); 36877c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl()); 3688ed97649e9574b9d854fa4d6109c9333ae0993554John McCall if (!D) 3689ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return QualType(); 3690ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 3691ed97649e9574b9d854fa4d6109c9333ae0993554John McCall QualType Result = TL.getType(); 3692ed97649e9574b9d854fa4d6109c9333ae0993554John McCall if (getDerived().AlwaysRebuild() || D != T->getDecl()) { 3693ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Result = getDerived().RebuildUnresolvedUsingType(D); 3694ed97649e9574b9d854fa4d6109c9333ae0993554John McCall if (Result.isNull()) 3695ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return QualType(); 3696ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 3697ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 3698ed97649e9574b9d854fa4d6109c9333ae0993554John McCall // We might get an arbitrary type spec type back. We should at 3699ed97649e9574b9d854fa4d6109c9333ae0993554John McCall // least always get a type spec type, though. 3700ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result); 3701ed97649e9574b9d854fa4d6109c9333ae0993554John McCall NewTL.setNameLoc(TL.getNameLoc()); 3702ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 3703ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return Result; 3704ed97649e9574b9d854fa4d6109c9333ae0993554John McCall} 3705ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 3706577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3707a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB, 370843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypedefTypeLoc TL) { 3709a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypedefType *T = TL.getTypePtr(); 3710577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor TypedefDecl *Typedef 37117c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<TypedefDecl>(getDerived().TransformDecl(TL.getNameLoc(), 37127c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor T->getDecl())); 3713577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (!Typedef) 3714577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 37151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3716a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3717a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3718a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Typedef != T->getDecl()) { 3719a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildTypedefType(Typedef); 3720a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3721a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3722a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3723a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3724a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result); 3725a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 37261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3727a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3728577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 37291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3730577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3731a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB, 373243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeOfExprTypeLoc TL) { 3733670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // typeof expressions are not potentially evaluated contexts 3734f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 37351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 373660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr()); 3737577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (E.isInvalid()) 3738577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 3739577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 3740a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3741a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3742cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall E.get() != TL.getUnderlyingExpr()) { 37432a984cad5ac3fdceeff2bd99daa7b90979313475John McCall Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc()); 3744a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3745a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3746577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 3747a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall else E.take(); 37481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3749a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result); 3750cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setTypeofLoc(TL.getTypeofLoc()); 3751cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setLParenLoc(TL.getLParenLoc()); 3752cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setRParenLoc(TL.getRParenLoc()); 3753a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3754a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3755577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 37561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 37571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3758a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB, 375943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeOfTypeLoc TL) { 3760cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo(); 3761cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI); 3762cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall if (!New_Under_TI) 3763577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 37641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3765a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3766cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) { 3767cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall Result = getDerived().RebuildTypeOfType(New_Under_TI->getType()); 3768a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3769a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3770a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 37711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3772a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result); 3773cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setTypeofLoc(TL.getTypeofLoc()); 3774cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setLParenLoc(TL.getLParenLoc()); 3775cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setRParenLoc(TL.getRParenLoc()); 3776cfb708c354e2f30ccc5cba9d644650f408a1ec3eJohn McCall NewTL.setUnderlyingTInfo(New_Under_TI); 3777a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3778a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3779577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 37801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 37811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3782a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB, 378343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DecltypeTypeLoc TL) { 3784a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall DecltypeType *T = TL.getTypePtr(); 3785a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3786670444ed30cc8ff66eb4847d921d9af0291a7111Douglas Gregor // decltype expressions are not potentially evaluated contexts 3787f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 37881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 378960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr()); 3790577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (E.isInvalid()) 3791577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 37921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3793a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3794a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3795a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall E.get() != T->getUnderlyingExpr()) { 37962a984cad5ac3fdceeff2bd99daa7b90979313475John McCall Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc()); 3797a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3798a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3799577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 3800a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall else E.take(); 3801a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3802a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result); 3803a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 38041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3805a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3806577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 3807577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 3808577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3809a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB, 381043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall RecordTypeLoc TL) { 3811a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall RecordType *T = TL.getTypePtr(); 3812577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor RecordDecl *Record 38137c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(), 38147c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor T->getDecl())); 3815577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (!Record) 3816577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 38171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3818a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3819a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3820a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Record != T->getDecl()) { 3821a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildRecordType(Record); 3822a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3823a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3824a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 38251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3826a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result); 3827a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 3828a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3829a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3830577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 38311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 38321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 3833a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB, 383443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall EnumTypeLoc TL) { 3835a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall EnumType *T = TL.getTypePtr(); 3836577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor EnumDecl *Enum 38377c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(), 38387c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor T->getDecl())); 3839577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (!Enum) 3840577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 38411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3842a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 3843a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 3844a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Enum != T->getDecl()) { 3845a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall Result = getDerived().RebuildEnumType(Enum); 3846a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 3847a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 3848a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 3849a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 3850a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result); 3851a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NewTL.setNameLoc(TL.getNameLoc()); 38521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3853a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 3854577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 38557da2431c23ef1ee8acb114e39692246e1801afc2John McCall 38563cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCalltemplate<typename Derived> 38573cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCallQualType TreeTransform<Derived>::TransformInjectedClassNameType( 38583cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall TypeLocBuilder &TLB, 385943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall InjectedClassNameTypeLoc TL) { 38603cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall Decl *D = getDerived().TransformDecl(TL.getNameLoc(), 38613cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall TL.getTypePtr()->getDecl()); 38623cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall if (!D) return QualType(); 38633cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 38643cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D)); 38653cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc()); 38663cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall return T; 38673cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall} 38683cb0ebd5f76abcb776f7cb4062bd79e3268c0dc4John McCall 3869577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 3870577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::TransformTemplateTypeParmType( 3871a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLocBuilder &TLB, 387243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateTypeParmTypeLoc TL) { 3873a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return TransformTypeSpecType(TLB, TL); 3874577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 3875577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 38761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 387749a832bd499d6f61c23655f1fac99f0dd229756eJohn McCallQualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType( 3878a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall TypeLocBuilder &TLB, 387943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall SubstTemplateTypeParmTypeLoc TL) { 3880a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return TransformTypeSpecType(TLB, TL); 388149a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall} 388249a832bd499d6f61c23655f1fac99f0dd229756eJohn McCall 388349a832bd499d6f61c23655f1fac99f0dd229756eJohn McCalltemplate<typename Derived> 3884833ca991c1bfc967f0995974ca86f66ba1f666b5John McCallQualType TreeTransform<Derived>::TransformTemplateSpecializationType( 388543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TypeLocBuilder &TLB, 388643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateSpecializationTypeLoc TL) { 388743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall const TemplateSpecializationType *T = TL.getTypePtr(); 3888828bff2079b6a91ecd7ed5b842c59527d7682789John McCall 388943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateName Template 389043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall = getDerived().TransformTemplateName(T->getTemplateName()); 389143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (Template.isNull()) 389243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return QualType(); 3893833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 389443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return getDerived().TransformTemplateSpecializationType(TLB, TL, Template); 3895dd62b15665a4144c45c1f7c53665414ad5f7f4f2Douglas Gregor} 389643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 38977ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregornamespace { 38987ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// \brief Simple iterator that traverses the template arguments in a 38997ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// container that provides a \c getArgLoc() member function. 39007ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// 39017ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// This iterator is intended to be used with the iterator form of 39027ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor /// \c TreeTransform<Derived>::TransformTemplateArguments(). 39037ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor template<typename ArgLocContainer> 39047ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor class TemplateArgumentLocContainerIterator { 39057ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ArgLocContainer *Container; 39067ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor unsigned Index; 39077ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39087ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor public: 39097ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLoc value_type; 39107ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLoc reference; 39117ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef int difference_type; 39127ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef std::input_iterator_tag iterator_category; 39137ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39147ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor class pointer { 39157ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLoc Arg; 39167ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39177ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor public: 39187ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { } 39197ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39207ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor const TemplateArgumentLoc *operator->() const { 39217ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return &Arg; 39227ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39237ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor }; 39247ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39257ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39267ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocContainerIterator() {} 39277ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39287ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocContainerIterator(ArgLocContainer &Container, 39297ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor unsigned Index) 39307ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor : Container(&Container), Index(Index) { } 39317ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39327ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocContainerIterator &operator++() { 39337ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ++Index; 39347ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return *this; 39357ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39367ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39377ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocContainerIterator operator++(int) { 39387ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLocContainerIterator Old(*this); 39397ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ++(*this); 39407ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return Old; 39417ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39427ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39437ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor TemplateArgumentLoc operator*() const { 39447ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return Container->getArgLoc(Index); 39457ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39467ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39477ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor pointer operator->() const { 39487ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return pointer(Container->getArgLoc(Index)); 39497ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39507ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39517ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor friend bool operator==(const TemplateArgumentLocContainerIterator &X, 3952f7dd69969aa25093ca9a7897a0d8819c145d1c77Douglas Gregor const TemplateArgumentLocContainerIterator &Y) { 39537ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return X.Container == Y.Container && X.Index == Y.Index; 39547ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39557ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39567ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor friend bool operator!=(const TemplateArgumentLocContainerIterator &X, 3957f7dd69969aa25093ca9a7897a0d8819c145d1c77Douglas Gregor const TemplateArgumentLocContainerIterator &Y) { 39587ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor return !(X == Y); 39597ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor } 39607ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor }; 39617ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor} 39627ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 39637ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 396443fed0de4f5bc189e45562491f83d5193eb8dac0John McCalltemplate <typename Derived> 3965577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::TransformTemplateSpecializationType( 3966833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TypeLocBuilder &TLB, 3967833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc TL, 396843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TemplateName Template) { 3969d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall TemplateArgumentListInfo NewTemplateArgs; 3970d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc()); 3971d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc()); 39727ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLocContainerIterator<TemplateSpecializationTypeLoc> 39737ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ArgIterator; 39747ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0), 39757ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ArgIterator(TL, TL.getNumArgs()), 39767ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor NewTemplateArgs)) 39777f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor return QualType(); 39781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3979833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall // FIXME: maybe don't rebuild if all the template arguments are the same. 3980833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 3981833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall QualType Result = 3982833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall getDerived().RebuildTemplateSpecializationType(Template, 3983833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TL.getTemplateNameLoc(), 3984d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall NewTemplateArgs); 39851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3986833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall if (!Result.isNull()) { 3987833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateSpecializationTypeLoc NewTL 3988833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall = TLB.push<TemplateSpecializationTypeLoc>(Result); 3989833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall NewTL.setTemplateNameLoc(TL.getTemplateNameLoc()); 3990833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall NewTL.setLAngleLoc(TL.getLAngleLoc()); 3991833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall NewTL.setRAngleLoc(TL.getRAngleLoc()); 3992833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i) 3993833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo()); 3994833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall } 39951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 3996833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall return Result; 3997577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 39981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 39991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 4000a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 4001465d41b92b2c862f3062c412a0538db65c6a2661Abramo BagnaraTreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB, 400243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ElaboratedTypeLoc TL) { 4003465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara ElaboratedType *T = TL.getTypePtr(); 4004465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara 4005465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara NestedNameSpecifier *NNS = 0; 4006465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara // NOTE: the qualifier in an ElaboratedType is optional. 4007465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara if (T->getQualifier() != 0) { 4008465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara NNS = getDerived().TransformNestedNameSpecifier(T->getQualifier(), 400943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TL.getQualifierRange()); 4010465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara if (!NNS) 4011465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara return QualType(); 4012465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara } 40131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 401443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc()); 401543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (NamedT.isNull()) 401643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return QualType(); 4017a63db84b164d3f1c987a3ea6251e3092db4f317bDaniel Dunbar 4018a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall QualType Result = TL.getType(); 4019a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (getDerived().AlwaysRebuild() || 4020a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall NNS != T->getQualifier() || 4021e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NamedT != T->getNamedType()) { 402221e413fe6305a198564d436ac515497716c47844John McCall Result = getDerived().RebuildElaboratedType(TL.getKeywordLoc(), 402321e413fe6305a198564d436ac515497716c47844John McCall T->getKeyword(), NNS, NamedT); 4024a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 4025a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 4026a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall } 4027577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 4028465d41b92b2c862f3062c412a0538db65c6a2661Abramo Bagnara ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result); 4029e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setKeywordLoc(TL.getKeywordLoc()); 4030e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setQualifierRange(TL.getQualifierRange()); 4031a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 4032a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 4033577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 40341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 40351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 40369d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCallQualType TreeTransform<Derived>::TransformAttributedType( 40379d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall TypeLocBuilder &TLB, 40389d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedTypeLoc TL) { 40399d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall const AttributedType *oldType = TL.getTypePtr(); 40409d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc()); 40419d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (modifiedType.isNull()) 40429d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return QualType(); 40439d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 40449d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType result = TL.getType(); 40459d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 40469d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // FIXME: dependent operand expressions? 40479d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (getDerived().AlwaysRebuild() || 40489d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall modifiedType != oldType->getModifiedType()) { 40499d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // TODO: this is really lame; we should really be rebuilding the 40509d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall // equivalent type from first principles. 40519d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall QualType equivalentType 40529d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall = getDerived().TransformType(oldType->getEquivalentType()); 40539d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (equivalentType.isNull()) 40549d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return QualType(); 40559d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall result = SemaRef.Context.getAttributedType(oldType->getAttrKind(), 40569d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall modifiedType, 40579d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall equivalentType); 40589d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall } 40599d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 40609d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result); 40619d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall newTL.setAttrNameLoc(TL.getAttrNameLoc()); 40629d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (TL.hasAttrOperand()) 40639d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall newTL.setAttrOperandParensRange(TL.getAttrOperandParensRange()); 40649d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall if (TL.hasAttrExprOperand()) 40659d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall newTL.setAttrExprOperand(TL.getAttrExprOperand()); 40669d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall else if (TL.hasAttrEnumOperand()) 40679d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall newTL.setAttrEnumOperandLoc(TL.getAttrEnumOperandLoc()); 40689d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 40699d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall return result; 40709d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall} 40719d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCall 40729d156a7b1b2771e191f2f5a45a7b7a694129463bJohn McCalltemplate<typename Derived> 4073075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo BagnaraQualType 4074075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo BagnaraTreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB, 4075075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara ParenTypeLoc TL) { 4076075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc()); 4077075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara if (Inner.isNull()) 4078075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return QualType(); 4079075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 4080075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara QualType Result = TL.getType(); 4081075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara if (getDerived().AlwaysRebuild() || 4082075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara Inner != TL.getInnerLoc().getType()) { 4083075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara Result = getDerived().RebuildParenType(Inner); 4084075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara if (Result.isNull()) 4085075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return QualType(); 4086075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara } 4087075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 4088075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result); 4089075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara NewTL.setLParenLoc(TL.getLParenLoc()); 4090075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara NewTL.setRParenLoc(TL.getRParenLoc()); 4091075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara return Result; 4092075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara} 4093075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnara 4094075f8f1b6bed4d1b224c74f87508534cc6392ce6Abramo Bagnaratemplate<typename Derived> 40954714c12a1ab759156b78be8f109ea4c12213af57Douglas GregorQualType TreeTransform<Derived>::TransformDependentNameType(TypeLocBuilder &TLB, 409643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentNameTypeLoc TL) { 40974714c12a1ab759156b78be8f109ea4c12213af57Douglas Gregor DependentNameType *T = TL.getTypePtr(); 4098833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall 4099577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor NestedNameSpecifier *NNS 4100e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara = getDerived().TransformNestedNameSpecifier(T->getQualifier(), 410143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TL.getQualifierRange()); 4102577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (!NNS) 4103577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return QualType(); 41041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 410533500955d731c73717af52088b7fc0e7a85681e7John McCall QualType Result 410633500955d731c73717af52088b7fc0e7a85681e7John McCall = getDerived().RebuildDependentNameType(T->getKeyword(), NNS, 410733500955d731c73717af52088b7fc0e7a85681e7John McCall T->getIdentifier(), 410833500955d731c73717af52088b7fc0e7a85681e7John McCall TL.getKeywordLoc(), 410933500955d731c73717af52088b7fc0e7a85681e7John McCall TL.getQualifierRange(), 411033500955d731c73717af52088b7fc0e7a85681e7John McCall TL.getNameLoc()); 4111a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall if (Result.isNull()) 4112a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return QualType(); 4113a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 4114e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) { 4115e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara QualType NamedT = ElabT->getNamedType(); 411633500955d731c73717af52088b7fc0e7a85681e7John McCall TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc()); 411733500955d731c73717af52088b7fc0e7a85681e7John McCall 4118e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result); 4119e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setKeywordLoc(TL.getKeywordLoc()); 4120e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setQualifierRange(TL.getQualifierRange()); 412133500955d731c73717af52088b7fc0e7a85681e7John McCall } else { 4122e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result); 4123e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setKeywordLoc(TL.getKeywordLoc()); 4124e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setQualifierRange(TL.getQualifierRange()); 4125e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara NewTL.setNameLoc(TL.getNameLoc()); 4126e4da7a034a2fcf4b14d0bcc28d05de0878159061Abramo Bagnara } 4127a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return Result; 4128577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 41291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4130577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 413133500955d731c73717af52088b7fc0e7a85681e7John McCallQualType TreeTransform<Derived>:: 413233500955d731c73717af52088b7fc0e7a85681e7John McCall TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, 413343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentTemplateSpecializationTypeLoc TL) { 413433500955d731c73717af52088b7fc0e7a85681e7John McCall DependentTemplateSpecializationType *T = TL.getTypePtr(); 413533500955d731c73717af52088b7fc0e7a85681e7John McCall 413633500955d731c73717af52088b7fc0e7a85681e7John McCall NestedNameSpecifier *NNS 413733500955d731c73717af52088b7fc0e7a85681e7John McCall = getDerived().TransformNestedNameSpecifier(T->getQualifier(), 413843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TL.getQualifierRange()); 413933500955d731c73717af52088b7fc0e7a85681e7John McCall if (!NNS) 414033500955d731c73717af52088b7fc0e7a85681e7John McCall return QualType(); 414133500955d731c73717af52088b7fc0e7a85681e7John McCall 414243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return getDerived() 414343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall .TransformDependentTemplateSpecializationType(TLB, TL, NNS); 414443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall} 414543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 414643fed0de4f5bc189e45562491f83d5193eb8dac0John McCalltemplate<typename Derived> 414743fed0de4f5bc189e45562491f83d5193eb8dac0John McCallQualType TreeTransform<Derived>:: 414843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB, 414943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentTemplateSpecializationTypeLoc TL, 415043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *NNS) { 415143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall DependentTemplateSpecializationType *T = TL.getTypePtr(); 415243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 415333500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateArgumentListInfo NewTemplateArgs; 415433500955d731c73717af52088b7fc0e7a85681e7John McCall NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc()); 415533500955d731c73717af52088b7fc0e7a85681e7John McCall NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc()); 41567ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor 41577ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor typedef TemplateArgumentLocContainerIterator< 41587ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor DependentTemplateSpecializationTypeLoc> ArgIterator; 41597ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0), 41607ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor ArgIterator(TL, TL.getNumArgs()), 41617ca7ac40ad45d5253ba474dddfa5ee233f35c2feDouglas Gregor NewTemplateArgs)) 41627f61f2fc1a880ac3bf5b0993525922dd2c1f09bfDouglas Gregor return QualType(); 416333500955d731c73717af52088b7fc0e7a85681e7John McCall 41641efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor QualType Result 41651efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor = getDerived().RebuildDependentTemplateSpecializationType(T->getKeyword(), 41661efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor NNS, 41671efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor TL.getQualifierRange(), 41681efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor T->getIdentifier(), 41691efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor TL.getNameLoc(), 41701efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor NewTemplateArgs); 417133500955d731c73717af52088b7fc0e7a85681e7John McCall if (Result.isNull()) 417233500955d731c73717af52088b7fc0e7a85681e7John McCall return QualType(); 417333500955d731c73717af52088b7fc0e7a85681e7John McCall 417433500955d731c73717af52088b7fc0e7a85681e7John McCall if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) { 417533500955d731c73717af52088b7fc0e7a85681e7John McCall QualType NamedT = ElabT->getNamedType(); 417633500955d731c73717af52088b7fc0e7a85681e7John McCall 417733500955d731c73717af52088b7fc0e7a85681e7John McCall // Copy information relevant to the template specialization. 417833500955d731c73717af52088b7fc0e7a85681e7John McCall TemplateSpecializationTypeLoc NamedTL 417933500955d731c73717af52088b7fc0e7a85681e7John McCall = TLB.push<TemplateSpecializationTypeLoc>(NamedT); 418033500955d731c73717af52088b7fc0e7a85681e7John McCall NamedTL.setLAngleLoc(TL.getLAngleLoc()); 418133500955d731c73717af52088b7fc0e7a85681e7John McCall NamedTL.setRAngleLoc(TL.getRAngleLoc()); 418233500955d731c73717af52088b7fc0e7a85681e7John McCall for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I) 418333500955d731c73717af52088b7fc0e7a85681e7John McCall NamedTL.setArgLocInfo(I, TL.getArgLocInfo(I)); 418433500955d731c73717af52088b7fc0e7a85681e7John McCall 418533500955d731c73717af52088b7fc0e7a85681e7John McCall // Copy information relevant to the elaborated type. 418633500955d731c73717af52088b7fc0e7a85681e7John McCall ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result); 418733500955d731c73717af52088b7fc0e7a85681e7John McCall NewTL.setKeywordLoc(TL.getKeywordLoc()); 418833500955d731c73717af52088b7fc0e7a85681e7John McCall NewTL.setQualifierRange(TL.getQualifierRange()); 418933500955d731c73717af52088b7fc0e7a85681e7John McCall } else { 4190e2872d0bda1d209d4409de2ed13648e6811628b7Douglas Gregor TypeLoc NewTL(Result, TL.getOpaqueData()); 4191e2872d0bda1d209d4409de2ed13648e6811628b7Douglas Gregor TLB.pushFullCopy(NewTL); 419233500955d731c73717af52088b7fc0e7a85681e7John McCall } 419333500955d731c73717af52088b7fc0e7a85681e7John McCall return Result; 419433500955d731c73717af52088b7fc0e7a85681e7John McCall} 419533500955d731c73717af52088b7fc0e7a85681e7John McCall 419633500955d731c73717af52088b7fc0e7a85681e7John McCalltemplate<typename Derived> 41977536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas GregorQualType TreeTransform<Derived>::TransformPackExpansionType(TypeLocBuilder &TLB, 41987536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor PackExpansionTypeLoc TL) { 41991d65ebba273e6797902dcfa93964bae5ca0fe8d2Douglas Gregor llvm_unreachable("Caller must expansion pack expansion types"); 42007536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor return QualType(); 42017536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor} 42027536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregor 42037536dd5e6c99584481b7dab68b7e7d8df9c54054Douglas Gregortemplate<typename Derived> 4204a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 4205a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB, 420643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjCInterfaceTypeLoc TL) { 4207ef57c61ec3642ba7faaf7b9c0c4a6f23fa39d77cDouglas Gregor // ObjCInterfaceType is never dependent. 4208c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TLB.pushFullCopy(TL); 4209c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall return TL.getType(); 4210c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall} 4211c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall 4212c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCalltemplate<typename Derived> 4213c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallQualType 4214c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCallTreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB, 421543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjCObjectTypeLoc TL) { 4216c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall // ObjCObjectType is never dependent. 4217c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TLB.pushFullCopy(TL); 4218ef57c61ec3642ba7faaf7b9c0c4a6f23fa39d77cDouglas Gregor return TL.getType(); 4219577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 42201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 42211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 4222a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType 4223a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallTreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB, 422443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjCObjectPointerTypeLoc TL) { 4225ef57c61ec3642ba7faaf7b9c0c4a6f23fa39d77cDouglas Gregor // ObjCObjectPointerType is never dependent. 4226c12c5bba6ceb6acd4e51e7a0fc03257da9cfd44eJohn McCall TLB.pushFullCopy(TL); 4227ef57c61ec3642ba7faaf7b9c0c4a6f23fa39d77cDouglas Gregor return TL.getType(); 422824fab41057e4b67ed69a6b4027d5ae0f2f6934dcArgyrios Kyrtzidis} 422924fab41057e4b67ed69a6b4027d5ae0f2f6934dcArgyrios Kyrtzidis 4230577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor//===----------------------------------------------------------------------===// 423143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor// Statement transformation 423243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor//===----------------------------------------------------------------------===// 423343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 423460d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 42351eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformNullStmt(NullStmt *S) { 42363fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 423743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 423843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 423943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 424060d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 424143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S) { 424243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().TransformCompoundStmt(S, false); 424343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 424443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 424543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 424660d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 42471eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S, 424843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor bool IsStmtExpr) { 42497114cbab7eb6e8b714eb22f014327daf2c741c08John McCall bool SubStmtInvalid = false; 425043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor bool SubStmtChanged = false; 4251ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Stmt*> Statements(getSema()); 425243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor for (CompoundStmt::body_iterator B = S->body_begin(), BEnd = S->body_end(); 425343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor B != BEnd; ++B) { 425460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Result = getDerived().TransformStmt(*B); 42557114cbab7eb6e8b714eb22f014327daf2c741c08John McCall if (Result.isInvalid()) { 42567114cbab7eb6e8b714eb22f014327daf2c741c08John McCall // Immediately fail if this was a DeclStmt, since it's very 42577114cbab7eb6e8b714eb22f014327daf2c741c08John McCall // likely that this will cause problems for future statements. 42587114cbab7eb6e8b714eb22f014327daf2c741c08John McCall if (isa<DeclStmt>(*B)) 42597114cbab7eb6e8b714eb22f014327daf2c741c08John McCall return StmtError(); 42607114cbab7eb6e8b714eb22f014327daf2c741c08John McCall 42617114cbab7eb6e8b714eb22f014327daf2c741c08John McCall // Otherwise, just keep processing substatements and fail later. 42627114cbab7eb6e8b714eb22f014327daf2c741c08John McCall SubStmtInvalid = true; 42637114cbab7eb6e8b714eb22f014327daf2c741c08John McCall continue; 42647114cbab7eb6e8b714eb22f014327daf2c741c08John McCall } 42651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 426643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SubStmtChanged = SubStmtChanged || Result.get() != *B; 426743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Statements.push_back(Result.takeAs<Stmt>()); 426843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 42691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 42707114cbab7eb6e8b714eb22f014327daf2c741c08John McCall if (SubStmtInvalid) 42717114cbab7eb6e8b714eb22f014327daf2c741c08John McCall return StmtError(); 42727114cbab7eb6e8b714eb22f014327daf2c741c08John McCall 427343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 427443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor !SubStmtChanged) 42753fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 427643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 427743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().RebuildCompoundStmt(S->getLBracLoc(), 427843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor move_arg(Statements), 427943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor S->getRBracLoc(), 428043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor IsStmtExpr); 428143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 42821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 428343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 428460d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 42851eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) { 428660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult LHS, RHS; 4287264c1f8ec895952466eab59b84b8b06801e721faEli Friedman { 4288264c1f8ec895952466eab59b84b8b06801e721faEli Friedman // The case value expressions are not potentially evaluated. 4289f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 42901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4291264c1f8ec895952466eab59b84b8b06801e721faEli Friedman // Transform the left-hand case value. 4292264c1f8ec895952466eab59b84b8b06801e721faEli Friedman LHS = getDerived().TransformExpr(S->getLHS()); 4293264c1f8ec895952466eab59b84b8b06801e721faEli Friedman if (LHS.isInvalid()) 4294f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 42951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4296264c1f8ec895952466eab59b84b8b06801e721faEli Friedman // Transform the right-hand case value (for the GNU case-range extension). 4297264c1f8ec895952466eab59b84b8b06801e721faEli Friedman RHS = getDerived().TransformExpr(S->getRHS()); 4298264c1f8ec895952466eab59b84b8b06801e721faEli Friedman if (RHS.isInvalid()) 4299f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4300264c1f8ec895952466eab59b84b8b06801e721faEli Friedman } 43011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 430243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Build the case statement. 430343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Case statements are always rebuilt so that they will attached to their 430443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // transformed switch statement. 430560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(), 43069ae2f076ca5ab1feb3ba95629099ec2319833701John McCall LHS.get(), 430743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor S->getEllipsisLoc(), 43089ae2f076ca5ab1feb3ba95629099ec2319833701John McCall RHS.get(), 430943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor S->getColonLoc()); 431043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Case.isInvalid()) 4311f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 43121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 431343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the statement following the case 431460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt()); 431543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (SubStmt.isInvalid()) 4316f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 43171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 431843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Attach the body to the case statement 43199ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get()); 432043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 432143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 432243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 432360d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 43241eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) { 432543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the statement following the default case 432660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt()); 432743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (SubStmt.isInvalid()) 4328f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 43291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 433043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Default statements are always rebuilt 433143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(), 43329ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubStmt.get()); 433343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 43341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 433543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 433660d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 43371eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformLabelStmt(LabelStmt *S) { 433860d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt()); 433943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (SubStmt.isInvalid()) 4340f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 43411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 434243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // FIXME: Pass the real colon location in. 434343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor SourceLocation ColonLoc = SemaRef.PP.getLocForEndOfToken(S->getIdentLoc()); 434443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().RebuildLabelStmt(S->getIdentLoc(), S->getID(), ColonLoc, 43451a18600b85aaa691122983dd8dcf4225cfc9ef68Argyrios Kyrtzidis SubStmt.get(), S->HasUnusedAttribute()); 434643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 43471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 434843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 434960d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 43501eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformIfStmt(IfStmt *S) { 435143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the condition 435260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond; 43538cfe5a784133d90bf329fd20801824a6f71bb8caDouglas Gregor VarDecl *ConditionVar = 0; 43548cfe5a784133d90bf329fd20801824a6f71bb8caDouglas Gregor if (S->getConditionVariable()) { 4355c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt ConditionVar 43568cfe5a784133d90bf329fd20801824a6f71bb8caDouglas Gregor = cast_or_null<VarDecl>( 4357aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor getDerived().TransformDefinition( 4358aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable()->getLocation(), 4359aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable())); 43608cfe5a784133d90bf329fd20801824a6f71bb8caDouglas Gregor if (!ConditionVar) 4361f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 436299e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } else { 43638cfe5a784133d90bf329fd20801824a6f71bb8caDouglas Gregor Cond = getDerived().TransformExpr(S->getCond()); 4364c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 436599e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor if (Cond.isInvalid()) 4366f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4367eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 4368eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor // Convert the condition to a boolean value. 4369afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor if (S->getCond()) { 43708491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getIfLoc(), 43718491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Cond.get()); 4372afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor if (CondE.isInvalid()) 4373f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4374eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 43759ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Cond = CondE.get(); 4376afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor } 437799e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } 4378c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 43799ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.take())); 43809ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (!S->getConditionVariable() && S->getCond() && !FullCond.get()) 4381f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4382eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 438343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the "then" branch. 438460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Then = getDerived().TransformStmt(S->getThen()); 438543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Then.isInvalid()) 4386f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 43871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 438843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the "else" branch. 438960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Else = getDerived().TransformStmt(S->getElse()); 439043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Else.isInvalid()) 4391f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 43921eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 439343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 43949ae2f076ca5ab1feb3ba95629099ec2319833701John McCall FullCond.get() == S->getCond() && 439599e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor ConditionVar == S->getConditionVariable() && 439643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Then.get() == S->getThen() && 439743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Else.get() == S->getElse()) 43983fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 43991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4400eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor return getDerived().RebuildIfStmt(S->getIfLoc(), FullCond, ConditionVar, 440144aa1f397855f130e88e62ffc1029f7f83bb5d2eArgyrios Kyrtzidis Then.get(), 44029ae2f076ca5ab1feb3ba95629099ec2319833701John McCall S->getElseLoc(), Else.get()); 440343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 440443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 440543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 440660d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 44071eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) { 440843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the condition. 440960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond; 4410d3d5301c44138b92bf01286183f5bf310cdd37cfDouglas Gregor VarDecl *ConditionVar = 0; 4411d3d5301c44138b92bf01286183f5bf310cdd37cfDouglas Gregor if (S->getConditionVariable()) { 4412c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt ConditionVar 4413d3d5301c44138b92bf01286183f5bf310cdd37cfDouglas Gregor = cast_or_null<VarDecl>( 4414aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor getDerived().TransformDefinition( 4415aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable()->getLocation(), 4416aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable())); 4417d3d5301c44138b92bf01286183f5bf310cdd37cfDouglas Gregor if (!ConditionVar) 4418f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 441999e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } else { 4420d3d5301c44138b92bf01286183f5bf310cdd37cfDouglas Gregor Cond = getDerived().TransformExpr(S->getCond()); 4421c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 442299e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor if (Cond.isInvalid()) 4423f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 442499e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } 44251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 442643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Rebuild the switch statement. 442760d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Switch 44289ae2f076ca5ab1feb3ba95629099ec2319833701John McCall = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Cond.get(), 4429586596fd7f7a336a2847b300c80614dcf39ab6d5Douglas Gregor ConditionVar); 443043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Switch.isInvalid()) 4431f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 44321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 443343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the body of the switch statement. 443460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getBody()); 443543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Body.isInvalid()) 4436f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 44371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 443843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Complete the switch statement. 44399ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(), 44409ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Body.get()); 444143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 44421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 444343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 444460d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 44451eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) { 444643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the condition 444760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond; 44485656e14d91405417182171a705ed3e3d2d6d7aa3Douglas Gregor VarDecl *ConditionVar = 0; 44495656e14d91405417182171a705ed3e3d2d6d7aa3Douglas Gregor if (S->getConditionVariable()) { 4450c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt ConditionVar 44515656e14d91405417182171a705ed3e3d2d6d7aa3Douglas Gregor = cast_or_null<VarDecl>( 4452aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor getDerived().TransformDefinition( 4453aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable()->getLocation(), 4454aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable())); 44555656e14d91405417182171a705ed3e3d2d6d7aa3Douglas Gregor if (!ConditionVar) 4456f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 445799e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } else { 44585656e14d91405417182171a705ed3e3d2d6d7aa3Douglas Gregor Cond = getDerived().TransformExpr(S->getCond()); 4459c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 446099e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor if (Cond.isInvalid()) 4461f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4462afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor 4463afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor if (S->getCond()) { 4464afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor // Convert the condition to a boolean value. 44658491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getWhileLoc(), 44668491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Cond.get()); 4467afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor if (CondE.isInvalid()) 4468f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 44699ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Cond = CondE; 4470afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor } 447199e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } 44721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 44739ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.take())); 44749ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (!S->getConditionVariable() && S->getCond() && !FullCond.get()) 4475f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4476eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 447743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the body 447860d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getBody()); 447943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Body.isInvalid()) 4480f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 44811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 448243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 44839ae2f076ca5ab1feb3ba95629099ec2319833701John McCall FullCond.get() == S->getCond() && 448499e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor ConditionVar == S->getConditionVariable() && 448543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Body.get() == S->getBody()) 44869ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return Owned(S); 44871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4488eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor return getDerived().RebuildWhileStmt(S->getWhileLoc(), FullCond, 44899ae2f076ca5ab1feb3ba95629099ec2319833701John McCall ConditionVar, Body.get()); 449043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 44911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 449243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 449360d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 449443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformDoStmt(DoStmt *S) { 449543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the body 449660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getBody()); 449743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Body.isInvalid()) 4498f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 44991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4500eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor // Transform the condition 450160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond = getDerived().TransformExpr(S->getCond()); 4502eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor if (Cond.isInvalid()) 4503f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4504eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 450543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 450643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Cond.get() == S->getCond() && 450743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Body.get() == S->getBody()) 45083fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 45091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 45109ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(), 45119ae2f076ca5ab1feb3ba95629099ec2319833701John McCall /*FIXME:*/S->getWhileLoc(), Cond.get(), 451243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor S->getRParenLoc()); 451343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 45141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 451543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 451660d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 45171eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformForStmt(ForStmt *S) { 451843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the initialization statement 451960d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Init = getDerived().TransformStmt(S->getInit()); 452043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Init.isInvalid()) 4521f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 45221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 452343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the condition 452460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond; 452599e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor VarDecl *ConditionVar = 0; 452699e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor if (S->getConditionVariable()) { 4527c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt ConditionVar 452899e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor = cast_or_null<VarDecl>( 4529aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor getDerived().TransformDefinition( 4530aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable()->getLocation(), 4531aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor S->getConditionVariable())); 453299e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor if (!ConditionVar) 4533f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 453499e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } else { 453599e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor Cond = getDerived().TransformExpr(S->getCond()); 4536c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 453799e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor if (Cond.isInvalid()) 4538f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4539afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor 4540afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor if (S->getCond()) { 4541afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor // Convert the condition to a boolean value. 45428491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getForLoc(), 45438491ffe86c50241b47c6d7ef8cd9ee00f5e675daDouglas Gregor Cond.get()); 4544afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor if (CondE.isInvalid()) 4545f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4546afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor 45479ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Cond = CondE.get(); 4548afa0fefb573f74ac7836daf1601c214eda946212Douglas Gregor } 454999e9b4d172f6877e6ba5ebe75bb8238721f5e01cDouglas Gregor } 45501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 45519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.take())); 45529ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (!S->getConditionVariable() && S->getCond() && !FullCond.get()) 4553f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4554eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 455543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the increment 455660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Inc = getDerived().TransformExpr(S->getInc()); 455743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Inc.isInvalid()) 4558f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 45591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 45609ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Sema::FullExprArg FullInc(getSema().MakeFullExpr(Inc.get())); 45619ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (S->getInc() && !FullInc.get()) 4562f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4563eaa18e449bb09c1e580aa35f9606ff2ca682f4cbDouglas Gregor 456443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the body 456560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getBody()); 456643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Body.isInvalid()) 4567f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 45681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 456943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 457043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Init.get() == S->getInit() && 45719ae2f076ca5ab1feb3ba95629099ec2319833701John McCall FullCond.get() == S->getCond() && 457243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Inc.get() == S->getInc() && 457343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Body.get() == S->getBody()) 45743fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 45751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 457643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(), 45779ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Init.get(), FullCond, ConditionVar, 45789ae2f076ca5ab1feb3ba95629099ec2319833701John McCall FullInc, S->getRParenLoc(), Body.get()); 457943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 458043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 458143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 458260d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 45831eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) { 458443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Goto statements must always be rebuilt, to resolve the label. 45851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(), 458643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor S->getLabel()); 458743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 458843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 458943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 459060d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 45911eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) { 459260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Target = getDerived().TransformExpr(S->getTarget()); 459343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Target.isInvalid()) 4594f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 45951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 459643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 459743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Target.get() == S->getTarget()) 45983fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 459943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 460043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(), 46019ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Target.get()); 460243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 460343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 460443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 460560d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 46061eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) { 46073fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 460843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 46091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 461043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 461160d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 46121eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) { 46133fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 461443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 46151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 461643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 461760d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 46181eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) { 461960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = getDerived().TransformExpr(S->getRetValue()); 462043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Result.isInvalid()) 4621f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 462243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 46231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump // FIXME: We always rebuild the return statement because there is no way 462443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // to tell whether the return type of the function has changed. 46259ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get()); 462643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 46271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 462843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 462960d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 46301eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) { 463143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor bool DeclChanged = false; 463243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor llvm::SmallVector<Decl *, 4> Decls; 463343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end(); 463443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor D != DEnd; ++D) { 4635aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor Decl *Transformed = getDerived().TransformDefinition((*D)->getLocation(), 4636aac571c68de0a7c58d92fba0057e308f0e6d115cDouglas Gregor *D); 463743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!Transformed) 4638f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 46391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 464043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Transformed != *D) 464143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor DeclChanged = true; 46421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 464343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Decls.push_back(Transformed); 464443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 46451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 464643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && !DeclChanged) 46473fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 46481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 46491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildDeclStmt(Decls.data(), Decls.size(), 465043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor S->getStartLoc(), S->getEndLoc()); 465143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 46521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 465343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 465460d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 46551eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformSwitchCase(SwitchCase *S) { 465643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor assert(false && "SwitchCase is abstract and cannot be transformed"); 46573fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 465843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 465943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 466043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 466160d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 466243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) { 4663c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4664ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Constraints(getSema()); 4665ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Exprs(getSema()); 4666ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson llvm::SmallVector<IdentifierInfo *, 4> Names; 4667a5a79f7d16b48d3be8bcc8c7650e31aefd92b657Anders Carlsson 466860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult AsmString; 4669ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Clobbers(getSema()); 4670703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson 4671703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson bool ExprsChanged = false; 4672c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4673703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // Go through the outputs. 4674703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) { 4675ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson Names.push_back(S->getOutputIdentifier(I)); 4676c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4677703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // No need to transform the constraint literal. 46783fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall Constraints.push_back(S->getOutputConstraintLiteral(I)); 4679c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4680703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // Transform the output expr. 4681703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson Expr *OutputExpr = S->getOutputExpr(I); 468260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = getDerived().TransformExpr(OutputExpr); 4683703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson if (Result.isInvalid()) 4684f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4685c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4686703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson ExprsChanged |= Result.get() != OutputExpr; 4687c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 46889ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Exprs.push_back(Result.get()); 4689703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson } 4690c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4691703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // Go through the inputs. 4692703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) { 4693ff93dbd887e40588ed55d135037bb9287488b285Anders Carlsson Names.push_back(S->getInputIdentifier(I)); 4694c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4695703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // No need to transform the constraint literal. 46963fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall Constraints.push_back(S->getInputConstraintLiteral(I)); 4697c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4698703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // Transform the input expr. 4699703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson Expr *InputExpr = S->getInputExpr(I); 470060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result = getDerived().TransformExpr(InputExpr); 4701703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson if (Result.isInvalid()) 4702f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4703c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4704703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson ExprsChanged |= Result.get() != InputExpr; 4705c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 47069ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Exprs.push_back(Result.get()); 4707703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson } 4708c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4709703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson if (!getDerived().AlwaysRebuild() && !ExprsChanged) 47103fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 4711703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson 4712703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // Go through the clobbers. 4713703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I) 47143fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall Clobbers.push_back(S->getClobber(I)); 4715703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson 4716703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson // No need to transform the asm string literal. 4717703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson AsmString = SemaRef.Owned(S->getAsmString()); 4718703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson 4719703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson return getDerived().RebuildAsmStmt(S->getAsmLoc(), 4720703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson S->isSimple(), 4721703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson S->isVolatile(), 4722703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson S->getNumOutputs(), 4723703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson S->getNumInputs(), 4724a5a79f7d16b48d3be8bcc8c7650e31aefd92b657Anders Carlsson Names.data(), 4725703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson move_arg(Constraints), 4726703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson move_arg(Exprs), 47279ae2f076ca5ab1feb3ba95629099ec2319833701John McCall AsmString.get(), 4728703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson move_arg(Clobbers), 4729703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson S->getRParenLoc(), 4730703e39486689d6660e75f6b6de0068db031a51c7Anders Carlsson S->isMSAsm()); 473143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 473243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 473343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 473443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 473560d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 47361eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) { 47374dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // Transform the body of the @try. 473860d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult TryBody = getDerived().TransformStmt(S->getTryBody()); 47394dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (TryBody.isInvalid()) 4740f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4741c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 47428f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor // Transform the @catch statements (if present). 47438f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor bool AnyCatchChanged = false; 4744ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Stmt*> CatchStmts(SemaRef); 47458f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) { 474660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I)); 47474dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (Catch.isInvalid()) 4748f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 47498f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor if (Catch.get() != S->getCatchStmt(I)) 47508f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor AnyCatchChanged = true; 47518f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor CatchStmts.push_back(Catch.release()); 47524dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor } 4753c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 47544dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // Transform the @finally statement (if present). 475560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Finally; 47564dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (S->getFinallyStmt()) { 47574dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor Finally = getDerived().TransformStmt(S->getFinallyStmt()); 47584dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (Finally.isInvalid()) 4759f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 47604dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor } 47614dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor 47624dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // If nothing changed, just retain this statement. 47634dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (!getDerived().AlwaysRebuild() && 47644dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor TryBody.get() == S->getTryBody() && 47658f5e3dd32e443768d9dbbad7191e123e6733750cDouglas Gregor !AnyCatchChanged && 47664dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor Finally.get() == S->getFinallyStmt()) 47673fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 4768c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 47694dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // Build a new statement. 47709ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(), 47719ae2f076ca5ab1feb3ba95629099ec2319833701John McCall move_arg(CatchStmts), Finally.get()); 477243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 47731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 477443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 477560d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 47761eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) { 4777be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor // Transform the @catch parameter, if there is one. 4778be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor VarDecl *Var = 0; 4779be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (VarDecl *FromVar = S->getCatchParamDecl()) { 4780be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor TypeSourceInfo *TSInfo = 0; 4781be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (FromVar->getTypeSourceInfo()) { 4782be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo()); 4783be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (!TSInfo) 4784f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4785be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor } 4786c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4787be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor QualType T; 4788be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (TSInfo) 4789be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor T = TSInfo->getType(); 4790be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor else { 4791be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor T = getDerived().TransformType(FromVar->getType()); 4792be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (T.isNull()) 4793f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4794be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor } 4795c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4796be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T); 4797be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (!Var) 4798f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4799be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor } 4800c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 480160d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getCatchBody()); 4802be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor if (Body.isInvalid()) 4803f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4804c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4805c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(), 4806be270a0fae647ae3fb4d6a21ba1ea5ab9c40853aDouglas Gregor S->getRParenLoc(), 48079ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Var, Body.get()); 480843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 48091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 481043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 481160d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 48121eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { 48134dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // Transform the body. 481460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getFinallyBody()); 48154dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (Body.isInvalid()) 4816f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4817c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 48184dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // If nothing changed, just retain this statement. 48194dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor if (!getDerived().AlwaysRebuild() && 48204dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor Body.get() == S->getFinallyBody()) 48213fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 48224dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor 48234dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor // Build a new statement. 48244dfdd1b5eb49999e3871f92310f2c53e1739f4f4Douglas Gregor return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(), 48259ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Body.get()); 482643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 48271eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 482843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 482960d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 48301eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) { 483160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Operand; 4832d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor if (S->getThrowExpr()) { 4833d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor Operand = getDerived().TransformExpr(S->getThrowExpr()); 4834d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor if (Operand.isInvalid()) 4835f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4836d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor } 4837c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4838d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor if (!getDerived().AlwaysRebuild() && 4839d1377b25a36adfe6604f78cbd3a23a07cf0f29e6Douglas Gregor Operand.get() == S->getThrowExpr()) 48403fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return getSema().Owned(S); 4841c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 48429ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get()); 484343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 48441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 484543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 484660d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 484743959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformObjCAtSynchronizedStmt( 48481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCAtSynchronizedStmt *S) { 48498fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor // Transform the object we are locking. 485060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Object = getDerived().TransformExpr(S->getSynchExpr()); 48518fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor if (Object.isInvalid()) 4852f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4853c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 48548fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor // Transform the body. 485560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getSynchBody()); 48568fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor if (Body.isInvalid()) 4857f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4858c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 48598fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor // If nothing change, just retain the current statement. 48608fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor if (!getDerived().AlwaysRebuild() && 48618fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor Object.get() == S->getSynchExpr() && 48628fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor Body.get() == S->getSynchBody()) 48633fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 48648fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor 48658fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor // Build a new statement. 48668fdc13a78a43f09ac396e682c35d57ca0b48216dDouglas Gregor return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(), 48679ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Object.get(), Body.get()); 486843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 486943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 487043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 487160d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 487243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformObjCForCollectionStmt( 48731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ObjCForCollectionStmt *S) { 4874c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor // Transform the element statement. 487560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Element = getDerived().TransformStmt(S->getElement()); 4876c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor if (Element.isInvalid()) 4877f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4878c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4879c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor // Transform the collection expression. 488060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Collection = getDerived().TransformExpr(S->getCollection()); 4881c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor if (Collection.isInvalid()) 4882f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4883c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4884c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor // Transform the body. 488560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Body = getDerived().TransformStmt(S->getBody()); 4886c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor if (Body.isInvalid()) 4887f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 4888c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4889c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor // If nothing changed, just retain this statement. 4890c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor if (!getDerived().AlwaysRebuild() && 4891c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor Element.get() == S->getElement() && 4892c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor Collection.get() == S->getCollection() && 4893c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor Body.get() == S->getBody()) 48943fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 4895c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 4896c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor // Build a new statement. 4897c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(), 4898c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor /*FIXME:*/S->getForLoc(), 48999ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Element.get(), 49009ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Collection.get(), 4901c3203e7ee1464a096f341c2e2a83a10be2da000aDouglas Gregor S->getRParenLoc(), 49029ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Body.get()); 490343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 490443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 490543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 490643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 490760d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 490843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) { 490943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the exception declaration, if any. 491043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor VarDecl *Var = 0; 491143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (S->getExceptionDecl()) { 491243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor VarDecl *ExceptionDecl = S->getExceptionDecl(); 491383cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor TypeSourceInfo *T = getDerived().TransformType( 491483cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor ExceptionDecl->getTypeSourceInfo()); 491583cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor if (!T) 4916f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 49171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 491883cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor Var = getDerived().RebuildExceptionDecl(ExceptionDecl, T, 491943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor ExceptionDecl->getIdentifier(), 492083cb94269015bf2770ade71e616c5322ea7e76e1Douglas Gregor ExceptionDecl->getLocation()); 4921ff331c15729f7d4439d253c97f4d60f2a7ffd0c6Douglas Gregor if (!Var || Var->isInvalidDecl()) 4922f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 492343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 49241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 492543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the actual exception handler. 492660d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock()); 4927ff331c15729f7d4439d253c97f4d60f2a7ffd0c6Douglas Gregor if (Handler.isInvalid()) 4928f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 49291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 493043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 493143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor !Var && 493243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Handler.get() == S->getHandlerBlock()) 49333fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 493443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 493543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), 493643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Var, 49379ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Handler.get()); 493843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 49391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 494043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregortemplate<typename Derived> 494160d7b3a319d84d688752be3870615ac0f111fb16John McCallStmtResult 494243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas GregorTreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) { 494343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the try block itself. 494460d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult TryBlock 494543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor = getDerived().TransformCompoundStmt(S->getTryBlock()); 494643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (TryBlock.isInvalid()) 4947f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 49481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 494943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // Transform the handlers. 495043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor bool HandlerChanged = false; 4951ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Stmt*> Handlers(SemaRef); 495243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) { 495360d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult Handler 495443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor = getDerived().TransformCXXCatchStmt(S->getHandler(I)); 495543959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (Handler.isInvalid()) 4956f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return StmtError(); 49571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 495843959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I); 495943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor Handlers.push_back(Handler.takeAs<Stmt>()); 496043959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor } 49611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 496243959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor if (!getDerived().AlwaysRebuild() && 496343959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor TryBlock.get() == S->getTryBlock() && 496443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor !HandlerChanged) 49653fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(S); 496643959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor 49679ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(), 49681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump move_arg(Handlers)); 496943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor} 49701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 497143959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor//===----------------------------------------------------------------------===// 4972b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor// Expression transformation 4973577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor//===----------------------------------------------------------------------===// 49741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 497560d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 4976454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) { 49773fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 49781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump} 49791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 49801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 498160d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 4982454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) { 4983a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor NestedNameSpecifier *Qualifier = 0; 4984a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor if (E->getQualifier()) { 4985a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(), 4986edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor E->getQualifierRange()); 4987a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor if (!Qualifier) 4988f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 4989a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor } 4990dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall 4991dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall ValueDecl *ND 49927c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(), 49937c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getDecl())); 4994b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!ND) 4995f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 49961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 4997ec8045d3f0375302eadaa63deb373bacaf25a569John McCall DeclarationNameInfo NameInfo = E->getNameInfo(); 4998ec8045d3f0375302eadaa63deb373bacaf25a569John McCall if (NameInfo.getName()) { 4999ec8045d3f0375302eadaa63deb373bacaf25a569John McCall NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo); 5000ec8045d3f0375302eadaa63deb373bacaf25a569John McCall if (!NameInfo.getName()) 5001f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5002ec8045d3f0375302eadaa63deb373bacaf25a569John McCall } 50032577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 50042577743c5650c646fb705df01403707e94f2df04Abramo Bagnara if (!getDerived().AlwaysRebuild() && 5005a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor Qualifier == E->getQualifier() && 5006a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor ND == E->getDecl() && 50072577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo.getName() == E->getDecl()->getDeclName() && 5008096832c5ed5b9106fa177ebc148489760c3bc496John McCall !E->hasExplicitTemplateArgs()) { 50091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5010dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall // Mark it referenced in the new context regardless. 5011dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall // FIXME: this is a bit instantiation-specific. 5012dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall SemaRef.MarkDeclarationReferenced(E->getLocation(), ND); 5013a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor 50143fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5015a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor } 5016dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall 5017dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall TemplateArgumentListInfo TransArgs, *TemplateArgs = 0; 5018096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (E->hasExplicitTemplateArgs()) { 5019dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall TemplateArgs = &TransArgs; 5020dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall TransArgs.setLAngleLoc(E->getLAngleLoc()); 5021dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall TransArgs.setRAngleLoc(E->getRAngleLoc()); 5022fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), 5023fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor E->getNumTemplateArgs(), 5024fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor TransArgs)) 5025fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor return ExprError(); 5026dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall } 5027dbd872f273a8dbf22e089b3def6c09f0a460965dJohn McCall 5028a2813cec2605ce7878d1b13471d685f689b251afDouglas Gregor return getDerived().RebuildDeclRefExpr(Qualifier, E->getQualifierRange(), 50292577743c5650c646fb705df01403707e94f2df04Abramo Bagnara ND, NameInfo, TemplateArgs); 5030577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 50311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5032b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 503360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5034454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) { 50353fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5036577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 50371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5038b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 503960d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5040454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) { 50413fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5042b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 50431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5044b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 504560d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5046454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) { 50473fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5048b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 50491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 50501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 505160d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5052454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) { 50533fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5054b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 50551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5056b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 505760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5058454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) { 50593fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5060b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 50611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5062b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 506360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5064454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformParenExpr(ParenExpr *E) { 506560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); 5066b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5067f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 50681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5069b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) 50703fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 50711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 50729ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(), 5073b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParen()); 5074b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 5075b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 50761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 507760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5078454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformUnaryOperator(UnaryOperator *E) { 507960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); 5080b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5081f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 50821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5083b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr()) 50843fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 50851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5086b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildUnaryOperator(E->getOperatorLoc(), 5087b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getOpcode(), 50889ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr.get()); 5089b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 50901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5091b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 509260d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 50938ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas GregorTreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) { 50948ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor // Transform the type. 50958ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo()); 50968ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor if (!Type) 5097f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5098c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 50998ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor // Transform all of the components into components similar to what the 51008ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor // parser uses. 5101c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt // FIXME: It would be slightly more efficient in the non-dependent case to 5102c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt // just map FieldDecls, rather than requiring the rebuilder to look for 5103c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt // the fields again. However, __builtin_offsetof is rare enough in 51048ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor // template code that we don't care. 51058ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor bool ExprChanged = false; 5106f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall typedef Sema::OffsetOfComponent Component; 51078ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor typedef OffsetOfExpr::OffsetOfNode Node; 51088ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor llvm::SmallVector<Component, 4> Components; 51098ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) { 51108ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor const Node &ON = E->getComponent(I); 51118ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Component Comp; 511272be24f39c162448e53dd73cf57cc6357114361eDouglas Gregor Comp.isBrackets = true; 51138ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Comp.LocStart = ON.getRange().getBegin(); 51148ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Comp.LocEnd = ON.getRange().getEnd(); 51158ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor switch (ON.getKind()) { 51168ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor case Node::Array: { 51178ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex()); 511860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Index = getDerived().TransformExpr(FromIndex); 51198ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor if (Index.isInvalid()) 5120f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5121c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 51228ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor ExprChanged = ExprChanged || Index.get() != FromIndex; 51238ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Comp.isBrackets = true; 51249ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Comp.U.E = Index.get(); 51258ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor break; 51268ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor } 5127c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 51288ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor case Node::Field: 51298ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor case Node::Identifier: 51308ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Comp.isBrackets = false; 51318ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Comp.U.IdentInfo = ON.getFieldName(); 513229d2fd56b5eeeb52f7fdbdd232229e570c30d62bDouglas Gregor if (!Comp.U.IdentInfo) 513329d2fd56b5eeeb52f7fdbdd232229e570c30d62bDouglas Gregor continue; 5134c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 51358ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor break; 5136c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 5137cc8a5d5f90bbbbcb46f342117b851b7e07ec34f1Douglas Gregor case Node::Base: 5138cc8a5d5f90bbbbcb46f342117b851b7e07ec34f1Douglas Gregor // Will be recomputed during the rebuild. 5139cc8a5d5f90bbbbcb46f342117b851b7e07ec34f1Douglas Gregor continue; 51408ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor } 5141c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 51428ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Components.push_back(Comp); 51438ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor } 5144c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 51458ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor // If nothing changed, retain the existing expression. 51468ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor if (!getDerived().AlwaysRebuild() && 51478ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Type == E->getTypeSourceInfo() && 51488ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor !ExprChanged) 51493fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5150c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 51518ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor // Build a new offsetof expression. 51528ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type, 51538ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor Components.data(), Components.size(), 51548ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor E->getRParenLoc()); 51557cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCall} 51567cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCall 51577cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCalltemplate<typename Derived> 51587cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCallExprResult 51597cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCallTreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) { 51607cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCall assert(getDerived().AlreadyTransformed(E->getType()) && 51617cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCall "opaque value expression requires transformation"); 51627cd7d1ad33fdf49eef83942e8855fe20d95aa1b9John McCall return SemaRef.Owned(E); 51638ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor} 51648ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregor 51658ecdb65716cd7914ffb2eeee993fa9039fcd31e8Douglas Gregortemplate<typename Derived> 516660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5167454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) { 5168b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (E->isArgumentType()) { 5169a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *OldT = E->getArgumentTypeInfo(); 51705557b25bdbd63536f687ebb63a0bab55aa227626Douglas Gregor 5171a93c934af4fbf97cbe8e649d82e68ccacfe57c95John McCall TypeSourceInfo *NewT = getDerived().TransformType(OldT); 51725ab75172051a6d2ea71a80a79e81c65519fd3462John McCall if (!NewT) 5173f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 51741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 51755ab75172051a6d2ea71a80a79e81c65519fd3462John McCall if (!getDerived().AlwaysRebuild() && OldT == NewT) 51763fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 51771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 51785ab75172051a6d2ea71a80a79e81c65519fd3462John McCall return getDerived().RebuildSizeOfAlignOf(NewT, E->getOperatorLoc(), 51791eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump E->isSizeOf(), 5180b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getSourceRange()); 5181b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 51821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 518360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr; 51841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump { 5185b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // C++0x [expr.sizeof]p1: 5186b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // The operand is either an expression, which is an unevaluated operand 5187b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // [...] 5188f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 51891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5190b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr = getDerived().TransformExpr(E->getArgumentExpr()); 5191b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5192f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 51931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5194b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr()) 51953fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5196b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 51971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 51989ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildSizeOfAlignOf(SubExpr.get(), E->getOperatorLoc(), 5199b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->isSizeOf(), 5200b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getSourceRange()); 5201b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 52021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5203b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 520460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5205454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) { 520660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult LHS = getDerived().TransformExpr(E->getLHS()); 5207b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (LHS.isInvalid()) 5208f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 52091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 521060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RHS = getDerived().TransformExpr(E->getRHS()); 5211b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (RHS.isInvalid()) 5212f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 52131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5215b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5216b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LHS.get() == E->getLHS() && 5217b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RHS.get() == E->getRHS()) 52183fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 52191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52209ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildArraySubscriptExpr(LHS.get(), 5221b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /*FIXME:*/E->getLHS()->getLocStart(), 52229ae2f076ca5ab1feb3ba95629099ec2319833701John McCall RHS.get(), 5223b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRBracketLoc()); 5224b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 52251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52261eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 522760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5228454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCallExpr(CallExpr *E) { 5229b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Transform the callee. 523060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Callee = getDerived().TransformExpr(E->getCallee()); 5231b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Callee.isInvalid()) 5232f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5233b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 5234b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Transform arguments. 5235b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgChanged = false; 5236ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Args(SemaRef); 5237aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, 5238aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor &ArgChanged)) 5239aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 5240aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 5241b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5242b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Callee.get() == E->getCallee() && 5243b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor !ArgChanged) 52443fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 52451eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5246b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // FIXME: Wrong source location information for the '('. 52471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation FakeLParenLoc 5248b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = ((Expr *)Callee.get())->getSourceRange().getBegin(); 52499ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc, 5250b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(Args), 5251b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 5252b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 52531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 525560d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5256454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) { 525760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base = getDerived().TransformExpr(E->getBase()); 5258b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Base.isInvalid()) 5259f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 52601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 526183f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor NestedNameSpecifier *Qualifier = 0; 526283f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor if (E->hasQualifier()) { 52631eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Qualifier 526483f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor = getDerived().TransformNestedNameSpecifier(E->getQualifier(), 5265edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor E->getQualifierRange()); 5266c4bf26fbdff42967d660f505a83f75a4df2cc752Douglas Gregor if (Qualifier == 0) 5267f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 526883f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor } 52691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5270f595cc41c4d95fe323f8a2b209523de9956f874dEli Friedman ValueDecl *Member 52717c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(), 52727c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getMemberDecl())); 5273b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!Member) 5274f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 52751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 52766bb8017bb9e828d118e15e59d71c66bba323c364John McCall NamedDecl *FoundDecl = E->getFoundDecl(); 52776bb8017bb9e828d118e15e59d71c66bba323c364John McCall if (FoundDecl == E->getMemberDecl()) { 52786bb8017bb9e828d118e15e59d71c66bba323c364John McCall FoundDecl = Member; 52796bb8017bb9e828d118e15e59d71c66bba323c364John McCall } else { 52806bb8017bb9e828d118e15e59d71c66bba323c364John McCall FoundDecl = cast_or_null<NamedDecl>( 52816bb8017bb9e828d118e15e59d71c66bba323c364John McCall getDerived().TransformDecl(E->getMemberLoc(), FoundDecl)); 52826bb8017bb9e828d118e15e59d71c66bba323c364John McCall if (!FoundDecl) 5283f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 52846bb8017bb9e828d118e15e59d71c66bba323c364John McCall } 52856bb8017bb9e828d118e15e59d71c66bba323c364John McCall 5286b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5287b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Base.get() == E->getBase() && 528883f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor Qualifier == E->getQualifier() && 52898a4386b3634065b96d08f94736bc1f953e385f50Douglas Gregor Member == E->getMemberDecl() && 52906bb8017bb9e828d118e15e59d71c66bba323c364John McCall FoundDecl == E->getFoundDecl() && 5291096832c5ed5b9106fa177ebc148489760c3bc496John McCall !E->hasExplicitTemplateArgs()) { 5292c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 52931f24032ea28d0df9d6227e4faf89306dfa990994Anders Carlsson // Mark it referenced in the new context regardless. 52941f24032ea28d0df9d6227e4faf89306dfa990994Anders Carlsson // FIXME: this is a bit instantiation-specific. 52951f24032ea28d0df9d6227e4faf89306dfa990994Anders Carlsson SemaRef.MarkDeclarationReferenced(E->getMemberLoc(), Member); 52963fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 52971f24032ea28d0df9d6227e4faf89306dfa990994Anders Carlsson } 5298b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 5299d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall TemplateArgumentListInfo TransArgs; 5300096832c5ed5b9106fa177ebc148489760c3bc496John McCall if (E->hasExplicitTemplateArgs()) { 5301d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall TransArgs.setLAngleLoc(E->getLAngleLoc()); 5302d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall TransArgs.setRAngleLoc(E->getRAngleLoc()); 5303fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), 5304fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor E->getNumTemplateArgs(), 5305fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor TransArgs)) 5306fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor return ExprError(); 53078a4386b3634065b96d08f94736bc1f953e385f50Douglas Gregor } 5308c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 5309b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // FIXME: Bogus source location for the operator 5310b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation FakeOperatorLoc 5311b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.PP.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd()); 5312b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 5313c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // FIXME: to do this check properly, we will need to preserve the 5314c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // first-qualifier-in-scope here, just in case we had a dependent 5315c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // base (and therefore couldn't do the check) and a 5316c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // nested-name-qualifier (and therefore could do the lookup). 5317c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall NamedDecl *FirstQualifierInScope = 0; 5318c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall 53199ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc, 5320b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->isArrow(), 532183f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor Qualifier, 532283f6faf37d9bf58986bedc9bc0ea897a56b4dbadDouglas Gregor E->getQualifierRange(), 53232577743c5650c646fb705df01403707e94f2df04Abramo Bagnara E->getMemberNameInfo(), 53248a4386b3634065b96d08f94736bc1f953e385f50Douglas Gregor Member, 53256bb8017bb9e828d118e15e59d71c66bba323c364John McCall FoundDecl, 5326096832c5ed5b9106fa177ebc148489760c3bc496John McCall (E->hasExplicitTemplateArgs() 5327d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall ? &TransArgs : 0), 5328c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall FirstQualifierInScope); 5329b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 53301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5331b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 533260d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5333454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) { 533460d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult LHS = getDerived().TransformExpr(E->getLHS()); 5335b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (LHS.isInvalid()) 5336f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 53371eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 533860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RHS = getDerived().TransformExpr(E->getRHS()); 5339b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (RHS.isInvalid()) 5340f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 53411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5342b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5343b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LHS.get() == E->getLHS() && 5344b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RHS.get() == E->getRHS()) 53453fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 53461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5347b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(), 53489ae2f076ca5ab1feb3ba95629099ec2319833701John McCall LHS.get(), RHS.get()); 5349b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 5350b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 53511eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 535260d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5353b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformCompoundAssignOperator( 5354454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall CompoundAssignOperator *E) { 5355454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall return getDerived().TransformBinaryOperator(E); 5356b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 53571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5358b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 535960d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5360454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) { 536160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond = getDerived().TransformExpr(E->getCond()); 5362b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Cond.isInvalid()) 5363f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 53641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 536560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult LHS = getDerived().TransformExpr(E->getLHS()); 5366b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (LHS.isInvalid()) 5367f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 53681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 536960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RHS = getDerived().TransformExpr(E->getRHS()); 5370b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (RHS.isInvalid()) 5371f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 53721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5373b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5374b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Cond.get() == E->getCond() && 5375b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LHS.get() == E->getLHS() && 5376b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RHS.get() == E->getRHS()) 53773fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 53781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 53799ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildConditionalOperator(Cond.get(), 538047e1f7c68bf375cac470fdb2b599ddbb395aeb52Douglas Gregor E->getQuestionLoc(), 53819ae2f076ca5ab1feb3ba95629099ec2319833701John McCall LHS.get(), 538247e1f7c68bf375cac470fdb2b599ddbb395aeb52Douglas Gregor E->getColonLoc(), 53839ae2f076ca5ab1feb3ba95629099ec2319833701John McCall RHS.get()); 5384b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 53851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 53861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 538760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5388454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) { 5389a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor // Implicit casts are eliminated during transformation, since they 5390a88cfbfac9bbcbb9858f048d6d73a48711d8e93dDouglas Gregor // will be recomputed by semantic analysis after transformation. 53916eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor return getDerived().TransformExpr(E->getSubExprAsWritten()); 5392b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 53931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5394b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 539560d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5396454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) { 5397ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten()); 5398ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor if (!Type) 5399ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor return ExprError(); 5400ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor 540160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr 54026eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor = getDerived().TransformExpr(E->getSubExprAsWritten()); 5403b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5404f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 54051eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5406b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5407ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor Type == E->getTypeInfoAsWritten() && 5408b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr.get() == E->getSubExpr()) 54093fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 54101eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 54119d125033a9853f3b572a4c9e2f9e2d4e5e346973John McCall return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(), 5412ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor Type, 5413b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc(), 54149ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr.get()); 5415b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 54161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5417b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 541860d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5419454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) { 542042f56b50062cd3b3c6b23fdb9053578ae9145664John McCall TypeSourceInfo *OldT = E->getTypeSourceInfo(); 542142f56b50062cd3b3c6b23fdb9053578ae9145664John McCall TypeSourceInfo *NewT = getDerived().TransformType(OldT); 542242f56b50062cd3b3c6b23fdb9053578ae9145664John McCall if (!NewT) 5423f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 54241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 542560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Init = getDerived().TransformExpr(E->getInitializer()); 5426b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Init.isInvalid()) 5427f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 54281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5429b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 543042f56b50062cd3b3c6b23fdb9053578ae9145664John McCall OldT == NewT && 5431b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Init.get() == E->getInitializer()) 54323fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5433b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 54341d7d8d66eff7ed0f3e957d330930cc9ab8047addJohn McCall // Note: the expression type doesn't necessarily match the 54351d7d8d66eff7ed0f3e957d330930cc9ab8047addJohn McCall // type-as-written, but that's okay, because it should always be 54361d7d8d66eff7ed0f3e957d330930cc9ab8047addJohn McCall // derivable from the initializer. 54371d7d8d66eff7ed0f3e957d330930cc9ab8047addJohn McCall 543842f56b50062cd3b3c6b23fdb9053578ae9145664John McCall return getDerived().RebuildCompoundLiteralExpr(E->getLParenLoc(), NewT, 5439b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /*FIXME:*/E->getInitializer()->getLocEnd(), 54409ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Init.get()); 5441b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 54421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5443b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 544460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5445454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) { 544660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base = getDerived().TransformExpr(E->getBase()); 5447b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Base.isInvalid()) 5448f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 54491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5450b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5451b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Base.get() == E->getBase()) 54523fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 54531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5454b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // FIXME: Bad source location 54551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation FakeOperatorLoc 5456b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.PP.getLocForEndOfToken(E->getBase()->getLocEnd()); 54579ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc, 5458b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getAccessorLoc(), 5459b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getAccessor()); 5460b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 54611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5462b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 546360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5464454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) { 5465b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool InitChanged = false; 54661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5467ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*, 4> Inits(SemaRef); 5468aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false, 5469aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Inits, &InitChanged)) 5470aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 5471aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 5472b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && !InitChanged) 54733fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 54741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5475b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildInitList(E->getLBraceLoc(), move_arg(Inits), 5476e48319a8a901bc915d48d02b99c62e5f2589dbd9Douglas Gregor E->getRBraceLoc(), E->getType()); 5477b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 54781eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5479b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 548060d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5481454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) { 5482b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Designation Desig; 54831eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 548443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // transform the initializer value 548560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Init = getDerived().TransformExpr(E->getInit()); 5486b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Init.isInvalid()) 5487f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 54881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 548943959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // transform the designators. 5490ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*, 4> ArrayExprs(SemaRef); 5491b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ExprChanged = false; 5492b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor for (DesignatedInitExpr::designators_iterator D = E->designators_begin(), 5493b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor DEnd = E->designators_end(); 5494b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor D != DEnd; ++D) { 5495b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (D->isFieldDesignator()) { 5496b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Desig.AddDesignator(Designator::getField(D->getFieldName(), 5497b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor D->getDotLoc(), 5498b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor D->getFieldLoc())); 5499b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor continue; 5500b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 55011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5502b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (D->isArrayDesignator()) { 550360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(*D)); 5504b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Index.isInvalid()) 5505f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 55061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 55071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Desig.AddDesignator(Designator::getArray(Index.get(), 5508b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor D->getLBracketLoc())); 55091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5510b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(*D); 5511b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ArrayExprs.push_back(Index.release()); 5512b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor continue; 5513b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 55141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5515b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor assert(D->isArrayRangeDesignator() && "New kind of designator?"); 551660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Start 5517b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = getDerived().TransformExpr(E->getArrayRangeStart(*D)); 5518b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Start.isInvalid()) 5519f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 55201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 552160d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(*D)); 5522b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (End.isInvalid()) 5523f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 55241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 55251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump Desig.AddDesignator(Designator::getArrayRange(Start.get(), 5526b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor End.get(), 5527b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor D->getLBracketLoc(), 5528b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor D->getEllipsisLoc())); 55291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5530b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(*D) || 5531b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor End.get() != E->getArrayRangeEnd(*D); 55321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5533b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ArrayExprs.push_back(Start.release()); 5534b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ArrayExprs.push_back(End.release()); 5535b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 55361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5537b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5538b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Init.get() == E->getInit() && 5539b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor !ExprChanged) 55403fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 55411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5542b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildDesignatedInitExpr(Desig, move_arg(ArrayExprs), 5543b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getEqualOrColonLoc(), 55449ae2f076ca5ab1feb3ba95629099ec2319833701John McCall E->usesGNUSyntax(), Init.get()); 5545b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 55461eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5547b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 554860d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5549b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformImplicitValueInitExpr( 5550454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall ImplicitValueInitExpr *E) { 55515557b25bdbd63536f687ebb63a0bab55aa227626Douglas Gregor TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName()); 5552c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 55535557b25bdbd63536f687ebb63a0bab55aa227626Douglas Gregor // FIXME: Will we ever have proper type location here? Will we actually 55545557b25bdbd63536f687ebb63a0bab55aa227626Douglas Gregor // need to transform the type? 5555b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor QualType T = getDerived().TransformType(E->getType()); 5556b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (T.isNull()) 5557f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 55581eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5559b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5560b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor T == E->getType()) 55613fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 55621eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5563b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildImplicitValueInitExpr(T); 5564b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 55651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5566b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 556760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5568454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) { 55699bcd4d4a4b9281ba3526b0e86e6d422db93a9074Douglas Gregor TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo()); 55709bcd4d4a4b9281ba3526b0e86e6d422db93a9074Douglas Gregor if (!TInfo) 5571f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 55721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 557360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); 5574b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5575f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 55761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5577b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 55782cad900202561cdda18ea6cc51ddbf3e20e3c23aAbramo Bagnara TInfo == E->getWrittenTypeInfo() && 5579b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr.get() == E->getSubExpr()) 55803fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 55811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 55829ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(), 55832cad900202561cdda18ea6cc51ddbf3e20e3c23aAbramo Bagnara TInfo, E->getRParenLoc()); 5584b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 5585b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 5586b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 558760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5588454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) { 5589b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgumentChanged = false; 5590ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*, 4> Inits(SemaRef); 5591aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits, 5592aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor &ArgumentChanged)) 5593aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 5594aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 5595b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildParenListExpr(E->getLParenLoc(), 5596b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(Inits), 5597b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 5598b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 55991eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5600b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// \brief Transform an address-of-label expression. 5601b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// 5602b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// By default, the transformation of an address-of-label expression always 5603b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// rebuilds the expression, so that the label identifier can be resolved to 5604b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// the corresponding label statement by semantic analysis. 5605b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 560660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5607454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) { 5608b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(), 5609b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLabel()); 5610b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 56111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 56121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 561360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5614454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) { 561560d7b3a319d84d688752be3870615ac0f111fb16John McCall StmtResult SubStmt 5616b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = getDerived().TransformCompoundStmt(E->getSubStmt(), true); 5617b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubStmt.isInvalid()) 5618f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 56191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5620b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5621b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubStmt.get() == E->getSubStmt()) 56223fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 56231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 56241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildStmtExpr(E->getLParenLoc(), 56259ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubStmt.get(), 5626b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 5627b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 56281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5629b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 563060d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5631454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) { 563260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Cond = getDerived().TransformExpr(E->getCond()); 5633b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Cond.isInvalid()) 5634f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 56351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 563660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult LHS = getDerived().TransformExpr(E->getLHS()); 5637b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (LHS.isInvalid()) 5638f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 56391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 564060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult RHS = getDerived().TransformExpr(E->getRHS()); 5641b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (RHS.isInvalid()) 5642f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 56431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5644b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5645b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Cond.get() == E->getCond() && 5646b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor LHS.get() == E->getLHS() && 5647b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor RHS.get() == E->getRHS()) 56483fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 56491eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5650b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildChooseExpr(E->getBuiltinLoc(), 56519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Cond.get(), LHS.get(), RHS.get(), 5652b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 5653b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 56541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5655b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 565660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5657454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) { 56583fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5659b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 5660b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 5661b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 566260d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5663454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) { 5664668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor switch (E->getOperator()) { 5665668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_New: 5666668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_Delete: 5667668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_Array_New: 5668668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_Array_Delete: 5669668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr"); 5670f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5671c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 5672668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_Call: { 5673668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor // This is a call to an object's operator(). 5674668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor assert(E->getNumArgs() >= 1 && "Object call is missing arguments"); 5675668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 5676668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor // Transform the object itself. 567760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Object = getDerived().TransformExpr(E->getArg(0)); 5678668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor if (Object.isInvalid()) 5679f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5680668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 5681668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor // FIXME: Poor location information 5682668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor SourceLocation FakeLParenLoc 5683668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor = SemaRef.PP.getLocForEndOfToken( 5684668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor static_cast<Expr *>(Object.get())->getLocEnd()); 5685668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 5686668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor // Transform the call arguments. 5687ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Args(SemaRef); 5688aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true, 5689aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Args)) 5690aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 5691668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 56929ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc, 5693668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor move_arg(Args), 5694668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor E->getLocEnd()); 5695668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor } 5696668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 5697668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \ 5698668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_##Name: 5699668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly) 5700668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor#include "clang/Basic/OperatorKinds.def" 5701668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_Subscript: 5702668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor // Handled below. 5703668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor break; 5704668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 5705668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_Conditional: 5706668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor llvm_unreachable("conditional operator is not actually overloadable"); 5707f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5708668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 5709668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case OO_None: 5710668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor case NUM_OVERLOADED_OPERATORS: 5711668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor llvm_unreachable("not an overloaded operator?"); 5712f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5713668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor } 5714668d6d9dc100b3ef28a9b8e6fe987c2f5b6edcc9Douglas Gregor 571560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Callee = getDerived().TransformExpr(E->getCallee()); 5716b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Callee.isInvalid()) 5717f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 57181eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 571960d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult First = getDerived().TransformExpr(E->getArg(0)); 5720b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (First.isInvalid()) 5721f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5722b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 572360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Second; 5724b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (E->getNumArgs() == 2) { 5725b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Second = getDerived().TransformExpr(E->getArg(1)); 5726b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Second.isInvalid()) 5727f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5728b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 57291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5730b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5731b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Callee.get() == E->getCallee() && 5732b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor First.get() == E->getArg(0) && 57331eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump (E->getNumArgs() != 2 || Second.get() == E->getArg(1))) 57343fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 57351eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5736b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(), 5737b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getOperatorLoc(), 57389ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Callee.get(), 57399ae2f076ca5ab1feb3ba95629099ec2319833701John McCall First.get(), 57409ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Second.get()); 5741b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 57421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5743b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 574460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5745454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) { 5746454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall return getDerived().TransformCallExpr(E); 5747b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 57481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5749b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 575060d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5751454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) { 5752ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten()); 5753ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor if (!Type) 5754ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor return ExprError(); 5755ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor 575660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr 57576eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor = getDerived().TransformExpr(E->getSubExprAsWritten()); 5758b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5759f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 57601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5761b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5762ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor Type == E->getTypeInfoAsWritten() && 5763b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr.get() == E->getSubExpr()) 57643fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 57651eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5766b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // FIXME: Poor source location information here. 57671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SourceLocation FakeLAngleLoc 5768b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.PP.getLocForEndOfToken(E->getOperatorLoc()); 5769b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation FakeRAngleLoc = E->getSubExpr()->getSourceRange().getBegin(); 5770b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation FakeRParenLoc 5771b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.PP.getLocForEndOfToken( 5772b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getSubExpr()->getSourceRange().getEnd()); 5773b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildCXXNamedCastExpr(E->getOperatorLoc(), 57741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump E->getStmtClass(), 5775b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor FakeLAngleLoc, 5776ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor Type, 5777b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor FakeRAngleLoc, 5778b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor FakeRAngleLoc, 57799ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr.get(), 5780b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor FakeRParenLoc); 5781b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 57821eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5783b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 578460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5785454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) { 5786454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall return getDerived().TransformCXXNamedCastExpr(E); 5787b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 57881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5789b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 579060d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5791454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) { 5792454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall return getDerived().TransformCXXNamedCastExpr(E); 5793b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 57941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5795b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 579660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5797b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformCXXReinterpretCastExpr( 5798454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall CXXReinterpretCastExpr *E) { 5799454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall return getDerived().TransformCXXNamedCastExpr(E); 5800b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 58011eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5802b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 580360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5804454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) { 5805454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall return getDerived().TransformCXXNamedCastExpr(E); 5806b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 58071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5808b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 580960d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5810b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformCXXFunctionalCastExpr( 5811454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall CXXFunctionalCastExpr *E) { 5812ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten()); 5813ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor if (!Type) 5814ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor return ExprError(); 58151eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 581660d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr 58176eef519fc8a97bb7ca6066f23d35e10f06b2c1b5Douglas Gregor = getDerived().TransformExpr(E->getSubExprAsWritten()); 5818b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5819f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 58201eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5821b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5822ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor Type == E->getTypeInfoAsWritten() && 5823b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr.get() == E->getSubExpr()) 58243fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 58251eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5826ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor return getDerived().RebuildCXXFunctionalCastExpr(Type, 5827b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /*FIXME:*/E->getSubExpr()->getLocStart(), 58289ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr.get(), 5829b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 5830b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 58311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5832b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 583360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5834454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) { 5835b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (E->isTypeOperand()) { 583657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TypeSourceInfo *TInfo 583757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor = getDerived().TransformType(E->getTypeOperandSourceInfo()); 583857fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor if (!TInfo) 5839f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 58401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5841b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 584257fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TInfo == E->getTypeOperandSourceInfo()) 58433fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 58441eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 584557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return getDerived().RebuildCXXTypeidExpr(E->getType(), 584657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor E->getLocStart(), 584757fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor TInfo, 5848b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLocEnd()); 5849b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 58501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5851b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // We don't know whether the expression is potentially evaluated until 5852b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // after we perform semantic analysis, so the expression is potentially 5853b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // potentially evaluated. 58541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump EnterExpressionEvaluationContext Unevaluated(SemaRef, 5855f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall Sema::PotentiallyPotentiallyEvaluated); 58561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 585760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand()); 5858b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5859f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 58601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5861b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5862b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr.get() == E->getExprOperand()) 58633fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 58641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 586557fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor return getDerived().RebuildCXXTypeidExpr(E->getType(), 586657fdc8a4382164955c7b30d09f4ce46fc7e67659Douglas Gregor E->getLocStart(), 58679ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SubExpr.get(), 5868b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLocEnd()); 5869b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 5870b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 5871b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 587260d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 587301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois PichetTreeTransform<Derived>::TransformCXXUuidofExpr(CXXUuidofExpr *E) { 587401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (E->isTypeOperand()) { 587501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TypeSourceInfo *TInfo 587601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet = getDerived().TransformType(E->getTypeOperandSourceInfo()); 587701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (!TInfo) 587801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return ExprError(); 587901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 588001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (!getDerived().AlwaysRebuild() && 588101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TInfo == E->getTypeOperandSourceInfo()) 58823fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 588301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 588401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return getDerived().RebuildCXXTypeidExpr(E->getType(), 588501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet E->getLocStart(), 588601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet TInfo, 588701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet E->getLocEnd()); 588801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet } 588901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 589001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // We don't know whether the expression is potentially evaluated until 589101b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // after we perform semantic analysis, so the expression is potentially 589201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet // potentially evaluated. 589301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated); 589401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 589501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand()); 589601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (SubExpr.isInvalid()) 589701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return ExprError(); 589801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 589901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet if (!getDerived().AlwaysRebuild() && 590001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SubExpr.get() == E->getExprOperand()) 59013fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 590201b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 590301b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet return getDerived().RebuildCXXUuidofExpr(E->getType(), 590401b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet E->getLocStart(), 590501b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet SubExpr.get(), 590601b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet E->getLocEnd()); 590701b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet} 590801b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichet 590901b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois Pichettemplate<typename Derived> 591001b7c3028da5bbcb9f8e52ba67e4613070de0e60Francois PichetExprResult 5911454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) { 59123fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5913b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 59141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5915b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 591660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5917b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformCXXNullPtrLiteralExpr( 5918454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall CXXNullPtrLiteralExpr *E) { 59193fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5920b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 59211eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5922b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 592360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5924454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) { 5925ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor DeclContext *DC = getSema().getFunctionLevelDeclContext(); 5926ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC); 5927ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor QualType T = MD->getThisType(getSema().Context); 59281eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5929ba48d6aad11a684d8557b25831764a61a37f65a2Douglas Gregor if (!getDerived().AlwaysRebuild() && T == E->getType()) 59303fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 59311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5932828a197317288e3333b0ce6f5cedadd036e3531fDouglas Gregor return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit()); 5933b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 59341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5935b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 593660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5937454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) { 593860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr()); 5939b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (SubExpr.isInvalid()) 5940f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 59411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5942b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5943b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SubExpr.get() == E->getSubExpr()) 59443fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 5945b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 59469ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get()); 5947b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 59481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5949b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 595060d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5951454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) { 59521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump ParmVarDecl *Param 59537c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor = cast_or_null<ParmVarDecl>(getDerived().TransformDecl(E->getLocStart(), 59547c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getParam())); 5955b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!Param) 5956f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 59571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 595853cb6f82c41397917b14fb8cdcb32e6c9bd07655Chandler Carruth if (!getDerived().AlwaysRebuild() && 5959b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Param == E->getParam()) 59603fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 59611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5962036aed18662e0193aafe0e8ae13d2e57efe6df25Douglas Gregor return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param); 5963b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 59641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5965b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 596660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5967ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas GregorTreeTransform<Derived>::TransformCXXScalarValueInitExpr( 5968ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXScalarValueInitExpr *E) { 5969ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo()); 5970ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor if (!T) 5971f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 5972ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 5973b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 5974ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor T == E->getTypeSourceInfo()) 59753fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 59761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5977ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getDerived().RebuildCXXScalarValueInitExpr(T, 5978ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /*FIXME:*/T->getTypeLoc().getEndLoc(), 5979ed8abf18329df67b0abcbb3a10458bd8c1d2a595Douglas Gregor E->getRParenLoc()); 5980b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 59811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5982b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 598360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 5984454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) { 5985b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Transform the type that we're allocating 59861bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor TypeSourceInfo *AllocTypeInfo 59871bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor = getDerived().TransformType(E->getAllocatedTypeSourceInfo()); 59881bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor if (!AllocTypeInfo) 5989f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 59901eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5991b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Transform the size of the array we're allocating (if any). 599260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult ArraySize = getDerived().TransformExpr(E->getArraySize()); 5993b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (ArraySize.isInvalid()) 5994f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 59951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 5996b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Transform the placement arguments (if any). 5997b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgumentChanged = false; 5998ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> PlacementArgs(SemaRef); 5999aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getPlacementArgs(), 6000aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor E->getNumPlacementArgs(), true, 6001aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor PlacementArgs, &ArgumentChanged)) 6002aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 60031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 600443959a93c6aba8b03b09116fe077f4ce8e80005eDouglas Gregor // transform the constructor arguments (if any). 6005ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> ConstructorArgs(SemaRef); 6006aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (TransformExprs(E->getConstructorArgs(), E->getNumConstructorArgs(), true, 6007aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor ConstructorArgs, &ArgumentChanged)) 6008aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 60091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 60101af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // Transform constructor, new operator, and delete operator. 60111af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor CXXConstructorDecl *Constructor = 0; 60121af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (E->getConstructor()) { 60131af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor Constructor = cast_or_null<CXXConstructorDecl>( 60147c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(E->getLocStart(), 60157c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getConstructor())); 60161af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (!Constructor) 6017f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 60181af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor } 60191af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor 60201af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor FunctionDecl *OperatorNew = 0; 60211af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (E->getOperatorNew()) { 60221af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor OperatorNew = cast_or_null<FunctionDecl>( 60237c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(E->getLocStart(), 60247c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getOperatorNew())); 60251af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (!OperatorNew) 6026f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 60271af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor } 60281af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor 60291af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor FunctionDecl *OperatorDelete = 0; 60301af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (E->getOperatorDelete()) { 60311af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor OperatorDelete = cast_or_null<FunctionDecl>( 60327c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(E->getLocStart(), 60337c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getOperatorDelete())); 60341af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (!OperatorDelete) 6035f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 60361af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor } 6037c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6038b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 60391bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor AllocTypeInfo == E->getAllocatedTypeSourceInfo() && 6040b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor ArraySize.get() == E->getArraySize() && 60411af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor Constructor == E->getConstructor() && 60421af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor OperatorNew == E->getOperatorNew() && 60431af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor OperatorDelete == E->getOperatorDelete() && 60441af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor !ArgumentChanged) { 60451af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // Mark any declarations we need as referenced. 60461af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // FIXME: instantiation-specific. 60471af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (Constructor) 60481af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor); 60491af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (OperatorNew) 60501af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorNew); 60511af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (OperatorDelete) 60521af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorDelete); 60533fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 60541af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor } 60551eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 60561bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor QualType AllocType = AllocTypeInfo->getType(); 60575b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor if (!ArraySize.get()) { 60585b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor // If no array size was specified, but the new expression was 60595b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor // instantiated with an array type (e.g., "new T" where T is 60605b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor // instantiated with "int[4]"), extract the outer bound from the 60615b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor // array type as our array size. We do this with constant and 60625b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor // dependently-sized array types. 60635b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType); 60645b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor if (!ArrayT) { 60655b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor // Do nothing 60665b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor } else if (const ConstantArrayType *ConsArrayT 60675b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor = dyn_cast<ConstantArrayType>(ArrayT)) { 6068c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt ArraySize 60699996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis = SemaRef.Owned(IntegerLiteral::Create(SemaRef.Context, 60709996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis ConsArrayT->getSize(), 60719996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis SemaRef.Context.getSizeType(), 60729996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis /*FIXME:*/E->getLocStart())); 60735b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor AllocType = ConsArrayT->getElementType(); 60745b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor } else if (const DependentSizedArrayType *DepArrayT 60755b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor = dyn_cast<DependentSizedArrayType>(ArrayT)) { 60765b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor if (DepArrayT->getSizeExpr()) { 60773fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall ArraySize = SemaRef.Owned(DepArrayT->getSizeExpr()); 60785b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor AllocType = DepArrayT->getElementType(); 60795b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor } 60805b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor } 60815b5ad8453c8e79f642c3ddfeeadf162ae67309c0Douglas Gregor } 60821bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor 6083b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildCXXNewExpr(E->getLocStart(), 6084b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->isGlobalNew(), 6085b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /*FIXME:*/E->getLocStart(), 6086b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(PlacementArgs), 6087b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /*FIXME:*/E->getLocStart(), 60884bd40318cbea15310a37343db46de96c4fcc15e6Douglas Gregor E->getTypeIdParens(), 6089b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor AllocType, 60901bb2a93ab7b1499dda6f6b58865bd0dce1864228Douglas Gregor AllocTypeInfo, 60919ae2f076ca5ab1feb3ba95629099ec2319833701John McCall ArraySize.get(), 6092b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor /*FIXME:*/E->getLocStart(), 6093b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(ConstructorArgs), 60941eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump E->getLocEnd()); 6095b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 60961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6097b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 609860d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6099454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) { 610060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Operand = getDerived().TransformExpr(E->getArgument()); 6101b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Operand.isInvalid()) 6102f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 61031eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 61041af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // Transform the delete operator, if known. 61051af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor FunctionDecl *OperatorDelete = 0; 61061af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (E->getOperatorDelete()) { 61071af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor OperatorDelete = cast_or_null<FunctionDecl>( 61087c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(E->getLocStart(), 61097c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getOperatorDelete())); 61101af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (!OperatorDelete) 6111f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 61121af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor } 6113c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6114b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 61151af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor Operand.get() == E->getArgument() && 61161af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor OperatorDelete == E->getOperatorDelete()) { 61171af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // Mark any declarations we need as referenced. 61181af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // FIXME: instantiation-specific. 61191af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor if (OperatorDelete) 61201af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorDelete); 61215833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor 61225833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor if (!E->getArgument()->isTypeDependent()) { 61235833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor QualType Destroyed = SemaRef.Context.getBaseElementType( 61245833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor E->getDestroyedType()); 61255833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) { 61265833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl()); 61275833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), 61285833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor SemaRef.LookupDestructor(Record)); 61295833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor } 61305833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor } 61315833b0b831d6afae2885e6af420e2bda639652e6Douglas Gregor 61323fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 61331af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor } 61341eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6135b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildCXXDeleteExpr(E->getLocStart(), 6136b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->isGlobalDelete(), 6137b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->isArrayForm(), 61389ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Operand.get()); 6139b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 61401eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6141b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 614260d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6143a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas GregorTreeTransform<Derived>::TransformCXXPseudoDestructorExpr( 6144454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall CXXPseudoDestructorExpr *E) { 614560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base = getDerived().TransformExpr(E->getBase()); 6146a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor if (Base.isInvalid()) 6147f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 61481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6149b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectTypePtr; 6150a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor bool MayBePseudoDestructor = false; 61519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(), 6152a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor E->getOperatorLoc(), 6153a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor E->isArrow()? tok::arrow : tok::period, 6154a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor ObjectTypePtr, 6155a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor MayBePseudoDestructor); 6156a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor if (Base.isInvalid()) 6157f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6158c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6159b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall QualType ObjectType = ObjectTypePtr.get(); 616043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NestedNameSpecifier *Qualifier = E->getQualifier(); 616143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (Qualifier) { 616243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall Qualifier 616343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall = getDerived().TransformNestedNameSpecifier(E->getQualifier(), 616443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall E->getQualifierRange(), 616543fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType); 616643fed0de4f5bc189e45562491f83d5193eb8dac0John McCall if (!Qualifier) 616743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return ExprError(); 616843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall } 61691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6170a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage Destroyed; 6171a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor if (E->getDestroyedTypeInfo()) { 6172a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *DestroyedTypeInfo 617343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(), 617443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ObjectType, 0, Qualifier); 6175a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor if (!DestroyedTypeInfo) 6176f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6177a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor Destroyed = DestroyedTypeInfo; 6178a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } else if (ObjectType->isDependentType()) { 6179a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor // We aren't likely to be able to resolve the identifier down to a type 6180a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor // now anyway, so just retain the identifier. 6181a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(), 6182a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor E->getDestroyedTypeLoc()); 6183a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } else { 6184a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor // Look for a destructor known with the given name. 6185a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor CXXScopeSpec SS; 6186a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor if (Qualifier) { 6187a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SS.setScopeRep(Qualifier); 6188a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SS.setRange(E->getQualifierRange()); 6189a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 6190c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6191b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(), 6192a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor *E->getDestroyedTypeIdentifier(), 6193a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor E->getDestroyedTypeLoc(), 6194a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor /*Scope=*/0, 6195a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor SS, ObjectTypePtr, 6196a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor false); 6197a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor if (!T) 6198f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6199c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6200a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor Destroyed 6201a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T), 6202a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor E->getDestroyedTypeLoc()); 6203a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor } 620426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor 620526d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *ScopeTypeInfo = 0; 620626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor if (E->getScopeTypeInfo()) { 620743fed0de4f5bc189e45562491f83d5193eb8dac0John McCall ScopeTypeInfo = getDerived().TransformType(E->getScopeTypeInfo()); 620826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor if (!ScopeTypeInfo) 6209f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6210a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor } 6211c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 62129ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(), 6213a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor E->getOperatorLoc(), 6214a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor E->isArrow(), 6215a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor Qualifier, 621626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor E->getQualifierRange(), 621726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor ScopeTypeInfo, 621826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor E->getColonColonLoc(), 6219fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor E->getTildeLoc(), 6220a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor Destroyed); 6221a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregor} 62221eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6223a71d819bb8f50c28938db0f2867d3fb6e2ce5910Douglas Gregortemplate<typename Derived> 622460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6225ba13543329afac4a0d01304ec2ec4924d99306a6John McCallTreeTransform<Derived>::TransformUnresolvedLookupExpr( 6226454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall UnresolvedLookupExpr *Old) { 6227f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemporaryBase Rebase(*this, Old->getNameLoc(), DeclarationName()); 6228f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6229f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(), 6230f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Sema::LookupOrdinaryName); 6231f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6232f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Transform all the decls. 6233f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall for (UnresolvedLookupExpr::decls_iterator I = Old->decls_begin(), 6234f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall E = Old->decls_end(); I != E; ++I) { 62357c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor NamedDecl *InstD = static_cast<NamedDecl*>( 62367c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(Old->getNameLoc(), 62377c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor *I)); 62389f54ad4381370c6b771424b53d219e661d6d6706John McCall if (!InstD) { 62399f54ad4381370c6b771424b53d219e661d6d6706John McCall // Silently ignore these if a UsingShadowDecl instantiated to nothing. 62409f54ad4381370c6b771424b53d219e661d6d6706John McCall // This can happen because of dependent hiding. 62419f54ad4381370c6b771424b53d219e661d6d6706John McCall if (isa<UsingShadowDecl>(*I)) 62429f54ad4381370c6b771424b53d219e661d6d6706John McCall continue; 62439f54ad4381370c6b771424b53d219e661d6d6706John McCall else 6244f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 62459f54ad4381370c6b771424b53d219e661d6d6706John McCall } 6246f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6247f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Expand using declarations. 6248f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (isa<UsingDecl>(InstD)) { 6249f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall UsingDecl *UD = cast<UsingDecl>(InstD); 6250f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall for (UsingDecl::shadow_iterator I = UD->shadow_begin(), 6251f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall E = UD->shadow_end(); I != E; ++I) 6252f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall R.addDecl(*I); 6253f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall continue; 6254f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 6255f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6256f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall R.addDecl(InstD); 6257f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 6258f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6259f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Resolve a kind, but don't do any further analysis. If it's 6260f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // ambiguous, the callee needs to deal with it. 6261f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall R.resolveKind(); 6262f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6263f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // Rebuild the nested-name qualifier, if present. 6264f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall CXXScopeSpec SS; 6265f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NestedNameSpecifier *Qualifier = 0; 6266f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (Old->getQualifier()) { 6267f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall Qualifier = getDerived().TransformNestedNameSpecifier(Old->getQualifier(), 6268edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor Old->getQualifierRange()); 6269f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (!Qualifier) 6270f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6271c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6272f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SS.setScopeRep(Qualifier); 6273f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall SS.setRange(Old->getQualifierRange()); 6274c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt } 6275c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6276c96be1ea33cdf63d07cec48d18fe8e3afea48f8dDouglas Gregor if (Old->getNamingClass()) { 627766c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor CXXRecordDecl *NamingClass 627866c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl( 627966c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor Old->getNameLoc(), 628066c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor Old->getNamingClass())); 628166c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor if (!NamingClass) 6282f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6283c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 628466c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor R.setNamingClass(NamingClass); 6285f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall } 6286f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6287f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // If we have no template arguments, it's a normal declaration name. 6288f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (!Old->hasExplicitTemplateArgs()) 6289f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL()); 6290f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6291f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // If we have template arguments, rebuild them, then rebuild the 6292f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall // templateid expression. 6293f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc()); 6294fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(), 6295fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor Old->getNumTemplateArgs(), 6296fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor TransArgs)) 6297fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor return ExprError(); 6298f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall 6299f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getDerived().RebuildTemplateIdExpr(SS, R, Old->requiresADL(), 6300f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall TransArgs); 6301b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 63021eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6303b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 630460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6305454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) { 63063d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo()); 63073d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor if (!T) 6308f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 63091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6310b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 63113d37c0ada0e46b87be0a10e8d52d990a97d3907aDouglas Gregor T == E->getQueriedTypeSourceInfo()) 63123fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 63131eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 63141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildUnaryTypeTrait(E->getTrait(), 6315b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLocStart(), 6316b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor T, 6317b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLocEnd()); 6318b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 63191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6320b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 632160d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 63226ad6f2848d7652ab2991286eb48be440d3493b28Francois PichetTreeTransform<Derived>::TransformBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) { 63236ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *LhsT = getDerived().TransformType(E->getLhsTypeSourceInfo()); 63246ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet if (!LhsT) 63256ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return ExprError(); 63266ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 63276ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet TypeSourceInfo *RhsT = getDerived().TransformType(E->getRhsTypeSourceInfo()); 63286ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet if (!RhsT) 63296ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return ExprError(); 63306ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 63316ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet if (!getDerived().AlwaysRebuild() && 63326ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet LhsT == E->getLhsTypeSourceInfo() && RhsT == E->getRhsTypeSourceInfo()) 63336ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return SemaRef.Owned(E); 63346ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 63356ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet return getDerived().RebuildBinaryTypeTrait(E->getTrait(), 63366ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet E->getLocStart(), 63376ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet LhsT, RhsT, 63386ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet E->getLocEnd()); 63396ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet} 63406ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichet 63416ad6f2848d7652ab2991286eb48be440d3493b28Francois Pichettemplate<typename Derived> 63426ad6f2848d7652ab2991286eb48be440d3493b28Francois PichetExprResult 6343865d447ac6a4721ab58e898d014a21f2eff74b06John McCallTreeTransform<Derived>::TransformDependentScopeDeclRefExpr( 63442577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DependentScopeDeclRefExpr *E) { 6345b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor NestedNameSpecifier *NNS 6346f17bb74e74aca9bb0525d2249041ab65c7d1fd48Douglas Gregor = getDerived().TransformNestedNameSpecifier(E->getQualifier(), 6347edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor E->getQualifierRange()); 6348b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!NNS) 6349f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 63501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 635143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // TODO: If this is a conversion-function-id, verify that the 635243fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // destination type name (if present) resolves the same way after 635343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // instantiation as it did in the local scope. 635443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 63552577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo 63562577743c5650c646fb705df01403707e94f2df04Abramo Bagnara = getDerived().TransformDeclarationNameInfo(E->getNameInfo()); 63572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara if (!NameInfo.getName()) 6358f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 63591eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6360f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (!E->hasExplicitTemplateArgs()) { 6361f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall if (!getDerived().AlwaysRebuild() && 6362f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall NNS == E->getQualifier() && 63632577743c5650c646fb705df01403707e94f2df04Abramo Bagnara // Note: it is sufficient to compare the Name component of NameInfo: 63642577743c5650c646fb705df01403707e94f2df04Abramo Bagnara // if name has not changed, DNLoc has not changed either. 63652577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo.getName() == E->getDeclName()) 63663fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 63671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6368f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getDerived().RebuildDependentScopeDeclRefExpr(NNS, 6369f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall E->getQualifierRange(), 63702577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo, 6371f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall /*TemplateArgs*/ 0); 6372f17bb74e74aca9bb0525d2249041ab65c7d1fd48Douglas Gregor } 6373d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall 6374d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc()); 6375fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), 6376fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor E->getNumTemplateArgs(), 6377fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor TransArgs)) 6378fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor return ExprError(); 6379b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 6380f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall return getDerived().RebuildDependentScopeDeclRefExpr(NNS, 6381f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall E->getQualifierRange(), 63822577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo, 6383f7a1a744eba4b29ceb0f20af8f34515d892fdd64John McCall &TransArgs); 6384b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6385b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 6386b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 638760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6388454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) { 6389321725d95d331d1612ac386d7d4235eca94b0021Douglas Gregor // CXXConstructExprs are always implicit, so when we have a 6390321725d95d331d1612ac386d7d4235eca94b0021Douglas Gregor // 1-argument construction we just transform that argument. 6391321725d95d331d1612ac386d7d4235eca94b0021Douglas Gregor if (E->getNumArgs() == 1 || 6392321725d95d331d1612ac386d7d4235eca94b0021Douglas Gregor (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) 6393321725d95d331d1612ac386d7d4235eca94b0021Douglas Gregor return getDerived().TransformExpr(E->getArg(0)); 6394321725d95d331d1612ac386d7d4235eca94b0021Douglas Gregor 6395b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName()); 6396b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 6397b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor QualType T = getDerived().TransformType(E->getType()); 6398b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (T.isNull()) 6399f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6400b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 6401b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor CXXConstructorDecl *Constructor 6402b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = cast_or_null<CXXConstructorDecl>( 64037c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(E->getLocStart(), 64047c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getConstructor())); 6405b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!Constructor) 6406f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 64071eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6408b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgumentChanged = false; 6409ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Args(SemaRef); 6410aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, 6411aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor &ArgumentChanged)) 6412aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 6413aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 6414b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 6415b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor T == E->getType() && 6416b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Constructor == E->getConstructor() && 6417c845aad6f7d012ab0cd0a040515ab512d1a93566Douglas Gregor !ArgumentChanged) { 64181af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // Mark the constructor as referenced. 64191af745143eb3066660d8855c17ccec6b38f5d789Douglas Gregor // FIXME: Instantiation-specific 6420c845aad6f7d012ab0cd0a040515ab512d1a93566Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor); 64213fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6422c845aad6f7d012ab0cd0a040515ab512d1a93566Douglas Gregor } 64231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 64244411d2e674b0119f682ac472c3a377f14fa9fa30Douglas Gregor return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(), 64254411d2e674b0119f682ac472c3a377f14fa9fa30Douglas Gregor Constructor, E->isElidable(), 64268c3e554d00d456d5093c21ce8a0c205461279aabDouglas Gregor move_arg(Args), 64278c3e554d00d456d5093c21ce8a0c205461279aabDouglas Gregor E->requiresZeroInitialization(), 6428428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth E->getConstructionKind(), 6429428edafa9eb80e01dd40aab31d4166a787a741e1Chandler Carruth E->getParenRange()); 6430b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 64311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6432b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// \brief Transform a C++ temporary-binding expression. 6433b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// 64345132655e4296b780672e9a96b46a740135073534Douglas Gregor/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just 64355132655e4296b780672e9a96b46a740135073534Douglas Gregor/// transform the subexpression and return that. 6436b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 643760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6438454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) { 64395132655e4296b780672e9a96b46a740135073534Douglas Gregor return getDerived().TransformExpr(E->getSubExpr()); 6440b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 64411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 64424765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// \brief Transform a C++ expression that contains cleanups that should 64434765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// be run after the expression is evaluated. 6444b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor/// 64454765fa05b5652fcc4356371c2f481d0ea9a1b007John McCall/// Since ExprWithCleanups nodes are implicitly generated, we 64465132655e4296b780672e9a96b46a740135073534Douglas Gregor/// just transform the subexpression and return that. 6447b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 644860d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 64494765fa05b5652fcc4356371c2f481d0ea9a1b007John McCallTreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *E) { 64505132655e4296b780672e9a96b46a740135073534Douglas Gregor return getDerived().TransformExpr(E->getSubExpr()); 6451b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 64521eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6453b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 645460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6455b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformCXXTemporaryObjectExpr( 6456ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor CXXTemporaryObjectExpr *E) { 6457ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo()); 6458ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor if (!T) 6459f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 64601eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6461b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor CXXConstructorDecl *Constructor 6462b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = cast_or_null<CXXConstructorDecl>( 6463c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt getDerived().TransformDecl(E->getLocStart(), 64647c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor E->getConstructor())); 6465b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!Constructor) 6466f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 64671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6468b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgumentChanged = false; 6469ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Args(SemaRef); 6470b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Args.reserve(E->getNumArgs()); 6471aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args, 6472aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor &ArgumentChanged)) 6473aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 64741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6475b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 6476ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor T == E->getTypeSourceInfo() && 6477b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor Constructor == E->getConstructor() && 647891be6f5ccbde073e592bed9a3e3bc363957714fbDouglas Gregor !ArgumentChanged) { 647991be6f5ccbde073e592bed9a3e3bc363957714fbDouglas Gregor // FIXME: Instantiation-specific 6480ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor); 64813fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.MaybeBindToTemporary(E); 648291be6f5ccbde073e592bed9a3e3bc363957714fbDouglas Gregor } 6483ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor 6484ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getDerived().RebuildCXXTemporaryObjectExpr(T, 6485ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor /*FIXME:*/T->getTypeLoc().getEndLoc(), 6486b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(Args), 6487b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLocEnd()); 6488b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 64891eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6490b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 649160d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6492b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::TransformCXXUnresolvedConstructExpr( 6493454feb9da67504b475d032ca2a9fc34c5744748eJohn McCall CXXUnresolvedConstructExpr *E) { 6494ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo()); 6495ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor if (!T) 6496f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 64971eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6498b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgumentChanged = false; 6499ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Args(SemaRef); 6500aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Args.reserve(E->arg_size()); 6501aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args, 6502aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor &ArgumentChanged)) 6503aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 6504aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 6505b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 6506ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor T == E->getTypeSourceInfo() && 6507b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor !ArgumentChanged) 65083fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 65091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6510b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // FIXME: we're faking the locations of the commas 6511ab6677ec401cfd2c82b34e4cdfebd55a9dc25778Douglas Gregor return getDerived().RebuildCXXUnresolvedConstructExpr(T, 6512b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getLParenLoc(), 6513b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(Args), 6514b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 6515b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 65161eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6517b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 651860d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6519865d447ac6a4721ab58e898d014a21f2eff74b06John McCallTreeTransform<Derived>::TransformCXXDependentScopeMemberExpr( 65202577743c5650c646fb705df01403707e94f2df04Abramo Bagnara CXXDependentScopeMemberExpr *E) { 6521b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Transform the base of the expression. 652260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base((Expr*) 0); 6523aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Expr *OldBase; 6524aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 6525aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType ObjectType; 6526aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!E->isImplicitAccess()) { 6527aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall OldBase = E->getBase(); 6528aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Base = getDerived().TransformExpr(OldBase); 6529aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (Base.isInvalid()) 6530f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 65311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6532aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall // Start the member reference and compute the object's type. 6533b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType ObjectTy; 6534d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor bool MayBePseudoDestructor = false; 65359ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(), 6536aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall E->getOperatorLoc(), 6537a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor E->isArrow()? tok::arrow : tok::period, 6538d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor ObjectTy, 6539d4dca08d6b7ed2e3e3718caa6fd735960b135e9aDouglas Gregor MayBePseudoDestructor); 6540aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (Base.isInvalid()) 6541f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6542aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall 6543b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ObjectType = ObjectTy.get(); 6544aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType = ((Expr*) Base.get())->getType(); 6545aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } else { 6546aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall OldBase = 0; 6547aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType = getDerived().TransformType(E->getBaseType()); 6548aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall ObjectType = BaseType->getAs<PointerType>()->getPointeeType(); 6549aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 65501eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 65516cd219879ffce00920189ec1dcea927a42602961Douglas Gregor // Transform the first part of the nested-name-specifier that qualifies 65526cd219879ffce00920189ec1dcea927a42602961Douglas Gregor // the member name. 6553c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor NamedDecl *FirstQualifierInScope 65546cd219879ffce00920189ec1dcea927a42602961Douglas Gregor = getDerived().TransformFirstQualifierInScope( 65556cd219879ffce00920189ec1dcea927a42602961Douglas Gregor E->getFirstQualifierFoundInScope(), 65566cd219879ffce00920189ec1dcea927a42602961Douglas Gregor E->getQualifierRange().getBegin()); 65571eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6558a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor NestedNameSpecifier *Qualifier = 0; 6559a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor if (E->getQualifier()) { 6560a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(), 6561a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor E->getQualifierRange(), 6562aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall ObjectType, 6563aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall FirstQualifierInScope); 6564a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor if (!Qualifier) 6565f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6566a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor } 65671eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 656843fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // TODO: If this is a conversion-function-id, verify that the 656943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // destination type name (if present) resolves the same way after 657043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall // instantiation as it did in the local scope. 657143fed0de4f5bc189e45562491f83d5193eb8dac0John McCall 65722577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo 657343fed0de4f5bc189e45562491f83d5193eb8dac0John McCall = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo()); 65742577743c5650c646fb705df01403707e94f2df04Abramo Bagnara if (!NameInfo.getName()) 6575f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 65761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6577aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!E->hasExplicitTemplateArgs()) { 65783b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor // This is a reference to a member without an explicitly-specified 65793b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor // template argument list. Optimize for this common case. 65803b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor if (!getDerived().AlwaysRebuild() && 6581aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Base.get() == OldBase && 6582aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType == E->getBaseType() && 65833b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Qualifier == E->getQualifier() && 65842577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo.getName() == E->getMember() && 65853b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor FirstQualifierInScope == E->getFirstQualifierFoundInScope()) 65863fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 65871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 65889ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(), 6589aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType, 65903b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor E->isArrow(), 65913b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor E->getOperatorLoc(), 65923b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor Qualifier, 65933b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor E->getQualifierRange(), 6594129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall FirstQualifierInScope, 65952577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo, 6596129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall /*TemplateArgs*/ 0); 65973b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor } 65983b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor 6599d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc()); 6600fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor if (getDerived().TransformTemplateArguments(E->getTemplateArgs(), 6601fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor E->getNumTemplateArgs(), 6602fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor TransArgs)) 6603fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor return ExprError(); 66041eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 66059ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(), 6606aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType, 6607b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->isArrow(), 6608b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getOperatorLoc(), 6609a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor Qualifier, 6610a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor E->getQualifierRange(), 66113b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor FirstQualifierInScope, 66122577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo, 6613129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall &TransArgs); 6614129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall} 6615129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6616129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCalltemplate<typename Derived> 661760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6618454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) { 6619129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Transform the base of the expression. 662060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base((Expr*) 0); 6621aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall QualType BaseType; 6622aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (!Old->isImplicitAccess()) { 6623aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall Base = getDerived().TransformExpr(Old->getBase()); 6624aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall if (Base.isInvalid()) 6625f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6626aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType = ((Expr*) Base.get())->getType(); 6627aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } else { 6628aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType = getDerived().TransformType(Old->getBaseType()); 6629aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall } 6630129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6631129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall NestedNameSpecifier *Qualifier = 0; 6632129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (Old->getQualifier()) { 6633129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Qualifier 6634129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall = getDerived().TransformNestedNameSpecifier(Old->getQualifier(), 6635edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor Old->getQualifierRange()); 6636129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (Qualifier == 0) 6637f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6638129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 6639129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 66402577743c5650c646fb705df01403707e94f2df04Abramo Bagnara LookupResult R(SemaRef, Old->getMemberNameInfo(), 6641129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Sema::LookupOrdinaryName); 6642129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6643129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Transform all the decls. 6644129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall for (UnresolvedMemberExpr::decls_iterator I = Old->decls_begin(), 6645129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall E = Old->decls_end(); I != E; ++I) { 66467c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor NamedDecl *InstD = static_cast<NamedDecl*>( 66477c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor getDerived().TransformDecl(Old->getMemberLoc(), 66487c1e98f1cb37b40e619a0c8aee8b337f037b432bDouglas Gregor *I)); 66499f54ad4381370c6b771424b53d219e661d6d6706John McCall if (!InstD) { 66509f54ad4381370c6b771424b53d219e661d6d6706John McCall // Silently ignore these if a UsingShadowDecl instantiated to nothing. 66519f54ad4381370c6b771424b53d219e661d6d6706John McCall // This can happen because of dependent hiding. 66529f54ad4381370c6b771424b53d219e661d6d6706John McCall if (isa<UsingShadowDecl>(*I)) 66539f54ad4381370c6b771424b53d219e661d6d6706John McCall continue; 66549f54ad4381370c6b771424b53d219e661d6d6706John McCall else 6655f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 66569f54ad4381370c6b771424b53d219e661d6d6706John McCall } 6657129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6658129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall // Expand using declarations. 6659129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (isa<UsingDecl>(InstD)) { 6660129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall UsingDecl *UD = cast<UsingDecl>(InstD); 6661129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall for (UsingDecl::shadow_iterator I = UD->shadow_begin(), 6662129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall E = UD->shadow_end(); I != E; ++I) 6663129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall R.addDecl(*I); 6664129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall continue; 6665129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 6666129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6667129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall R.addDecl(InstD); 6668129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 6669129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6670129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall R.resolveKind(); 6671129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall 6672c96be1ea33cdf63d07cec48d18fe8e3afea48f8dDouglas Gregor // Determine the naming class. 6673042d6f98ea73d781e43cc17077e8fc84a4201eefChandler Carruth if (Old->getNamingClass()) { 6674c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt CXXRecordDecl *NamingClass 6675c96be1ea33cdf63d07cec48d18fe8e3afea48f8dDouglas Gregor = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl( 667666c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor Old->getMemberLoc(), 667766c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor Old->getNamingClass())); 667866c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor if (!NamingClass) 6679f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6680c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 668166c45154186b7786d5dca645d548d73c47cf5d87Douglas Gregor R.setNamingClass(NamingClass); 6682c96be1ea33cdf63d07cec48d18fe8e3afea48f8dDouglas Gregor } 6683c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6684129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall TemplateArgumentListInfo TransArgs; 6685129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall if (Old->hasExplicitTemplateArgs()) { 6686129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall TransArgs.setLAngleLoc(Old->getLAngleLoc()); 6687129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall TransArgs.setRAngleLoc(Old->getRAngleLoc()); 6688fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(), 6689fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor Old->getNumTemplateArgs(), 6690fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor TransArgs)) 6691fcc1253ba28d1d1debacd147be15e1684cc2eda5Douglas Gregor return ExprError(); 6692129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall } 6693c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall 6694c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // FIXME: to do this check properly, we will need to preserve the 6695c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // first-qualifier-in-scope here, just in case we had a dependent 6696c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // base (and therefore couldn't do the check) and a 6697c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall // nested-name-qualifier (and therefore could do the lookup). 6698c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall NamedDecl *FirstQualifierInScope = 0; 6699c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 67009ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildUnresolvedMemberExpr(Base.get(), 6701aa81e1658d87b9011125c632aa902d154ae4b02cJohn McCall BaseType, 6702129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Old->getOperatorLoc(), 6703129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Old->isArrow(), 6704129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Qualifier, 6705129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall Old->getQualifierRange(), 6706c2233c5c46eafebd5529bf2bbd1f0a723b892e61John McCall FirstQualifierInScope, 6707129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall R, 6708129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall (Old->hasExplicitTemplateArgs() 6709129e2df52ed7e0434b3f1cf1867fd6a5cb083ff6John McCall ? &TransArgs : 0)); 6710b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6711b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 6712b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 671360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 67142e156225a29407a50dd19041aa5750171ad44ea3Sebastian RedlTreeTransform<Derived>::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) { 67152e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl ExprResult SubExpr = getDerived().TransformExpr(E->getOperand()); 67162e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl if (SubExpr.isInvalid()) 67172e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return ExprError(); 67182e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 67192e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand()) 67203fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 67212e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 67222e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get()); 67232e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl} 67242e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redl 67252e156225a29407a50dd19041aa5750171ad44ea3Sebastian Redltemplate<typename Derived> 67262e156225a29407a50dd19041aa5750171ad44ea3Sebastian RedlExprResult 6727be230c36e32142cbdcdbe9c97511d097beeecbabDouglas GregorTreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) { 6728be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor llvm_unreachable("pack expansion expression in unhandled context"); 6729be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor return ExprError(); 6730be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor} 6731ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 6732ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregortemplate<typename Derived> 6733ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas GregorExprResult 6734ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas GregorTreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) { 6735ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // If E is not value-dependent, then nothing will change when we transform it. 6736ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // Note: This is an instantiation-centric view. 6737ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor if (!E->isValueDependent()) 6738ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return SemaRef.Owned(E); 6739ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 6740ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // Note: None of the implementations of TryExpandParameterPacks can ever 6741ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // produce a diagnostic when given only a single unexpanded parameter pack, 6742ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // so 6743ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc()); 6744ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor bool ShouldExpand = false; 6745d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor bool RetainExpansion = false; 6746ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor unsigned NumExpansions = 0; 6747ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(), 6748ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor &Unexpanded, 1, 6749d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor ShouldExpand, RetainExpansion, 6750d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor NumExpansions)) 6751ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return ExprError(); 6752ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 6753d3731198193eee92796ddeb493973b7a598b003eDouglas Gregor if (!ShouldExpand || RetainExpansion) 6754ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return SemaRef.Owned(E); 6755be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregor 6756ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // We now know the length of the parameter pack, so build a new expression 6757ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor // that stores that length. 6758ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(), 6759ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor E->getPackLoc(), E->getRParenLoc(), 6760ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor NumExpansions); 6761ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor} 6762ee8aff06f6a96214731de17b2cb6df407c6c1820Douglas Gregor 6763be230c36e32142cbdcdbe9c97511d097beeecbabDouglas Gregortemplate<typename Derived> 6764be230c36e32142cbdcdbe9c97511d097beeecbabDouglas GregorExprResult 6765454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) { 67663fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6767b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6768b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 67691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 677060d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6771454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) { 677281d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor TypeSourceInfo *EncodedTypeInfo 677381d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor = getDerived().TransformType(E->getEncodedTypeSourceInfo()); 677481d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor if (!EncodedTypeInfo) 6775f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 67761eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6777b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 677881d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor EncodedTypeInfo == E->getEncodedTypeSourceInfo()) 67793fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6780b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 6781b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(), 678281d3466d037dc5844234c7a93dab21a6ad986e7dDouglas Gregor EncodedTypeInfo, 6783b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 6784b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 67851eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6786b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 678760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6788454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) { 678992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // Transform arguments. 679092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor bool ArgChanged = false; 6791ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> Args(SemaRef); 6792aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor Args.reserve(E->getNumArgs()); 6793aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args, 6794aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor &ArgChanged)) 6795aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 6796aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor 679792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (E->getReceiverKind() == ObjCMessageExpr::Class) { 679892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // Class message: transform the receiver type. 679992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor TypeSourceInfo *ReceiverTypeInfo 680092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor = getDerived().TransformType(E->getClassReceiverTypeInfo()); 680192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (!ReceiverTypeInfo) 6802f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6803c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 680492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // If nothing changed, just retain the existing message send. 680592e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (!getDerived().AlwaysRebuild() && 680692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged) 68073fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 680892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor 680992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // Build a new class message send. 681092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo, 681192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getSelector(), 6812f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis E->getSelectorLoc(), 681392e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getMethodDecl(), 681492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getLeftLoc(), 681592e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor move_arg(Args), 681692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getRightLoc()); 681792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor } 681892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor 681992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // Instance message: transform the receiver 682092e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor assert(E->getReceiverKind() == ObjCMessageExpr::Instance && 682192e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor "Only class and instance messages may be instantiated"); 682260d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Receiver 682392e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor = getDerived().TransformExpr(E->getInstanceReceiver()); 682492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (Receiver.isInvalid()) 6825f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 682692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor 682792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // If nothing changed, just retain the existing message send. 682892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor if (!getDerived().AlwaysRebuild() && 682992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor Receiver.get() == E->getInstanceReceiver() && !ArgChanged) 68303fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6831c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 683292e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // Build a new instance message send. 68339ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildObjCMessageExpr(Receiver.get(), 683492e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getSelector(), 6835f40f0d5a382395e0301d7dcbeaa2b8e90b8973b1Argyrios Kyrtzidis E->getSelectorLoc(), 683692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getMethodDecl(), 683792e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getLeftLoc(), 683892e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor move_arg(Args), 683992e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor E->getRightLoc()); 6840b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6841b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 68421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 684360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6844454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) { 68453fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6846b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6847b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 68481eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 684960d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6850454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) { 68513fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6852b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6853b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 68541eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 685560d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6856454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) { 6857f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor // Transform the base expression. 685860d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base = getDerived().TransformExpr(E->getBase()); 6859f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (Base.isInvalid()) 6860f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6861f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor 6862f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor // We don't need to transform the ivar; it will never change. 6863c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6864f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor // If nothing changed, just retain the existing expression. 6865f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (!getDerived().AlwaysRebuild() && 6866f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor Base.get() == E->getBase()) 68673fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6868c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 68699ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(), 6870f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor E->getLocation(), 6871f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor E->isArrow(), E->isFreeIvar()); 6872b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6873b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 68741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 687560d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6876454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) { 687712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall // 'super' and types never change. Property never changes. Just 687812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall // retain the existing expression. 687912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall if (!E->isObjectReceiver()) 68803fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 68818ac2d449820fd0df00fcbde5bf82165c1f49854dFariborz Jahanian 6882e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor // Transform the base expression. 688360d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base = getDerived().TransformExpr(E->getBase()); 6884e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor if (Base.isInvalid()) 6885f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6886c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6887e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor // We don't need to transform the property; it will never change. 6888c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6889e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor // If nothing changed, just retain the existing expression. 6890e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor if (!getDerived().AlwaysRebuild() && 6891e330354c6bfbb0d7856432fa9055d5236f1b2fa4Douglas Gregor Base.get() == E->getBase()) 68923fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6893b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 689412f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall if (E->isExplicitProperty()) 689512f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall return getDerived().RebuildObjCPropertyRefExpr(Base.get(), 689612f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall E->getExplicitProperty(), 689712f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall E->getLocation()); 689812f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall 689912f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall return getDerived().RebuildObjCPropertyRefExpr(Base.get(), 690012f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall E->getType(), 690112f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall E->getImplicitPropertyGetter(), 690212f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall E->getImplicitPropertySetter(), 690312f78a6741a4cb3d904340f8d3d2714568b50e7aJohn McCall E->getLocation()); 6904b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6905b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 69061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 690760d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6908454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) { 6909f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor // Transform the base expression. 691060d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Base = getDerived().TransformExpr(E->getBase()); 6911f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (Base.isInvalid()) 6912f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 6913c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 6914f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor // If nothing changed, just retain the existing expression. 6915f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor if (!getDerived().AlwaysRebuild() && 6916f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor Base.get() == E->getBase()) 69173fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 6918c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 69199ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(), 6920f9b9eab747e911ded499924b2616d8712d65efceDouglas Gregor E->isArrow()); 6921b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6922b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 69231eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 692460d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6925454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) { 6926b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor bool ArgumentChanged = false; 6927ca0408fb49c1370430672acf2d770b7151cf71deJohn McCall ASTOwningVector<Expr*> SubExprs(SemaRef); 6928aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor SubExprs.reserve(E->getNumSubExprs()); 6929aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false, 6930aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor SubExprs, &ArgumentChanged)) 6931aa165f8458b51c546bebff947343e1a36f3594cbDouglas Gregor return ExprError(); 69321eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6933b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (!getDerived().AlwaysRebuild() && 6934b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor !ArgumentChanged) 69353fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 69361eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 6937b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(), 6938b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor move_arg(SubExprs), 6939b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor E->getRParenLoc()); 6940b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6941b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 69421eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 694360d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6944454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) { 6945a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian SourceLocation CaretLoc(E->getExprLoc()); 6946a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian 6947a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian SemaRef.ActOnBlockStart(CaretLoc, /*Scope=*/0); 6948a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian BlockScopeInfo *CurBlock = SemaRef.getCurBlock(); 6949a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian CurBlock->TheDecl->setIsVariadic(E->getBlockDecl()->isVariadic()); 6950a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian llvm::SmallVector<ParmVarDecl*, 4> Params; 6951a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian llvm::SmallVector<QualType, 4> ParamTypes; 6952a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian 6953a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian // Parameter substitution. 695412c9c00024a01819e3a70ef6d951d32efaeb9312Douglas Gregor // FIXME: Variadic templates 6955a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian const BlockDecl *BD = E->getBlockDecl(); 6956a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian for (BlockDecl::param_const_iterator P = BD->param_begin(), 6957a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian EN = BD->param_end(); P != EN; ++P) { 6958a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ParmVarDecl *OldParm = (*P); 6959a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ParmVarDecl *NewParm = getDerived().TransformFunctionTypeParam(OldParm); 6960a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian QualType NewType = NewParm->getType(); 6961a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian Params.push_back(NewParm); 6962a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ParamTypes.push_back(NewParm->getType()); 6963a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian } 6964a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian 6965a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian const FunctionType *BExprFunctionType = E->getFunctionType(); 6966a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian QualType BExprResultType = BExprFunctionType->getResultType(); 6967a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian if (!BExprResultType.isNull()) { 6968a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian if (!BExprResultType->isDependentType()) 6969a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian CurBlock->ReturnType = BExprResultType; 6970a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian else if (BExprResultType != SemaRef.Context.DependentTy) 6971a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian CurBlock->ReturnType = getDerived().TransformType(BExprResultType); 6972a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian } 6973711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 6974a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian QualType FunctionType = getDerived().RebuildFunctionProtoType( 6975a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian CurBlock->ReturnType, 6976a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ParamTypes.data(), 6977a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ParamTypes.size(), 6978a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian BD->isVariadic(), 6979fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman 0, 6980fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman BExprFunctionType->getExtInfo()); 6981a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian CurBlock->FunctionType = FunctionType; 6982711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 6983711c52bb20d0c69063b52a99826fb7d2835501f1John McCall // Set the parameters on the block decl. 6984711c52bb20d0c69063b52a99826fb7d2835501f1John McCall if (!Params.empty()) 6985711c52bb20d0c69063b52a99826fb7d2835501f1John McCall CurBlock->TheDecl->setParams(Params.data(), Params.size()); 6986711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 6987711c52bb20d0c69063b52a99826fb7d2835501f1John McCall // Transform the body 6988711c52bb20d0c69063b52a99826fb7d2835501f1John McCall StmtResult Body = getDerived().TransformStmt(E->getBody()); 6989711c52bb20d0c69063b52a99826fb7d2835501f1John McCall if (Body.isInvalid()) 6990711c52bb20d0c69063b52a99826fb7d2835501f1John McCall return ExprError(); 6991711c52bb20d0c69063b52a99826fb7d2835501f1John McCall 69929ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.ActOnBlockStmtExpr(CaretLoc, Body.get(), /*Scope=*/0); 6993b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 6994b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 69951eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 699660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 6997454feb9da67504b475d032ca2a9fc34c5744748eJohn McCallTreeTransform<Derived>::TransformBlockDeclRefExpr(BlockDeclRefExpr *E) { 6998a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian NestedNameSpecifier *Qualifier = 0; 6999a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian 7000a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ValueDecl *ND 7001a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(), 7002a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian E->getDecl())); 7003a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian if (!ND) 7004f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 70052577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 7006a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian if (!getDerived().AlwaysRebuild() && 7007a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian ND == E->getDecl()) { 7008a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian // Mark it referenced in the new context regardless. 7009a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian // FIXME: this is a bit instantiation-specific. 7010a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian SemaRef.MarkDeclarationReferenced(E->getLocation(), ND); 7011a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian 70123fa5cae9b3812cab9fab6c042c3329bb70a3d046John McCall return SemaRef.Owned(E); 7013a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian } 7014a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian 70152577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo(E->getDecl()->getDeclName(), E->getLocation()); 7016a729da2c29e7df26319acf2675d51e377287a139Fariborz Jahanian return getDerived().RebuildDeclRefExpr(Qualifier, SourceLocation(), 70172577743c5650c646fb705df01403707e94f2df04Abramo Bagnara ND, NameInfo, 0); 7018b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 70191eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7020b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor//===----------------------------------------------------------------------===// 7021b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor// Type reconstruction 7022b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor//===----------------------------------------------------------------------===// 7023b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 70241eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 702585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCallQualType TreeTransform<Derived>::RebuildPointerType(QualType PointeeType, 702685737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceLocation Star) { 70272865474261a608c7873b87ba4af110d17907896dJohn McCall return SemaRef.BuildPointerType(PointeeType, Star, 7028b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor getDerived().getBaseEntity()); 7029b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 7030b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 70311eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 703285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCallQualType TreeTransform<Derived>::RebuildBlockPointerType(QualType PointeeType, 703385737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceLocation Star) { 70342865474261a608c7873b87ba4af110d17907896dJohn McCall return SemaRef.BuildBlockPointerType(PointeeType, Star, 7035b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor getDerived().getBaseEntity()); 7036b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 7037b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 70381eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 70391eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 704085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCallTreeTransform<Derived>::RebuildReferenceType(QualType ReferentType, 704185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall bool WrittenAsLValue, 704285737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceLocation Sigil) { 70432865474261a608c7873b87ba4af110d17907896dJohn McCall return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue, 704485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall Sigil, getDerived().getBaseEntity()); 7045b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 7046b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor 70471eb4433ac451dc16f4133a88af2d002ac26c58efMike Stumptemplate<typename Derived> 70481eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 704985737a71fee8c737f7cfba79a0aca89298fe573bJohn McCallTreeTransform<Derived>::RebuildMemberPointerType(QualType PointeeType, 705085737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall QualType ClassType, 705185737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceLocation Sigil) { 70522865474261a608c7873b87ba4af110d17907896dJohn McCall return SemaRef.BuildMemberPointerType(PointeeType, ClassType, 705385737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall Sigil, getDerived().getBaseEntity()); 7054577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7055577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7056577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 70571eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 7058577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorTreeTransform<Derived>::RebuildArrayType(QualType ElementType, 7059577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 7060577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor const llvm::APInt *Size, 7061577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor Expr *SizeExpr, 7062577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned IndexTypeQuals, 7063577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceRange BracketsRange) { 7064577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (SizeExpr || !Size) 7065577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr, 7066577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor IndexTypeQuals, BracketsRange, 7067577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor getDerived().getBaseEntity()); 70681eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 70691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType Types[] = { 70701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy, 70711eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy, 70721eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty 7073577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor }; 7074577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor const unsigned NumTypes = sizeof(Types) / sizeof(QualType); 7075577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor QualType SizeType; 7076577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor for (unsigned I = 0; I != NumTypes; ++I) 7077577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) { 7078577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SizeType = Types[I]; 7079577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor break; 7080577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor } 70811eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 70829996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis IntegerLiteral ArraySize(SemaRef.Context, *Size, SizeType, 70839996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis /*FIXME*/BracketsRange.getBegin()); 70841eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return SemaRef.BuildArrayType(ElementType, SizeMod, &ArraySize, 7085577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor IndexTypeQuals, BracketsRange, 70861eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump getDerived().getBaseEntity()); 7087577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 70881eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7089577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 70901eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 70911eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::RebuildConstantArrayType(QualType ElementType, 7092577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 7093577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor const llvm::APInt &Size, 709485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall unsigned IndexTypeQuals, 709585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange BracketsRange) { 70961eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0, 709785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall IndexTypeQuals, BracketsRange); 7098577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7099577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7100577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 71011eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 71021eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::RebuildIncompleteArrayType(QualType ElementType, 7103577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 710485737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall unsigned IndexTypeQuals, 710585737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall SourceRange BracketsRange) { 71061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 0, 710785737a71fee8c737f7cfba79a0aca89298fe573bJohn McCall IndexTypeQuals, BracketsRange); 7108577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 71091eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7110577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 71111eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 71121eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::RebuildVariableArrayType(QualType ElementType, 7113577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 71149ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SizeExpr, 7115577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned IndexTypeQuals, 7116577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceRange BracketsRange) { 71171eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 71189ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SizeExpr, 7119577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor IndexTypeQuals, BracketsRange); 7120577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7121577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7122577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 71231eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 71241eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType, 7125577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor ArrayType::ArraySizeModifier SizeMod, 71269ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SizeExpr, 7127577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned IndexTypeQuals, 7128577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceRange BracketsRange) { 71291eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 71309ae2f076ca5ab1feb3ba95629099ec2319833701John McCall SizeExpr, 7131577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor IndexTypeQuals, BracketsRange); 7132577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7133577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7134577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 7135577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType, 7136e86d78cf4754a6aef2cf9a33d847aa15338e276fBob Wilson unsigned NumElements, 7137e86d78cf4754a6aef2cf9a33d847aa15338e276fBob Wilson VectorType::VectorKind VecKind) { 7138577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor // FIXME: semantic checking! 7139e86d78cf4754a6aef2cf9a33d847aa15338e276fBob Wilson return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind); 7140577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 71411eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7142577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 7143577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::RebuildExtVectorType(QualType ElementType, 7144577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned NumElements, 7145577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceLocation AttributeLoc) { 7146577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy), 7147577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor NumElements, true); 7148577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor IntegerLiteral *VectorSize 71499996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy, 71509996a7f06a3c5b4554692e7177930cf4e8ef09afArgyrios Kyrtzidis AttributeLoc); 71519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc); 7152577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 71531eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7154577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 71551eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpQualType 71561eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTreeTransform<Derived>::RebuildDependentSizedExtVectorType(QualType ElementType, 71579ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *SizeExpr, 7158577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor SourceLocation AttributeLoc) { 71599ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc); 7160577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 71611eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7162577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 7163577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::RebuildFunctionProtoType(QualType T, 71641eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump QualType *ParamTypes, 7165577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor unsigned NumParamTypes, 71661eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump bool Variadic, 7167fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman unsigned Quals, 7168fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman const FunctionType::ExtInfo &Info) { 71691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic, 7170577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor Quals, 7171577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor getDerived().getBaseLocation(), 7172fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman getDerived().getBaseEntity(), 7173fa869547eb1cab12d7e0c0dfa8ba594e336b9b32Eli Friedman Info); 7174577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 71751eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7176577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 7177a2becad14a0eb19cde2f441ced588b975433d2edJohn McCallQualType TreeTransform<Derived>::RebuildFunctionNoProtoType(QualType T) { 7178a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall return SemaRef.Context.getFunctionNoProtoType(T); 7179a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall} 7180a2becad14a0eb19cde2f441ced588b975433d2edJohn McCall 7181a2becad14a0eb19cde2f441ced588b975433d2edJohn McCalltemplate<typename Derived> 7182ed97649e9574b9d854fa4d6109c9333ae0993554John McCallQualType TreeTransform<Derived>::RebuildUnresolvedUsingType(Decl *D) { 7183ed97649e9574b9d854fa4d6109c9333ae0993554John McCall assert(D && "no decl found"); 7184ed97649e9574b9d854fa4d6109c9333ae0993554John McCall if (D->isInvalidDecl()) return QualType(); 7185ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 718692e986e0adb79e8a47f738bd608e6c97c547641dDouglas Gregor // FIXME: Doesn't account for ObjCInterfaceDecl! 7187ed97649e9574b9d854fa4d6109c9333ae0993554John McCall TypeDecl *Ty; 7188ed97649e9574b9d854fa4d6109c9333ae0993554John McCall if (isa<UsingDecl>(D)) { 7189ed97649e9574b9d854fa4d6109c9333ae0993554John McCall UsingDecl *Using = cast<UsingDecl>(D); 7190ed97649e9574b9d854fa4d6109c9333ae0993554John McCall assert(Using->isTypeName() && 7191ed97649e9574b9d854fa4d6109c9333ae0993554John McCall "UnresolvedUsingTypenameDecl transformed to non-typename using"); 7192ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 7193ed97649e9574b9d854fa4d6109c9333ae0993554John McCall // A valid resolved using typename decl points to exactly one type decl. 7194ed97649e9574b9d854fa4d6109c9333ae0993554John McCall assert(++Using->shadow_begin() == Using->shadow_end()); 7195ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl()); 7196c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 7197ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } else { 7198ed97649e9574b9d854fa4d6109c9333ae0993554John McCall assert(isa<UnresolvedUsingTypenameDecl>(D) && 7199ed97649e9574b9d854fa4d6109c9333ae0993554John McCall "UnresolvedUsingTypenameDecl transformed to non-using decl"); 7200ed97649e9574b9d854fa4d6109c9333ae0993554John McCall Ty = cast<UnresolvedUsingTypenameDecl>(D); 7201ed97649e9574b9d854fa4d6109c9333ae0993554John McCall } 7202ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 7203ed97649e9574b9d854fa4d6109c9333ae0993554John McCall return SemaRef.Context.getTypeDeclType(Ty); 7204ed97649e9574b9d854fa4d6109c9333ae0993554John McCall} 7205ed97649e9574b9d854fa4d6109c9333ae0993554John McCall 7206ed97649e9574b9d854fa4d6109c9333ae0993554John McCalltemplate<typename Derived> 72072a984cad5ac3fdceeff2bd99daa7b90979313475John McCallQualType TreeTransform<Derived>::RebuildTypeOfExprType(Expr *E, 72082a984cad5ac3fdceeff2bd99daa7b90979313475John McCall SourceLocation Loc) { 72092a984cad5ac3fdceeff2bd99daa7b90979313475John McCall return SemaRef.BuildTypeofExprType(E, Loc); 7210577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7211577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7212577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 7213577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::RebuildTypeOfType(QualType Underlying) { 7214577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor return SemaRef.Context.getTypeOfType(Underlying); 7215577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7216577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7217577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 72182a984cad5ac3fdceeff2bd99daa7b90979313475John McCallQualType TreeTransform<Derived>::RebuildDecltypeType(Expr *E, 72192a984cad5ac3fdceeff2bd99daa7b90979313475John McCall SourceLocation Loc) { 72202a984cad5ac3fdceeff2bd99daa7b90979313475John McCall return SemaRef.BuildDecltypeType(E, Loc); 7221577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 7222577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7223577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregortemplate<typename Derived> 7224577f75a7498e9e2536434da0ef0da0eea390d18bDouglas GregorQualType TreeTransform<Derived>::RebuildTemplateSpecializationType( 7225833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall TemplateName Template, 7226833ca991c1bfc967f0995974ca86f66ba1f666b5John McCall SourceLocation TemplateNameLoc, 7227d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall const TemplateArgumentListInfo &TemplateArgs) { 7228d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs); 7229577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} 72301eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7231dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregortemplate<typename Derived> 7232dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorNestedNameSpecifier * 7233dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorTreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix, 7234dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SourceRange Range, 7235a38c687ef5354678b9d76a7b29354159f2b83736Douglas Gregor IdentifierInfo &II, 7236c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor QualType ObjectType, 7237d5532b6cfff2977e0c59fa6ead7f7973984a620dJohn McCall NamedDecl *FirstQualifierInScope) { 7238dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor CXXScopeSpec SS; 7239dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor // FIXME: The source location information is all wrong. 7240dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SS.setRange(Range); 7241dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SS.setScopeRep(Prefix); 7242dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return static_cast<NestedNameSpecifier *>( 72431eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SemaRef.BuildCXXNestedNameSpecifier(0, SS, Range.getEnd(), 7244495c35d291da48c4f5655bbb54d15128ddde0d4dDouglas Gregor Range.getEnd(), II, 7245c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor ObjectType, 7246c68afe2cbe7f875a9243c411077602fb5f5dc74bDouglas Gregor FirstQualifierInScope, 724746646491834cd8faabb22482dfe93b24ce28a6c1Chris Lattner false, false)); 7248dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor} 7249dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor 7250dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregortemplate<typename Derived> 7251dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorNestedNameSpecifier * 7252dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorTreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix, 7253dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SourceRange Range, 7254dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor NamespaceDecl *NS) { 7255dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return NestedNameSpecifier::Create(SemaRef.Context, Prefix, NS); 7256dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor} 7257dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor 7258dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregortemplate<typename Derived> 7259dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorNestedNameSpecifier * 7260dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas GregorTreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix, 7261dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SourceRange Range, 7262dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor bool TemplateKW, 7263edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor QualType T) { 7264edc90500b1d2587bf0b698fada14537d6741fddfDouglas Gregor if (T->isDependentType() || T->isRecordType() || 7265dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor (SemaRef.getLangOptions().CPlusPlus0x && T->isEnumeralType())) { 7266a4923eb7c4b04d360cb2747641a5e92818edf804Douglas Gregor assert(!T.hasLocalQualifiers() && "Can't get cv-qualifiers here"); 7267dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return NestedNameSpecifier::Create(SemaRef.Context, Prefix, TemplateKW, 7268dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor T.getTypePtr()); 7269dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor } 72701eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7271dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor SemaRef.Diag(Range.getBegin(), diag::err_nested_name_spec_non_tag) << T; 7272dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor return 0; 7273dcee1a12c83a6cbc9b5bf42df5d4efbc502664e7Douglas Gregor} 72741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7275d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregortemplate<typename Derived> 72761eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTemplateName 7277d1067e5a0a6e2aee7260c392452df9553034c92bDouglas GregorTreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier, 7278d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor bool TemplateKW, 7279d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor TemplateDecl *Template) { 72801eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return SemaRef.Context.getQualifiedTemplateName(Qualifier, TemplateKW, 7281d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor Template); 7282d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor} 7283d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor 7284d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregortemplate<typename Derived> 72851eb4433ac451dc16f4133a88af2d002ac26c58efMike StumpTemplateName 7286d1067e5a0a6e2aee7260c392452df9553034c92bDouglas GregorTreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier, 72871efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor SourceRange QualifierRange, 72883b6afbb99a1c44b4076f8e15fb7311405941b306Douglas Gregor const IdentifierInfo &II, 728943fed0de4f5bc189e45562491f83d5193eb8dac0John McCall QualType ObjectType, 729043fed0de4f5bc189e45562491f83d5193eb8dac0John McCall NamedDecl *FirstQualifierInScope) { 7291d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor CXXScopeSpec SS; 72921efb6c716397f2c4e3ede3a4853c5efebb375441Douglas Gregor SS.setRange(QualifierRange); 72931eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump SS.setScopeRep(Qualifier); 7294014e88d94ff83e3aad4e33b16413a2d1817ec208Douglas Gregor UnqualifiedId Name; 7295014e88d94ff83e3aad4e33b16413a2d1817ec208Douglas Gregor Name.setIdentifier(&II, /*FIXME:*/getDerived().getBaseLocation()); 7296d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor Sema::TemplateTy Template; 7297d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor getSema().ActOnDependentTemplateName(/*Scope=*/0, 7298d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor /*FIXME:*/getDerived().getBaseLocation(), 7299d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor SS, 7300d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor Name, 7301b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType::make(ObjectType), 7302d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor /*EnteringContext=*/false, 7303d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor Template); 730443fed0de4f5bc189e45562491f83d5193eb8dac0John McCall return Template.get(); 7305d1067e5a0a6e2aee7260c392452df9553034c92bDouglas Gregor} 73061eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7307b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregortemplate<typename Derived> 7308ca1bdd7c269a2390d43c040a60511edd017ee130Douglas GregorTemplateName 7309ca1bdd7c269a2390d43c040a60511edd017ee130Douglas GregorTreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier, 7310ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor OverloadedOperatorKind Operator, 7311ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor QualType ObjectType) { 7312ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor CXXScopeSpec SS; 7313ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor SS.setRange(SourceRange(getDerived().getBaseLocation())); 7314ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor SS.setScopeRep(Qualifier); 7315ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor UnqualifiedId Name; 7316ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor SourceLocation SymbolLocations[3]; // FIXME: Bogus location information. 7317ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor Name.setOperatorFunctionId(/*FIXME:*/getDerived().getBaseLocation(), 7318ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor Operator, SymbolLocations); 7319d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor Sema::TemplateTy Template; 7320d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor getSema().ActOnDependentTemplateName(/*Scope=*/0, 7321ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor /*FIXME:*/getDerived().getBaseLocation(), 7322d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor SS, 7323d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor Name, 7324b3d8748e797c6c2f1dc01186c8eeb3b1b5fe970cJohn McCall ParsedType::make(ObjectType), 7325d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor /*EnteringContext=*/false, 7326d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor Template); 7327d6ab232bb3ec9847de5af06249afb63078b5f2eeDouglas Gregor return Template.template getAsVal<TemplateName>(); 7328ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregor} 7329c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt 7330ca1bdd7c269a2390d43c040a60511edd017ee130Douglas Gregortemplate<typename Derived> 733160d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 7332b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas GregorTreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, 7333b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor SourceLocation OpLoc, 73349ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *OrigCallee, 73359ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *First, 73369ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Second) { 73379ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Callee = OrigCallee->IgnoreParenCasts(); 73389ae2f076ca5ab1feb3ba95629099ec2319833701John McCall bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus); 73391eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7340b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Determine whether this should be a builtin operation. 7341f322ed6d39a30f509023cf88588c1e6514226127Sebastian Redl if (Op == OO_Subscript) { 73429ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (!First->getType()->isOverloadableType() && 73439ae2f076ca5ab1feb3ba95629099ec2319833701John McCall !Second->getType()->isOverloadableType()) 73449ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().CreateBuiltinArraySubscriptExpr(First, 73459ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Callee->getLocStart(), 73469ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Second, OpLoc); 73471a3c75f32f0d27de5f3f6b2ef4c6bbe7e18bddadEli Friedman } else if (Op == OO_Arrow) { 73481a3c75f32f0d27de5f3f6b2ef4c6bbe7e18bddadEli Friedman // -> is never a builtin operation. 73499ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildOverloadedArrowExpr(0, First, OpLoc); 73509ae2f076ca5ab1feb3ba95629099ec2319833701John McCall } else if (Second == 0 || isPostIncDec) { 73519ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (!First->getType()->isOverloadableType()) { 7352b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // The argument is not of overloadable type, so try to create a 7353b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // built-in unary operation. 73542de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall UnaryOperatorKind Opc 7355b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec); 73561eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 73579ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First); 7358b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 7359b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } else { 73609ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (!First->getType()->isOverloadableType() && 73619ae2f076ca5ab1feb3ba95629099ec2319833701John McCall !Second->getType()->isOverloadableType()) { 7362b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Neither of the arguments is an overloadable type, so try to 7363b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // create a built-in binary operation. 73642de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); 736560d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result 73669ae2f076ca5ab1feb3ba95629099ec2319833701John McCall = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second); 7367b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Result.isInvalid()) 7368f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 73691eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7370b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor return move(Result); 7371b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 7372b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 73731eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 73741eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump // Compute the transformed set of functions (and function templates) to be 7375b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // used during overload resolution. 73766e26689f5d513e24ad7783a4493201930fdeccc0John McCall UnresolvedSet<16> Functions; 73771eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 73789ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) { 7379ba13543329afac4a0d01304ec2ec4924d99306a6John McCall assert(ULE->requiresADL()); 7380ba13543329afac4a0d01304ec2ec4924d99306a6John McCall 7381ba13543329afac4a0d01304ec2ec4924d99306a6John McCall // FIXME: Do we have to check 7382ba13543329afac4a0d01304ec2ec4924d99306a6John McCall // IsAcceptableNonMemberOperatorCandidate for each of these? 73836e26689f5d513e24ad7783a4493201930fdeccc0John McCall Functions.append(ULE->decls_begin(), ULE->decls_end()); 7384ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } else { 73859ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Functions.addDecl(cast<DeclRefExpr>(Callee)->getDecl()); 7386ba13543329afac4a0d01304ec2ec4924d99306a6John McCall } 73871eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7388b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Add any functions found via argument-dependent lookup. 73899ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Expr *Args[2] = { First, Second }; 73909ae2f076ca5ab1feb3ba95629099ec2319833701John McCall unsigned NumArgs = 1 + (Second != 0); 73911eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7392b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Create the overloaded operator invocation for unary operators. 7393b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (NumArgs == 1 || isPostIncDec) { 73942de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall UnaryOperatorKind Opc 7395b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec); 73969ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First); 7397b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor } 73981eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 7399f322ed6d39a30f509023cf88588c1e6514226127Sebastian Redl if (Op == OO_Subscript) 74009ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.CreateOverloadedArraySubscriptExpr(Callee->getLocStart(), 7401ba13543329afac4a0d01304ec2ec4924d99306a6John McCall OpLoc, 74029ae2f076ca5ab1feb3ba95629099ec2319833701John McCall First, 74039ae2f076ca5ab1feb3ba95629099ec2319833701John McCall Second); 7404f322ed6d39a30f509023cf88588c1e6514226127Sebastian Redl 7405b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor // Create the overloaded operator invocation for binary operators. 74062de56d1d0c3a504ad1529de2677628bdfbb95cd4John McCall BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op); 740760d7b3a319d84d688752be3870615ac0f111fb16John McCall ExprResult Result 7408b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor = SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions, Args[0], Args[1]); 7409b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor if (Result.isInvalid()) 7410f312b1ea179f1c44371f9ee0cd0bc006f612de11John McCall return ExprError(); 74111eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 74121eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump return move(Result); 7413b98b1991c7ad1eaedb863bdbdd784ec164277675Douglas Gregor} 74141eb4433ac451dc16f4133a88af2d002ac26c58efMike Stump 741526d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregortemplate<typename Derived> 741660d7b3a319d84d688752be3870615ac0f111fb16John McCallExprResult 74179ae2f076ca5ab1feb3ba95629099ec2319833701John McCallTreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base, 741826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SourceLocation OperatorLoc, 741926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor bool isArrow, 742026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor NestedNameSpecifier *Qualifier, 742126d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SourceRange QualifierRange, 742226d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor TypeSourceInfo *ScopeType, 742326d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SourceLocation CCLoc, 7424fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SourceLocation TildeLoc, 7425a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor PseudoDestructorTypeStorage Destroyed) { 742626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor CXXScopeSpec SS; 742726d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor if (Qualifier) { 742826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SS.setRange(QualifierRange); 742926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SS.setScopeRep(Qualifier); 743026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor } 743126d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor 74329ae2f076ca5ab1feb3ba95629099ec2319833701John McCall QualType BaseType = Base->getType(); 74339ae2f076ca5ab1feb3ba95629099ec2319833701John McCall if (Base->isTypeDependent() || Destroyed.getIdentifier() || 743426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor (!isArrow && !BaseType->getAs<RecordType>()) || 7435c302113179a1c2b1254224ea9b6f5316ceeb375cSean Hunt (isArrow && BaseType->getAs<PointerType>() && 7436bf2ca2f87ff0b33b839b1b51d233a79bb56e5bacGabor Greif !BaseType->getAs<PointerType>()->getPointeeType() 7437bf2ca2f87ff0b33b839b1b51d233a79bb56e5bacGabor Greif ->template getAs<RecordType>())){ 743826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor // This pseudo-destructor expression is still a pseudo-destructor. 74399ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return SemaRef.BuildPseudoDestructorExpr(Base, OperatorLoc, 744026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor isArrow? tok::arrow : tok::period, 7441fce46ee68f779e239826e69e45d01d4c8e5323caDouglas Gregor SS, ScopeType, CCLoc, TildeLoc, 7442a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor Destroyed, 744326d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /*FIXME?*/true); 744426d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor } 74452577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 7446a2e7dd2f4a50d835351153aee568d35ccc986310Douglas Gregor TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo(); 74472577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName( 74482577743c5650c646fb705df01403707e94f2df04Abramo Bagnara SemaRef.Context.getCanonicalType(DestroyedType->getType()))); 74492577743c5650c646fb705df01403707e94f2df04Abramo Bagnara DeclarationNameInfo NameInfo(Name, Destroyed.getLocation()); 74502577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo.setNamedTypeInfo(DestroyedType); 74512577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 745226d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor // FIXME: the ScopeType should be tacked onto SS. 74532577743c5650c646fb705df01403707e94f2df04Abramo Bagnara 74549ae2f076ca5ab1feb3ba95629099ec2319833701John McCall return getSema().BuildMemberReferenceExpr(Base, BaseType, 745526d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor OperatorLoc, isArrow, 745626d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor SS, /*FIXME: FirstQualifier*/ 0, 74572577743c5650c646fb705df01403707e94f2df04Abramo Bagnara NameInfo, 745826d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor /*TemplateArgs*/ 0); 745926d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor} 746026d4ac97fb514bb60c2536eae6f203dc569159d9Douglas Gregor 7461577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor} // end namespace clang 7462577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor 7463577f75a7498e9e2536434da0ef0da0eea390d18bDouglas Gregor#endif // LLVM_CLANG_SEMA_TREETRANSFORM_H 7464