2009-10-21 04:40:46 +04:00
|
|
|
//===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===/
|
2009-08-04 20:50:30 +04:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//===----------------------------------------------------------------------===/
|
|
|
|
//
|
|
|
|
// This file implements a semantic tree transformation that takes a given
|
|
|
|
// AST and rebuilds it, possibly transforming some nodes in the process.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===/
|
|
|
|
#ifndef LLVM_CLANG_SEMA_TREETRANSFORM_H
|
|
|
|
#define LLVM_CLANG_SEMA_TREETRANSFORM_H
|
|
|
|
|
2010-08-26 02:03:47 +04:00
|
|
|
#include "clang/Sema/SemaInternal.h"
|
2010-08-13 00:07:10 +04:00
|
|
|
#include "clang/Sema/Lookup.h"
|
2009-08-06 09:28:30 +04:00
|
|
|
#include "clang/Sema/SemaDiagnostic.h"
|
2010-08-25 12:40:02 +04:00
|
|
|
#include "clang/Sema/ScopeInfo.h"
|
2009-09-04 01:38:09 +04:00
|
|
|
#include "clang/AST/Decl.h"
|
2010-08-24 11:21:54 +04:00
|
|
|
#include "clang/AST/DeclObjC.h"
|
2009-08-07 02:17:10 +04:00
|
|
|
#include "clang/AST/Expr.h"
|
2009-08-11 09:31:07 +04:00
|
|
|
#include "clang/AST/ExprCXX.h"
|
|
|
|
#include "clang/AST/ExprObjC.h"
|
2009-08-20 11:17:43 +04:00
|
|
|
#include "clang/AST/Stmt.h"
|
|
|
|
#include "clang/AST/StmtCXX.h"
|
|
|
|
#include "clang/AST/StmtObjC.h"
|
2009-10-21 04:40:46 +04:00
|
|
|
#include "clang/AST/TypeLocBuilder.h"
|
2010-08-20 22:27:03 +04:00
|
|
|
#include "clang/Sema/Ownership.h"
|
|
|
|
#include "clang/Sema/Designator.h"
|
2009-08-11 09:31:07 +04:00
|
|
|
#include "clang/Lex/Preprocessor.h"
|
2009-10-21 04:40:46 +04:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2009-08-04 20:50:30 +04:00
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace clang {
|
2010-08-25 12:40:02 +04:00
|
|
|
using namespace sema;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief A semantic tree transformation that allows one to transform one
|
|
|
|
/// abstract syntax tree into another.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// A new tree transformation is defined by creating a new subclass \c X of
|
|
|
|
/// \c TreeTransform<X> and then overriding certain operations to provide
|
|
|
|
/// behavior specific to that transformation. For example, template
|
2009-08-04 20:50:30 +04:00
|
|
|
/// instantiation is implemented as a tree transformation where the
|
|
|
|
/// transformation of TemplateTypeParmType nodes involves substituting the
|
|
|
|
/// template arguments for their corresponding template parameters; a similar
|
|
|
|
/// transformation is performed for non-type template parameters and
|
|
|
|
/// template template parameters.
|
|
|
|
///
|
|
|
|
/// This tree-transformation template uses static polymorphism to allow
|
2009-09-09 19:08:12 +04:00
|
|
|
/// subclasses to customize any of its operations. Thus, a subclass can
|
2009-08-04 20:50:30 +04:00
|
|
|
/// override any of the transformation or rebuild operators by providing an
|
|
|
|
/// operation with the same signature as the default implementation. The
|
|
|
|
/// overridding function should not be virtual.
|
|
|
|
///
|
|
|
|
/// Semantic tree transformations are split into two stages, either of which
|
|
|
|
/// can be replaced by a subclass. The "transform" step transforms an AST node
|
|
|
|
/// or the parts of an AST node using the various transformation functions,
|
|
|
|
/// then passes the pieces on to the "rebuild" step, which constructs a new AST
|
|
|
|
/// node of the appropriate kind from the pieces. The default transformation
|
|
|
|
/// routines recursively transform the operands to composite AST nodes (e.g.,
|
|
|
|
/// the pointee type of a PointerType node) and, if any of those operand nodes
|
|
|
|
/// were changed by the transformation, invokes the rebuild operation to create
|
|
|
|
/// a new AST node.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// Subclasses can customize the transformation at various levels. The
|
2009-08-05 02:27:00 +04:00
|
|
|
/// most coarse-grained transformations involve replacing TransformType(),
|
2009-08-04 20:50:30 +04:00
|
|
|
/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifier(),
|
|
|
|
/// TransformTemplateName(), or TransformTemplateArgument() with entirely
|
|
|
|
/// new implementations.
|
|
|
|
///
|
|
|
|
/// For more fine-grained transformations, subclasses can replace any of the
|
|
|
|
/// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
|
2009-08-20 11:17:43 +04:00
|
|
|
/// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
|
2009-08-04 20:50:30 +04:00
|
|
|
/// replacing TransformTemplateTypeParmType() allows template instantiation
|
2009-09-09 19:08:12 +04:00
|
|
|
/// to substitute template arguments for their corresponding template
|
2009-08-04 20:50:30 +04:00
|
|
|
/// parameters. Additionally, subclasses can override the \c RebuildXXX
|
|
|
|
/// functions to control how AST nodes are rebuilt when their operands change.
|
|
|
|
/// By default, \c TreeTransform will invoke semantic analysis to rebuild
|
|
|
|
/// AST nodes. However, certain other tree transformations (e.g, cloning) may
|
|
|
|
/// be able to use more efficient rebuild steps.
|
|
|
|
///
|
|
|
|
/// There are a handful of other functions that can be overridden, allowing one
|
2009-09-09 19:08:12 +04:00
|
|
|
/// to avoid traversing nodes that don't need any transformation
|
2009-08-04 20:50:30 +04:00
|
|
|
/// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
|
|
|
|
/// operands have not changed (\c AlwaysRebuild()), and customize the
|
|
|
|
/// default locations and entity names used for type-checking
|
|
|
|
/// (\c getBaseLocation(), \c getBaseEntity()).
|
|
|
|
template<typename Derived>
|
|
|
|
class TreeTransform {
|
|
|
|
protected:
|
|
|
|
Sema &SemaRef;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
public:
|
2009-08-11 09:31:07 +04:00
|
|
|
typedef Sema::MultiExprArg MultiExprArg;
|
2009-08-20 11:17:43 +04:00
|
|
|
typedef Sema::MultiStmtArg MultiStmtArg;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Initializes a new tree transformer.
|
|
|
|
TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Retrieves a reference to the derived class.
|
|
|
|
Derived &getDerived() { return static_cast<Derived&>(*this); }
|
|
|
|
|
|
|
|
/// \brief Retrieves a reference to the derived class.
|
2009-09-09 19:08:12 +04:00
|
|
|
const Derived &getDerived() const {
|
|
|
|
return static_cast<const Derived&>(*this);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
static inline ExprResult Owned(Expr *E) { return E; }
|
|
|
|
static inline StmtResult Owned(Stmt *S) { return S; }
|
2010-08-24 03:25:46 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Retrieves a reference to the semantic analysis object used for
|
|
|
|
/// this tree transform.
|
|
|
|
Sema &getSema() const { return SemaRef; }
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Whether the transformation should always rebuild AST nodes, even
|
|
|
|
/// if none of the children have changed.
|
|
|
|
///
|
|
|
|
/// Subclasses may override this function to specify when the transformation
|
|
|
|
/// should rebuild all AST nodes.
|
|
|
|
bool AlwaysRebuild() { return false; }
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Returns the location of the entity being transformed, if that
|
|
|
|
/// information was not available elsewhere in the AST.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// By default, returns no source-location information. Subclasses can
|
2009-08-04 20:50:30 +04:00
|
|
|
/// provide an alternative implementation that provides better location
|
|
|
|
/// information.
|
|
|
|
SourceLocation getBaseLocation() { return SourceLocation(); }
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Returns the name of the entity being transformed, if that
|
|
|
|
/// information was not available elsewhere in the AST.
|
|
|
|
///
|
|
|
|
/// By default, returns an empty name. Subclasses can provide an alternative
|
|
|
|
/// implementation with a more precise name.
|
|
|
|
DeclarationName getBaseEntity() { return DeclarationName(); }
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Sets the "base" location and entity when that
|
|
|
|
/// information is known based on another transformation.
|
|
|
|
///
|
|
|
|
/// By default, the source location and entity are ignored. Subclasses can
|
|
|
|
/// override this function to provide a customized implementation.
|
|
|
|
void setBase(SourceLocation Loc, DeclarationName Entity) { }
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief RAII object that temporarily sets the base location and entity
|
|
|
|
/// used for reporting diagnostics in types.
|
|
|
|
class TemporaryBase {
|
|
|
|
TreeTransform &Self;
|
|
|
|
SourceLocation OldLocation;
|
|
|
|
DeclarationName OldEntity;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
public:
|
|
|
|
TemporaryBase(TreeTransform &Self, SourceLocation Location,
|
2009-09-09 19:08:12 +04:00
|
|
|
DeclarationName Entity) : Self(Self) {
|
2009-08-11 09:31:07 +04:00
|
|
|
OldLocation = Self.getDerived().getBaseLocation();
|
|
|
|
OldEntity = Self.getDerived().getBaseEntity();
|
|
|
|
Self.getDerived().setBase(Location, Entity);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
~TemporaryBase() {
|
|
|
|
Self.getDerived().setBase(OldLocation, OldEntity);
|
|
|
|
}
|
|
|
|
};
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
/// \brief Determine whether the given type \p T has already been
|
2009-08-04 20:50:30 +04:00
|
|
|
/// transformed.
|
|
|
|
///
|
|
|
|
/// Subclasses can provide an alternative implementation of this routine
|
2009-09-09 19:08:12 +04:00
|
|
|
/// to short-circuit evaluation when it is known that a given type will
|
2009-08-04 20:50:30 +04:00
|
|
|
/// not change. For example, template instantiation need not traverse
|
|
|
|
/// non-dependent types.
|
|
|
|
bool AlreadyTransformed(QualType T) {
|
|
|
|
return T.isNull();
|
|
|
|
}
|
|
|
|
|
2009-12-14 22:27:10 +03:00
|
|
|
/// \brief Determine whether the given call argument should be dropped, e.g.,
|
|
|
|
/// because it is a default argument.
|
|
|
|
///
|
|
|
|
/// Subclasses can provide an alternative implementation of this routine to
|
|
|
|
/// determine which kinds of call arguments get dropped. By default,
|
|
|
|
/// CXXDefaultArgument nodes are dropped (prior to transformation).
|
|
|
|
bool DropCallArgument(Expr *E) {
|
|
|
|
return E->isDefaultArgument();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Transforms the given type into another type.
|
|
|
|
///
|
2009-10-21 04:40:46 +04:00
|
|
|
/// By default, this routine transforms a type by creating a
|
2009-12-07 05:54:59 +03:00
|
|
|
/// TypeSourceInfo for it and delegating to the appropriate
|
2009-10-21 04:40:46 +04:00
|
|
|
/// function. This is expensive, but we don't mind, because
|
|
|
|
/// this method is deprecated anyway; all users should be
|
2009-12-07 05:54:59 +03:00
|
|
|
/// switched to storing TypeSourceInfos.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
|
|
|
/// \returns the transformed type.
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType TransformType(QualType T, QualType ObjectType = QualType());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
/// \brief Transforms the given type-with-location into a new
|
|
|
|
/// type-with-location.
|
|
|
|
///
|
|
|
|
/// By default, this routine transforms a type by delegating to the
|
|
|
|
/// appropriate TransformXXXType to build a new type. Subclasses
|
|
|
|
/// may override this function (to take over all type
|
|
|
|
/// transformations) or some set of the TransformXXXType functions
|
|
|
|
/// to alter the transformation.
|
2010-05-05 19:23:54 +04:00
|
|
|
TypeSourceInfo *TransformType(TypeSourceInfo *DI,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType ObjectType = QualType());
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
/// \brief Transform the given type-with-location into a new
|
|
|
|
/// type, collecting location information in the given builder
|
|
|
|
/// as necessary.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
2010-05-05 19:23:54 +04:00
|
|
|
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType ObjectType = QualType());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-07 02:17:10 +04:00
|
|
|
/// \brief Transform the given statement.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// By default, this routine transforms a statement by delegating to the
|
2009-08-20 11:17:43 +04:00
|
|
|
/// appropriate TransformXXXStmt function to transform a specific kind of
|
|
|
|
/// statement or the TransformExpr() function to transform an expression.
|
|
|
|
/// Subclasses may override this function to transform statements using some
|
|
|
|
/// other mechanism.
|
|
|
|
///
|
|
|
|
/// \returns the transformed statement.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult TransformStmt(Stmt *S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-07 02:17:10 +04:00
|
|
|
/// \brief Transform the given expression.
|
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, this routine transforms an expression by delegating to the
|
|
|
|
/// appropriate TransformXXXExpr function to build a new expression.
|
|
|
|
/// Subclasses may override this function to transform expressions using some
|
|
|
|
/// other mechanism.
|
|
|
|
///
|
|
|
|
/// \returns the transformed expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult TransformExpr(Expr *E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Transform the given declaration, which is referenced from a type
|
|
|
|
/// or expression.
|
|
|
|
///
|
2009-08-06 09:28:30 +04:00
|
|
|
/// By default, acts as the identity function on declarations. Subclasses
|
|
|
|
/// may override this function to provide alternate behavior.
|
2010-03-01 18:56:25 +03:00
|
|
|
Decl *TransformDecl(SourceLocation Loc, Decl *D) { return D; }
|
2009-08-20 11:17:43 +04:00
|
|
|
|
|
|
|
/// \brief Transform the definition of the given declaration.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// By default, invokes TransformDecl() to transform the declaration.
|
2009-08-20 11:17:43 +04:00
|
|
|
/// Subclasses may override this function to provide alternate behavior.
|
2010-05-05 19:23:54 +04:00
|
|
|
Decl *TransformDefinition(SourceLocation Loc, Decl *D) {
|
|
|
|
return getDerived().TransformDecl(Loc, D);
|
2010-03-01 18:56:25 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-20 09:58:46 +04:00
|
|
|
/// \brief Transform the given declaration, which was the first part of a
|
|
|
|
/// nested-name-specifier in a member access expression.
|
|
|
|
///
|
2010-05-05 19:23:54 +04:00
|
|
|
/// This specific declaration transformation only applies to the first
|
2009-10-20 09:58:46 +04:00
|
|
|
/// identifier in a nested-name-specifier of a member access expression, e.g.,
|
|
|
|
/// the \c T in \c x->T::member
|
|
|
|
///
|
|
|
|
/// By default, invokes TransformDecl() to transform the declaration.
|
|
|
|
/// Subclasses may override this function to provide alternate behavior.
|
2010-05-05 19:23:54 +04:00
|
|
|
NamedDecl *TransformFirstQualifierInScope(NamedDecl *D, SourceLocation Loc) {
|
|
|
|
return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
|
2009-10-20 09:58:46 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Transform the given nested-name-specifier.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// By default, transforms all of the types and declarations within the
|
2009-08-06 09:28:30 +04:00
|
|
|
/// nested-name-specifier. Subclasses may override this function to provide
|
|
|
|
/// alternate behavior.
|
2009-08-04 20:50:30 +04:00
|
|
|
NestedNameSpecifier *TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
|
2009-09-03 20:14:30 +04:00
|
|
|
SourceRange Range,
|
2009-09-04 01:38:09 +04:00
|
|
|
QualType ObjectType = QualType(),
|
|
|
|
NamedDecl *FirstQualifierInScope = 0);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-04 02:13:48 +04:00
|
|
|
/// \brief Transform the given declaration name.
|
|
|
|
///
|
|
|
|
/// By default, transforms the types of conversion function, constructor,
|
|
|
|
/// and destructor names and then (if needed) rebuilds the declaration name.
|
|
|
|
/// Identifiers and selectors are returned unmodified. Sublcasses may
|
|
|
|
/// override this function to provide alternate behavior.
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo
|
|
|
|
TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
|
|
|
|
QualType ObjectType = QualType());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Transform the given template name.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-06 10:41:21 +04:00
|
|
|
/// By default, transforms the template name by transforming the declarations
|
2009-09-09 19:08:12 +04:00
|
|
|
/// and nested-name-specifiers that occur within the template name.
|
2009-08-06 10:41:21 +04:00
|
|
|
/// Subclasses may override this function to provide alternate behavior.
|
2009-09-09 04:23:06 +04:00
|
|
|
TemplateName TransformTemplateName(TemplateName Name,
|
|
|
|
QualType ObjectType = QualType());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Transform the given template argument.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// By default, this operation transforms the type, expression, or
|
|
|
|
/// declaration stored within the template argument and constructs a
|
2009-08-05 02:27:00 +04:00
|
|
|
/// new template argument from the transformed result. Subclasses may
|
|
|
|
/// override this function to provide alternate behavior.
|
2009-10-29 11:12:44 +03:00
|
|
|
///
|
|
|
|
/// Returns true if there was an error.
|
|
|
|
bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
|
|
|
|
TemplateArgumentLoc &Output);
|
|
|
|
|
|
|
|
/// \brief Fakes up a TemplateArgumentLoc for a given TemplateArgument.
|
|
|
|
void InventTemplateArgumentLoc(const TemplateArgument &Arg,
|
|
|
|
TemplateArgumentLoc &ArgLoc);
|
|
|
|
|
2009-12-07 05:54:59 +03:00
|
|
|
/// \brief Fakes up a TypeSourceInfo for a type.
|
|
|
|
TypeSourceInfo *InventTypeSourceInfo(QualType T) {
|
|
|
|
return SemaRef.Context.getTrivialTypeSourceInfo(T,
|
2009-10-29 11:12:44 +03:00
|
|
|
getDerived().getBaseLocation());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
|
|
|
#define TYPELOC(CLASS, PARENT) \
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T, \
|
|
|
|
QualType ObjectType = QualType());
|
2009-10-21 04:40:46 +04:00
|
|
|
#include "clang/AST/TypeLocNodes.def"
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2010-03-11 12:03:00 +03:00
|
|
|
/// \brief Transforms the parameters of a function type into the
|
|
|
|
/// given vectors.
|
|
|
|
///
|
|
|
|
/// The result vectors should be kept in sync; null entries in the
|
|
|
|
/// variables vector are acceptable.
|
|
|
|
///
|
|
|
|
/// Return true on error.
|
|
|
|
bool TransformFunctionTypeParams(FunctionProtoTypeLoc TL,
|
|
|
|
llvm::SmallVectorImpl<QualType> &PTypes,
|
|
|
|
llvm::SmallVectorImpl<ParmVarDecl*> &PVars);
|
|
|
|
|
|
|
|
/// \brief Transforms a single function-type parameter. Return null
|
|
|
|
/// on error.
|
|
|
|
ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm);
|
|
|
|
|
2010-05-05 19:23:54 +04:00
|
|
|
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType ObjectType);
|
2009-10-30 03:06:24 +03:00
|
|
|
|
2010-05-05 19:23:54 +04:00
|
|
|
QualType
|
2009-10-20 02:04:39 +04:00
|
|
|
TransformTemplateSpecializationType(const TemplateSpecializationType *T,
|
|
|
|
QualType ObjectType);
|
2009-10-29 11:12:44 +03:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
|
|
|
|
ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
#define STMT(Node, Parent) \
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Transform##Node(Node *S);
|
2009-08-11 09:31:07 +04:00
|
|
|
#define EXPR(Node, Parent) \
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Transform##Node(Node *E);
|
2010-05-18 10:22:21 +04:00
|
|
|
#define ABSTRACT_STMT(Stmt)
|
2010-05-05 19:24:00 +04:00
|
|
|
#include "clang/AST/StmtNodes.inc"
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new pointer type given its pointee type.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the pointer type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-10-30 03:06:24 +03:00
|
|
|
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil);
|
2009-08-04 20:50:30 +04:00
|
|
|
|
|
|
|
/// \brief Build a new block pointer type given its pointee type.
|
|
|
|
///
|
2009-09-09 19:08:12 +04:00
|
|
|
/// By default, performs semantic analysis when building the block pointer
|
2009-08-04 20:50:30 +04:00
|
|
|
/// type. Subclasses may override this routine to provide different behavior.
|
2009-10-30 03:06:24 +03:00
|
|
|
QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil);
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2009-10-30 03:06:24 +03:00
|
|
|
/// \brief Build a new reference type given the type it references.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
2009-10-30 03:06:24 +03:00
|
|
|
/// By default, performs semantic analysis when building the
|
|
|
|
/// reference type. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
2009-10-30 03:06:24 +03:00
|
|
|
/// \param LValue whether the type was written with an lvalue sigil
|
|
|
|
/// or an rvalue sigil.
|
|
|
|
QualType RebuildReferenceType(QualType ReferentType,
|
|
|
|
bool LValue,
|
|
|
|
SourceLocation Sigil);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new member pointer type given the pointee type and the
|
|
|
|
/// class type it refers into.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the member pointer
|
|
|
|
/// type. Subclasses may override this routine to provide different behavior.
|
2009-10-30 03:06:24 +03:00
|
|
|
QualType RebuildMemberPointerType(QualType PointeeType, QualType ClassType,
|
|
|
|
SourceLocation Sigil);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new array type given the element type, size
|
|
|
|
/// modifier, size of the array (if known), size expression, and index type
|
|
|
|
/// qualifiers.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the array type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
/// Also by default, all of the other Rebuild*Array
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType RebuildArrayType(QualType ElementType,
|
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
|
|
|
const llvm::APInt *Size,
|
|
|
|
Expr *SizeExpr,
|
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new constant array type given the element type, size
|
|
|
|
/// modifier, (known) size of the array, and index type qualifiers.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the array type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType RebuildConstantArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
|
|
|
const llvm::APInt &Size,
|
2009-10-30 03:06:24 +03:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange);
|
2009-08-04 20:50:30 +04:00
|
|
|
|
|
|
|
/// \brief Build a new incomplete array type given the element type, size
|
|
|
|
/// modifier, and index type qualifiers.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the array type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType RebuildIncompleteArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
2009-10-30 03:06:24 +03:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange);
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new variable-length array type given the element type,
|
2009-08-04 20:50:30 +04:00
|
|
|
/// size modifier, size expression, and index type qualifiers.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the array type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType RebuildVariableArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange);
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new dependent-sized array type given the element type,
|
2009-08-04 20:50:30 +04:00
|
|
|
/// size modifier, size expression, and index type qualifiers.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the array type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType RebuildDependentSizedArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange);
|
|
|
|
|
|
|
|
/// \brief Build a new vector type given the element type and
|
|
|
|
/// number of elements.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the vector type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-02-05 03:12:22 +03:00
|
|
|
QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
|
2010-06-23 10:00:24 +04:00
|
|
|
VectorType::AltiVecSpecific AltiVecSpec);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new extended vector type given the element type and
|
|
|
|
/// number of elements.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the vector type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
|
|
|
|
SourceLocation AttributeLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
/// \brief Build a new potentially dependently-sized extended vector type
|
2009-08-04 20:50:30 +04:00
|
|
|
/// given the element type and number of elements.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the vector type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType RebuildDependentSizedExtVectorType(QualType ElementType,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
SourceLocation AttributeLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new function type.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the function type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
QualType RebuildFunctionProtoType(QualType T,
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType *ParamTypes,
|
2009-08-04 20:50:30 +04:00
|
|
|
unsigned NumParamTypes,
|
2010-08-05 06:54:05 +04:00
|
|
|
bool Variadic, unsigned Quals,
|
|
|
|
const FunctionType::ExtInfo &Info);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
/// \brief Build a new unprototyped function type.
|
|
|
|
QualType RebuildFunctionNoProtoType(QualType ResultType);
|
|
|
|
|
2009-12-05 01:46:56 +03:00
|
|
|
/// \brief Rebuild an unresolved typename type, given the decl that
|
|
|
|
/// the UnresolvedUsingTypenameDecl was transformed to.
|
|
|
|
QualType RebuildUnresolvedUsingType(Decl *D);
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new typedef type.
|
|
|
|
QualType RebuildTypedefType(TypedefDecl *Typedef) {
|
|
|
|
return SemaRef.Context.getTypeDeclType(Typedef);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new class/struct/union type.
|
|
|
|
QualType RebuildRecordType(RecordDecl *Record) {
|
|
|
|
return SemaRef.Context.getTypeDeclType(Record);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new Enum type.
|
|
|
|
QualType RebuildEnumType(EnumDecl *Enum) {
|
|
|
|
return SemaRef.Context.getTypeDeclType(Enum);
|
|
|
|
}
|
2009-09-05 04:15:47 +04:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new typeof(expr) type.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the typeof type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 03:25:46 +04:00
|
|
|
QualType RebuildTypeOfExprType(Expr *Underlying);
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new typeof(type) type.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
|
|
|
/// By default, builds a new TypeOfType with the given underlying type.
|
|
|
|
QualType RebuildTypeOfType(QualType Underlying);
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new C++0x decltype type.
|
2009-08-04 20:50:30 +04:00
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the decltype type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 03:25:46 +04:00
|
|
|
QualType RebuildDecltypeType(Expr *Underlying);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new template specialization type.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the template
|
|
|
|
/// specialization type. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
|
|
|
QualType RebuildTemplateSpecializationType(TemplateName Template,
|
2009-10-29 11:12:44 +03:00
|
|
|
SourceLocation TemplateLoc,
|
2009-11-23 04:53:49 +03:00
|
|
|
const TemplateArgumentListInfo &Args);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Build a new qualified name type.
|
|
|
|
///
|
2010-05-12 01:36:43 +04:00
|
|
|
/// By default, builds a new ElaboratedType type from the keyword,
|
|
|
|
/// the nested-name-specifier and the named type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
QualType RebuildElaboratedType(ElaboratedTypeKeyword Keyword,
|
|
|
|
NestedNameSpecifier *NNS, QualType Named) {
|
|
|
|
return SemaRef.Context.getElaboratedType(Keyword, NNS, Named);
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
|
|
|
|
/// \brief Build a new typename type that refers to a template-id.
|
|
|
|
///
|
2010-05-20 01:37:53 +04:00
|
|
|
/// By default, builds a new DependentNameType type from the
|
|
|
|
/// nested-name-specifier and the given type. Subclasses may override
|
|
|
|
/// this routine to provide different behavior.
|
2010-06-11 04:33:02 +04:00
|
|
|
QualType RebuildDependentTemplateSpecializationType(
|
|
|
|
ElaboratedTypeKeyword Keyword,
|
|
|
|
NestedNameSpecifier *NNS,
|
|
|
|
const IdentifierInfo *Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
const TemplateArgumentListInfo &Args) {
|
|
|
|
// Rebuild the template name.
|
|
|
|
// TODO: avoid TemplateName abstraction
|
|
|
|
TemplateName InstName =
|
|
|
|
getDerived().RebuildTemplateName(NNS, *Name, QualType());
|
|
|
|
|
2010-06-19 02:12:56 +04:00
|
|
|
if (InstName.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
2010-06-11 04:33:02 +04:00
|
|
|
// If it's still dependent, make a dependent specialization.
|
|
|
|
if (InstName.getAsDependentTemplateName())
|
|
|
|
return SemaRef.Context.getDependentTemplateSpecializationType(
|
|
|
|
Keyword, NNS, Name, Args);
|
|
|
|
|
|
|
|
// Otherwise, make an elaborated type wrapping a non-dependent
|
|
|
|
// specialization.
|
|
|
|
QualType T =
|
|
|
|
getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
|
|
|
|
if (T.isNull()) return QualType();
|
2010-05-12 01:36:43 +04:00
|
|
|
|
2010-08-10 17:46:45 +04:00
|
|
|
// NOTE: NNS is already recorded in template specialization type T.
|
|
|
|
return SemaRef.Context.getElaboratedType(Keyword, /*NNS=*/0, T);
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
|
|
|
|
/// \brief Build a new typename type that refers to an identifier.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the typename type
|
2010-05-20 01:37:53 +04:00
|
|
|
/// (or elaborated type). Subclasses may override this routine to provide
|
2009-08-04 20:50:30 +04:00
|
|
|
/// different behavior.
|
2010-05-20 01:37:53 +04:00
|
|
|
QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword,
|
2010-04-01 00:19:30 +04:00
|
|
|
NestedNameSpecifier *NNS,
|
|
|
|
const IdentifierInfo *Id,
|
2010-05-20 01:37:53 +04:00
|
|
|
SourceLocation KeywordLoc,
|
|
|
|
SourceRange NNSRange,
|
|
|
|
SourceLocation IdLoc) {
|
2010-04-01 02:19:08 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.setScopeRep(NNS);
|
2010-05-20 01:37:53 +04:00
|
|
|
SS.setRange(NNSRange);
|
|
|
|
|
2010-04-01 02:19:08 +04:00
|
|
|
if (NNS->isDependent()) {
|
|
|
|
// If the name is still dependent, just build a new dependent name type.
|
|
|
|
if (!SemaRef.computeDeclContext(SS))
|
|
|
|
return SemaRef.Context.getDependentNameType(Keyword, NNS, Id);
|
|
|
|
}
|
|
|
|
|
2010-05-12 01:36:43 +04:00
|
|
|
if (Keyword == ETK_None || Keyword == ETK_Typename)
|
2010-05-20 01:37:53 +04:00
|
|
|
return SemaRef.CheckTypenameType(Keyword, NNS, *Id,
|
|
|
|
KeywordLoc, NNSRange, IdLoc);
|
2010-05-12 01:36:43 +04:00
|
|
|
|
|
|
|
TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForKeyword(Keyword);
|
|
|
|
|
2010-05-20 01:37:53 +04:00
|
|
|
// We had a dependent elaborated-type-specifier that has been transformed
|
2010-04-01 02:19:08 +04:00
|
|
|
// into a non-dependent elaborated-type-specifier. Find the tag we're
|
|
|
|
// referring to.
|
2010-05-20 01:37:53 +04:00
|
|
|
LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
|
2010-04-01 02:19:08 +04:00
|
|
|
DeclContext *DC = SemaRef.computeDeclContext(SS, false);
|
|
|
|
if (!DC)
|
|
|
|
return QualType();
|
|
|
|
|
2010-05-27 10:40:31 +04:00
|
|
|
if (SemaRef.RequireCompleteDeclContext(SS, DC))
|
|
|
|
return QualType();
|
|
|
|
|
2010-04-01 02:19:08 +04:00
|
|
|
TagDecl *Tag = 0;
|
|
|
|
SemaRef.LookupQualifiedName(Result, DC);
|
|
|
|
switch (Result.getResultKind()) {
|
|
|
|
case LookupResult::NotFound:
|
|
|
|
case LookupResult::NotFoundInCurrentInstantiation:
|
|
|
|
break;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-01 02:19:08 +04:00
|
|
|
case LookupResult::Found:
|
|
|
|
Tag = Result.getAsSingle<TagDecl>();
|
|
|
|
break;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-01 02:19:08 +04:00
|
|
|
case LookupResult::FoundOverloaded:
|
|
|
|
case LookupResult::FoundUnresolvedValue:
|
|
|
|
llvm_unreachable("Tag lookup cannot find non-tags");
|
|
|
|
return QualType();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-01 02:19:08 +04:00
|
|
|
case LookupResult::Ambiguous:
|
|
|
|
// Let the LookupResult structure handle ambiguities.
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Tag) {
|
2010-04-01 03:17:41 +04:00
|
|
|
// FIXME: Would be nice to highlight just the source range.
|
2010-05-20 01:37:53 +04:00
|
|
|
SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
|
2010-04-01 03:17:41 +04:00
|
|
|
<< Kind << Id << DC;
|
2010-04-01 02:19:08 +04:00
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-12 01:36:43 +04:00
|
|
|
|
2010-05-20 01:37:53 +04:00
|
|
|
if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, IdLoc, *Id)) {
|
|
|
|
SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
|
2010-04-01 02:19:08 +04:00
|
|
|
SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Build the elaborated-type-specifier type.
|
|
|
|
QualType T = SemaRef.Context.getTypeDeclType(Tag);
|
2010-05-12 01:36:43 +04:00
|
|
|
return SemaRef.Context.getElaboratedType(Keyword, NNS, T);
|
2009-08-06 09:28:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
/// \brief Build a new nested-name-specifier given the prefix and an
|
|
|
|
/// identifier that names the next step in the nested-name-specifier.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the new
|
|
|
|
/// nested-name-specifier. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
|
|
|
NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
|
|
|
|
SourceRange Range,
|
2009-09-03 20:14:30 +04:00
|
|
|
IdentifierInfo &II,
|
2009-09-04 01:38:09 +04:00
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope);
|
2009-08-06 09:28:30 +04:00
|
|
|
|
|
|
|
/// \brief Build a new nested-name-specifier given the prefix and the
|
|
|
|
/// namespace named in the next step in the nested-name-specifier.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the new
|
|
|
|
/// nested-name-specifier. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
|
|
|
NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
|
|
|
|
SourceRange Range,
|
|
|
|
NamespaceDecl *NS);
|
|
|
|
|
|
|
|
/// \brief Build a new nested-name-specifier given the prefix and the
|
|
|
|
/// type named in the next step in the nested-name-specifier.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the new
|
|
|
|
/// nested-name-specifier. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
|
|
|
NestedNameSpecifier *RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
|
|
|
|
SourceRange Range,
|
|
|
|
bool TemplateKW,
|
2010-02-25 07:46:04 +03:00
|
|
|
QualType T);
|
2009-08-06 10:41:21 +04:00
|
|
|
|
|
|
|
/// \brief Build a new template name given a nested name specifier, a flag
|
|
|
|
/// indicating whether the "template" keyword was provided, and the template
|
|
|
|
/// that the template name refers to.
|
|
|
|
///
|
|
|
|
/// By default, builds the new template name directly. Subclasses may override
|
|
|
|
/// this routine to provide different behavior.
|
|
|
|
TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
|
|
|
|
bool TemplateKW,
|
|
|
|
TemplateDecl *Template);
|
|
|
|
|
|
|
|
/// \brief Build a new template name given a nested name specifier and the
|
|
|
|
/// name that is referred to as a template.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to determine whether the name can
|
|
|
|
/// be resolved to a specific template, then builds the appropriate kind of
|
|
|
|
/// template name. Subclasses may override this routine to provide different
|
|
|
|
/// behavior.
|
|
|
|
TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
|
2009-09-09 04:23:06 +04:00
|
|
|
const IdentifierInfo &II,
|
|
|
|
QualType ObjectType);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-04 03:56:37 +03:00
|
|
|
/// \brief Build a new template name given a nested name specifier and the
|
|
|
|
/// overloaded operator name that is referred to as a template.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to determine whether the name can
|
|
|
|
/// be resolved to a specific template, then builds the appropriate kind of
|
|
|
|
/// template name. Subclasses may override this routine to provide different
|
|
|
|
/// behavior.
|
|
|
|
TemplateName RebuildTemplateName(NestedNameSpecifier *Qualifier,
|
|
|
|
OverloadedOperatorKind Operator,
|
|
|
|
QualType ObjectType);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new compound statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
MultiStmtArg Statements,
|
|
|
|
SourceLocation RBraceLoc,
|
|
|
|
bool IsStmtExpr) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
|
2009-08-20 11:17:43 +04:00
|
|
|
IsStmtExpr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new case statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildCaseStmt(SourceLocation CaseLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *LHS,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation EllipsisLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *RHS,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation ColonLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
|
2009-08-20 11:17:43 +04:00
|
|
|
ColonLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Attach the body to a new case statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildCaseStmtBody(Stmt *S, Stmt *Body) {
|
2010-08-24 03:25:46 +04:00
|
|
|
getSema().ActOnCaseStmtBody(S, Body);
|
|
|
|
return S;
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new default statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildDefaultStmt(SourceLocation DefaultLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation ColonLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *SubStmt) {
|
|
|
|
return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
|
2009-08-20 11:17:43 +04:00
|
|
|
/*CurScope=*/0);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new label statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildLabelStmt(SourceLocation IdentLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
IdentifierInfo *Id,
|
|
|
|
SourceLocation ColonLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *SubStmt) {
|
|
|
|
return SemaRef.ActOnLabelStmt(IdentLoc, Id, ColonLoc, SubStmt);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new "if" statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildIfStmt(SourceLocation IfLoc, Sema::FullExprArg Cond,
|
2010-08-24 03:25:46 +04:00
|
|
|
VarDecl *CondVar, Stmt *Then,
|
|
|
|
SourceLocation ElseLoc, Stmt *Else) {
|
|
|
|
return getSema().ActOnIfStmt(IfLoc, Cond, CondVar, Then, ElseLoc, Else);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Start building a new switch statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Cond, VarDecl *CondVar) {
|
|
|
|
return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Cond,
|
2010-08-21 13:40:31 +04:00
|
|
|
CondVar);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Attach the body to the switch statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Switch, Stmt *Body) {
|
|
|
|
return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new while statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildWhileStmt(SourceLocation WhileLoc,
|
2010-05-09 02:20:28 +04:00
|
|
|
Sema::FullExprArg Cond,
|
2009-11-25 03:27:52 +03:00
|
|
|
VarDecl *CondVar,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Body) {
|
|
|
|
return getSema().ActOnWhileStmt(WhileLoc, Cond, CondVar, Body);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new do-while statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildDoStmt(SourceLocation DoLoc, Stmt *Body,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation WhileLoc,
|
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Cond,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
|
|
|
|
Cond, RParenLoc);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new for statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildForStmt(SourceLocation ForLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Init, Sema::FullExprArg Cond,
|
2009-11-25 03:27:52 +03:00
|
|
|
VarDecl *CondVar, Sema::FullExprArg Inc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SourceLocation RParenLoc, Stmt *Body) {
|
|
|
|
return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
|
2010-08-21 13:40:31 +04:00
|
|
|
CondVar,
|
2010-08-24 03:25:46 +04:00
|
|
|
Inc, RParenLoc, Body);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new goto statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildGotoStmt(SourceLocation GotoLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation LabelLoc,
|
|
|
|
LabelStmt *Label) {
|
|
|
|
return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label->getID());
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new indirect goto statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildIndirectGotoStmt(SourceLocation GotoLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation StarLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Target) {
|
|
|
|
return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new return statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Result) {
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnReturnStmt(ReturnLoc, Result);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new declaration statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildDeclStmt(Decl **Decls, unsigned NumDecls,
|
2009-09-09 19:08:12 +04:00
|
|
|
SourceLocation StartLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
SourceLocation EndLoc) {
|
|
|
|
return getSema().Owned(
|
|
|
|
new (getSema().Context) DeclStmt(
|
|
|
|
DeclGroupRef::Create(getSema().Context,
|
|
|
|
Decls, NumDecls),
|
|
|
|
StartLoc, EndLoc));
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
/// \brief Build a new inline asm statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildAsmStmt(SourceLocation AsmLoc,
|
2010-01-24 08:50:09 +03:00
|
|
|
bool IsSimple,
|
|
|
|
bool IsVolatile,
|
|
|
|
unsigned NumOutputs,
|
|
|
|
unsigned NumInputs,
|
2010-01-31 01:25:16 +03:00
|
|
|
IdentifierInfo **Names,
|
2010-01-24 08:50:09 +03:00
|
|
|
MultiExprArg Constraints,
|
|
|
|
MultiExprArg Exprs,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *AsmString,
|
2010-01-24 08:50:09 +03:00
|
|
|
MultiExprArg Clobbers,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
bool MSAsm) {
|
2010-05-05 19:23:54 +04:00
|
|
|
return getSema().ActOnAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
|
2010-01-24 08:50:09 +03:00
|
|
|
NumInputs, Names, move(Constraints),
|
2010-08-24 03:25:46 +04:00
|
|
|
Exprs, AsmString, Clobbers,
|
2010-01-24 08:50:09 +03:00
|
|
|
RParenLoc, MSAsm);
|
|
|
|
}
|
2010-04-23 03:59:56 +04:00
|
|
|
|
|
|
|
/// \brief Build a new Objective-C @try statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildObjCAtTryStmt(SourceLocation AtLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *TryBody,
|
2010-04-24 02:50:49 +04:00
|
|
|
MultiStmtArg CatchStmts,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Finally) {
|
|
|
|
return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, move(CatchStmts),
|
|
|
|
Finally);
|
2010-04-23 03:59:56 +04:00
|
|
|
}
|
|
|
|
|
2010-04-26 21:57:08 +04:00
|
|
|
/// \brief Rebuild an Objective-C exception declaration.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new declaration.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
VarDecl *RebuildObjCExceptionDecl(VarDecl *ExceptionDecl,
|
|
|
|
TypeSourceInfo *TInfo, QualType T) {
|
2010-05-05 19:23:54 +04:00
|
|
|
return getSema().BuildObjCExceptionDecl(TInfo, T,
|
|
|
|
ExceptionDecl->getIdentifier(),
|
2010-04-26 21:57:08 +04:00
|
|
|
ExceptionDecl->getLocation());
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-26 21:57:08 +04:00
|
|
|
/// \brief Build a new Objective-C @catch statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildObjCAtCatchStmt(SourceLocation AtLoc,
|
2010-04-26 21:57:08 +04:00
|
|
|
SourceLocation RParenLoc,
|
|
|
|
VarDecl *Var,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Body) {
|
2010-04-26 21:57:08 +04:00
|
|
|
return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Var, Body);
|
2010-04-26 21:57:08 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:59:56 +04:00
|
|
|
/// \brief Build a new Objective-C @finally statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildObjCAtFinallyStmt(SourceLocation AtLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Body) {
|
|
|
|
return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
|
2010-04-23 03:59:56 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 02:01:21 +04:00
|
|
|
/// \brief Build a new Objective-C @throw statement.
|
2010-04-23 01:44:01 +04:00
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildObjCAtThrowStmt(SourceLocation AtLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Operand) {
|
|
|
|
return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
|
2010-04-23 01:44:01 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 02:01:21 +04:00
|
|
|
/// \brief Build a new Objective-C @synchronized statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Object,
|
|
|
|
Stmt *Body) {
|
|
|
|
return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object,
|
|
|
|
Body);
|
2010-04-23 02:01:21 +04:00
|
|
|
}
|
2010-04-23 03:10:45 +04:00
|
|
|
|
|
|
|
/// \brief Build a new Objective-C fast enumeration statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildObjCForCollectionStmt(SourceLocation ForLoc,
|
2010-04-23 03:10:45 +04:00
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Element,
|
|
|
|
Expr *Collection,
|
2010-04-23 03:10:45 +04:00
|
|
|
SourceLocation RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Body) {
|
2010-04-23 03:10:45 +04:00
|
|
|
return getSema().ActOnObjCForCollectionStmt(ForLoc, LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Element,
|
|
|
|
Collection,
|
2010-04-23 03:10:45 +04:00
|
|
|
RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Body);
|
2010-04-23 03:10:45 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new C++ exception declaration.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new decaration.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2009-09-09 19:08:12 +04:00
|
|
|
VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl, QualType T,
|
2009-12-07 05:54:59 +03:00
|
|
|
TypeSourceInfo *Declarator,
|
2009-08-20 11:17:43 +04:00
|
|
|
IdentifierInfo *Name,
|
|
|
|
SourceLocation Loc,
|
|
|
|
SourceRange TypeRange) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getSema().BuildExceptionDeclaration(0, T, Declarator, Name, Loc,
|
2009-08-20 11:17:43 +04:00
|
|
|
TypeRange);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ catch statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc,
|
2009-08-20 11:17:43 +04:00
|
|
|
VarDecl *ExceptionDecl,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *Handler) {
|
|
|
|
return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
|
|
|
|
Handler));
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
/// \brief Build a new C++ try statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *TryBlock,
|
2009-08-20 11:17:43 +04:00
|
|
|
MultiStmtArg Handlers) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, move(Handlers));
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
/// \brief Build a new expression that references a declaration.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS,
|
2009-11-24 22:00:30 +03:00
|
|
|
LookupResult &R,
|
|
|
|
bool RequiresADL) {
|
|
|
|
return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new expression that references a declaration.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildDeclRefExpr(NestedNameSpecifier *Qualifier,
|
2009-10-23 22:54:35 +04:00
|
|
|
SourceRange QualifierRange,
|
2010-08-12 02:01:17 +04:00
|
|
|
ValueDecl *VD,
|
|
|
|
const DeclarationNameInfo &NameInfo,
|
2009-12-08 12:08:17 +03:00
|
|
|
TemplateArgumentListInfo *TemplateArgs) {
|
2009-10-23 22:54:35 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.setScopeRep(Qualifier);
|
|
|
|
SS.setRange(QualifierRange);
|
2009-12-08 12:08:17 +03:00
|
|
|
|
|
|
|
// FIXME: loses template args.
|
2010-08-12 02:01:17 +04:00
|
|
|
|
|
|
|
return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new expression in parentheses.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildParenExpr(Expr *SubExpr, SourceLocation LParen,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParen) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-04 21:36:40 +04:00
|
|
|
/// \brief Build a new pseudo-destructor expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-09-04 21:36:40 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base,
|
2009-09-04 21:36:40 +04:00
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
bool isArrow,
|
2010-02-25 04:56:36 +03:00
|
|
|
NestedNameSpecifier *Qualifier,
|
2010-02-25 02:40:28 +03:00
|
|
|
SourceRange QualifierRange,
|
|
|
|
TypeSourceInfo *ScopeType,
|
|
|
|
SourceLocation CCLoc,
|
2010-02-25 02:50:37 +03:00
|
|
|
SourceLocation TildeLoc,
|
2010-02-25 04:56:36 +03:00
|
|
|
PseudoDestructorTypeStorage Destroyed);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new unary operator expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildUnaryOperator(SourceLocation OpLoc,
|
2010-08-25 15:45:40 +04:00
|
|
|
UnaryOperatorKind Opc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr) {
|
|
|
|
return getSema().BuildUnaryOp(/*Scope=*/0, OpLoc, Opc, SubExpr);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
/// \brief Build a new builtin offsetof expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildOffsetOfExpr(SourceLocation OperatorLoc,
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
TypeSourceInfo *Type,
|
|
|
|
Action::OffsetOfComponent *Components,
|
|
|
|
unsigned NumComponents,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
|
|
|
|
NumComponents, RParenLoc);
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new sizeof or alignof expression with a type argument.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildSizeOfAlignOf(TypeSourceInfo *TInfo,
|
2009-11-04 10:28:41 +03:00
|
|
|
SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
bool isSizeOf, SourceRange R) {
|
2009-12-07 05:54:59 +03:00
|
|
|
return getSema().CreateSizeOfAlignOfExpr(TInfo, OpLoc, isSizeOf, R);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new sizeof or alignof expression with an expression
|
2009-08-11 09:31:07 +04:00
|
|
|
/// argument.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildSizeOfAlignOf(Expr *SubExpr, SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
bool isSizeOf, SourceRange R) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result
|
2010-08-24 03:25:46 +04:00
|
|
|
= getSema().CreateSizeOfAlignOfExpr(SubExpr, OpLoc, isSizeOf, R);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return getSema().ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return move(Result);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new array subscript expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildArraySubscriptExpr(Expr *LHS,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LBracketLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *RHS,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RBracketLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnArraySubscriptExpr(/*Scope=*/0, LHS,
|
|
|
|
LBracketLoc, RHS,
|
2009-08-11 09:31:07 +04:00
|
|
|
RBracketLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new call expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation *CommaLocs,
|
|
|
|
SourceLocation RParenLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnCallExpr(/*Scope=*/0, Callee, LParenLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
move(Args), CommaLocs, RParenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new member access expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc,
|
2009-09-09 19:08:12 +04:00
|
|
|
bool isArrow,
|
2009-09-01 03:41:50 +04:00
|
|
|
NestedNameSpecifier *Qualifier,
|
|
|
|
SourceRange QualifierRange,
|
2010-08-12 02:01:17 +04:00
|
|
|
const DeclarationNameInfo &MemberNameInfo,
|
2009-12-04 09:40:45 +03:00
|
|
|
ValueDecl *Member,
|
2010-03-31 01:47:33 +04:00
|
|
|
NamedDecl *FoundDecl,
|
2009-11-23 04:53:49 +03:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
2009-11-05 02:20:05 +03:00
|
|
|
NamedDecl *FirstQualifierInScope) {
|
2009-09-01 08:26:58 +04:00
|
|
|
if (!Member->getDeclName()) {
|
|
|
|
// We have a reference to an unnamed field.
|
|
|
|
assert(!Qualifier && "Can't have an unnamed field with a qualifier!");
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
if (getSema().PerformObjectMemberConversion(Base, Qualifier,
|
2010-03-31 01:47:33 +04:00
|
|
|
FoundDecl, Member))
|
2009-12-24 23:02:50 +03:00
|
|
|
return getSema().ExprError();
|
2009-12-24 23:23:34 +03:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
MemberExpr *ME =
|
2010-08-24 03:25:46 +04:00
|
|
|
new (getSema().Context) MemberExpr(Base, isArrow,
|
2010-08-12 02:01:17 +04:00
|
|
|
Member, MemberNameInfo,
|
2009-09-01 08:26:58 +04:00
|
|
|
cast<FieldDecl>(Member)->getType());
|
|
|
|
return getSema().Owned(ME);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-01 03:41:50 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
if (Qualifier) {
|
|
|
|
SS.setRange(QualifierRange);
|
|
|
|
SS.setScopeRep(Qualifier);
|
|
|
|
}
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
getSema().DefaultFunctionArrayConversion(Base);
|
|
|
|
QualType BaseType = Base->getType();
|
2009-12-02 01:10:20 +03:00
|
|
|
|
2010-03-31 01:47:33 +04:00
|
|
|
// FIXME: this involves duplicating earlier analysis in a lot of
|
|
|
|
// cases; we should avoid this when possible.
|
2010-08-12 02:01:17 +04:00
|
|
|
LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
|
2010-03-31 01:47:33 +04:00
|
|
|
R.addDecl(FoundDecl);
|
2010-01-15 11:34:02 +03:00
|
|
|
R.resolveKind();
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
|
2009-12-01 01:42:35 +03:00
|
|
|
SS, FirstQualifierInScope,
|
2010-01-15 11:34:02 +03:00
|
|
|
R, ExplicitTemplateArgs);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new binary operator expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildBinaryOperator(SourceLocation OpLoc,
|
2010-08-25 15:45:40 +04:00
|
|
|
BinaryOperatorKind Opc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *LHS, Expr *RHS) {
|
|
|
|
return getSema().BuildBinOp(/*Scope=*/0, OpLoc, Opc, LHS, RHS);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new conditional operator expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildConditionalOperator(Expr *Cond,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation QuestionLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *LHS,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation ColonLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *RHS) {
|
|
|
|
return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
|
|
|
|
LHS, RHS);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C-style cast expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCStyleCastExpr(SourceLocation LParenLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr) {
|
2010-01-15 21:56:44 +03:00
|
|
|
return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new compound literal expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCompoundLiteralExpr(SourceLocation LParenLoc,
|
2010-01-18 22:35:47 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Init) {
|
2010-01-18 22:35:47 +03:00
|
|
|
return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Init);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new extended vector element access expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildExtVectorElementExpr(Expr *Base,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation OpLoc,
|
|
|
|
SourceLocation AccessorLoc,
|
|
|
|
IdentifierInfo &Accessor) {
|
2009-12-02 01:10:20 +03:00
|
|
|
|
2009-12-01 01:42:35 +03:00
|
|
|
CXXScopeSpec SS;
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
|
2009-12-01 01:42:35 +03:00
|
|
|
OpLoc, /*IsArrow*/ false,
|
|
|
|
SS, /*FirstQualifierInScope*/ 0,
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo,
|
2009-12-01 01:42:35 +03:00
|
|
|
/* TemplateArgs */ 0);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new initializer list expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildInitList(SourceLocation LBraceLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
MultiExprArg Inits,
|
2009-11-09 20:16:50 +03:00
|
|
|
SourceLocation RBraceLoc,
|
|
|
|
QualType ResultTy) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result
|
2009-11-09 20:16:50 +03:00
|
|
|
= SemaRef.ActOnInitList(LBraceLoc, move(Inits), RBraceLoc);
|
|
|
|
if (Result.isInvalid() || ResultTy->isDependentType())
|
|
|
|
return move(Result);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-09 20:16:50 +03:00
|
|
|
// Patch in the result type we were given, which may have been computed
|
|
|
|
// when the initial InitListExpr was built.
|
|
|
|
InitListExpr *ILE = cast<InitListExpr>((Expr *)Result.get());
|
|
|
|
ILE->setType(ResultTy);
|
|
|
|
return move(Result);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new designated initializer expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildDesignatedInitExpr(Designation &Desig,
|
2009-08-11 09:31:07 +04:00
|
|
|
MultiExprArg ArrayExprs,
|
|
|
|
SourceLocation EqualOrColonLoc,
|
|
|
|
bool GNUSyntax,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Init) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
|
2010-08-24 03:25:46 +04:00
|
|
|
Init);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArrayExprs.release();
|
|
|
|
return move(Result);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new value-initialized expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, builds the implicit value initialization without performing
|
|
|
|
/// any semantic analysis. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildImplicitValueInitExpr(QualType T) {
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.Owned(new (SemaRef.Context) ImplicitValueInitExpr(T));
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new \c va_arg expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr, TypeSourceInfo *TInfo,
|
2010-08-10 14:06:15 +04:00
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildVAArgExpr(BuiltinLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr, TInfo,
|
2010-08-10 14:06:15 +04:00
|
|
|
RParenLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new expression list in parentheses.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildParenListExpr(SourceLocation LParenLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
MultiExprArg SubExprs,
|
|
|
|
SourceLocation RParenLoc) {
|
2010-05-05 19:23:54 +04:00
|
|
|
return getSema().ActOnParenOrParenListExpr(LParenLoc, RParenLoc,
|
2009-11-25 04:26:41 +03:00
|
|
|
move(SubExprs));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new address-of-label expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis, using the name of the label
|
2009-08-11 09:31:07 +04:00
|
|
|
/// rather than attempting to map the label statement itself.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildAddrLabelExpr(SourceLocation AmpAmpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LabelLoc,
|
|
|
|
LabelStmt *Label) {
|
|
|
|
return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label->getID());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new GNU statement expression.
|
2009-09-09 19:08:12 +04:00
|
|
|
///
|
2009-08-11 09:31:07 +04:00
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildStmtExpr(SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Stmt *SubStmt,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new __builtin_types_compatible_p expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildTypesCompatibleExpr(SourceLocation BuiltinLoc,
|
2010-08-10 12:50:03 +04:00
|
|
|
TypeSourceInfo *TInfo1,
|
|
|
|
TypeSourceInfo *TInfo2,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-08-10 12:50:03 +04:00
|
|
|
return getSema().BuildTypesCompatibleExpr(BuiltinLoc,
|
|
|
|
TInfo1, TInfo2,
|
2009-08-11 09:31:07 +04:00
|
|
|
RParenLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new __builtin_choose_expr expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildChooseExpr(SourceLocation BuiltinLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Cond, Expr *LHS, Expr *RHS,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return SemaRef.ActOnChooseExpr(BuiltinLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond, LHS, RHS,
|
2009-08-11 09:31:07 +04:00
|
|
|
RParenLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new overloaded operator call expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// The semantic analysis provides the behavior of template instantiation,
|
|
|
|
/// copying with transformations that turn what looks like an overloaded
|
2009-09-09 19:08:12 +04:00
|
|
|
/// operator call into a use of a builtin operator, performing
|
2009-08-11 09:31:07 +04:00
|
|
|
/// argument-dependent lookup, etc. Subclasses may override this routine to
|
|
|
|
/// provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation OpLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Callee,
|
|
|
|
Expr *First,
|
|
|
|
Expr *Second);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
/// \brief Build a new C++ "named" cast expression, such as static_cast or
|
2009-08-11 09:31:07 +04:00
|
|
|
/// reinterpret_cast.
|
|
|
|
///
|
|
|
|
/// By default, this routine dispatches to one of the more-specific routines
|
2009-09-09 19:08:12 +04:00
|
|
|
/// for a particular named case, e.g., RebuildCXXStaticCastExpr().
|
2009-08-11 09:31:07 +04:00
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXNamedCastExpr(SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
Stmt::StmtClass Class,
|
|
|
|
SourceLocation LAngleLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
switch (Class) {
|
|
|
|
case Stmt::CXXStaticCastExprClass:
|
2010-01-15 21:39:57 +03:00
|
|
|
return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
|
2009-09-09 19:08:12 +04:00
|
|
|
RAngleLoc, LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr, RParenLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
|
|
|
|
case Stmt::CXXDynamicCastExprClass:
|
2010-01-15 21:39:57 +03:00
|
|
|
return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
|
2009-09-09 19:08:12 +04:00
|
|
|
RAngleLoc, LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr, RParenLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
case Stmt::CXXReinterpretCastExprClass:
|
2010-01-15 21:39:57 +03:00
|
|
|
return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
|
2009-09-09 19:08:12 +04:00
|
|
|
RAngleLoc, LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr,
|
2009-08-11 09:31:07 +04:00
|
|
|
RParenLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
case Stmt::CXXConstCastExprClass:
|
2010-01-15 21:39:57 +03:00
|
|
|
return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
|
2009-09-09 19:08:12 +04:00
|
|
|
RAngleLoc, LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr, RParenLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
default:
|
|
|
|
assert(false && "Invalid C++ named cast");
|
|
|
|
break;
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getSema().ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ static_cast expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXStaticCastExpr(SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LAngleLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-01-15 22:13:16 +03:00
|
|
|
return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
|
2010-08-24 03:25:46 +04:00
|
|
|
TInfo, SubExpr,
|
2010-01-15 22:13:16 +03:00
|
|
|
SourceRange(LAngleLoc, RAngleLoc),
|
|
|
|
SourceRange(LParenLoc, RParenLoc));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ dynamic_cast expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXDynamicCastExpr(SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LAngleLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-01-15 22:13:16 +03:00
|
|
|
return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
|
2010-08-24 03:25:46 +04:00
|
|
|
TInfo, SubExpr,
|
2010-01-15 22:13:16 +03:00
|
|
|
SourceRange(LAngleLoc, RAngleLoc),
|
|
|
|
SourceRange(LParenLoc, RParenLoc));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ reinterpret_cast expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXReinterpretCastExpr(SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LAngleLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-01-15 22:13:16 +03:00
|
|
|
return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
|
2010-08-24 03:25:46 +04:00
|
|
|
TInfo, SubExpr,
|
2010-01-15 22:13:16 +03:00
|
|
|
SourceRange(LAngleLoc, RAngleLoc),
|
|
|
|
SourceRange(LParenLoc, RParenLoc));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ const_cast expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LAngleLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RAngleLoc,
|
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SubExpr,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-01-15 22:13:16 +03:00
|
|
|
return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
|
2010-08-24 03:25:46 +04:00
|
|
|
TInfo, SubExpr,
|
2010-01-15 22:13:16 +03:00
|
|
|
SourceRange(LAngleLoc, RAngleLoc),
|
|
|
|
SourceRange(LParenLoc, RParenLoc));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ functional-style cast expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXFunctionalCastExpr(SourceRange TypeRange,
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LParenLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Sub,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().ActOnCXXTypeConstructExpr(TypeRange,
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(TInfo->getType()),
|
2009-08-11 09:31:07 +04:00
|
|
|
LParenLoc,
|
2009-08-24 09:19:01 +04:00
|
|
|
Sema::MultiExprArg(getSema(), &Sub, 1),
|
2009-09-09 19:08:12 +04:00
|
|
|
/*CommaLocs=*/0,
|
2009-08-11 09:31:07 +04:00
|
|
|
RParenLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ typeid(type) expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType,
|
2010-04-27 02:37:10 +04:00
|
|
|
SourceLocation TypeidLoc,
|
|
|
|
TypeSourceInfo *Operand,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-05-05 19:23:54 +04:00
|
|
|
return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
|
2010-04-27 02:37:10 +04:00
|
|
|
RParenLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ typeid(expr) expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType,
|
2010-04-27 02:37:10 +04:00
|
|
|
SourceLocation TypeidLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Operand,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildCXXTypeId(TypeInfoType, TypeidLoc, Operand,
|
2010-04-27 02:37:10 +04:00
|
|
|
RParenLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ "this" expression.
|
|
|
|
///
|
|
|
|
/// By default, builds a new "this" expression without performing any
|
2009-09-09 19:08:12 +04:00
|
|
|
/// semantic analysis. Subclasses may override this routine to provide
|
2009-08-11 09:31:07 +04:00
|
|
|
/// different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXThisExpr(SourceLocation ThisLoc,
|
2010-01-08 02:12:05 +03:00
|
|
|
QualType ThisType,
|
|
|
|
bool isImplicit) {
|
2009-08-11 09:31:07 +04:00
|
|
|
return getSema().Owned(
|
2010-01-08 02:12:05 +03:00
|
|
|
new (getSema().Context) CXXThisExpr(ThisLoc, ThisType,
|
|
|
|
isImplicit));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ throw expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnCXXThrow(ThrowLoc, Sub);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ default-argument expression.
|
|
|
|
///
|
|
|
|
/// By default, builds a new default-argument expression, which does not
|
|
|
|
/// require any semantic analysis. Subclasses may override this routine to
|
|
|
|
/// provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXDefaultArgExpr(SourceLocation Loc,
|
2009-12-24 02:03:06 +03:00
|
|
|
ParmVarDecl *Param) {
|
|
|
|
return getSema().Owned(CXXDefaultArgExpr::Create(getSema().Context, Loc,
|
|
|
|
Param));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ zero-initialization expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXScalarValueInitExpr(SourceLocation TypeStartLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
QualType T,
|
|
|
|
SourceLocation RParenLoc) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeStartLoc),
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(T), LParenLoc,
|
2009-09-09 19:08:12 +04:00
|
|
|
MultiExprArg(getSema(), 0, 0),
|
2009-08-11 09:31:07 +04:00
|
|
|
0, RParenLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ "new" expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
bool UseGlobal,
|
|
|
|
SourceLocation PlacementLParen,
|
|
|
|
MultiExprArg PlacementArgs,
|
|
|
|
SourceLocation PlacementRParen,
|
2010-07-13 19:54:32 +04:00
|
|
|
SourceRange TypeIdParens,
|
2009-08-11 09:31:07 +04:00
|
|
|
QualType AllocType,
|
|
|
|
SourceLocation TypeLoc,
|
|
|
|
SourceRange TypeRange,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *ArraySize,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation ConstructorLParen,
|
|
|
|
MultiExprArg ConstructorArgs,
|
|
|
|
SourceLocation ConstructorRParen) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getSema().BuildCXXNew(StartLoc, UseGlobal,
|
2009-08-11 09:31:07 +04:00
|
|
|
PlacementLParen,
|
|
|
|
move(PlacementArgs),
|
|
|
|
PlacementRParen,
|
2010-07-13 19:54:32 +04:00
|
|
|
TypeIdParens,
|
2009-08-11 09:31:07 +04:00
|
|
|
AllocType,
|
|
|
|
TypeLoc,
|
|
|
|
TypeRange,
|
2010-08-24 03:25:46 +04:00
|
|
|
ArraySize,
|
2009-08-11 09:31:07 +04:00
|
|
|
ConstructorLParen,
|
|
|
|
move(ConstructorArgs),
|
|
|
|
ConstructorRParen);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new C++ "delete" expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXDeleteExpr(SourceLocation StartLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
bool IsGlobalDelete,
|
|
|
|
bool IsArrayForm,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Operand) {
|
2009-08-11 09:31:07 +04:00
|
|
|
return getSema().ActOnCXXDelete(StartLoc, IsGlobalDelete, IsArrayForm,
|
2010-08-24 03:25:46 +04:00
|
|
|
Operand);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new unary type trait expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildUnaryTypeTrait(UnaryTypeTrait Trait,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
QualType T,
|
|
|
|
SourceLocation RParenLoc) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getSema().ActOnUnaryTypeTrait(Trait, StartLoc, LParenLoc,
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(T), RParenLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Build a new (previously unresolved) declaration reference
|
2009-08-11 09:31:07 +04:00
|
|
|
/// expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildDependentScopeDeclRefExpr(NestedNameSpecifier *NNS,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceRange QualifierRange,
|
2010-08-12 02:01:17 +04:00
|
|
|
const DeclarationNameInfo &NameInfo,
|
2009-11-24 22:00:30 +03:00
|
|
|
const TemplateArgumentListInfo *TemplateArgs) {
|
2009-08-11 09:31:07 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.setRange(QualifierRange);
|
|
|
|
SS.setScopeRep(NNS);
|
2009-11-24 22:00:30 +03:00
|
|
|
|
|
|
|
if (TemplateArgs)
|
2010-08-12 02:01:17 +04:00
|
|
|
return getSema().BuildQualifiedTemplateIdExpr(SS, NameInfo,
|
2009-11-24 22:00:30 +03:00
|
|
|
*TemplateArgs);
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
return getSema().BuildQualifiedDeclarationNameExpr(SS, NameInfo);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new template-id expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS,
|
2009-11-24 22:00:30 +03:00
|
|
|
LookupResult &R,
|
|
|
|
bool RequiresADL,
|
2009-11-23 04:53:49 +03:00
|
|
|
const TemplateArgumentListInfo &TemplateArgs) {
|
2009-11-24 22:00:30 +03:00
|
|
|
return getSema().BuildTemplateIdExpr(SS, R, RequiresADL, TemplateArgs);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new object-construction expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXConstructExpr(QualType T,
|
2009-12-14 19:27:04 +03:00
|
|
|
SourceLocation Loc,
|
2009-08-11 09:31:07 +04:00
|
|
|
CXXConstructorDecl *Constructor,
|
|
|
|
bool IsElidable,
|
2010-08-22 21:20:18 +04:00
|
|
|
MultiExprArg Args,
|
|
|
|
bool RequiresZeroInit,
|
|
|
|
CXXConstructExpr::ConstructionKind ConstructKind) {
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> ConvertedArgs(SemaRef);
|
2010-05-05 19:23:54 +04:00
|
|
|
if (getSema().CompleteConstructorCall(Constructor, move(Args), Loc,
|
2009-12-14 19:27:04 +03:00
|
|
|
ConvertedArgs))
|
|
|
|
return getSema().ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-12-14 19:27:04 +03:00
|
|
|
return getSema().BuildCXXConstructExpr(Loc, T, Constructor, IsElidable,
|
2010-08-22 21:20:18 +04:00
|
|
|
move_arg(ConvertedArgs),
|
|
|
|
RequiresZeroInit, ConstructKind);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new object-construction expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXTemporaryObjectExpr(SourceLocation TypeBeginLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
QualType T,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation *Commas,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeBeginLoc),
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(T),
|
2009-08-11 09:31:07 +04:00
|
|
|
LParenLoc,
|
|
|
|
move(Args),
|
|
|
|
Commas,
|
|
|
|
RParenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new object-construction expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXUnresolvedConstructExpr(SourceLocation TypeBeginLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
QualType T,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation *Commas,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().ActOnCXXTypeConstructExpr(SourceRange(TypeBeginLoc,
|
|
|
|
/*FIXME*/LParenLoc),
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(T),
|
2009-08-11 09:31:07 +04:00
|
|
|
LParenLoc,
|
|
|
|
move(Args),
|
|
|
|
Commas,
|
|
|
|
RParenLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new member reference expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildCXXDependentScopeMemberExpr(Expr *BaseE,
|
2009-12-02 01:10:20 +03:00
|
|
|
QualType BaseType,
|
2009-08-11 09:31:07 +04:00
|
|
|
bool IsArrow,
|
|
|
|
SourceLocation OperatorLoc,
|
2009-09-03 20:14:30 +04:00
|
|
|
NestedNameSpecifier *Qualifier,
|
|
|
|
SourceRange QualifierRange,
|
2009-12-01 01:42:35 +03:00
|
|
|
NamedDecl *FirstQualifierInScope,
|
2010-08-12 02:01:17 +04:00
|
|
|
const DeclarationNameInfo &MemberNameInfo,
|
2009-12-01 01:42:35 +03:00
|
|
|
const TemplateArgumentListInfo *TemplateArgs) {
|
2009-08-11 09:31:07 +04:00
|
|
|
CXXScopeSpec SS;
|
2009-09-03 20:14:30 +04:00
|
|
|
SS.setRange(QualifierRange);
|
|
|
|
SS.setScopeRep(Qualifier);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
|
2009-12-02 01:10:20 +03:00
|
|
|
OperatorLoc, IsArrow,
|
2009-12-01 01:42:35 +03:00
|
|
|
SS, FirstQualifierInScope,
|
2010-08-12 02:01:17 +04:00
|
|
|
MemberNameInfo,
|
|
|
|
TemplateArgs);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-12-01 01:42:35 +03:00
|
|
|
/// \brief Build a new member reference expression.
|
2009-09-09 04:23:06 +04:00
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE,
|
2009-12-02 01:10:20 +03:00
|
|
|
QualType BaseType,
|
2009-12-01 01:42:35 +03:00
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
bool IsArrow,
|
|
|
|
NestedNameSpecifier *Qualifier,
|
|
|
|
SourceRange QualifierRange,
|
2010-01-15 11:34:02 +03:00
|
|
|
NamedDecl *FirstQualifierInScope,
|
2009-12-01 01:42:35 +03:00
|
|
|
LookupResult &R,
|
|
|
|
const TemplateArgumentListInfo *TemplateArgs) {
|
2009-09-09 04:23:06 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.setRange(QualifierRange);
|
|
|
|
SS.setScopeRep(Qualifier);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
|
2009-12-02 01:10:20 +03:00
|
|
|
OperatorLoc, IsArrow,
|
2010-01-15 11:34:02 +03:00
|
|
|
SS, FirstQualifierInScope,
|
|
|
|
R, TemplateArgs);
|
2009-09-09 04:23:06 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new Objective-C @encode expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCEncodeExpr(SourceLocation AtLoc,
|
2010-04-20 19:39:42 +04:00
|
|
|
TypeSourceInfo *EncodeTypeInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
SourceLocation RParenLoc) {
|
2010-04-20 19:39:42 +04:00
|
|
|
return SemaRef.Owned(SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
RParenLoc));
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
/// \brief Build a new Objective-C class message.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCMessageExpr(TypeSourceInfo *ReceiverTypeInfo,
|
2010-04-22 20:44:27 +04:00
|
|
|
Selector Sel,
|
|
|
|
ObjCMethodDecl *Method,
|
2010-05-05 19:23:54 +04:00
|
|
|
SourceLocation LBracLoc,
|
2010-04-22 20:44:27 +04:00
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation RBracLoc) {
|
|
|
|
return SemaRef.BuildClassMessage(ReceiverTypeInfo,
|
|
|
|
ReceiverTypeInfo->getType(),
|
|
|
|
/*SuperLoc=*/SourceLocation(),
|
2010-04-22 21:01:48 +04:00
|
|
|
Sel, Method, LBracLoc, RBracLoc,
|
2010-04-22 20:44:27 +04:00
|
|
|
move(Args));
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new Objective-C instance message.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCMessageExpr(Expr *Receiver,
|
2010-04-22 20:44:27 +04:00
|
|
|
Selector Sel,
|
|
|
|
ObjCMethodDecl *Method,
|
2010-05-05 19:23:54 +04:00
|
|
|
SourceLocation LBracLoc,
|
2010-04-22 20:44:27 +04:00
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation RBracLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildInstanceMessage(Receiver,
|
|
|
|
Receiver->getType(),
|
2010-04-22 20:44:27 +04:00
|
|
|
/*SuperLoc=*/SourceLocation(),
|
2010-04-22 21:01:48 +04:00
|
|
|
Sel, Method, LBracLoc, RBracLoc,
|
2010-04-22 20:44:27 +04:00
|
|
|
move(Args));
|
|
|
|
}
|
|
|
|
|
2010-04-27 00:11:03 +04:00
|
|
|
/// \brief Build a new Objective-C ivar reference expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar,
|
2010-04-27 00:11:03 +04:00
|
|
|
SourceLocation IvarLoc,
|
|
|
|
bool IsArrow, bool IsFreeIvar) {
|
|
|
|
// FIXME: We lose track of the IsFreeIvar bit.
|
|
|
|
CXXScopeSpec SS;
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Base = BaseArg;
|
2010-04-27 00:11:03 +04:00
|
|
|
LookupResult R(getSema(), Ivar->getDeclName(), IvarLoc,
|
|
|
|
Sema::LookupMemberName);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow,
|
2010-04-27 00:11:03 +04:00
|
|
|
/*FIME:*/IvarLoc,
|
2010-08-21 13:40:31 +04:00
|
|
|
SS, 0,
|
2010-06-16 12:42:20 +04:00
|
|
|
false);
|
2010-04-27 00:11:03 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return getSema().ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:11:03 +04:00
|
|
|
if (Result.get())
|
|
|
|
return move(Result);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
|
2010-05-05 19:23:54 +04:00
|
|
|
/*FIXME:*/IvarLoc, IsArrow, SS,
|
2010-04-27 00:11:03 +04:00
|
|
|
/*FirstQualifierInScope=*/0,
|
2010-05-05 19:23:54 +04:00
|
|
|
R,
|
2010-04-27 00:11:03 +04:00
|
|
|
/*TemplateArgs=*/0);
|
|
|
|
}
|
2010-04-27 00:47:02 +04:00
|
|
|
|
|
|
|
/// \brief Build a new Objective-C property reference expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCPropertyRefExpr(Expr *BaseArg,
|
2010-04-27 00:47:02 +04:00
|
|
|
ObjCPropertyDecl *Property,
|
|
|
|
SourceLocation PropertyLoc) {
|
|
|
|
CXXScopeSpec SS;
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Base = BaseArg;
|
2010-04-27 00:47:02 +04:00
|
|
|
LookupResult R(getSema(), Property->getDeclName(), PropertyLoc,
|
|
|
|
Sema::LookupMemberName);
|
|
|
|
bool IsArrow = false;
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow,
|
2010-04-27 00:47:02 +04:00
|
|
|
/*FIME:*/PropertyLoc,
|
2010-08-21 13:40:31 +04:00
|
|
|
SS, 0, false);
|
2010-04-27 00:47:02 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return getSema().ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:47:02 +04:00
|
|
|
if (Result.get())
|
|
|
|
return move(Result);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
|
2010-05-05 19:23:54 +04:00
|
|
|
/*FIXME:*/PropertyLoc, IsArrow,
|
|
|
|
SS,
|
2010-04-27 00:47:02 +04:00
|
|
|
/*FirstQualifierInScope=*/0,
|
2010-05-05 19:23:54 +04:00
|
|
|
R,
|
2010-04-27 00:47:02 +04:00
|
|
|
/*TemplateArgs=*/0);
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
|
|
|
/// \brief Build a new Objective-C implicit setter/getter reference
|
2010-04-27 01:04:54 +04:00
|
|
|
/// expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
2010-05-05 19:23:54 +04:00
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCImplicitSetterGetterRefExpr(
|
2010-04-27 01:04:54 +04:00
|
|
|
ObjCMethodDecl *Getter,
|
|
|
|
QualType T,
|
|
|
|
ObjCMethodDecl *Setter,
|
|
|
|
SourceLocation NameLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Base) {
|
2010-04-27 01:04:54 +04:00
|
|
|
// Since these expressions can only be value-dependent, we do not need to
|
|
|
|
// perform semantic analysis again.
|
2010-08-24 03:25:46 +04:00
|
|
|
return Owned(
|
2010-04-27 01:04:54 +04:00
|
|
|
new (getSema().Context) ObjCImplicitSetterGetterRefExpr(Getter, T,
|
|
|
|
Setter,
|
|
|
|
NameLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Base));
|
2010-04-27 01:04:54 +04:00
|
|
|
}
|
|
|
|
|
2010-04-27 00:11:03 +04:00
|
|
|
/// \brief Build a new Objective-C "isa" expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildObjCIsaExpr(Expr *BaseArg, SourceLocation IsaLoc,
|
2010-04-27 00:11:03 +04:00
|
|
|
bool IsArrow) {
|
|
|
|
CXXScopeSpec SS;
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Base = BaseArg;
|
2010-04-27 00:11:03 +04:00
|
|
|
LookupResult R(getSema(), &getSema().Context.Idents.get("isa"), IsaLoc,
|
|
|
|
Sema::LookupMemberName);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = getSema().LookupMemberExpr(R, Base, IsArrow,
|
2010-04-27 00:11:03 +04:00
|
|
|
/*FIME:*/IsaLoc,
|
2010-08-21 13:40:31 +04:00
|
|
|
SS, 0, false);
|
2010-04-27 00:11:03 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return getSema().ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:11:03 +04:00
|
|
|
if (Result.get())
|
|
|
|
return move(Result);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
|
2010-05-05 19:23:54 +04:00
|
|
|
/*FIXME:*/IsaLoc, IsArrow, SS,
|
2010-04-27 00:11:03 +04:00
|
|
|
/*FirstQualifierInScope=*/0,
|
2010-05-05 19:23:54 +04:00
|
|
|
R,
|
2010-04-27 00:11:03 +04:00
|
|
|
/*TemplateArgs=*/0);
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Build a new shuffle vector expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
MultiExprArg SubExprs,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
// Find the declaration for __builtin_shufflevector
|
2009-09-09 19:08:12 +04:00
|
|
|
const IdentifierInfo &Name
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.Context.Idents.get("__builtin_shufflevector");
|
|
|
|
TranslationUnitDecl *TUDecl = SemaRef.Context.getTranslationUnitDecl();
|
|
|
|
DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
|
|
|
|
assert(Lookup.first != Lookup.second && "No __builtin_shufflevector?");
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Build a reference to the __builtin_shufflevector builtin
|
|
|
|
FunctionDecl *Builtin = cast<FunctionDecl>(*Lookup.first);
|
2009-09-09 19:08:12 +04:00
|
|
|
Expr *Callee
|
2009-08-11 09:31:07 +04:00
|
|
|
= new (SemaRef.Context) DeclRefExpr(Builtin, Builtin->getType(),
|
2009-11-23 14:41:28 +03:00
|
|
|
BuiltinLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
SemaRef.UsualUnaryConversions(Callee);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
// Build the CallExpr
|
2009-08-11 09:31:07 +04:00
|
|
|
unsigned NumSubExprs = SubExprs.size();
|
|
|
|
Expr **Subs = (Expr **)SubExprs.release();
|
|
|
|
CallExpr *TheCall = new (SemaRef.Context) CallExpr(SemaRef.Context, Callee,
|
|
|
|
Subs, NumSubExprs,
|
2010-07-13 12:18:22 +04:00
|
|
|
Builtin->getCallResultType(),
|
2009-08-11 09:31:07 +04:00
|
|
|
RParenLoc);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult OwnedCall(SemaRef.Owned(TheCall));
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Type-check the __builtin_shufflevector expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = SemaRef.SemaBuiltinShuffleVector(TheCall);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
OwnedCall.release();
|
2009-09-09 19:08:12 +04:00
|
|
|
return move(Result);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
};
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult TreeTransform<Derived>::TransformStmt(Stmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!S)
|
|
|
|
return SemaRef.Owned(S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
switch (S->getStmtClass()) {
|
|
|
|
case Stmt::NoStmtClass: break;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform individual statement nodes
|
|
|
|
#define STMT(Node, Parent) \
|
|
|
|
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
|
|
|
|
#define EXPR(Node, Parent)
|
2010-05-05 19:24:00 +04:00
|
|
|
#include "clang/AST/StmtNodes.inc"
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform expressions by calling TransformExpr.
|
|
|
|
#define STMT(Node, Parent)
|
2010-05-18 10:22:21 +04:00
|
|
|
#define ABSTRACT_STMT(Stmt)
|
2009-08-20 11:17:43 +04:00
|
|
|
#define EXPR(Node, Parent) case Stmt::Node##Class:
|
2010-05-05 19:24:00 +04:00
|
|
|
#include "clang/AST/StmtNodes.inc"
|
2009-08-20 11:17:43 +04:00
|
|
|
{
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
|
2009-08-20 11:17:43 +04:00
|
|
|
if (E.isInvalid())
|
|
|
|
return getSema().StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnExprStmt(getSema().MakeFullExpr(E.take()));
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
|
2009-08-07 02:17:10 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult TreeTransform<Derived>::TransformExpr(Expr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!E)
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
switch (E->getStmtClass()) {
|
|
|
|
case Stmt::NoStmtClass: break;
|
|
|
|
#define STMT(Node, Parent) case Stmt::Node##Class: break;
|
2010-05-18 10:22:21 +04:00
|
|
|
#define ABSTRACT_STMT(Stmt)
|
2009-08-11 09:31:07 +04:00
|
|
|
#define EXPR(Node, Parent) \
|
2009-12-08 12:21:05 +03:00
|
|
|
case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
|
2010-05-05 19:24:00 +04:00
|
|
|
#include "clang/AST/StmtNodes.inc"
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-07 02:17:10 +04:00
|
|
|
}
|
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
NestedNameSpecifier *
|
|
|
|
TreeTransform<Derived>::TransformNestedNameSpecifier(NestedNameSpecifier *NNS,
|
2009-09-03 20:14:30 +04:00
|
|
|
SourceRange Range,
|
2009-09-04 01:38:09 +04:00
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope) {
|
2009-09-01 01:41:48 +04:00
|
|
|
if (!NNS)
|
|
|
|
return 0;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the prefix of this nested name specifier.
|
2009-08-06 09:28:30 +04:00
|
|
|
NestedNameSpecifier *Prefix = NNS->getPrefix();
|
|
|
|
if (Prefix) {
|
2009-09-09 19:08:12 +04:00
|
|
|
Prefix = getDerived().TransformNestedNameSpecifier(Prefix, Range,
|
2009-09-04 01:38:09 +04:00
|
|
|
ObjectType,
|
|
|
|
FirstQualifierInScope);
|
2009-08-06 09:28:30 +04:00
|
|
|
if (!Prefix)
|
|
|
|
return 0;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
// Clear out the object type and the first qualifier in scope; they only
|
2009-09-04 01:38:09 +04:00
|
|
|
// apply to the first element in the nested-name-specifier.
|
2009-09-03 20:14:30 +04:00
|
|
|
ObjectType = QualType();
|
2009-09-04 01:38:09 +04:00
|
|
|
FirstQualifierInScope = 0;
|
2009-08-06 09:28:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
switch (NNS->getKind()) {
|
|
|
|
case NestedNameSpecifier::Identifier:
|
2009-09-09 19:08:12 +04:00
|
|
|
assert((Prefix || !ObjectType.isNull()) &&
|
2009-09-03 20:14:30 +04:00
|
|
|
"Identifier nested-name-specifier with no prefix or object type");
|
|
|
|
if (!getDerived().AlwaysRebuild() && Prefix == NNS->getPrefix() &&
|
|
|
|
ObjectType.isNull())
|
2009-08-06 09:28:30 +04:00
|
|
|
return NNS;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
|
2009-09-03 20:14:30 +04:00
|
|
|
*NNS->getAsIdentifier(),
|
2009-09-04 01:38:09 +04:00
|
|
|
ObjectType,
|
|
|
|
FirstQualifierInScope);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
case NestedNameSpecifier::Namespace: {
|
2009-09-09 19:08:12 +04:00
|
|
|
NamespaceDecl *NS
|
2009-08-06 09:28:30 +04:00
|
|
|
= cast_or_null<NamespaceDecl>(
|
2010-03-01 18:56:25 +03:00
|
|
|
getDerived().TransformDecl(Range.getBegin(),
|
|
|
|
NNS->getAsNamespace()));
|
2009-09-09 19:08:12 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2009-08-06 09:28:30 +04:00
|
|
|
Prefix == NNS->getPrefix() &&
|
|
|
|
NS == NNS->getAsNamespace())
|
|
|
|
return NNS;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
return getDerived().RebuildNestedNameSpecifier(Prefix, Range, NS);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
case NestedNameSpecifier::Global:
|
|
|
|
// There is no meaningful transformation that one could perform on the
|
|
|
|
// global scope.
|
|
|
|
return NNS;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
case NestedNameSpecifier::TypeSpecWithTemplate:
|
|
|
|
case NestedNameSpecifier::TypeSpec: {
|
2009-10-30 01:21:39 +03:00
|
|
|
TemporaryBase Rebase(*this, Range.getBegin(), DeclarationName());
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType T = getDerived().TransformType(QualType(NNS->getAsType(), 0),
|
|
|
|
ObjectType);
|
2009-08-06 10:41:21 +04:00
|
|
|
if (T.isNull())
|
|
|
|
return 0;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Prefix == NNS->getPrefix() &&
|
|
|
|
T == QualType(NNS->getAsType(), 0))
|
|
|
|
return NNS;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildNestedNameSpecifier(Prefix, Range,
|
|
|
|
NNS->getKind() == NestedNameSpecifier::TypeSpecWithTemplate,
|
2010-02-25 07:46:04 +03:00
|
|
|
T);
|
2009-08-06 09:28:30 +04:00
|
|
|
}
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
// Required to silence a GCC warning
|
2009-09-09 19:08:12 +04:00
|
|
|
return 0;
|
2009-08-06 09:28:30 +04:00
|
|
|
}
|
|
|
|
|
2009-09-04 02:13:48 +04:00
|
|
|
template<typename Derived>
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo
|
|
|
|
TreeTransform<Derived>
|
|
|
|
::TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
|
|
|
|
QualType ObjectType) {
|
|
|
|
DeclarationName Name = NameInfo.getName();
|
2009-09-04 02:13:48 +04:00
|
|
|
if (!Name)
|
2010-08-12 02:01:17 +04:00
|
|
|
return DeclarationNameInfo();
|
2009-09-04 02:13:48 +04:00
|
|
|
|
|
|
|
switch (Name.getNameKind()) {
|
|
|
|
case DeclarationName::Identifier:
|
|
|
|
case DeclarationName::ObjCZeroArgSelector:
|
|
|
|
case DeclarationName::ObjCOneArgSelector:
|
|
|
|
case DeclarationName::ObjCMultiArgSelector:
|
|
|
|
case DeclarationName::CXXOperatorName:
|
2009-11-29 10:34:05 +03:00
|
|
|
case DeclarationName::CXXLiteralOperatorName:
|
2009-09-04 02:13:48 +04:00
|
|
|
case DeclarationName::CXXUsingDirective:
|
2010-08-12 02:01:17 +04:00
|
|
|
return NameInfo;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-04 02:13:48 +04:00
|
|
|
case DeclarationName::CXXConstructorName:
|
|
|
|
case DeclarationName::CXXDestructorName:
|
|
|
|
case DeclarationName::CXXConversionFunctionName: {
|
2010-08-12 02:01:17 +04:00
|
|
|
TypeSourceInfo *NewTInfo;
|
|
|
|
CanQualType NewCanTy;
|
|
|
|
if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
|
|
|
|
NewTInfo = getDerived().TransformType(OldTInfo, ObjectType);
|
|
|
|
if (!NewTInfo)
|
|
|
|
return DeclarationNameInfo();
|
|
|
|
NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NewTInfo = 0;
|
|
|
|
TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
|
|
|
|
QualType NewT = getDerived().TransformType(Name.getCXXNameType(),
|
|
|
|
ObjectType);
|
|
|
|
if (NewT.isNull())
|
|
|
|
return DeclarationNameInfo();
|
|
|
|
NewCanTy = SemaRef.Context.getCanonicalType(NewT);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationName NewName
|
|
|
|
= SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
|
|
|
|
NewCanTy);
|
|
|
|
DeclarationNameInfo NewNameInfo(NameInfo);
|
|
|
|
NewNameInfo.setName(NewName);
|
|
|
|
NewNameInfo.setNamedTypeInfo(NewTInfo);
|
|
|
|
return NewNameInfo;
|
2009-09-04 02:13:48 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
assert(0 && "Unknown name kind.");
|
|
|
|
return DeclarationNameInfo();
|
2009-09-04 02:13:48 +04:00
|
|
|
}
|
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateName
|
2009-09-09 04:23:06 +04:00
|
|
|
TreeTransform<Derived>::TransformTemplateName(TemplateName Name,
|
|
|
|
QualType ObjectType) {
|
2010-03-01 18:56:25 +03:00
|
|
|
SourceLocation Loc = getDerived().getBaseLocation();
|
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
|
2009-09-09 19:08:12 +04:00
|
|
|
NestedNameSpecifier *NNS
|
2009-08-06 10:41:21 +04:00
|
|
|
= getDerived().TransformNestedNameSpecifier(QTN->getQualifier(),
|
2010-02-16 22:09:40 +03:00
|
|
|
/*FIXME:*/SourceRange(getDerived().getBaseLocation()),
|
|
|
|
ObjectType);
|
2009-08-06 10:41:21 +04:00
|
|
|
if (!NNS)
|
|
|
|
return TemplateName();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (TemplateDecl *Template = QTN->getTemplateDecl()) {
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateDecl *TransTemplate
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<TemplateDecl>(getDerived().TransformDecl(Loc, Template));
|
2009-08-06 10:41:21 +04:00
|
|
|
if (!TransTemplate)
|
|
|
|
return TemplateName();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
NNS == QTN->getQualifier() &&
|
|
|
|
TransTemplate == Template)
|
|
|
|
return Name;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
return getDerived().RebuildTemplateName(NNS, QTN->hasTemplateKeyword(),
|
|
|
|
TransTemplate);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
// These should be getting filtered out before they make it into the AST.
|
|
|
|
assert(false && "overloaded template name survived to here");
|
2009-08-06 10:41:21 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) {
|
2009-09-09 19:08:12 +04:00
|
|
|
NestedNameSpecifier *NNS
|
2009-08-06 10:41:21 +04:00
|
|
|
= getDerived().TransformNestedNameSpecifier(DTN->getQualifier(),
|
2010-02-16 22:09:40 +03:00
|
|
|
/*FIXME:*/SourceRange(getDerived().getBaseLocation()),
|
|
|
|
ObjectType);
|
2009-09-09 04:23:06 +04:00
|
|
|
if (!NNS && DTN->getQualifier())
|
2009-08-06 10:41:21 +04:00
|
|
|
return TemplateName();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2009-10-20 02:04:39 +04:00
|
|
|
NNS == DTN->getQualifier() &&
|
|
|
|
ObjectType.isNull())
|
2009-08-06 10:41:21 +04:00
|
|
|
return Name;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-04 03:56:37 +03:00
|
|
|
if (DTN->isIdentifier())
|
2010-05-05 19:23:54 +04:00
|
|
|
return getDerived().RebuildTemplateName(NNS, *DTN->getIdentifier(),
|
2009-11-04 03:56:37 +03:00
|
|
|
ObjectType);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildTemplateName(NNS, DTN->getOperator(),
|
2009-11-04 03:56:37 +03:00
|
|
|
ObjectType);
|
2009-08-06 10:41:21 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateDecl *TransTemplate
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<TemplateDecl>(getDerived().TransformDecl(Loc, Template));
|
2009-08-06 10:41:21 +04:00
|
|
|
if (!TransTemplate)
|
|
|
|
return TemplateName();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TransTemplate == Template)
|
|
|
|
return Name;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
return TemplateName(TransTemplate);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
// These should be getting filtered out before they reach the AST.
|
|
|
|
assert(false && "overloaded function decl survived to here");
|
|
|
|
return TemplateName();
|
2009-08-06 10:41:21 +04:00
|
|
|
}
|
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
template<typename Derived>
|
2009-10-29 11:12:44 +03:00
|
|
|
void TreeTransform<Derived>::InventTemplateArgumentLoc(
|
|
|
|
const TemplateArgument &Arg,
|
|
|
|
TemplateArgumentLoc &Output) {
|
|
|
|
SourceLocation Loc = getDerived().getBaseLocation();
|
2009-08-05 02:27:00 +04:00
|
|
|
switch (Arg.getKind()) {
|
|
|
|
case TemplateArgument::Null:
|
2009-12-12 08:05:38 +03:00
|
|
|
llvm_unreachable("null template argument in TreeTransform");
|
2009-10-29 11:12:44 +03:00
|
|
|
break;
|
|
|
|
|
|
|
|
case TemplateArgument::Type:
|
|
|
|
Output = TemplateArgumentLoc(Arg,
|
2009-12-07 05:54:59 +03:00
|
|
|
SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
break;
|
|
|
|
|
2009-11-11 04:00:40 +03:00
|
|
|
case TemplateArgument::Template:
|
|
|
|
Output = TemplateArgumentLoc(Arg, SourceRange(), Loc);
|
|
|
|
break;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
case TemplateArgument::Expression:
|
|
|
|
Output = TemplateArgumentLoc(Arg, Arg.getAsExpr());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TemplateArgument::Declaration:
|
2009-08-05 02:27:00 +04:00
|
|
|
case TemplateArgument::Integral:
|
2009-10-29 11:12:44 +03:00
|
|
|
case TemplateArgument::Pack:
|
2009-10-29 21:45:58 +03:00
|
|
|
Output = TemplateArgumentLoc(Arg, TemplateArgumentLocInfo());
|
2009-10-29 11:12:44 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
bool TreeTransform<Derived>::TransformTemplateArgument(
|
|
|
|
const TemplateArgumentLoc &Input,
|
|
|
|
TemplateArgumentLoc &Output) {
|
|
|
|
const TemplateArgument &Arg = Input.getArgument();
|
|
|
|
switch (Arg.getKind()) {
|
|
|
|
case TemplateArgument::Null:
|
|
|
|
case TemplateArgument::Integral:
|
|
|
|
Output = Input;
|
|
|
|
return false;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
case TemplateArgument::Type: {
|
2009-12-07 05:54:59 +03:00
|
|
|
TypeSourceInfo *DI = Input.getTypeSourceInfo();
|
2009-10-29 11:12:44 +03:00
|
|
|
if (DI == NULL)
|
2009-12-07 05:54:59 +03:00
|
|
|
DI = InventTypeSourceInfo(Input.getArgument().getAsType());
|
2009-10-29 11:12:44 +03:00
|
|
|
|
|
|
|
DI = getDerived().TransformType(DI);
|
|
|
|
if (!DI) return true;
|
|
|
|
|
|
|
|
Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
|
|
|
|
return false;
|
2009-08-05 02:27:00 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
case TemplateArgument::Declaration: {
|
2009-10-29 11:12:44 +03:00
|
|
|
// FIXME: we should never have to transform one of these.
|
2009-10-27 09:26:26 +03:00
|
|
|
DeclarationName Name;
|
|
|
|
if (NamedDecl *ND = dyn_cast<NamedDecl>(Arg.getAsDecl()))
|
|
|
|
Name = ND->getDeclName();
|
2009-11-11 04:00:40 +03:00
|
|
|
TemporaryBase Rebase(*this, Input.getLocation(), Name);
|
2010-03-01 18:56:25 +03:00
|
|
|
Decl *D = getDerived().TransformDecl(Input.getLocation(), Arg.getAsDecl());
|
2009-10-29 11:12:44 +03:00
|
|
|
if (!D) return true;
|
|
|
|
|
2009-10-29 21:45:58 +03:00
|
|
|
Expr *SourceExpr = Input.getSourceDeclExpression();
|
|
|
|
if (SourceExpr) {
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(getSema(),
|
|
|
|
Action::Unevaluated);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult E = getDerived().TransformExpr(SourceExpr);
|
2010-08-24 03:25:46 +04:00
|
|
|
SourceExpr = (E.isInvalid() ? 0 : E.take());
|
2009-10-29 21:45:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Output = TemplateArgumentLoc(TemplateArgument(D), SourceExpr);
|
2009-10-29 11:12:44 +03:00
|
|
|
return false;
|
2009-08-05 02:27:00 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-11 04:00:40 +03:00
|
|
|
case TemplateArgument::Template: {
|
2010-05-05 19:23:54 +04:00
|
|
|
TemporaryBase Rebase(*this, Input.getLocation(), DeclarationName());
|
2009-11-11 04:00:40 +03:00
|
|
|
TemplateName Template
|
|
|
|
= getDerived().TransformTemplateName(Arg.getAsTemplate());
|
|
|
|
if (Template.isNull())
|
|
|
|
return true;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-11 04:00:40 +03:00
|
|
|
Output = TemplateArgumentLoc(TemplateArgument(Template),
|
|
|
|
Input.getTemplateQualifierRange(),
|
|
|
|
Input.getTemplateNameLoc());
|
|
|
|
return false;
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
case TemplateArgument::Expression: {
|
|
|
|
// Template argument expressions are not potentially evaluated.
|
2009-09-09 19:08:12 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(getSema(),
|
2009-08-05 02:27:00 +04:00
|
|
|
Action::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
Expr *InputExpr = Input.getSourceExpression();
|
|
|
|
if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult E
|
2009-10-29 11:12:44 +03:00
|
|
|
= getDerived().TransformExpr(InputExpr);
|
|
|
|
if (E.isInvalid()) return true;
|
2010-08-24 03:25:46 +04:00
|
|
|
Output = TemplateArgumentLoc(TemplateArgument(E.take()), E.take());
|
2009-10-29 11:12:44 +03:00
|
|
|
return false;
|
2009-08-05 02:27:00 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
case TemplateArgument::Pack: {
|
|
|
|
llvm::SmallVector<TemplateArgument, 4> TransformedArgs;
|
|
|
|
TransformedArgs.reserve(Arg.pack_size());
|
2009-09-09 19:08:12 +04:00
|
|
|
for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
|
2009-08-05 02:27:00 +04:00
|
|
|
AEnd = Arg.pack_end();
|
|
|
|
A != AEnd; ++A) {
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
// FIXME: preserve source information here when we start
|
|
|
|
// caring about parameter packs.
|
|
|
|
|
2009-10-29 21:45:58 +03:00
|
|
|
TemplateArgumentLoc InputArg;
|
|
|
|
TemplateArgumentLoc OutputArg;
|
|
|
|
getDerived().InventTemplateArgumentLoc(*A, InputArg);
|
|
|
|
if (getDerived().TransformTemplateArgument(InputArg, OutputArg))
|
2009-10-29 11:12:44 +03:00
|
|
|
return true;
|
|
|
|
|
2009-10-29 21:45:58 +03:00
|
|
|
TransformedArgs.push_back(OutputArg.getArgument());
|
2009-08-05 02:27:00 +04:00
|
|
|
}
|
|
|
|
TemplateArgument Result;
|
2009-09-09 19:08:12 +04:00
|
|
|
Result.setArgumentPack(TransformedArgs.data(), TransformedArgs.size(),
|
2009-08-05 02:27:00 +04:00
|
|
|
true);
|
2009-10-29 21:45:58 +03:00
|
|
|
Output = TemplateArgumentLoc(Result, Input.getLocInfo());
|
2009-10-29 11:12:44 +03:00
|
|
|
return false;
|
2009-08-05 02:27:00 +04:00
|
|
|
}
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
// Work around bogus GCC warning
|
2009-10-29 11:12:44 +03:00
|
|
|
return true;
|
2009-08-05 02:27:00 +04:00
|
|
|
}
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Type transformation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-05-05 19:23:54 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformType(QualType T,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType ObjectType) {
|
2009-08-04 20:50:30 +04:00
|
|
|
if (getDerived().AlreadyTransformed(T))
|
|
|
|
return T;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
// Temporary workaround. All of these transformations should
|
|
|
|
// eventually turn into transformations on TypeLocs.
|
2009-12-07 05:54:59 +03:00
|
|
|
TypeSourceInfo *DI = getSema().Context.CreateTypeSourceInfo(T);
|
2009-10-21 04:44:26 +04:00
|
|
|
DI->getTypeLoc().initialize(getDerived().getBaseLocation());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-02-16 22:09:40 +03:00
|
|
|
TypeSourceInfo *NewDI = getDerived().TransformType(DI, ObjectType);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
if (!NewDI)
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return NewDI->getType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2010-02-16 22:09:40 +03:00
|
|
|
TypeSourceInfo *TreeTransform<Derived>::TransformType(TypeSourceInfo *DI,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
if (getDerived().AlreadyTransformed(DI->getType()))
|
|
|
|
return DI;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder TLB;
|
2009-08-19 05:28:17 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLoc TL = DI->getTypeLoc();
|
|
|
|
TLB.reserve(TL.getFullDataSize());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType Result = getDerived().TransformType(TLB, TL, ObjectType);
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return 0;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-07 05:54:59 +03:00
|
|
|
return TLB.getTypeSourceInfo(SemaRef.Context, Result);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType
|
2010-02-16 22:09:40 +03:00
|
|
|
TreeTransform<Derived>::TransformType(TypeLocBuilder &TLB, TypeLoc T,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
switch (T.getTypeLocClass()) {
|
|
|
|
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
|
|
|
#define TYPELOC(CLASS, PARENT) \
|
|
|
|
case TypeLoc::CLASS: \
|
2010-02-16 22:09:40 +03:00
|
|
|
return getDerived().Transform##CLASS##Type(TLB, cast<CLASS##TypeLoc>(T), \
|
|
|
|
ObjectType);
|
2009-10-21 04:40:46 +04:00
|
|
|
#include "clang/AST/TypeLocNodes.def"
|
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2009-12-12 08:05:38 +03:00
|
|
|
llvm_unreachable("unhandled type loc!");
|
2009-10-21 04:40:46 +04:00
|
|
|
return QualType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
/// FIXME: By default, this routine adds type qualifiers only to types
|
|
|
|
/// that can have qualifiers, and silently suppresses those qualifiers
|
|
|
|
/// that are not permitted (e.g., qualifiers on reference or function
|
|
|
|
/// types). This is the right thing for template instantiation, but
|
|
|
|
/// probably not for other clients.
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
2009-10-21 04:40:46 +04:00
|
|
|
TreeTransform<Derived>::TransformQualifiedType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualifiedTypeLoc T,
|
|
|
|
QualType ObjectType) {
|
First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:
typedef const int CInt;
typedef CInt Self;
Self.isConstQualified() currently returns false!
Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions:
- the "local" version only returns qualifiers on this particular
QualType instance
- the "normal" version that will eventually combine qualifiers from this
QualType instance with the qualifiers on the canonical type to
produce the full set of qualifiers.
This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()
expressions over to
Context.hasSameUnqualifiedType(T1, T2)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 00:35:15 +03:00
|
|
|
Qualifiers Quals = T.getType().getLocalQualifiers();
|
2009-10-21 04:40:46 +04:00
|
|
|
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc(),
|
|
|
|
ObjectType);
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
// Silently suppress qualifiers if the result type can't be qualified.
|
|
|
|
// FIXME: this is the right thing for template instantiation, but
|
|
|
|
// probably not for other clients.
|
|
|
|
if (Result->isFunctionType() || Result->isReferenceType())
|
|
|
|
return Result;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-06-05 10:41:15 +04:00
|
|
|
if (!Quals.empty()) {
|
|
|
|
Result = SemaRef.BuildQualifiedType(Result, T.getBeginLoc(), Quals);
|
|
|
|
TLB.push<QualifiedTypeLoc>(Result);
|
|
|
|
// No location information to preserve.
|
|
|
|
}
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class TyLoc> static inline
|
|
|
|
QualType TransformTypeSpecType(TypeLocBuilder &TLB, TyLoc T) {
|
|
|
|
TyLoc NewT = TLB.push<TyLoc>(T.getType());
|
|
|
|
NewT.setNameLoc(T.getNameLoc());
|
|
|
|
return T.getType();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformBuiltinType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
BuiltinTypeLoc T,
|
|
|
|
QualType ObjectType) {
|
2010-01-18 21:04:31 +03:00
|
|
|
BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
|
|
|
|
NewT.setBuiltinLoc(T.getBuiltinLoc());
|
|
|
|
if (T.needsExtraLocalData())
|
|
|
|
NewT.getWrittenBuiltinSpecs() = T.getWrittenBuiltinSpecs();
|
|
|
|
return T.getType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformComplexType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
ComplexTypeLoc T,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
// FIXME: recurse?
|
|
|
|
return TransformTypeSpecType(TLB, T);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformPointerType(TypeLocBuilder &TLB,
|
2010-05-05 19:23:54 +04:00
|
|
|
PointerTypeLoc TL,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType ObjectType) {
|
2010-05-05 19:23:54 +04:00
|
|
|
QualType PointeeType
|
|
|
|
= getDerived().TransformType(TLB, TL.getPointeeLoc());
|
2010-04-22 20:44:27 +04:00
|
|
|
if (PointeeType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
2010-05-15 15:32:37 +04:00
|
|
|
if (PointeeType->getAs<ObjCObjectType>()) {
|
2010-04-22 20:44:27 +04:00
|
|
|
// A dependent pointer type 'T *' has is being transformed such
|
|
|
|
// that an Objective-C class type is being replaced for 'T'. The
|
|
|
|
// resulting pointer type is an ObjCObjectPointerType, not a
|
|
|
|
// PointerType.
|
2010-05-15 15:32:37 +04:00
|
|
|
Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-05-15 15:32:37 +04:00
|
|
|
ObjCObjectPointerTypeLoc NewT = TLB.push<ObjCObjectPointerTypeLoc>(Result);
|
|
|
|
NewT.setStarLoc(TL.getStarLoc());
|
2010-04-22 20:44:27 +04:00
|
|
|
return Result;
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
PointeeType != TL.getPointeeLoc().getType()) {
|
|
|
|
Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
|
|
|
|
NewT.setSigilLoc(TL.getSigilLoc());
|
2010-05-05 19:23:54 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
2009-10-21 04:40:46 +04:00
|
|
|
TreeTransform<Derived>::TransformBlockPointerType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
BlockPointerTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2010-04-22 20:46:21 +04:00
|
|
|
QualType PointeeType
|
2010-05-05 19:23:54 +04:00
|
|
|
= getDerived().TransformType(TLB, TL.getPointeeLoc());
|
|
|
|
if (PointeeType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
PointeeType != TL.getPointeeLoc().getType()) {
|
|
|
|
Result = getDerived().RebuildBlockPointerType(PointeeType,
|
2010-04-22 20:46:21 +04:00
|
|
|
TL.getSigilLoc());
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
2010-04-22 20:50:51 +04:00
|
|
|
BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
|
2010-04-22 20:46:21 +04:00
|
|
|
NewT.setSigilLoc(TL.getSigilLoc());
|
|
|
|
return Result;
|
2009-10-21 04:40:46 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-30 03:06:24 +03:00
|
|
|
/// Transforms a reference type. Note that somewhat paradoxically we
|
|
|
|
/// don't care whether the type itself is an l-value type or an r-value
|
|
|
|
/// type; we only care if the type was *written* as an l-value type
|
|
|
|
/// or an r-value type.
|
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformReferenceType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
ReferenceTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-30 03:06:24 +03:00
|
|
|
const ReferenceType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
// Note that this works with the pointee-as-written.
|
|
|
|
QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
|
|
|
|
if (PointeeType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
PointeeType != T->getPointeeTypeAsWritten()) {
|
|
|
|
Result = getDerived().RebuildReferenceType(PointeeType,
|
|
|
|
T->isSpelledAsLValue(),
|
|
|
|
TL.getSigilLoc());
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
// r-value references can be rebuilt as l-value references.
|
|
|
|
ReferenceTypeLoc NewTL;
|
|
|
|
if (isa<LValueReferenceType>(Result))
|
|
|
|
NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
|
|
|
|
else
|
|
|
|
NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
|
|
|
|
NewTL.setSigilLoc(TL.getSigilLoc());
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformLValueReferenceType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
LValueReferenceTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
return TransformReferenceType(TLB, TL, ObjectType);
|
2009-10-21 04:40:46 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformRValueReferenceType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
RValueReferenceTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
return TransformReferenceType(TLB, TL, ObjectType);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
2009-10-21 04:40:46 +04:00
|
|
|
TreeTransform<Derived>::TransformMemberPointerType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
MemberPointerTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
MemberPointerType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (PointeeType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
// TODO: preserve source information for this.
|
|
|
|
QualType ClassType
|
|
|
|
= getDerived().TransformType(QualType(T->getClass(), 0));
|
2009-08-04 20:50:30 +04:00
|
|
|
if (ClassType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
PointeeType != T->getPointeeType() ||
|
|
|
|
ClassType != QualType(T->getClass(), 0)) {
|
2009-10-30 03:06:24 +03:00
|
|
|
Result = getDerived().RebuildMemberPointerType(PointeeType, ClassType,
|
|
|
|
TL.getStarLoc());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
|
|
|
|
NewTL.setSigilLoc(TL.getSigilLoc());
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
2009-10-21 04:40:46 +04:00
|
|
|
TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
ConstantArrayTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
ConstantArrayType *T = TL.getTypePtr();
|
|
|
|
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType()) {
|
|
|
|
Result = getDerived().RebuildConstantArrayType(ElementType,
|
|
|
|
T->getSizeModifier(),
|
|
|
|
T->getSize(),
|
2009-10-30 03:06:24 +03:00
|
|
|
T->getIndexTypeCVRQualifiers(),
|
|
|
|
TL.getBracketsRange());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
ConstantArrayTypeLoc NewTL = TLB.push<ConstantArrayTypeLoc>(Result);
|
|
|
|
NewTL.setLBracketLoc(TL.getLBracketLoc());
|
|
|
|
NewTL.setRBracketLoc(TL.getRBracketLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
Expr *Size = TL.getSizeExpr();
|
|
|
|
if (Size) {
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
|
|
|
Size = getDerived().TransformExpr(Size).template takeAs<Expr>();
|
|
|
|
}
|
|
|
|
NewTL.setSizeExpr(Size);
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformIncompleteArrayType(
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
IncompleteArrayTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
IncompleteArrayType *T = TL.getTypePtr();
|
|
|
|
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType()) {
|
|
|
|
Result = getDerived().RebuildIncompleteArrayType(ElementType,
|
|
|
|
T->getSizeModifier(),
|
2009-10-30 03:06:24 +03:00
|
|
|
T->getIndexTypeCVRQualifiers(),
|
|
|
|
TL.getBracketsRange());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
|
|
|
|
NewTL.setLBracketLoc(TL.getLBracketLoc());
|
|
|
|
NewTL.setRBracketLoc(TL.getRBracketLoc());
|
|
|
|
NewTL.setSizeExpr(0);
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformVariableArrayType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
VariableArrayTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
VariableArrayType *T = TL.getTypePtr();
|
|
|
|
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
// Array bounds are not potentially evaluated contexts
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SizeResult
|
2009-10-21 04:40:46 +04:00
|
|
|
= getDerived().TransformExpr(T->getSizeExpr());
|
|
|
|
if (SizeResult.isInvalid())
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Size = SizeResult.take();
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType() ||
|
|
|
|
Size != T->getSizeExpr()) {
|
|
|
|
Result = getDerived().RebuildVariableArrayType(ElementType,
|
|
|
|
T->getSizeModifier(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Size,
|
2009-10-21 04:40:46 +04:00
|
|
|
T->getIndexTypeCVRQualifiers(),
|
2009-10-30 03:06:24 +03:00
|
|
|
TL.getBracketsRange());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
VariableArrayTypeLoc NewTL = TLB.push<VariableArrayTypeLoc>(Result);
|
|
|
|
NewTL.setLBracketLoc(TL.getLBracketLoc());
|
|
|
|
NewTL.setRBracketLoc(TL.getRBracketLoc());
|
|
|
|
NewTL.setSizeExpr(Size);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformDependentSizedArrayType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
DependentSizedArrayTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
DependentSizedArrayType *T = TL.getTypePtr();
|
|
|
|
QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
// Array bounds are not potentially evaluated contexts
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SizeResult
|
2009-10-21 04:40:46 +04:00
|
|
|
= getDerived().TransformExpr(T->getSizeExpr());
|
|
|
|
if (SizeResult.isInvalid())
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
Expr *Size = static_cast<Expr*>(SizeResult.get());
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType() ||
|
|
|
|
Size != T->getSizeExpr()) {
|
|
|
|
Result = getDerived().RebuildDependentSizedArrayType(ElementType,
|
|
|
|
T->getSizeModifier(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Size,
|
2009-10-21 04:40:46 +04:00
|
|
|
T->getIndexTypeCVRQualifiers(),
|
2009-10-30 03:06:24 +03:00
|
|
|
TL.getBracketsRange());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-10-21 04:40:46 +04:00
|
|
|
else SizeResult.take();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
// We might have any sort of array type now, but fortunately they
|
|
|
|
// all have the same location layout.
|
|
|
|
ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
|
|
|
|
NewTL.setLBracketLoc(TL.getLBracketLoc());
|
|
|
|
NewTL.setRBracketLoc(TL.getRBracketLoc());
|
|
|
|
NewTL.setSizeExpr(Size);
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
DependentSizedExtVectorTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
DependentSizedExtVectorType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
// FIXME: ext vector locs should be nested
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType ElementType = getDerived().TransformType(T->getElementType());
|
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
// Vector sizes are not potentially evaluated contexts
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (Size.isInvalid())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
2009-10-23 21:55:45 +04:00
|
|
|
ElementType != T->getElementType() ||
|
|
|
|
Size.get() != T->getSizeExpr()) {
|
2009-10-21 04:40:46 +04:00
|
|
|
Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
|
2010-08-24 03:25:46 +04:00
|
|
|
Size.take(),
|
2009-08-04 20:50:30 +04:00
|
|
|
T->getAttributeLoc());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Result might be dependent or not.
|
|
|
|
if (isa<DependentSizedExtVectorType>(Result)) {
|
|
|
|
DependentSizedExtVectorTypeLoc NewTL
|
|
|
|
= TLB.push<DependentSizedExtVectorTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
} else {
|
|
|
|
ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformVectorType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
VectorTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
VectorType *T = TL.getTypePtr();
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType ElementType = getDerived().TransformType(T->getElementType());
|
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType()) {
|
2010-02-05 03:12:22 +03:00
|
|
|
Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
|
2010-06-23 10:00:24 +04:00
|
|
|
T->getAltiVecSpecific());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformExtVectorType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
ExtVectorTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
VectorType *T = TL.getTypePtr();
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType ElementType = getDerived().TransformType(T->getElementType());
|
|
|
|
if (ElementType.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType()) {
|
|
|
|
Result = getDerived().RebuildExtVectorType(ElementType,
|
|
|
|
T->getNumElements(),
|
|
|
|
/*FIXME*/ SourceLocation());
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-03-11 12:03:00 +03:00
|
|
|
ParmVarDecl *
|
|
|
|
TreeTransform<Derived>::TransformFunctionTypeParam(ParmVarDecl *OldParm) {
|
|
|
|
TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
|
|
|
|
TypeSourceInfo *NewDI = getDerived().TransformType(OldDI);
|
|
|
|
if (!NewDI)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (NewDI == OldDI)
|
|
|
|
return OldParm;
|
|
|
|
else
|
|
|
|
return ParmVarDecl::Create(SemaRef.Context,
|
|
|
|
OldParm->getDeclContext(),
|
|
|
|
OldParm->getLocation(),
|
|
|
|
OldParm->getIdentifier(),
|
|
|
|
NewDI->getType(),
|
|
|
|
NewDI,
|
|
|
|
OldParm->getStorageClass(),
|
2010-04-20 02:54:31 +04:00
|
|
|
OldParm->getStorageClassAsWritten(),
|
2010-03-11 12:03:00 +03:00
|
|
|
/* DefArg */ NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
bool TreeTransform<Derived>::
|
|
|
|
TransformFunctionTypeParams(FunctionProtoTypeLoc TL,
|
|
|
|
llvm::SmallVectorImpl<QualType> &PTypes,
|
|
|
|
llvm::SmallVectorImpl<ParmVarDecl*> &PVars) {
|
2009-10-21 04:40:46 +04:00
|
|
|
FunctionProtoType *T = TL.getTypePtr();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) {
|
|
|
|
ParmVarDecl *OldParm = TL.getArg(i);
|
|
|
|
|
|
|
|
QualType NewType;
|
|
|
|
ParmVarDecl *NewParm;
|
|
|
|
|
|
|
|
if (OldParm) {
|
2010-03-11 12:03:00 +03:00
|
|
|
NewParm = getDerived().TransformFunctionTypeParam(OldParm);
|
|
|
|
if (!NewParm)
|
|
|
|
return true;
|
2009-10-21 04:40:46 +04:00
|
|
|
NewType = NewParm->getType();
|
|
|
|
|
|
|
|
// Deal with the possibility that we don't have a parameter
|
|
|
|
// declaration for this parameter.
|
|
|
|
} else {
|
|
|
|
NewParm = 0;
|
|
|
|
|
|
|
|
QualType OldType = T->getArgType(i);
|
|
|
|
NewType = getDerived().TransformType(OldType);
|
|
|
|
if (NewType.isNull())
|
2010-03-11 12:03:00 +03:00
|
|
|
return true;
|
2009-10-21 04:40:46 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-03-11 12:03:00 +03:00
|
|
|
PTypes.push_back(NewType);
|
|
|
|
PVars.push_back(NewParm);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-03-11 12:03:00 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB,
|
|
|
|
FunctionProtoTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2010-04-30 22:55:50 +04:00
|
|
|
// Transform the parameters. We do this first for the benefit of template
|
|
|
|
// instantiations, so that the ParmVarDecls get/ placed into the template
|
|
|
|
// instantiation scope before we transform the function type.
|
2010-03-11 12:03:00 +03:00
|
|
|
llvm::SmallVector<QualType, 4> ParamTypes;
|
|
|
|
llvm::SmallVector<ParmVarDecl*, 4> ParamDecls;
|
|
|
|
if (getDerived().TransformFunctionTypeParams(TL, ParamTypes, ParamDecls))
|
|
|
|
return QualType();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-30 22:55:50 +04:00
|
|
|
FunctionProtoType *T = TL.getTypePtr();
|
|
|
|
QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
|
|
|
|
if (ResultType.isNull())
|
|
|
|
return QualType();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ResultType != T->getResultType() ||
|
|
|
|
!std::equal(T->arg_type_begin(), T->arg_type_end(), ParamTypes.begin())) {
|
|
|
|
Result = getDerived().RebuildFunctionProtoType(ResultType,
|
|
|
|
ParamTypes.data(),
|
|
|
|
ParamTypes.size(),
|
|
|
|
T->isVariadic(),
|
2010-08-05 06:54:05 +04:00
|
|
|
T->getTypeQuals(),
|
|
|
|
T->getExtInfo());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
|
|
|
|
NewTL.setLParenLoc(TL.getLParenLoc());
|
|
|
|
NewTL.setRParenLoc(TL.getRParenLoc());
|
|
|
|
for (unsigned i = 0, e = NewTL.getNumArgs(); i != e; ++i)
|
|
|
|
NewTL.setArg(i, ParamDecls[i]);
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformFunctionNoProtoType(
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
FunctionNoProtoTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
FunctionNoProtoType *T = TL.getTypePtr();
|
|
|
|
QualType ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
|
|
|
|
if (ResultType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ResultType != T->getResultType())
|
|
|
|
Result = getDerived().RebuildFunctionNoProtoType(ResultType);
|
|
|
|
|
|
|
|
FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
|
|
|
|
NewTL.setLParenLoc(TL.getLParenLoc());
|
|
|
|
NewTL.setRParenLoc(TL.getRParenLoc());
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-05 01:46:56 +03:00
|
|
|
template<typename Derived> QualType
|
|
|
|
TreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
UnresolvedUsingTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-12-05 01:46:56 +03:00
|
|
|
UnresolvedUsingType *T = TL.getTypePtr();
|
2010-03-01 18:56:25 +03:00
|
|
|
Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
|
2009-12-05 01:46:56 +03:00
|
|
|
if (!D)
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
|
|
|
|
Result = getDerived().RebuildUnresolvedUsingType(D);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
// We might get an arbitrary type spec type back. We should at
|
|
|
|
// least always get a type spec type, though.
|
|
|
|
TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformTypedefType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
TypedefTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
TypedefType *T = TL.getTypePtr();
|
2009-08-04 20:50:30 +04:00
|
|
|
TypedefDecl *Typedef
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<TypedefDecl>(getDerived().TransformDecl(TL.getNameLoc(),
|
|
|
|
T->getDecl()));
|
2009-08-04 20:50:30 +04:00
|
|
|
if (!Typedef)
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
Typedef != T->getDecl()) {
|
|
|
|
Result = getDerived().RebuildTypedefType(Typedef);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformTypeOfExprType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
TypeOfExprTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-08-05 02:27:00 +04:00
|
|
|
// typeof expressions are not potentially evaluated contexts
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (E.isInvalid())
|
|
|
|
return QualType();
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
2010-01-13 23:03:27 +03:00
|
|
|
E.get() != TL.getUnderlyingExpr()) {
|
2010-08-24 03:25:46 +04:00
|
|
|
Result = getDerived().RebuildTypeOfExprType(E.get());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-10-21 04:40:46 +04:00
|
|
|
else E.take();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
|
2010-01-13 23:03:27 +03:00
|
|
|
NewTL.setTypeofLoc(TL.getTypeofLoc());
|
|
|
|
NewTL.setLParenLoc(TL.getLParenLoc());
|
|
|
|
NewTL.setRParenLoc(TL.getRParenLoc());
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformTypeOfType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
TypeOfTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2010-01-13 23:03:27 +03:00
|
|
|
TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo();
|
|
|
|
TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
|
|
|
|
if (!New_Under_TI)
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
2010-01-13 23:03:27 +03:00
|
|
|
if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
|
|
|
|
Result = getDerived().RebuildTypeOfType(New_Under_TI->getType());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
|
2010-01-13 23:03:27 +03:00
|
|
|
NewTL.setTypeofLoc(TL.getTypeofLoc());
|
|
|
|
NewTL.setLParenLoc(TL.getLParenLoc());
|
|
|
|
NewTL.setRParenLoc(TL.getRParenLoc());
|
|
|
|
NewTL.setUnderlyingTInfo(New_Under_TI);
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformDecltypeType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
DecltypeTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
DecltypeType *T = TL.getTypePtr();
|
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
// decltype expressions are not potentially evaluated contexts
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
|
2009-08-04 20:50:30 +04:00
|
|
|
if (E.isInvalid())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
E.get() != T->getUnderlyingExpr()) {
|
2010-08-24 03:25:46 +04:00
|
|
|
Result = getDerived().RebuildDecltypeType(E.get());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-10-21 04:40:46 +04:00
|
|
|
else E.take();
|
|
|
|
|
|
|
|
DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformRecordType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
RecordTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
RecordType *T = TL.getTypePtr();
|
2009-08-04 20:50:30 +04:00
|
|
|
RecordDecl *Record
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
|
|
|
|
T->getDecl()));
|
2009-08-04 20:50:30 +04:00
|
|
|
if (!Record)
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
Record != T->getDecl()) {
|
|
|
|
Result = getDerived().RebuildRecordType(Record);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformEnumType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
EnumTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
EnumType *T = TL.getTypePtr();
|
2009-08-04 20:50:30 +04:00
|
|
|
EnumDecl *Enum
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
|
|
|
|
T->getDecl()));
|
2009-08-04 20:50:30 +04:00
|
|
|
if (!Enum)
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
Enum != T->getDecl()) {
|
|
|
|
Result = getDerived().RebuildEnumType(Enum);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-05 04:15:47 +04:00
|
|
|
|
2010-03-10 06:28:59 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformInjectedClassNameType(
|
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
InjectedClassNameTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
|
|
|
|
TL.getTypePtr()->getDecl());
|
|
|
|
if (!D) return QualType();
|
|
|
|
|
|
|
|
QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
|
|
|
|
TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
|
|
|
|
return T;
|
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformTemplateTypeParmType(
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
TemplateTypeParmTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
return TransformTypeSpecType(TLB, TL);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2009-10-18 13:09:24 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmType(
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
SubstTemplateTypeParmTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2009-10-21 04:40:46 +04:00
|
|
|
return TransformTypeSpecType(TLB, TL);
|
2009-10-18 13:09:24 +04:00
|
|
|
}
|
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
|
|
|
|
const TemplateSpecializationType *TST,
|
|
|
|
QualType ObjectType) {
|
|
|
|
// FIXME: this entire method is a temporary workaround; callers
|
|
|
|
// should be rewritten to provide real type locs.
|
2009-10-21 04:40:46 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
// Fake up a TemplateSpecializationTypeLoc.
|
|
|
|
TypeLocBuilder TLB;
|
|
|
|
TemplateSpecializationTypeLoc TL
|
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(QualType(TST, 0));
|
|
|
|
|
2009-10-29 21:45:58 +03:00
|
|
|
SourceLocation BaseLoc = getDerived().getBaseLocation();
|
|
|
|
|
|
|
|
TL.setTemplateNameLoc(BaseLoc);
|
|
|
|
TL.setLAngleLoc(BaseLoc);
|
|
|
|
TL.setRAngleLoc(BaseLoc);
|
2009-10-29 11:12:44 +03:00
|
|
|
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i) {
|
|
|
|
const TemplateArgument &TA = TST->getArg(i);
|
|
|
|
TemplateArgumentLoc TAL;
|
|
|
|
getDerived().InventTemplateArgumentLoc(TA, TAL);
|
|
|
|
TL.setArgLocInfo(i, TAL.getLocInfo());
|
|
|
|
}
|
|
|
|
|
|
|
|
TypeLocBuilder IgnoredTLB;
|
|
|
|
return TransformTemplateSpecializationType(IgnoredTLB, TL, ObjectType);
|
2009-10-20 02:04:39 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2009-08-04 20:50:30 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
|
2009-10-29 11:12:44 +03:00
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
TemplateSpecializationTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
const TemplateSpecializationType *T = TL.getTypePtr();
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateName Template
|
2009-10-20 02:04:39 +04:00
|
|
|
= getDerived().TransformTemplateName(T->getTemplateName(), ObjectType);
|
2009-08-04 20:50:30 +04:00
|
|
|
if (Template.isNull())
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentListInfo NewTemplateArgs;
|
|
|
|
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
|
|
|
|
for (unsigned i = 0, e = T->getNumArgs(); i != e; ++i) {
|
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(TL.getArgLoc(i), Loc))
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-11-23 04:53:49 +03:00
|
|
|
NewTemplateArgs.addArgument(Loc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
// FIXME: maybe don't rebuild if all the template arguments are the same.
|
|
|
|
|
|
|
|
QualType Result =
|
|
|
|
getDerived().RebuildTemplateSpecializationType(Template,
|
|
|
|
TL.getTemplateNameLoc(),
|
2009-11-23 04:53:49 +03:00
|
|
|
NewTemplateArgs);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
if (!Result.isNull()) {
|
|
|
|
TemplateSpecializationTypeLoc NewTL
|
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(Result);
|
|
|
|
NewTL.setTemplateNameLoc(TL.getTemplateNameLoc());
|
|
|
|
NewTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTL.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
|
|
|
|
NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType
|
2010-05-12 01:36:43 +04:00
|
|
|
TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
|
|
|
|
ElaboratedTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
ElaboratedType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
NestedNameSpecifier *NNS = 0;
|
|
|
|
// NOTE: the qualifier in an ElaboratedType is optional.
|
|
|
|
if (T->getQualifier() != 0) {
|
|
|
|
NNS = getDerived().TransformNestedNameSpecifier(T->getQualifier(),
|
2010-05-20 01:37:53 +04:00
|
|
|
TL.getQualifierRange(),
|
2010-05-12 01:36:43 +04:00
|
|
|
ObjectType);
|
|
|
|
if (!NNS)
|
|
|
|
return QualType();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-05-20 01:37:53 +04:00
|
|
|
QualType NamedT;
|
|
|
|
// FIXME: this test is meant to workaround a problem (failing assertion)
|
|
|
|
// occurring if directly executing the code in the else branch.
|
|
|
|
if (isa<TemplateSpecializationTypeLoc>(TL.getNamedTypeLoc())) {
|
|
|
|
TemplateSpecializationTypeLoc OldNamedTL
|
|
|
|
= cast<TemplateSpecializationTypeLoc>(TL.getNamedTypeLoc());
|
|
|
|
const TemplateSpecializationType* OldTST
|
2010-05-20 03:53:08 +04:00
|
|
|
= OldNamedTL.getType()->template getAs<TemplateSpecializationType>();
|
2010-05-20 01:37:53 +04:00
|
|
|
NamedT = TransformTemplateSpecializationType(OldTST, ObjectType);
|
|
|
|
if (NamedT.isNull())
|
|
|
|
return QualType();
|
|
|
|
TemplateSpecializationTypeLoc NewNamedTL
|
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(NamedT);
|
|
|
|
NewNamedTL.copy(OldNamedTL);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
|
|
|
|
if (NamedT.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-14 20:34:09 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
NNS != T->getQualifier() ||
|
2010-05-20 01:37:53 +04:00
|
|
|
NamedT != T->getNamedType()) {
|
|
|
|
Result = getDerived().RebuildElaboratedType(T->getKeyword(), NNS, NamedT);
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2010-05-12 01:36:43 +04:00
|
|
|
ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
|
2010-05-20 01:37:53 +04:00
|
|
|
NewTL.setKeywordLoc(TL.getKeywordLoc());
|
|
|
|
NewTL.setQualifierRange(TL.getQualifierRange());
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-03-31 21:34:00 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformDependentNameType(TypeLocBuilder &TLB,
|
|
|
|
DependentNameTypeLoc TL,
|
2010-02-16 22:09:40 +03:00
|
|
|
QualType ObjectType) {
|
2010-03-31 21:34:00 +04:00
|
|
|
DependentNameType *T = TL.getTypePtr();
|
2009-10-29 11:12:44 +03:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
NestedNameSpecifier *NNS
|
2010-05-20 01:37:53 +04:00
|
|
|
= getDerived().TransformNestedNameSpecifier(T->getQualifier(),
|
|
|
|
TL.getQualifierRange(),
|
2010-02-25 07:46:04 +03:00
|
|
|
ObjectType);
|
2009-08-04 20:50:30 +04:00
|
|
|
if (!NNS)
|
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-06-11 04:33:02 +04:00
|
|
|
QualType Result
|
|
|
|
= getDerived().RebuildDependentNameType(T->getKeyword(), NNS,
|
|
|
|
T->getIdentifier(),
|
|
|
|
TL.getKeywordLoc(),
|
|
|
|
TL.getQualifierRange(),
|
|
|
|
TL.getNameLoc());
|
2009-10-21 04:40:46 +04:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
2010-05-20 01:37:53 +04:00
|
|
|
if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
|
|
|
|
QualType NamedT = ElabT->getNamedType();
|
2010-06-11 04:33:02 +04:00
|
|
|
TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
|
|
|
|
|
2010-05-20 01:37:53 +04:00
|
|
|
ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
|
|
|
|
NewTL.setKeywordLoc(TL.getKeywordLoc());
|
|
|
|
NewTL.setQualifierRange(TL.getQualifierRange());
|
2010-06-11 04:33:02 +04:00
|
|
|
} else {
|
2010-05-20 01:37:53 +04:00
|
|
|
DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
|
|
|
|
NewTL.setKeywordLoc(TL.getKeywordLoc());
|
|
|
|
NewTL.setQualifierRange(TL.getQualifierRange());
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
}
|
2009-10-21 04:40:46 +04:00
|
|
|
return Result;
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-06-11 04:33:02 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::
|
|
|
|
TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
|
|
|
|
DependentTemplateSpecializationTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
DependentTemplateSpecializationType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
NestedNameSpecifier *NNS
|
|
|
|
= getDerived().TransformNestedNameSpecifier(T->getQualifier(),
|
|
|
|
TL.getQualifierRange(),
|
|
|
|
ObjectType);
|
|
|
|
if (!NNS)
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
TemplateArgumentListInfo NewTemplateArgs;
|
|
|
|
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
|
|
|
|
for (unsigned I = 0, E = T->getNumArgs(); I != E; ++I) {
|
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(TL.getArgLoc(I), Loc))
|
|
|
|
return QualType();
|
|
|
|
NewTemplateArgs.addArgument(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
|
|
|
|
T->getKeyword(),
|
|
|
|
NNS,
|
|
|
|
T->getIdentifier(),
|
|
|
|
TL.getNameLoc(),
|
|
|
|
NewTemplateArgs);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
|
|
|
|
QualType NamedT = ElabT->getNamedType();
|
|
|
|
|
|
|
|
// Copy information relevant to the template specialization.
|
|
|
|
TemplateSpecializationTypeLoc NamedTL
|
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(NamedT);
|
|
|
|
NamedTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NamedTL.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
|
|
|
|
NamedTL.setArgLocInfo(I, TL.getArgLocInfo(I));
|
|
|
|
|
|
|
|
// Copy information relevant to the elaborated type.
|
|
|
|
ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
|
|
|
|
NewTL.setKeywordLoc(TL.getKeywordLoc());
|
|
|
|
NewTL.setQualifierRange(TL.getQualifierRange());
|
|
|
|
} else {
|
2010-06-17 20:03:49 +04:00
|
|
|
TypeLoc NewTL(Result, TL.getOpaqueData());
|
|
|
|
TLB.pushFullCopy(NewTL);
|
2010-06-11 04:33:02 +04:00
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformObjCInterfaceType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
ObjCInterfaceTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2010-04-22 21:28:13 +04:00
|
|
|
// ObjCInterfaceType is never dependent.
|
2010-05-15 15:32:37 +04:00
|
|
|
TLB.pushFullCopy(TL);
|
|
|
|
return TL.getType();
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformObjCObjectType(TypeLocBuilder &TLB,
|
|
|
|
ObjCObjectTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
|
|
|
// ObjCObjectType is never dependent.
|
|
|
|
TLB.pushFullCopy(TL);
|
2010-04-22 21:28:13 +04:00
|
|
|
return TL.getType();
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformObjCObjectPointerType(TypeLocBuilder &TLB,
|
2010-02-16 22:09:40 +03:00
|
|
|
ObjCObjectPointerTypeLoc TL,
|
|
|
|
QualType ObjectType) {
|
2010-04-22 21:28:13 +04:00
|
|
|
// ObjCObjectPointerType is never dependent.
|
2010-05-15 15:32:37 +04:00
|
|
|
TLB.pushFullCopy(TL);
|
2010-04-22 21:28:13 +04:00
|
|
|
return TL.getType();
|
2009-09-29 23:42:55 +04:00
|
|
|
}
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Statement transformation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformNullStmt(NullStmt *S) {
|
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S) {
|
|
|
|
return getDerived().TransformCompoundStmt(S, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformCompoundStmt(CompoundStmt *S,
|
2009-08-20 11:17:43 +04:00
|
|
|
bool IsStmtExpr) {
|
|
|
|
bool SubStmtChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Stmt*> Statements(getSema());
|
2009-08-20 11:17:43 +04:00
|
|
|
for (CompoundStmt::body_iterator B = S->body_begin(), BEnd = S->body_end();
|
|
|
|
B != BEnd; ++B) {
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Result = getDerived().TransformStmt(*B);
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return getSema().StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
SubStmtChanged = SubStmtChanged || Result.get() != *B;
|
|
|
|
Statements.push_back(Result.takeAs<Stmt>());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
!SubStmtChanged)
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
|
|
|
|
move_arg(Statements),
|
|
|
|
S->getRBracLoc(),
|
|
|
|
IsStmtExpr);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformCaseStmt(CaseStmt *S) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult LHS, RHS;
|
2009-11-19 06:14:00 +03:00
|
|
|
{
|
|
|
|
// The case value expressions are not potentially evaluated.
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-19 06:14:00 +03:00
|
|
|
// Transform the left-hand case value.
|
|
|
|
LHS = getDerived().TransformExpr(S->getLHS());
|
|
|
|
if (LHS.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-19 06:14:00 +03:00
|
|
|
// Transform the right-hand case value (for the GNU case-range extension).
|
|
|
|
RHS = getDerived().TransformExpr(S->getRHS());
|
|
|
|
if (RHS.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Build the case statement.
|
|
|
|
// Case statements are always rebuilt so that they will attached to their
|
|
|
|
// transformed switch statement.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
LHS.get(),
|
2009-08-20 11:17:43 +04:00
|
|
|
S->getEllipsisLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
RHS.get(),
|
2009-08-20 11:17:43 +04:00
|
|
|
S->getColonLoc());
|
|
|
|
if (Case.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the statement following the case
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (SubStmt.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Attach the body to the case statement
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformDefaultStmt(DefaultStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the statement following the default case
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (SubStmt.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Default statements are always rebuilt
|
|
|
|
return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
SubStmt.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S) {
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (SubStmt.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// FIXME: Pass the real colon location in.
|
|
|
|
SourceLocation ColonLoc = SemaRef.PP.getLocForEndOfToken(S->getIdentLoc());
|
|
|
|
return getDerived().RebuildLabelStmt(S->getIdentLoc(), S->getID(), ColonLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubStmt.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformIfStmt(IfStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the condition
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond;
|
2009-11-24 02:44:04 +03:00
|
|
|
VarDecl *ConditionVar = 0;
|
|
|
|
if (S->getConditionVariable()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
ConditionVar
|
2009-11-24 02:44:04 +03:00
|
|
|
= cast_or_null<VarDecl>(
|
2010-03-01 20:25:41 +03:00
|
|
|
getDerived().TransformDefinition(
|
|
|
|
S->getConditionVariable()->getLocation(),
|
|
|
|
S->getConditionVariable()));
|
2009-11-24 02:44:04 +03:00
|
|
|
if (!ConditionVar)
|
|
|
|
return SemaRef.StmtError();
|
2009-11-25 03:27:52 +03:00
|
|
|
} else {
|
2009-11-24 02:44:04 +03:00
|
|
|
Cond = getDerived().TransformExpr(S->getCond());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-25 03:27:52 +03:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
|
|
|
// Convert the condition to a boolean value.
|
2010-05-09 03:34:38 +04:00
|
|
|
if (S->getCond()) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult CondE = getSema().ActOnBooleanCondition(0,
|
2010-05-09 03:34:38 +04:00
|
|
|
S->getIfLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond.get());
|
2010-05-09 03:34:38 +04:00
|
|
|
if (CondE.isInvalid())
|
|
|
|
return getSema().StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond = CondE.get();
|
2010-05-09 03:34:38 +04:00
|
|
|
}
|
2009-11-25 03:27:52 +03:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.take()));
|
|
|
|
if (!S->getConditionVariable() && S->getCond() && !FullCond.get())
|
2010-05-09 02:20:28 +04:00
|
|
|
return SemaRef.StmtError();
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the "then" branch.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Then = getDerived().TransformStmt(S->getThen());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Then.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the "else" branch.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Else = getDerived().TransformStmt(S->getElse());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Else.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-08-24 03:25:46 +04:00
|
|
|
FullCond.get() == S->getCond() &&
|
2009-11-25 03:27:52 +03:00
|
|
|
ConditionVar == S->getConditionVariable() &&
|
2009-08-20 11:17:43 +04:00
|
|
|
Then.get() == S->getThen() &&
|
|
|
|
Else.get() == S->getElse())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
2010-05-09 02:20:28 +04:00
|
|
|
return getDerived().RebuildIfStmt(S->getIfLoc(), FullCond, ConditionVar,
|
2010-08-24 03:25:46 +04:00
|
|
|
Then.get(),
|
|
|
|
S->getElseLoc(), Else.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformSwitchStmt(SwitchStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the condition.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond;
|
2009-11-24 20:07:59 +03:00
|
|
|
VarDecl *ConditionVar = 0;
|
|
|
|
if (S->getConditionVariable()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
ConditionVar
|
2009-11-24 20:07:59 +03:00
|
|
|
= cast_or_null<VarDecl>(
|
2010-03-01 20:25:41 +03:00
|
|
|
getDerived().TransformDefinition(
|
|
|
|
S->getConditionVariable()->getLocation(),
|
|
|
|
S->getConditionVariable()));
|
2009-11-24 20:07:59 +03:00
|
|
|
if (!ConditionVar)
|
|
|
|
return SemaRef.StmtError();
|
2009-11-25 03:27:52 +03:00
|
|
|
} else {
|
2009-11-24 20:07:59 +03:00
|
|
|
Cond = getDerived().TransformExpr(S->getCond());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-25 03:27:52 +03:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Rebuild the switch statement.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Switch
|
2010-08-24 03:25:46 +04:00
|
|
|
= getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Cond.get(),
|
2010-05-06 21:25:47 +04:00
|
|
|
ConditionVar);
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Switch.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the body of the switch statement.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getBody());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Complete the switch statement.
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
|
|
|
|
Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformWhileStmt(WhileStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the condition
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond;
|
2009-11-25 00:15:44 +03:00
|
|
|
VarDecl *ConditionVar = 0;
|
|
|
|
if (S->getConditionVariable()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
ConditionVar
|
2009-11-25 00:15:44 +03:00
|
|
|
= cast_or_null<VarDecl>(
|
2010-03-01 20:25:41 +03:00
|
|
|
getDerived().TransformDefinition(
|
|
|
|
S->getConditionVariable()->getLocation(),
|
|
|
|
S->getConditionVariable()));
|
2009-11-25 00:15:44 +03:00
|
|
|
if (!ConditionVar)
|
|
|
|
return SemaRef.StmtError();
|
2009-11-25 03:27:52 +03:00
|
|
|
} else {
|
2009-11-25 00:15:44 +03:00
|
|
|
Cond = getDerived().TransformExpr(S->getCond());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-25 03:27:52 +03:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-09 03:34:38 +04:00
|
|
|
|
|
|
|
if (S->getCond()) {
|
|
|
|
// Convert the condition to a boolean value.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult CondE = getSema().ActOnBooleanCondition(0,
|
2010-05-09 02:20:28 +04:00
|
|
|
S->getWhileLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond.get());
|
2010-05-09 03:34:38 +04:00
|
|
|
if (CondE.isInvalid())
|
|
|
|
return getSema().StmtError();
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond = CondE;
|
2010-05-09 03:34:38 +04:00
|
|
|
}
|
2009-11-25 03:27:52 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.take()));
|
|
|
|
if (!S->getConditionVariable() && S->getCond() && !FullCond.get())
|
2010-05-09 02:20:28 +04:00
|
|
|
return SemaRef.StmtError();
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the body
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getBody());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-08-24 03:25:46 +04:00
|
|
|
FullCond.get() == S->getCond() &&
|
2009-11-25 03:27:52 +03:00
|
|
|
ConditionVar == S->getConditionVariable() &&
|
2009-08-20 11:17:43 +04:00
|
|
|
Body.get() == S->getBody())
|
2010-08-24 03:25:46 +04:00
|
|
|
return Owned(S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-05-09 02:20:28 +04:00
|
|
|
return getDerived().RebuildWhileStmt(S->getWhileLoc(), FullCond,
|
2010-08-24 03:25:46 +04:00
|
|
|
ConditionVar, Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformDoStmt(DoStmt *S) {
|
|
|
|
// Transform the body
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getBody());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-05-09 02:20:28 +04:00
|
|
|
// Transform the condition
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond = getDerived().TransformExpr(S->getCond());
|
2010-05-09 02:20:28 +04:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Cond.get() == S->getCond() &&
|
|
|
|
Body.get() == S->getBody())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
|
|
|
|
/*FIXME:*/S->getWhileLoc(), Cond.get(),
|
2009-08-20 11:17:43 +04:00
|
|
|
S->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformForStmt(ForStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the initialization statement
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Init = getDerived().TransformStmt(S->getInit());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Init.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the condition
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond;
|
2009-11-25 03:27:52 +03:00
|
|
|
VarDecl *ConditionVar = 0;
|
|
|
|
if (S->getConditionVariable()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
ConditionVar
|
2009-11-25 03:27:52 +03:00
|
|
|
= cast_or_null<VarDecl>(
|
2010-03-01 20:25:41 +03:00
|
|
|
getDerived().TransformDefinition(
|
|
|
|
S->getConditionVariable()->getLocation(),
|
|
|
|
S->getConditionVariable()));
|
2009-11-25 03:27:52 +03:00
|
|
|
if (!ConditionVar)
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
} else {
|
|
|
|
Cond = getDerived().TransformExpr(S->getCond());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-25 03:27:52 +03:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-09 03:34:38 +04:00
|
|
|
|
|
|
|
if (S->getCond()) {
|
|
|
|
// Convert the condition to a boolean value.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult CondE = getSema().ActOnBooleanCondition(0,
|
2010-05-09 03:34:38 +04:00
|
|
|
S->getForLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond.get());
|
2010-05-09 03:34:38 +04:00
|
|
|
if (CondE.isInvalid())
|
|
|
|
return getSema().StmtError();
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond = CondE.get();
|
2010-05-09 03:34:38 +04:00
|
|
|
}
|
2009-11-25 03:27:52 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Sema::FullExprArg FullCond(getSema().MakeFullExpr(Cond.take()));
|
|
|
|
if (!S->getConditionVariable() && S->getCond() && !FullCond.get())
|
2010-05-09 02:20:28 +04:00
|
|
|
return SemaRef.StmtError();
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the increment
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Inc = getDerived().TransformExpr(S->getInc());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Inc.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Sema::FullExprArg FullInc(getSema().MakeFullExpr(Inc.get()));
|
|
|
|
if (S->getInc() && !FullInc.get())
|
2010-05-09 02:20:28 +04:00
|
|
|
return SemaRef.StmtError();
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the body
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getBody());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Init.get() == S->getInit() &&
|
2010-08-24 03:25:46 +04:00
|
|
|
FullCond.get() == S->getCond() &&
|
2009-08-20 11:17:43 +04:00
|
|
|
Inc.get() == S->getInc() &&
|
|
|
|
Body.get() == S->getBody())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Init.get(), FullCond, ConditionVar,
|
|
|
|
FullInc, S->getRParenLoc(), Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformGotoStmt(GotoStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
// Goto statements must always be rebuilt, to resolve the label.
|
2009-09-09 19:08:12 +04:00
|
|
|
return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
|
2009-08-20 11:17:43 +04:00
|
|
|
S->getLabel());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformIndirectGotoStmt(IndirectGotoStmt *S) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Target = getDerived().TransformExpr(S->getTarget());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Target.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Target.get() == S->getTarget())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Target.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformContinueStmt(ContinueStmt *S) {
|
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformBreakStmt(BreakStmt *S) {
|
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformReturnStmt(ReturnStmt *S) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = getDerived().TransformExpr(S->getRetValue());
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
// FIXME: We always rebuild the return statement because there is no way
|
2009-08-20 11:17:43 +04:00
|
|
|
// to tell whether the return type of the function has changed.
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
bool DeclChanged = false;
|
|
|
|
llvm::SmallVector<Decl *, 4> Decls;
|
|
|
|
for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
|
|
|
|
D != DEnd; ++D) {
|
2010-03-01 20:25:41 +03:00
|
|
|
Decl *Transformed = getDerived().TransformDefinition((*D)->getLocation(),
|
|
|
|
*D);
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!Transformed)
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (Transformed != *D)
|
|
|
|
DeclChanged = true;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
Decls.push_back(Transformed);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && !DeclChanged)
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
|
|
|
return getDerived().RebuildDeclStmt(Decls.data(), Decls.size(),
|
2009-08-20 11:17:43 +04:00
|
|
|
S->getStartLoc(), S->getEndLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformSwitchCase(SwitchCase *S) {
|
2009-08-20 11:17:43 +04:00
|
|
|
assert(false && "SwitchCase is abstract and cannot be transformed");
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformAsmStmt(AsmStmt *S) {
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Constraints(getSema());
|
|
|
|
ASTOwningVector<Expr*> Exprs(getSema());
|
2010-01-31 01:25:16 +03:00
|
|
|
llvm::SmallVector<IdentifierInfo *, 4> Names;
|
2010-01-30 23:05:21 +03:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult AsmString;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Clobbers(getSema());
|
2010-01-24 08:50:09 +03:00
|
|
|
|
|
|
|
bool ExprsChanged = false;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
// Go through the outputs.
|
|
|
|
for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
|
2010-01-31 01:25:16 +03:00
|
|
|
Names.push_back(S->getOutputIdentifier(I));
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
// No need to transform the constraint literal.
|
|
|
|
Constraints.push_back(S->getOutputConstraintLiteral(I)->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
// Transform the output expr.
|
|
|
|
Expr *OutputExpr = S->getOutputExpr(I);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = getDerived().TransformExpr(OutputExpr);
|
2010-01-24 08:50:09 +03:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
ExprsChanged |= Result.get() != OutputExpr;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Exprs.push_back(Result.get());
|
2010-01-24 08:50:09 +03:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
// Go through the inputs.
|
|
|
|
for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
|
2010-01-31 01:25:16 +03:00
|
|
|
Names.push_back(S->getInputIdentifier(I));
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
// No need to transform the constraint literal.
|
|
|
|
Constraints.push_back(S->getInputConstraintLiteral(I)->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
// Transform the input expr.
|
|
|
|
Expr *InputExpr = S->getInputExpr(I);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result = getDerived().TransformExpr(InputExpr);
|
2010-01-24 08:50:09 +03:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
ExprsChanged |= Result.get() != InputExpr;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
Exprs.push_back(Result.get());
|
2010-01-24 08:50:09 +03:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-01-24 08:50:09 +03:00
|
|
|
if (!getDerived().AlwaysRebuild() && !ExprsChanged)
|
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
|
|
|
// Go through the clobbers.
|
|
|
|
for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
|
|
|
|
Clobbers.push_back(S->getClobber(I)->Retain());
|
|
|
|
|
|
|
|
// No need to transform the asm string literal.
|
|
|
|
AsmString = SemaRef.Owned(S->getAsmString());
|
|
|
|
|
|
|
|
return getDerived().RebuildAsmStmt(S->getAsmLoc(),
|
|
|
|
S->isSimple(),
|
|
|
|
S->isVolatile(),
|
|
|
|
S->getNumOutputs(),
|
|
|
|
S->getNumInputs(),
|
2010-01-30 23:05:21 +03:00
|
|
|
Names.data(),
|
2010-01-24 08:50:09 +03:00
|
|
|
move_arg(Constraints),
|
|
|
|
move_arg(Exprs),
|
2010-08-24 03:25:46 +04:00
|
|
|
AsmString.get(),
|
2010-01-24 08:50:09 +03:00
|
|
|
move_arg(Clobbers),
|
|
|
|
S->getRParenLoc(),
|
|
|
|
S->isMSAsm());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCAtTryStmt(ObjCAtTryStmt *S) {
|
2010-04-23 03:59:56 +04:00
|
|
|
// Transform the body of the @try.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
|
2010-04-23 03:59:56 +04:00
|
|
|
if (TryBody.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-24 02:50:49 +04:00
|
|
|
// Transform the @catch statements (if present).
|
|
|
|
bool AnyCatchChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Stmt*> CatchStmts(SemaRef);
|
2010-04-24 02:50:49 +04:00
|
|
|
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
|
2010-04-23 03:59:56 +04:00
|
|
|
if (Catch.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-04-24 02:50:49 +04:00
|
|
|
if (Catch.get() != S->getCatchStmt(I))
|
|
|
|
AnyCatchChanged = true;
|
|
|
|
CatchStmts.push_back(Catch.release());
|
2010-04-23 03:59:56 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:59:56 +04:00
|
|
|
// Transform the @finally statement (if present).
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Finally;
|
2010-04-23 03:59:56 +04:00
|
|
|
if (S->getFinallyStmt()) {
|
|
|
|
Finally = getDerived().TransformStmt(S->getFinallyStmt());
|
|
|
|
if (Finally.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
}
|
|
|
|
|
|
|
|
// If nothing changed, just retain this statement.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TryBody.get() == S->getTryBody() &&
|
2010-04-24 02:50:49 +04:00
|
|
|
!AnyCatchChanged &&
|
2010-04-23 03:59:56 +04:00
|
|
|
Finally.get() == S->getFinallyStmt())
|
|
|
|
return SemaRef.Owned(S->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:59:56 +04:00
|
|
|
// Build a new statement.
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
|
|
|
|
move_arg(CatchStmts), Finally.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCAtCatchStmt(ObjCAtCatchStmt *S) {
|
2010-04-26 21:57:08 +04:00
|
|
|
// Transform the @catch parameter, if there is one.
|
|
|
|
VarDecl *Var = 0;
|
|
|
|
if (VarDecl *FromVar = S->getCatchParamDecl()) {
|
|
|
|
TypeSourceInfo *TSInfo = 0;
|
|
|
|
if (FromVar->getTypeSourceInfo()) {
|
|
|
|
TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
|
|
|
|
if (!TSInfo)
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-26 21:57:08 +04:00
|
|
|
QualType T;
|
|
|
|
if (TSInfo)
|
|
|
|
T = TSInfo->getType();
|
|
|
|
else {
|
|
|
|
T = getDerived().TransformType(FromVar->getType());
|
|
|
|
if (T.isNull())
|
2010-05-05 19:23:54 +04:00
|
|
|
return SemaRef.StmtError();
|
2010-04-26 21:57:08 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-26 21:57:08 +04:00
|
|
|
Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
|
|
|
|
if (!Var)
|
|
|
|
return SemaRef.StmtError();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
|
2010-04-26 21:57:08 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
|
2010-04-26 21:57:08 +04:00
|
|
|
S->getRParenLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Var, Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
|
2010-04-23 03:59:56 +04:00
|
|
|
// Transform the body.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
|
2010-04-23 03:59:56 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:59:56 +04:00
|
|
|
// If nothing changed, just retain this statement.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Body.get() == S->getFinallyBody())
|
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
|
|
|
// Build a new statement.
|
|
|
|
return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-09-09 19:08:12 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCAtThrowStmt(ObjCAtThrowStmt *S) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Operand;
|
2010-04-23 01:44:01 +04:00
|
|
|
if (S->getThrowExpr()) {
|
|
|
|
Operand = getDerived().TransformExpr(S->getThrowExpr());
|
|
|
|
if (Operand.isInvalid())
|
|
|
|
return getSema().StmtError();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 01:44:01 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Operand.get() == S->getThrowExpr())
|
|
|
|
return getSema().Owned(S->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCAtSynchronizedStmt(
|
2009-09-09 19:08:12 +04:00
|
|
|
ObjCAtSynchronizedStmt *S) {
|
2010-04-23 02:01:21 +04:00
|
|
|
// Transform the object we are locking.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
|
2010-04-23 02:01:21 +04:00
|
|
|
if (Object.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 02:01:21 +04:00
|
|
|
// Transform the body.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
|
2010-04-23 02:01:21 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 02:01:21 +04:00
|
|
|
// If nothing change, just retain the current statement.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Object.get() == S->getSynchExpr() &&
|
|
|
|
Body.get() == S->getSynchBody())
|
|
|
|
return SemaRef.Owned(S->Retain());
|
|
|
|
|
|
|
|
// Build a new statement.
|
|
|
|
return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Object.get(), Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCForCollectionStmt(
|
2009-09-09 19:08:12 +04:00
|
|
|
ObjCForCollectionStmt *S) {
|
2010-04-23 03:10:45 +04:00
|
|
|
// Transform the element statement.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Element = getDerived().TransformStmt(S->getElement());
|
2010-04-23 03:10:45 +04:00
|
|
|
if (Element.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:10:45 +04:00
|
|
|
// Transform the collection expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Collection = getDerived().TransformExpr(S->getCollection());
|
2010-04-23 03:10:45 +04:00
|
|
|
if (Collection.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:10:45 +04:00
|
|
|
// Transform the body.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getBody());
|
2010-04-23 03:10:45 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:10:45 +04:00
|
|
|
// If nothing changed, just retain this statement.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Element.get() == S->getElement() &&
|
|
|
|
Collection.get() == S->getCollection() &&
|
|
|
|
Body.get() == S->getBody())
|
|
|
|
return SemaRef.Owned(S->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 03:10:45 +04:00
|
|
|
// Build a new statement.
|
|
|
|
return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
|
|
|
|
/*FIXME:*/S->getForLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Element.get(),
|
|
|
|
Collection.get(),
|
2010-04-23 03:10:45 +04:00
|
|
|
S->getRParenLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Body.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXCatchStmt(CXXCatchStmt *S) {
|
|
|
|
// Transform the exception declaration, if any.
|
|
|
|
VarDecl *Var = 0;
|
|
|
|
if (S->getExceptionDecl()) {
|
|
|
|
VarDecl *ExceptionDecl = S->getExceptionDecl();
|
|
|
|
TemporaryBase Rebase(*this, ExceptionDecl->getLocation(),
|
|
|
|
ExceptionDecl->getDeclName());
|
|
|
|
|
|
|
|
QualType T = getDerived().TransformType(ExceptionDecl->getType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
Var = getDerived().RebuildExceptionDecl(ExceptionDecl,
|
|
|
|
T,
|
2009-12-07 05:54:59 +03:00
|
|
|
ExceptionDecl->getTypeSourceInfo(),
|
2009-08-20 11:17:43 +04:00
|
|
|
ExceptionDecl->getIdentifier(),
|
|
|
|
ExceptionDecl->getLocation(),
|
|
|
|
/*FIXME: Inaccurate*/
|
|
|
|
SourceRange(ExceptionDecl->getLocation()));
|
2010-07-25 22:17:45 +04:00
|
|
|
if (!Var || Var->isInvalidDecl())
|
2009-08-20 11:17:43 +04:00
|
|
|
return SemaRef.StmtError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the actual exception handler.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
|
2010-07-25 22:17:45 +04:00
|
|
|
if (Handler.isInvalid())
|
2009-08-20 11:17:43 +04:00
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
!Var &&
|
|
|
|
Handler.get() == S->getHandlerBlock())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(),
|
|
|
|
Var,
|
2010-08-24 03:25:46 +04:00
|
|
|
Handler.get());
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult
|
2009-08-20 11:17:43 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXTryStmt(CXXTryStmt *S) {
|
|
|
|
// Transform the try block itself.
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult TryBlock
|
2009-08-20 11:17:43 +04:00
|
|
|
= getDerived().TransformCompoundStmt(S->getTryBlock());
|
|
|
|
if (TryBlock.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// Transform the handlers.
|
|
|
|
bool HandlerChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Stmt*> Handlers(SemaRef);
|
2009-08-20 11:17:43 +04:00
|
|
|
for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Handler
|
2009-08-20 11:17:43 +04:00
|
|
|
= getDerived().TransformCXXCatchStmt(S->getHandler(I));
|
|
|
|
if (Handler.isInvalid())
|
|
|
|
return SemaRef.StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
|
|
|
|
Handlers.push_back(Handler.takeAs<Stmt>());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TryBlock.get() == S->getTryBlock() &&
|
|
|
|
!HandlerChanged)
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(S->Retain());
|
2009-08-20 11:17:43 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
|
2009-09-09 19:08:12 +04:00
|
|
|
move_arg(Handlers));
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-08-11 09:31:07 +04:00
|
|
|
// Expression transformation
|
2009-08-04 20:50:30 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformPredefinedExpr(PredefinedExpr *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformDeclRefExpr(DeclRefExpr *E) {
|
2009-10-23 22:54:35 +04:00
|
|
|
NestedNameSpecifier *Qualifier = 0;
|
|
|
|
if (E->getQualifier()) {
|
|
|
|
Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(),
|
2010-02-25 07:46:04 +03:00
|
|
|
E->getQualifierRange());
|
2009-10-23 22:54:35 +04:00
|
|
|
if (!Qualifier)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-12-08 12:08:17 +03:00
|
|
|
|
|
|
|
ValueDecl *ND
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
|
|
|
|
E->getDecl()));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!ND)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-18 01:27:17 +04:00
|
|
|
DeclarationNameInfo NameInfo = E->getNameInfo();
|
|
|
|
if (NameInfo.getName()) {
|
|
|
|
NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
|
|
|
|
if (!NameInfo.getName())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2010-08-12 02:01:17 +04:00
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2009-10-23 22:54:35 +04:00
|
|
|
Qualifier == E->getQualifier() &&
|
|
|
|
ND == E->getDecl() &&
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo.getName() == E->getDecl()->getDeclName() &&
|
2010-08-20 03:49:38 +04:00
|
|
|
!E->hasExplicitTemplateArgs()) {
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-08 12:08:17 +03:00
|
|
|
// Mark it referenced in the new context regardless.
|
|
|
|
// FIXME: this is a bit instantiation-specific.
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocation(), ND);
|
2009-10-23 22:54:35 +04:00
|
|
|
|
2009-12-08 12:08:17 +03:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-10-23 22:54:35 +04:00
|
|
|
}
|
2009-12-08 12:08:17 +03:00
|
|
|
|
|
|
|
TemplateArgumentListInfo TransArgs, *TemplateArgs = 0;
|
2010-08-20 03:49:38 +04:00
|
|
|
if (E->hasExplicitTemplateArgs()) {
|
2009-12-08 12:08:17 +03:00
|
|
|
TemplateArgs = &TransArgs;
|
|
|
|
TransArgs.setLAngleLoc(E->getLAngleLoc());
|
|
|
|
TransArgs.setRAngleLoc(E->getRAngleLoc());
|
|
|
|
for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
|
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(E->getTemplateArgs()[I], Loc))
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
TransArgs.addArgument(Loc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-23 22:54:35 +04:00
|
|
|
return getDerived().RebuildDeclRefExpr(Qualifier, E->getQualifierRange(),
|
2010-08-12 02:01:17 +04:00
|
|
|
ND, NameInfo, TemplateArgs);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformIntegerLiteral(IntegerLiteral *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformFloatingLiteral(FloatingLiteral *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformStringLiteral(StringLiteral *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCharacterLiteral(CharacterLiteral *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformParenExpr(ParenExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRParen());
|
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformUnaryOperator(UnaryOperator *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
|
|
|
|
E->getOpcode(),
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
TreeTransform<Derived>::TransformOffsetOfExpr(OffsetOfExpr *E) {
|
|
|
|
// Transform the type.
|
|
|
|
TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
|
|
|
|
if (!Type)
|
|
|
|
return getSema().ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
// Transform all of the components into components similar to what the
|
|
|
|
// parser uses.
|
2010-05-05 19:23:54 +04:00
|
|
|
// FIXME: It would be slightly more efficient in the non-dependent case to
|
|
|
|
// just map FieldDecls, rather than requiring the rebuilder to look for
|
|
|
|
// the fields again. However, __builtin_offsetof is rare enough in
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
// template code that we don't care.
|
|
|
|
bool ExprChanged = false;
|
|
|
|
typedef Action::OffsetOfComponent Component;
|
|
|
|
typedef OffsetOfExpr::OffsetOfNode Node;
|
|
|
|
llvm::SmallVector<Component, 4> Components;
|
|
|
|
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
|
|
|
|
const Node &ON = E->getComponent(I);
|
|
|
|
Component Comp;
|
2010-05-01 00:35:01 +04:00
|
|
|
Comp.isBrackets = true;
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
Comp.LocStart = ON.getRange().getBegin();
|
|
|
|
Comp.LocEnd = ON.getRange().getEnd();
|
|
|
|
switch (ON.getKind()) {
|
|
|
|
case Node::Array: {
|
|
|
|
Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Index = getDerived().TransformExpr(FromIndex);
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
if (Index.isInvalid())
|
|
|
|
return getSema().ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
ExprChanged = ExprChanged || Index.get() != FromIndex;
|
|
|
|
Comp.isBrackets = true;
|
2010-08-24 03:25:46 +04:00
|
|
|
Comp.U.E = Index.get();
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
break;
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
case Node::Field:
|
|
|
|
case Node::Identifier:
|
|
|
|
Comp.isBrackets = false;
|
|
|
|
Comp.U.IdentInfo = ON.getFieldName();
|
2010-04-29 02:43:14 +04:00
|
|
|
if (!Comp.U.IdentInfo)
|
|
|
|
continue;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
break;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-29 04:18:15 +04:00
|
|
|
case Node::Base:
|
|
|
|
// Will be recomputed during the rebuild.
|
|
|
|
continue;
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
Components.push_back(Comp);
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
// If nothing changed, retain the existing expression.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Type == E->getTypeSourceInfo() &&
|
|
|
|
!ExprChanged)
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
Completely reimplement __builtin_offsetof, based on a patch by Roberto
Amadini.
This change introduces a new expression node type, OffsetOfExpr, that
describes __builtin_offsetof. Previously, __builtin_offsetof was
implemented using a unary operator whose subexpression involved
various synthesized array-subscript and member-reference expressions,
which was ugly and made it very hard to instantiate as a
template. OffsetOfExpr represents the AST more faithfully, with proper
type source information and a more compact representation.
OffsetOfExpr also has support for dependent __builtin_offsetof
expressions; it can be value-dependent, but will never be
type-dependent (like sizeof or alignof). This commit introduces
template instantiation for __builtin_offsetof as well.
There are two major caveats to this patch:
1) CodeGen cannot handle the case where __builtin_offsetof is not a
constant expression, so it produces an error. So, to avoid
regressing in C, we retain the old UnaryOperator-based
__builtin_offsetof implementation in C while using the shiny new
OffsetOfExpr implementation in C++. The old implementation can go
away once we have proper CodeGen support for this case, which we
expect won't cause much trouble in C++.
2) __builtin_offsetof doesn't work well with non-POD class types,
particularly when the designated field is found within a base
class. I will address this in a subsequent patch.
Fixes PR5880 and a bunch of assertions when building Boost.Python
tests.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-29 02:16:22 +04:00
|
|
|
// Build a new offsetof expression.
|
|
|
|
return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
|
|
|
|
Components.data(), Components.size(),
|
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformSizeOfAlignOfExpr(SizeOfAlignOfExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
if (E->isArgumentType()) {
|
2009-12-07 05:54:59 +03:00
|
|
|
TypeSourceInfo *OldT = E->getArgumentTypeInfo();
|
2009-10-28 03:29:27 +03:00
|
|
|
|
2009-12-07 05:54:59 +03:00
|
|
|
TypeSourceInfo *NewT = getDerived().TransformType(OldT);
|
2009-11-04 10:28:41 +03:00
|
|
|
if (!NewT)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-04 10:28:41 +03:00
|
|
|
if (!getDerived().AlwaysRebuild() && OldT == NewT)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-04 10:28:41 +03:00
|
|
|
return getDerived().RebuildSizeOfAlignOf(NewT, E->getOperatorLoc(),
|
2009-09-09 19:08:12 +04:00
|
|
|
E->isSizeOf(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getSourceRange());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr;
|
2009-09-09 19:08:12 +04:00
|
|
|
{
|
2009-08-11 09:31:07 +04:00
|
|
|
// C++0x [expr.sizeof]p1:
|
|
|
|
// The operand is either an expression, which is an unevaluated operand
|
|
|
|
// [...]
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Action::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
|
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildSizeOfAlignOf(SubExpr.get(), E->getOperatorLoc(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->isSizeOf(),
|
|
|
|
E->getSourceRange());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformArraySubscriptExpr(ArraySubscriptExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult LHS = getDerived().TransformExpr(E->getLHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (LHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RHS = getDerived().TransformExpr(E->getRHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (RHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
LHS.get() == E->getLHS() &&
|
|
|
|
RHS.get() == E->getRHS())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildArraySubscriptExpr(LHS.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
/*FIXME:*/E->getLHS()->getLocStart(),
|
2010-08-24 03:25:46 +04:00
|
|
|
RHS.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRBracketLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCallExpr(CallExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
// Transform the callee.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Callee = getDerived().TransformExpr(E->getCallee());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Callee.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
// Transform arguments.
|
|
|
|
bool ArgChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
llvm::SmallVector<SourceLocation, 4> FakeCommaLocs;
|
|
|
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Arg = getDerived().TransformExpr(E->getArg(I));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Arg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Wrong source location information for the ','.
|
|
|
|
FakeCommaLocs.push_back(
|
|
|
|
SemaRef.PP.getLocForEndOfToken(E->getArg(I)->getSourceRange().getEnd()));
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
ArgChanged = ArgChanged || Arg.get() != E->getArg(I);
|
2010-08-24 03:25:46 +04:00
|
|
|
Args.push_back(Arg.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Callee.get() == E->getCallee() &&
|
|
|
|
!ArgChanged)
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Wrong source location information for the '('.
|
2009-09-09 19:08:12 +04:00
|
|
|
SourceLocation FakeLParenLoc
|
2009-08-11 09:31:07 +04:00
|
|
|
= ((Expr *)Callee.get())->getSourceRange().getBegin();
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
move_arg(Args),
|
|
|
|
FakeCommaLocs.data(),
|
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformMemberExpr(MemberExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-01 03:41:50 +04:00
|
|
|
NestedNameSpecifier *Qualifier = 0;
|
|
|
|
if (E->hasQualifier()) {
|
2009-09-09 19:08:12 +04:00
|
|
|
Qualifier
|
2009-09-01 03:41:50 +04:00
|
|
|
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
|
2010-02-25 07:46:04 +03:00
|
|
|
E->getQualifierRange());
|
2009-09-01 04:37:14 +04:00
|
|
|
if (Qualifier == 0)
|
2009-09-01 03:41:50 +04:00
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-04 09:40:45 +03:00
|
|
|
ValueDecl *Member
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
|
|
|
|
E->getMemberDecl()));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!Member)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-03-31 01:47:33 +04:00
|
|
|
NamedDecl *FoundDecl = E->getFoundDecl();
|
|
|
|
if (FoundDecl == E->getMemberDecl()) {
|
|
|
|
FoundDecl = Member;
|
|
|
|
} else {
|
|
|
|
FoundDecl = cast_or_null<NamedDecl>(
|
|
|
|
getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
|
|
|
|
if (!FoundDecl)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase() &&
|
2009-09-01 03:41:50 +04:00
|
|
|
Qualifier == E->getQualifier() &&
|
2009-11-05 02:20:05 +03:00
|
|
|
Member == E->getMemberDecl() &&
|
2010-03-31 01:47:33 +04:00
|
|
|
FoundDecl == E->getFoundDecl() &&
|
2010-08-20 03:49:38 +04:00
|
|
|
!E->hasExplicitTemplateArgs()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-12-22 08:24:09 +03:00
|
|
|
// Mark it referenced in the new context regardless.
|
|
|
|
// FIXME: this is a bit instantiation-specific.
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getMemberLoc(), Member);
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-12-22 08:24:09 +03:00
|
|
|
}
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentListInfo TransArgs;
|
2010-08-20 03:49:38 +04:00
|
|
|
if (E->hasExplicitTemplateArgs()) {
|
2009-11-23 04:53:49 +03:00
|
|
|
TransArgs.setLAngleLoc(E->getLAngleLoc());
|
|
|
|
TransArgs.setRAngleLoc(E->getRAngleLoc());
|
2009-11-05 02:20:05 +03:00
|
|
|
for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(E->getTemplateArgs()[I], Loc))
|
2009-11-05 02:20:05 +03:00
|
|
|
return SemaRef.ExprError();
|
2009-11-23 04:53:49 +03:00
|
|
|
TransArgs.addArgument(Loc);
|
2009-11-05 02:20:05 +03:00
|
|
|
}
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Bogus source location for the operator
|
|
|
|
SourceLocation FakeOperatorLoc
|
|
|
|
= SemaRef.PP.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
|
|
|
|
|
2010-01-15 11:34:02 +03:00
|
|
|
// FIXME: to do this check properly, we will need to preserve the
|
|
|
|
// first-qualifier-in-scope here, just in case we had a dependent
|
|
|
|
// base (and therefore couldn't do the check) and a
|
|
|
|
// nested-name-qualifier (and therefore could do the lookup).
|
|
|
|
NamedDecl *FirstQualifierInScope = 0;
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->isArrow(),
|
2009-09-01 03:41:50 +04:00
|
|
|
Qualifier,
|
|
|
|
E->getQualifierRange(),
|
2010-08-12 02:01:17 +04:00
|
|
|
E->getMemberNameInfo(),
|
2009-11-05 02:20:05 +03:00
|
|
|
Member,
|
2010-03-31 01:47:33 +04:00
|
|
|
FoundDecl,
|
2010-08-20 03:49:38 +04:00
|
|
|
(E->hasExplicitTemplateArgs()
|
2009-11-23 04:53:49 +03:00
|
|
|
? &TransArgs : 0),
|
2010-01-15 11:34:02 +03:00
|
|
|
FirstQualifierInScope);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformBinaryOperator(BinaryOperator *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult LHS = getDerived().TransformExpr(E->getLHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (LHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RHS = getDerived().TransformExpr(E->getRHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (RHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
LHS.get() == E->getLHS() &&
|
|
|
|
RHS.get() == E->getRHS())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
|
2010-08-24 03:25:46 +04:00
|
|
|
LHS.get(), RHS.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCompoundAssignOperator(
|
2009-12-08 12:21:05 +03:00
|
|
|
CompoundAssignOperator *E) {
|
|
|
|
return getDerived().TransformBinaryOperator(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformConditionalOperator(ConditionalOperator *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond = getDerived().TransformExpr(E->getCond());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult LHS = getDerived().TransformExpr(E->getLHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (LHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RHS = getDerived().TransformExpr(E->getRHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (RHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Cond.get() == E->getCond() &&
|
|
|
|
LHS.get() == E->getLHS() &&
|
|
|
|
RHS.get() == E->getRHS())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildConditionalOperator(Cond.get(),
|
2009-08-26 18:37:04 +04:00
|
|
|
E->getQuestionLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
LHS.get(),
|
2009-08-26 18:37:04 +04:00
|
|
|
E->getColonLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
RHS.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformImplicitCastExpr(ImplicitCastExpr *E) {
|
2009-12-12 21:16:41 +03:00
|
|
|
// Implicit casts are eliminated during transformation, since they
|
|
|
|
// will be recomputed by semantic analysis after transformation.
|
2009-12-14 22:27:10 +03:00
|
|
|
return getDerived().TransformExpr(E->getSubExprAsWritten());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCStyleCastExpr(CStyleCastExpr *E) {
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *OldT;
|
|
|
|
TypeSourceInfo *NewT;
|
2009-08-11 09:31:07 +04:00
|
|
|
{
|
|
|
|
// FIXME: Source location isn't quite accurate.
|
2009-09-09 19:08:12 +04:00
|
|
|
SourceLocation TypeStartLoc
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.PP.getLocForEndOfToken(E->getLParenLoc());
|
|
|
|
TemporaryBase Rebase(*this, TypeStartLoc, DeclarationName());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-15 21:39:57 +03:00
|
|
|
OldT = E->getTypeInfoAsWritten();
|
|
|
|
NewT = getDerived().TransformType(OldT);
|
|
|
|
if (!NewT)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr
|
2009-12-14 22:27:10 +03:00
|
|
|
= getDerived().TransformExpr(E->getSubExprAsWritten());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-01-15 21:39:57 +03:00
|
|
|
OldT == NewT &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2010-01-15 21:39:57 +03:00
|
|
|
return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
|
|
|
|
NewT,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRParenLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCompoundLiteralExpr(CompoundLiteralExpr *E) {
|
2010-01-18 22:35:47 +03:00
|
|
|
TypeSourceInfo *OldT = E->getTypeSourceInfo();
|
|
|
|
TypeSourceInfo *NewT = getDerived().TransformType(OldT);
|
|
|
|
if (!NewT)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Init = getDerived().TransformExpr(E->getInitializer());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Init.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-01-18 22:35:47 +03:00
|
|
|
OldT == NewT &&
|
2009-08-11 09:31:07 +04:00
|
|
|
Init.get() == E->getInitializer())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2010-01-20 01:33:45 +03:00
|
|
|
// Note: the expression type doesn't necessarily match the
|
|
|
|
// type-as-written, but that's okay, because it should always be
|
|
|
|
// derivable from the initializer.
|
|
|
|
|
2010-01-18 22:35:47 +03:00
|
|
|
return getDerived().RebuildCompoundLiteralExpr(E->getLParenLoc(), NewT,
|
2009-08-11 09:31:07 +04:00
|
|
|
/*FIXME:*/E->getInitializer()->getLocEnd(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Init.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformExtVectorElementExpr(ExtVectorElementExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Bad source location
|
2009-09-09 19:08:12 +04:00
|
|
|
SourceLocation FakeOperatorLoc
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.PP.getLocForEndOfToken(E->getBase()->getLocEnd());
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getAccessorLoc(),
|
|
|
|
E->getAccessor());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformInitListExpr(InitListExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
bool InitChanged = false;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*, 4> Inits(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Init = getDerived().TransformExpr(E->getInit(I));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Init.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
InitChanged = InitChanged || Init.get() != E->getInit(I);
|
2010-08-24 03:25:46 +04:00
|
|
|
Inits.push_back(Init.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && !InitChanged)
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildInitList(E->getLBraceLoc(), move_arg(Inits),
|
2009-11-09 20:16:50 +03:00
|
|
|
E->getRBraceLoc(), E->getType());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformDesignatedInitExpr(DesignatedInitExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
Designation Desig;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// transform the initializer value
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Init = getDerived().TransformExpr(E->getInit());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Init.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// transform the designators.
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*, 4> ArrayExprs(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
bool ExprChanged = false;
|
|
|
|
for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
|
|
|
|
DEnd = E->designators_end();
|
|
|
|
D != DEnd; ++D) {
|
|
|
|
if (D->isFieldDesignator()) {
|
|
|
|
Desig.AddDesignator(Designator::getField(D->getFieldName(),
|
|
|
|
D->getDotLoc(),
|
|
|
|
D->getFieldLoc()));
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (D->isArrayDesignator()) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(*D));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Index.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
Desig.AddDesignator(Designator::getArray(Index.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
D->getLBracketLoc()));
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(*D);
|
|
|
|
ArrayExprs.push_back(Index.release());
|
|
|
|
continue;
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
assert(D->isArrayRangeDesignator() && "New kind of designator?");
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Start
|
2009-08-11 09:31:07 +04:00
|
|
|
= getDerived().TransformExpr(E->getArrayRangeStart(*D));
|
|
|
|
if (Start.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(*D));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (End.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
Desig.AddDesignator(Designator::getArrayRange(Start.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
End.get(),
|
|
|
|
D->getLBracketLoc(),
|
|
|
|
D->getEllipsisLoc()));
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(*D) ||
|
|
|
|
End.get() != E->getArrayRangeEnd(*D);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArrayExprs.push_back(Start.release());
|
|
|
|
ArrayExprs.push_back(End.release());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Init.get() == E->getInit() &&
|
|
|
|
!ExprChanged)
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildDesignatedInitExpr(Desig, move_arg(ArrayExprs),
|
|
|
|
E->getEqualOrColonLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
E->usesGNUSyntax(), Init.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformImplicitValueInitExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
ImplicitValueInitExpr *E) {
|
2009-10-28 03:29:27 +03:00
|
|
|
TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-10-28 03:29:27 +03:00
|
|
|
// FIXME: Will we ever have proper type location here? Will we actually
|
|
|
|
// need to transform the type?
|
2009-08-11 09:31:07 +04:00
|
|
|
QualType T = getDerived().TransformType(E->getType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getType())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildImplicitValueInitExpr(T);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformVAArgExpr(VAArgExpr *E) {
|
2010-08-10 18:27:00 +04:00
|
|
|
TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
|
|
|
|
if (!TInfo)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-08-10 14:06:15 +04:00
|
|
|
TInfo == E->getWrittenTypeInfo() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
|
2010-08-10 14:06:15 +04:00
|
|
|
TInfo, E->getRParenLoc());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformParenListExpr(ParenListExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
bool ArgumentChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*, 4> Inits(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumExprs(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Init = getDerived().TransformExpr(E->getExpr(I));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Init.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || Init.get() != E->getExpr(I);
|
2010-08-24 03:25:46 +04:00
|
|
|
Inits.push_back(Init.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildParenListExpr(E->getLParenLoc(),
|
|
|
|
move_arg(Inits),
|
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Transform an address-of-label expression.
|
|
|
|
///
|
|
|
|
/// By default, the transformation of an address-of-label expression always
|
|
|
|
/// rebuilds the expression, so that the label identifier can be resolved to
|
|
|
|
/// the corresponding label statement by semantic analysis.
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformAddrLabelExpr(AddrLabelExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
|
|
|
|
E->getLabel());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformStmtExpr(StmtExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult SubStmt
|
2009-08-11 09:31:07 +04:00
|
|
|
= getDerived().TransformCompoundStmt(E->getSubStmt(), true);
|
|
|
|
if (SubStmt.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubStmt.get() == E->getSubStmt())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildStmtExpr(E->getLParenLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
SubStmt.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformTypesCompatibleExpr(TypesCompatibleExpr *E) {
|
2010-08-10 12:50:03 +04:00
|
|
|
TypeSourceInfo *TInfo1;
|
|
|
|
TypeSourceInfo *TInfo2;
|
2010-08-10 18:27:00 +04:00
|
|
|
|
|
|
|
TInfo1 = getDerived().TransformType(E->getArgTInfo1());
|
|
|
|
if (!TInfo1)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-10 18:27:00 +04:00
|
|
|
TInfo2 = getDerived().TransformType(E->getArgTInfo2());
|
|
|
|
if (!TInfo2)
|
|
|
|
return SemaRef.ExprError();
|
2009-08-11 09:31:07 +04:00
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-08-10 12:50:03 +04:00
|
|
|
TInfo1 == E->getArgTInfo1() &&
|
|
|
|
TInfo2 == E->getArgTInfo2())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildTypesCompatibleExpr(E->getBuiltinLoc(),
|
2010-08-10 12:50:03 +04:00
|
|
|
TInfo1, TInfo2,
|
|
|
|
E->getRParenLoc());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformChooseExpr(ChooseExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Cond = getDerived().TransformExpr(E->getCond());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Cond.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult LHS = getDerived().TransformExpr(E->getLHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (LHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult RHS = getDerived().TransformExpr(E->getRHS());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (RHS.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Cond.get() == E->getCond() &&
|
|
|
|
LHS.get() == E->getLHS() &&
|
|
|
|
RHS.get() == E->getRHS())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Cond.get(), LHS.get(), RHS.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformGNUNullExpr(GNUNullExpr *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
|
2009-12-13 23:44:55 +03:00
|
|
|
switch (E->getOperator()) {
|
|
|
|
case OO_New:
|
|
|
|
case OO_Delete:
|
|
|
|
case OO_Array_New:
|
|
|
|
case OO_Array_Delete:
|
|
|
|
llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-12-13 23:44:55 +03:00
|
|
|
case OO_Call: {
|
|
|
|
// This is a call to an object's operator().
|
|
|
|
assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
|
|
|
|
|
|
|
|
// Transform the object itself.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Object = getDerived().TransformExpr(E->getArg(0));
|
2009-12-13 23:44:55 +03:00
|
|
|
if (Object.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
// FIXME: Poor location information
|
|
|
|
SourceLocation FakeLParenLoc
|
|
|
|
= SemaRef.PP.getLocForEndOfToken(
|
|
|
|
static_cast<Expr *>(Object.get())->getLocEnd());
|
|
|
|
|
|
|
|
// Transform the call arguments.
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2009-12-13 23:44:55 +03:00
|
|
|
llvm::SmallVector<SourceLocation, 4> FakeCommaLocs;
|
|
|
|
for (unsigned I = 1, N = E->getNumArgs(); I != N; ++I) {
|
2009-12-14 22:27:10 +03:00
|
|
|
if (getDerived().DropCallArgument(E->getArg(I)))
|
|
|
|
break;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Arg = getDerived().TransformExpr(E->getArg(I));
|
2009-12-13 23:44:55 +03:00
|
|
|
if (Arg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
// FIXME: Poor source location information.
|
|
|
|
SourceLocation FakeCommaLoc
|
|
|
|
= SemaRef.PP.getLocForEndOfToken(
|
|
|
|
static_cast<Expr *>(Arg.get())->getLocEnd());
|
|
|
|
FakeCommaLocs.push_back(FakeCommaLoc);
|
|
|
|
Args.push_back(Arg.release());
|
|
|
|
}
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc,
|
2009-12-13 23:44:55 +03:00
|
|
|
move_arg(Args),
|
|
|
|
FakeCommaLocs.data(),
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
|
|
|
#define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
|
|
|
|
case OO_##Name:
|
|
|
|
#define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
|
|
|
|
#include "clang/Basic/OperatorKinds.def"
|
|
|
|
case OO_Subscript:
|
|
|
|
// Handled below.
|
|
|
|
break;
|
|
|
|
|
|
|
|
case OO_Conditional:
|
|
|
|
llvm_unreachable("conditional operator is not actually overloadable");
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
case OO_None:
|
|
|
|
case NUM_OVERLOADED_OPERATORS:
|
|
|
|
llvm_unreachable("not an overloaded operator?");
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Callee = getDerived().TransformExpr(E->getCallee());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Callee.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult First = getDerived().TransformExpr(E->getArg(0));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (First.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Second;
|
2009-08-11 09:31:07 +04:00
|
|
|
if (E->getNumArgs() == 2) {
|
|
|
|
Second = getDerived().TransformExpr(E->getArg(1));
|
|
|
|
if (Second.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Callee.get() == E->getCallee() &&
|
|
|
|
First.get() == E->getArg(0) &&
|
2009-09-09 19:08:12 +04:00
|
|
|
(E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
|
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
|
|
|
|
E->getOperatorLoc(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Callee.get(),
|
|
|
|
First.get(),
|
|
|
|
Second.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXMemberCallExpr(CXXMemberCallExpr *E) {
|
|
|
|
return getDerived().TransformCallExpr(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXNamedCastExpr(CXXNamedCastExpr *E) {
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *OldT;
|
|
|
|
TypeSourceInfo *NewT;
|
2009-08-11 09:31:07 +04:00
|
|
|
{
|
|
|
|
// FIXME: Source location isn't quite accurate.
|
2009-09-09 19:08:12 +04:00
|
|
|
SourceLocation TypeStartLoc
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.PP.getLocForEndOfToken(E->getOperatorLoc());
|
|
|
|
TemporaryBase Rebase(*this, TypeStartLoc, DeclarationName());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-15 21:39:57 +03:00
|
|
|
OldT = E->getTypeInfoAsWritten();
|
|
|
|
NewT = getDerived().TransformType(OldT);
|
|
|
|
if (!NewT)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr
|
2009-12-14 22:27:10 +03:00
|
|
|
= getDerived().TransformExpr(E->getSubExprAsWritten());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-01-15 21:39:57 +03:00
|
|
|
OldT == NewT &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Poor source location information here.
|
2009-09-09 19:08:12 +04:00
|
|
|
SourceLocation FakeLAngleLoc
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.PP.getLocForEndOfToken(E->getOperatorLoc());
|
|
|
|
SourceLocation FakeRAngleLoc = E->getSubExpr()->getSourceRange().getBegin();
|
|
|
|
SourceLocation FakeRParenLoc
|
|
|
|
= SemaRef.PP.getLocForEndOfToken(
|
|
|
|
E->getSubExpr()->getSourceRange().getEnd());
|
|
|
|
return getDerived().RebuildCXXNamedCastExpr(E->getOperatorLoc(),
|
2009-09-09 19:08:12 +04:00
|
|
|
E->getStmtClass(),
|
2009-08-11 09:31:07 +04:00
|
|
|
FakeLAngleLoc,
|
2010-01-15 21:39:57 +03:00
|
|
|
NewT,
|
2009-08-11 09:31:07 +04:00
|
|
|
FakeRAngleLoc,
|
|
|
|
FakeRAngleLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
FakeRParenLoc);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXStaticCastExpr(CXXStaticCastExpr *E) {
|
|
|
|
return getDerived().TransformCXXNamedCastExpr(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXDynamicCastExpr(CXXDynamicCastExpr *E) {
|
|
|
|
return getDerived().TransformCXXNamedCastExpr(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXReinterpretCastExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXReinterpretCastExpr *E) {
|
|
|
|
return getDerived().TransformCXXNamedCastExpr(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXConstCastExpr(CXXConstCastExpr *E) {
|
|
|
|
return getDerived().TransformCXXNamedCastExpr(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXFunctionalCastExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXFunctionalCastExpr *E) {
|
2010-01-15 21:39:57 +03:00
|
|
|
TypeSourceInfo *OldT;
|
|
|
|
TypeSourceInfo *NewT;
|
2009-08-11 09:31:07 +04:00
|
|
|
{
|
|
|
|
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-15 21:39:57 +03:00
|
|
|
OldT = E->getTypeInfoAsWritten();
|
|
|
|
NewT = getDerived().TransformType(OldT);
|
|
|
|
if (!NewT)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr
|
2009-12-14 22:27:10 +03:00
|
|
|
= getDerived().TransformExpr(E->getSubExprAsWritten());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-01-15 21:39:57 +03:00
|
|
|
OldT == NewT &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: The end of the type's source range is wrong
|
|
|
|
return getDerived().RebuildCXXFunctionalCastExpr(
|
|
|
|
/*FIXME:*/SourceRange(E->getTypeBeginLoc()),
|
2010-01-15 21:39:57 +03:00
|
|
|
NewT,
|
2009-08-11 09:31:07 +04:00
|
|
|
/*FIXME:*/E->getSubExpr()->getLocStart(),
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXTypeidExpr(CXXTypeidExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
if (E->isTypeOperand()) {
|
2010-04-27 02:37:10 +04:00
|
|
|
TypeSourceInfo *TInfo
|
|
|
|
= getDerived().TransformType(E->getTypeOperandSourceInfo());
|
|
|
|
if (!TInfo)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-04-27 02:37:10 +04:00
|
|
|
TInfo == E->getTypeOperandSourceInfo())
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-04-27 02:37:10 +04:00
|
|
|
return getDerived().RebuildCXXTypeidExpr(E->getType(),
|
|
|
|
E->getLocStart(),
|
|
|
|
TInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getLocEnd());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// We don't know whether the expression is potentially evaluated until
|
|
|
|
// after we perform semantic analysis, so the expression is potentially
|
|
|
|
// potentially evaluated.
|
2009-09-09 19:08:12 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef,
|
2009-08-11 09:31:07 +04:00
|
|
|
Action::PotentiallyPotentiallyEvaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubExpr.get() == E->getExprOperand())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2010-04-27 02:37:10 +04:00
|
|
|
return getDerived().RebuildCXXTypeidExpr(E->getType(),
|
|
|
|
E->getLocStart(),
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExpr.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXNullPtrLiteralExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXNullPtrLiteralExpr *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXThisExpr(CXXThisExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
QualType T = getDerived().TransformType(E->getType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getType())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-08 02:12:05 +03:00
|
|
|
return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXThrowExpr(CXXThrowExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubExpr.get() == E->getSubExpr())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
ParmVarDecl *Param
|
2010-03-01 18:56:25 +03:00
|
|
|
= cast_or_null<ParmVarDecl>(getDerived().TransformDecl(E->getLocStart(),
|
|
|
|
E->getParam()));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!Param)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-08 09:42:49 +03:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
Param == E->getParam())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-24 02:03:06 +03:00
|
|
|
return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2010-07-08 10:14:04 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
|
|
|
|
|
|
|
|
QualType T = getDerived().TransformType(E->getType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getType())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2010-07-08 10:14:04 +04:00
|
|
|
return getDerived().RebuildCXXScalarValueInitExpr(E->getTypeBeginLoc(),
|
|
|
|
/*FIXME:*/E->getTypeBeginLoc(),
|
|
|
|
T,
|
|
|
|
E->getRParenLoc());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXNewExpr(CXXNewExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
// Transform the type that we're allocating
|
|
|
|
TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
|
|
|
|
QualType AllocType = getDerived().TransformType(E->getAllocatedType());
|
|
|
|
if (AllocType.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Transform the size of the array we're allocating (if any).
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult ArraySize = getDerived().TransformExpr(E->getArraySize());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (ArraySize.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Transform the placement arguments (if any).
|
|
|
|
bool ArgumentChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> PlacementArgs(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumPlacementArgs(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Arg = getDerived().TransformExpr(E->getPlacementArg(I));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Arg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || Arg.get() != E->getPlacementArg(I);
|
|
|
|
PlacementArgs.push_back(Arg.take());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// transform the constructor arguments (if any).
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> ConstructorArgs(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumConstructorArgs(); I != N; ++I) {
|
2010-05-26 11:10:06 +04:00
|
|
|
if (getDerived().DropCallArgument(E->getConstructorArg(I)))
|
|
|
|
break;
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Arg = getDerived().TransformExpr(E->getConstructorArg(I));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Arg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || Arg.get() != E->getConstructorArg(I);
|
|
|
|
ConstructorArgs.push_back(Arg.take());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-26 03:38:10 +03:00
|
|
|
// Transform constructor, new operator, and delete operator.
|
|
|
|
CXXConstructorDecl *Constructor = 0;
|
|
|
|
if (E->getConstructor()) {
|
|
|
|
Constructor = cast_or_null<CXXConstructorDecl>(
|
2010-03-01 18:56:25 +03:00
|
|
|
getDerived().TransformDecl(E->getLocStart(),
|
|
|
|
E->getConstructor()));
|
2010-02-26 03:38:10 +03:00
|
|
|
if (!Constructor)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionDecl *OperatorNew = 0;
|
|
|
|
if (E->getOperatorNew()) {
|
|
|
|
OperatorNew = cast_or_null<FunctionDecl>(
|
2010-03-01 18:56:25 +03:00
|
|
|
getDerived().TransformDecl(E->getLocStart(),
|
|
|
|
E->getOperatorNew()));
|
2010-02-26 03:38:10 +03:00
|
|
|
if (!OperatorNew)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionDecl *OperatorDelete = 0;
|
|
|
|
if (E->getOperatorDelete()) {
|
|
|
|
OperatorDelete = cast_or_null<FunctionDecl>(
|
2010-03-01 18:56:25 +03:00
|
|
|
getDerived().TransformDecl(E->getLocStart(),
|
|
|
|
E->getOperatorDelete()));
|
2010-02-26 03:38:10 +03:00
|
|
|
if (!OperatorDelete)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
AllocType == E->getAllocatedType() &&
|
|
|
|
ArraySize.get() == E->getArraySize() &&
|
2010-02-26 03:38:10 +03:00
|
|
|
Constructor == E->getConstructor() &&
|
|
|
|
OperatorNew == E->getOperatorNew() &&
|
|
|
|
OperatorDelete == E->getOperatorDelete() &&
|
|
|
|
!ArgumentChanged) {
|
|
|
|
// Mark any declarations we need as referenced.
|
|
|
|
// FIXME: instantiation-specific.
|
|
|
|
if (Constructor)
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
|
|
|
|
if (OperatorNew)
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorNew);
|
|
|
|
if (OperatorDelete)
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorDelete);
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-22 20:13:37 +03:00
|
|
|
if (!ArraySize.get()) {
|
|
|
|
// If no array size was specified, but the new expression was
|
|
|
|
// instantiated with an array type (e.g., "new T" where T is
|
|
|
|
// instantiated with "int[4]"), extract the outer bound from the
|
|
|
|
// array type as our array size. We do this with constant and
|
|
|
|
// dependently-sized array types.
|
|
|
|
const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
|
|
|
|
if (!ArrayT) {
|
|
|
|
// Do nothing
|
|
|
|
} else if (const ConstantArrayType *ConsArrayT
|
|
|
|
= dyn_cast<ConstantArrayType>(ArrayT)) {
|
2010-05-05 19:23:54 +04:00
|
|
|
ArraySize
|
2009-12-22 20:13:37 +03:00
|
|
|
= SemaRef.Owned(new (SemaRef.Context) IntegerLiteral(
|
2010-05-05 19:23:54 +04:00
|
|
|
ConsArrayT->getSize(),
|
2009-12-22 20:13:37 +03:00
|
|
|
SemaRef.Context.getSizeType(),
|
|
|
|
/*FIXME:*/E->getLocStart()));
|
|
|
|
AllocType = ConsArrayT->getElementType();
|
|
|
|
} else if (const DependentSizedArrayType *DepArrayT
|
|
|
|
= dyn_cast<DependentSizedArrayType>(ArrayT)) {
|
|
|
|
if (DepArrayT->getSizeExpr()) {
|
|
|
|
ArraySize = SemaRef.Owned(DepArrayT->getSizeExpr()->Retain());
|
|
|
|
AllocType = DepArrayT->getElementType();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildCXXNewExpr(E->getLocStart(),
|
|
|
|
E->isGlobalNew(),
|
|
|
|
/*FIXME:*/E->getLocStart(),
|
|
|
|
move_arg(PlacementArgs),
|
|
|
|
/*FIXME:*/E->getLocStart(),
|
2010-07-13 19:54:32 +04:00
|
|
|
E->getTypeIdParens(),
|
2009-08-11 09:31:07 +04:00
|
|
|
AllocType,
|
|
|
|
/*FIXME:*/E->getLocStart(),
|
|
|
|
/*FIXME:*/SourceRange(),
|
2010-08-24 03:25:46 +04:00
|
|
|
ArraySize.get(),
|
2009-08-11 09:31:07 +04:00
|
|
|
/*FIXME:*/E->getLocStart(),
|
|
|
|
move_arg(ConstructorArgs),
|
2009-09-09 19:08:12 +04:00
|
|
|
E->getLocEnd());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXDeleteExpr(CXXDeleteExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Operand = getDerived().TransformExpr(E->getArgument());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Operand.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-26 03:38:10 +03:00
|
|
|
// Transform the delete operator, if known.
|
|
|
|
FunctionDecl *OperatorDelete = 0;
|
|
|
|
if (E->getOperatorDelete()) {
|
|
|
|
OperatorDelete = cast_or_null<FunctionDecl>(
|
2010-03-01 18:56:25 +03:00
|
|
|
getDerived().TransformDecl(E->getLocStart(),
|
|
|
|
E->getOperatorDelete()));
|
2010-02-26 03:38:10 +03:00
|
|
|
if (!OperatorDelete)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-02-26 03:38:10 +03:00
|
|
|
Operand.get() == E->getArgument() &&
|
|
|
|
OperatorDelete == E->getOperatorDelete()) {
|
|
|
|
// Mark any declarations we need as referenced.
|
|
|
|
// FIXME: instantiation-specific.
|
|
|
|
if (OperatorDelete)
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), OperatorDelete);
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildCXXDeleteExpr(E->getLocStart(),
|
|
|
|
E->isGlobalDelete(),
|
|
|
|
E->isArrayForm(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Operand.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-09-04 21:36:40 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXPseudoDestructorExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXPseudoDestructorExpr *E) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2009-09-04 21:36:40 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType ObjectTypePtr;
|
2010-02-25 04:56:36 +03:00
|
|
|
bool MayBePseudoDestructor = false;
|
2010-08-24 03:25:46 +04:00
|
|
|
Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(),
|
2010-02-25 04:56:36 +03:00
|
|
|
E->getOperatorLoc(),
|
|
|
|
E->isArrow()? tok::arrow : tok::period,
|
|
|
|
ObjectTypePtr,
|
|
|
|
MayBePseudoDestructor);
|
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 09:47:05 +04:00
|
|
|
QualType ObjectType = ObjectTypePtr.get();
|
2009-09-04 21:36:40 +04:00
|
|
|
NestedNameSpecifier *Qualifier
|
|
|
|
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
|
2010-02-21 21:36:56 +03:00
|
|
|
E->getQualifierRange(),
|
2010-02-25 04:56:36 +03:00
|
|
|
ObjectType);
|
2009-09-04 21:36:40 +04:00
|
|
|
if (E->getQualifier() && !Qualifier)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-25 04:56:36 +03:00
|
|
|
PseudoDestructorTypeStorage Destroyed;
|
|
|
|
if (E->getDestroyedTypeInfo()) {
|
|
|
|
TypeSourceInfo *DestroyedTypeInfo
|
|
|
|
= getDerived().TransformType(E->getDestroyedTypeInfo(), ObjectType);
|
|
|
|
if (!DestroyedTypeInfo)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
Destroyed = DestroyedTypeInfo;
|
|
|
|
} else if (ObjectType->isDependentType()) {
|
|
|
|
// We aren't likely to be able to resolve the identifier down to a type
|
|
|
|
// now anyway, so just retain the identifier.
|
|
|
|
Destroyed = PseudoDestructorTypeStorage(E->getDestroyedTypeIdentifier(),
|
|
|
|
E->getDestroyedTypeLoc());
|
|
|
|
} else {
|
|
|
|
// Look for a destructor known with the given name.
|
|
|
|
CXXScopeSpec SS;
|
|
|
|
if (Qualifier) {
|
|
|
|
SS.setScopeRep(Qualifier);
|
|
|
|
SS.setRange(E->getQualifierRange());
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
|
2010-02-25 04:56:36 +03:00
|
|
|
*E->getDestroyedTypeIdentifier(),
|
|
|
|
E->getDestroyedTypeLoc(),
|
|
|
|
/*Scope=*/0,
|
|
|
|
SS, ObjectTypePtr,
|
|
|
|
false);
|
|
|
|
if (!T)
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-02-25 04:56:36 +03:00
|
|
|
Destroyed
|
|
|
|
= SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T),
|
|
|
|
E->getDestroyedTypeLoc());
|
|
|
|
}
|
2010-02-25 02:40:28 +03:00
|
|
|
|
|
|
|
TypeSourceInfo *ScopeTypeInfo = 0;
|
|
|
|
if (E->getScopeTypeInfo()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
ScopeTypeInfo = getDerived().TransformType(E->getScopeTypeInfo(),
|
2010-02-25 04:56:36 +03:00
|
|
|
ObjectType);
|
2010-02-25 02:40:28 +03:00
|
|
|
if (!ScopeTypeInfo)
|
2009-09-04 21:36:40 +04:00
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
|
2009-09-04 21:36:40 +04:00
|
|
|
E->getOperatorLoc(),
|
|
|
|
E->isArrow(),
|
|
|
|
Qualifier,
|
2010-02-25 02:40:28 +03:00
|
|
|
E->getQualifierRange(),
|
|
|
|
ScopeTypeInfo,
|
|
|
|
E->getColonColonLoc(),
|
2010-02-25 02:50:37 +03:00
|
|
|
E->getTildeLoc(),
|
2010-02-25 04:56:36 +03:00
|
|
|
Destroyed);
|
2009-09-04 21:36:40 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-04 21:36:40 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-11-21 11:51:07 +03:00
|
|
|
TreeTransform<Derived>::TransformUnresolvedLookupExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
UnresolvedLookupExpr *Old) {
|
2009-11-24 22:00:30 +03:00
|
|
|
TemporaryBase Rebase(*this, Old->getNameLoc(), DeclarationName());
|
|
|
|
|
|
|
|
LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
|
|
|
|
Sema::LookupOrdinaryName);
|
|
|
|
|
|
|
|
// Transform all the decls.
|
|
|
|
for (UnresolvedLookupExpr::decls_iterator I = Old->decls_begin(),
|
|
|
|
E = Old->decls_end(); I != E; ++I) {
|
2010-03-01 18:56:25 +03:00
|
|
|
NamedDecl *InstD = static_cast<NamedDecl*>(
|
|
|
|
getDerived().TransformDecl(Old->getNameLoc(),
|
|
|
|
*I));
|
2009-12-10 12:41:52 +03:00
|
|
|
if (!InstD) {
|
|
|
|
// Silently ignore these if a UsingShadowDecl instantiated to nothing.
|
|
|
|
// This can happen because of dependent hiding.
|
|
|
|
if (isa<UsingShadowDecl>(*I))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-11-24 22:00:30 +03:00
|
|
|
|
|
|
|
// Expand using declarations.
|
|
|
|
if (isa<UsingDecl>(InstD)) {
|
|
|
|
UsingDecl *UD = cast<UsingDecl>(InstD);
|
|
|
|
for (UsingDecl::shadow_iterator I = UD->shadow_begin(),
|
|
|
|
E = UD->shadow_end(); I != E; ++I)
|
|
|
|
R.addDecl(*I);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
R.addDecl(InstD);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resolve a kind, but don't do any further analysis. If it's
|
|
|
|
// ambiguous, the callee needs to deal with it.
|
|
|
|
R.resolveKind();
|
|
|
|
|
|
|
|
// Rebuild the nested-name qualifier, if present.
|
|
|
|
CXXScopeSpec SS;
|
|
|
|
NestedNameSpecifier *Qualifier = 0;
|
|
|
|
if (Old->getQualifier()) {
|
|
|
|
Qualifier = getDerived().TransformNestedNameSpecifier(Old->getQualifier(),
|
2010-02-25 07:46:04 +03:00
|
|
|
Old->getQualifierRange());
|
2009-11-24 22:00:30 +03:00
|
|
|
if (!Qualifier)
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
SS.setScopeRep(Qualifier);
|
|
|
|
SS.setRange(Old->getQualifierRange());
|
2010-05-05 19:23:54 +04:00
|
|
|
}
|
|
|
|
|
2010-04-27 22:19:34 +04:00
|
|
|
if (Old->getNamingClass()) {
|
2010-04-27 20:10:10 +04:00
|
|
|
CXXRecordDecl *NamingClass
|
|
|
|
= cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
|
|
|
|
Old->getNameLoc(),
|
|
|
|
Old->getNamingClass()));
|
|
|
|
if (!NamingClass)
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 20:10:10 +04:00
|
|
|
R.setNamingClass(NamingClass);
|
2009-11-24 22:00:30 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// If we have no template arguments, it's a normal declaration name.
|
|
|
|
if (!Old->hasExplicitTemplateArgs())
|
|
|
|
return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
|
|
|
|
|
|
|
|
// If we have template arguments, rebuild them, then rebuild the
|
|
|
|
// templateid expression.
|
|
|
|
TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
|
|
|
|
for (unsigned I = 0, N = Old->getNumTemplateArgs(); I != N; ++I) {
|
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(Old->getTemplateArgs()[I], Loc))
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
TransArgs.addArgument(Loc);
|
|
|
|
}
|
|
|
|
|
|
|
|
return getDerived().RebuildTemplateIdExpr(SS, R, Old->requiresADL(),
|
|
|
|
TransArgs);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformUnaryTypeTraitExpr(UnaryTypeTraitExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
QualType T = getDerived().TransformType(E->getQueriedType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getQueriedType())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Bad location information
|
|
|
|
SourceLocation FakeLParenLoc
|
|
|
|
= SemaRef.PP.getLocForEndOfToken(E->getLocStart());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildUnaryTypeTrait(E->getTrait(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getLocStart(),
|
|
|
|
/*FIXME:*/FakeLParenLoc,
|
|
|
|
T,
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-11-20 01:55:06 +03:00
|
|
|
TreeTransform<Derived>::TransformDependentScopeDeclRefExpr(
|
2010-08-12 02:01:17 +04:00
|
|
|
DependentScopeDeclRefExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
NestedNameSpecifier *NNS
|
2009-10-22 21:20:55 +04:00
|
|
|
= getDerived().TransformNestedNameSpecifier(E->getQualifier(),
|
2010-02-25 07:46:04 +03:00
|
|
|
E->getQualifierRange());
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!NNS)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo
|
|
|
|
= getDerived().TransformDeclarationNameInfo(E->getNameInfo());
|
|
|
|
if (!NameInfo.getName())
|
2009-09-04 02:13:48 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
if (!E->hasExplicitTemplateArgs()) {
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
NNS == E->getQualifier() &&
|
2010-08-12 02:01:17 +04:00
|
|
|
// Note: it is sufficient to compare the Name component of NameInfo:
|
|
|
|
// if name has not changed, DNLoc has not changed either.
|
|
|
|
NameInfo.getName() == E->getDeclName())
|
2009-11-24 22:00:30 +03:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
return getDerived().RebuildDependentScopeDeclRefExpr(NNS,
|
|
|
|
E->getQualifierRange(),
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo,
|
2009-11-24 22:00:30 +03:00
|
|
|
/*TemplateArgs*/ 0);
|
2009-10-22 21:20:55 +04:00
|
|
|
}
|
2009-11-23 04:53:49 +03:00
|
|
|
|
|
|
|
TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
|
2009-08-11 09:31:07 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(E->getTemplateArgs()[I], Loc))
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-11-23 04:53:49 +03:00
|
|
|
TransArgs.addArgument(Loc);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
return getDerived().RebuildDependentScopeDeclRefExpr(NNS,
|
|
|
|
E->getQualifierRange(),
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo,
|
2009-11-24 22:00:30 +03:00
|
|
|
&TransArgs);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXConstructExpr(CXXConstructExpr *E) {
|
2010-02-03 06:01:57 +03:00
|
|
|
// CXXConstructExprs are always implicit, so when we have a
|
|
|
|
// 1-argument construction we just transform that argument.
|
|
|
|
if (E->getNumArgs() == 1 ||
|
|
|
|
(E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1))))
|
|
|
|
return getDerived().TransformExpr(E->getArg(0));
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
|
|
|
|
|
|
|
|
QualType T = getDerived().TransformType(E->getType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
CXXConstructorDecl *Constructor
|
|
|
|
= cast_or_null<CXXConstructorDecl>(
|
2010-03-01 18:56:25 +03:00
|
|
|
getDerived().TransformDecl(E->getLocStart(),
|
|
|
|
E->getConstructor()));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!Constructor)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
bool ArgumentChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2009-09-09 19:08:12 +04:00
|
|
|
for (CXXConstructExpr::arg_iterator Arg = E->arg_begin(),
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgEnd = E->arg_end();
|
|
|
|
Arg != ArgEnd; ++Arg) {
|
2009-12-14 22:27:10 +03:00
|
|
|
if (getDerived().DropCallArgument(*Arg)) {
|
|
|
|
ArgumentChanged = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult TransArg = getDerived().TransformExpr(*Arg);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (TransArg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || TransArg.get() != *Arg;
|
2010-08-24 03:25:46 +04:00
|
|
|
Args.push_back(TransArg.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getType() &&
|
|
|
|
Constructor == E->getConstructor() &&
|
2010-02-26 03:01:57 +03:00
|
|
|
!ArgumentChanged) {
|
2010-02-26 03:38:10 +03:00
|
|
|
// Mark the constructor as referenced.
|
|
|
|
// FIXME: Instantiation-specific
|
2010-02-26 03:01:57 +03:00
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-02-26 03:01:57 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-14 19:27:04 +03:00
|
|
|
return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
|
|
|
|
Constructor, E->isElidable(),
|
2010-08-22 21:20:18 +04:00
|
|
|
move_arg(Args),
|
|
|
|
E->requiresZeroInitialization(),
|
|
|
|
E->getConstructionKind());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
/// \brief Transform a C++ temporary-binding expression.
|
|
|
|
///
|
2009-12-24 21:51:59 +03:00
|
|
|
/// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
|
|
|
|
/// transform the subexpression and return that.
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
|
2009-12-24 21:51:59 +03:00
|
|
|
return getDerived().TransformExpr(E->getSubExpr());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-29 05:39:32 +03:00
|
|
|
/// \brief Transform a C++ reference-binding expression.
|
|
|
|
///
|
|
|
|
/// Since CXXBindReferenceExpr nodes are implicitly generated, we just
|
|
|
|
/// transform the subexpression and return that.
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2010-01-29 05:39:32 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXBindReferenceExpr(CXXBindReferenceExpr *E) {
|
|
|
|
return getDerived().TransformExpr(E->getSubExpr());
|
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
/// \brief Transform a C++ expression that contains temporaries that should
|
2009-08-11 09:31:07 +04:00
|
|
|
/// be destroyed after the expression is evaluated.
|
|
|
|
///
|
2009-12-24 21:51:59 +03:00
|
|
|
/// Since CXXExprWithTemporaries nodes are implicitly generated, we
|
|
|
|
/// just transform the subexpression and return that.
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXExprWithTemporaries(
|
2009-12-24 21:51:59 +03:00
|
|
|
CXXExprWithTemporaries *E) {
|
|
|
|
return getDerived().TransformExpr(E->getSubExpr());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXTemporaryObjectExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXTemporaryObjectExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
|
|
|
|
QualType T = getDerived().TransformType(E->getType());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
CXXConstructorDecl *Constructor
|
|
|
|
= cast_or_null<CXXConstructorDecl>(
|
2010-05-05 19:23:54 +04:00
|
|
|
getDerived().TransformDecl(E->getLocStart(),
|
2010-03-01 18:56:25 +03:00
|
|
|
E->getConstructor()));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!Constructor)
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
bool ArgumentChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
Args.reserve(E->getNumArgs());
|
2009-09-09 19:08:12 +04:00
|
|
|
for (CXXTemporaryObjectExpr::arg_iterator Arg = E->arg_begin(),
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgEnd = E->arg_end();
|
|
|
|
Arg != ArgEnd; ++Arg) {
|
2010-03-02 20:18:33 +03:00
|
|
|
if (getDerived().DropCallArgument(*Arg)) {
|
|
|
|
ArgumentChanged = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult TransArg = getDerived().TransformExpr(*Arg);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (TransArg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || TransArg.get() != *Arg;
|
|
|
|
Args.push_back((Expr *)TransArg.release());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getType() &&
|
|
|
|
Constructor == E->getConstructor() &&
|
2010-03-02 20:18:33 +03:00
|
|
|
!ArgumentChanged) {
|
|
|
|
// FIXME: Instantiation-specific
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getTypeBeginLoc(), Constructor);
|
2010-03-31 22:34:58 +04:00
|
|
|
return SemaRef.MaybeBindToTemporary(E->Retain());
|
2010-03-02 20:18:33 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: Bogus location information
|
|
|
|
SourceLocation CommaLoc;
|
|
|
|
if (Args.size() > 1) {
|
|
|
|
Expr *First = (Expr *)Args[0];
|
2009-09-09 19:08:12 +04:00
|
|
|
CommaLoc
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.PP.getLocForEndOfToken(First->getSourceRange().getEnd());
|
|
|
|
}
|
|
|
|
return getDerived().RebuildCXXTemporaryObjectExpr(E->getTypeBeginLoc(),
|
|
|
|
T,
|
|
|
|
/*FIXME:*/E->getTypeBeginLoc(),
|
|
|
|
move_arg(Args),
|
|
|
|
&CommaLoc,
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXUnresolvedConstructExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXUnresolvedConstructExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
TemporaryBase Rebase(*this, E->getTypeBeginLoc(), DeclarationName());
|
|
|
|
QualType T = getDerived().TransformType(E->getTypeAsWritten());
|
|
|
|
if (T.isNull())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
bool ArgumentChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
llvm::SmallVector<SourceLocation, 8> FakeCommaLocs;
|
|
|
|
for (CXXUnresolvedConstructExpr::arg_iterator Arg = E->arg_begin(),
|
|
|
|
ArgEnd = E->arg_end();
|
|
|
|
Arg != ArgEnd; ++Arg) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult TransArg = getDerived().TransformExpr(*Arg);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (TransArg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || TransArg.get() != *Arg;
|
|
|
|
FakeCommaLocs.push_back(
|
|
|
|
SemaRef.PP.getLocForEndOfToken((*Arg)->getLocEnd()));
|
2010-08-24 03:25:46 +04:00
|
|
|
Args.push_back(TransArg.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getTypeAsWritten() &&
|
|
|
|
!ArgumentChanged)
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: we're faking the locations of the commas
|
|
|
|
return getDerived().RebuildCXXUnresolvedConstructExpr(E->getTypeBeginLoc(),
|
|
|
|
T,
|
|
|
|
E->getLParenLoc(),
|
|
|
|
move_arg(Args),
|
|
|
|
FakeCommaLocs.data(),
|
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-11-20 01:55:06 +03:00
|
|
|
TreeTransform<Derived>::TransformCXXDependentScopeMemberExpr(
|
2010-08-12 02:01:17 +04:00
|
|
|
CXXDependentScopeMemberExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
// Transform the base of the expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base((Expr*) 0);
|
2009-12-02 01:10:20 +03:00
|
|
|
Expr *OldBase;
|
|
|
|
QualType BaseType;
|
|
|
|
QualType ObjectType;
|
|
|
|
if (!E->isImplicitAccess()) {
|
|
|
|
OldBase = E->getBase();
|
|
|
|
Base = getDerived().TransformExpr(OldBase);
|
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-02 01:10:20 +03:00
|
|
|
// Start the member reference and compute the object's type.
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType ObjectTy;
|
Rework parsing of pseudo-destructor expressions and explicit
destructor calls, e.g.,
p->T::~T
We now detect when the member access that we've parsed, e.g.,
p-> or x.
may be a pseudo-destructor expression, either because the type of p or
x is a scalar or because it is dependent (and, therefore, may become a
scalar at template instantiation time).
We then parse the pseudo-destructor grammar specifically:
::[opt] nested-name-specifier[opt] type-name :: ∼ type-name
and hand those results to a new action, ActOnPseudoDestructorExpr,
which will cope with both dependent member accesses of destructors and
with pseudo-destructor expressions.
This commit affects the parsing of pseudo-destructors, only; the
semantic actions still go through the semantic actions for member
access expressions. That will change soon.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97045 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 21:44:31 +03:00
|
|
|
bool MayBePseudoDestructor = false;
|
2010-08-24 03:25:46 +04:00
|
|
|
Base = SemaRef.ActOnStartCXXMemberReference(0, Base.get(),
|
2009-12-02 01:10:20 +03:00
|
|
|
E->getOperatorLoc(),
|
2009-09-03 20:14:30 +04:00
|
|
|
E->isArrow()? tok::arrow : tok::period,
|
Rework parsing of pseudo-destructor expressions and explicit
destructor calls, e.g.,
p->T::~T
We now detect when the member access that we've parsed, e.g.,
p-> or x.
may be a pseudo-destructor expression, either because the type of p or
x is a scalar or because it is dependent (and, therefore, may become a
scalar at template instantiation time).
We then parse the pseudo-destructor grammar specifically:
::[opt] nested-name-specifier[opt] type-name :: ∼ type-name
and hand those results to a new action, ActOnPseudoDestructorExpr,
which will cope with both dependent member accesses of destructors and
with pseudo-destructor expressions.
This commit affects the parsing of pseudo-destructors, only; the
semantic actions still go through the semantic actions for member
access expressions. That will change soon.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97045 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-24 21:44:31 +03:00
|
|
|
ObjectTy,
|
|
|
|
MayBePseudoDestructor);
|
2009-12-02 01:10:20 +03:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
2010-08-24 09:47:05 +04:00
|
|
|
ObjectType = ObjectTy.get();
|
2009-12-02 01:10:20 +03:00
|
|
|
BaseType = ((Expr*) Base.get())->getType();
|
|
|
|
} else {
|
|
|
|
OldBase = 0;
|
|
|
|
BaseType = getDerived().TransformType(E->getBaseType());
|
|
|
|
ObjectType = BaseType->getAs<PointerType>()->getPointeeType();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-20 09:58:46 +04:00
|
|
|
// Transform the first part of the nested-name-specifier that qualifies
|
|
|
|
// the member name.
|
2009-09-04 01:38:09 +04:00
|
|
|
NamedDecl *FirstQualifierInScope
|
2009-10-20 09:58:46 +04:00
|
|
|
= getDerived().TransformFirstQualifierInScope(
|
|
|
|
E->getFirstQualifierFoundInScope(),
|
|
|
|
E->getQualifierRange().getBegin());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-03 20:14:30 +04:00
|
|
|
NestedNameSpecifier *Qualifier = 0;
|
|
|
|
if (E->getQualifier()) {
|
|
|
|
Qualifier = getDerived().TransformNestedNameSpecifier(E->getQualifier(),
|
|
|
|
E->getQualifierRange(),
|
2009-12-02 01:10:20 +03:00
|
|
|
ObjectType,
|
|
|
|
FirstQualifierInScope);
|
2009-09-03 20:14:30 +04:00
|
|
|
if (!Qualifier)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo
|
|
|
|
= getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo(),
|
|
|
|
ObjectType);
|
|
|
|
if (!NameInfo.getName())
|
2009-09-04 02:13:48 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-12-02 01:10:20 +03:00
|
|
|
if (!E->hasExplicitTemplateArgs()) {
|
2009-09-09 04:23:06 +04:00
|
|
|
// This is a reference to a member without an explicitly-specified
|
|
|
|
// template argument list. Optimize for this common case.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2009-12-02 01:10:20 +03:00
|
|
|
Base.get() == OldBase &&
|
|
|
|
BaseType == E->getBaseType() &&
|
2009-09-09 04:23:06 +04:00
|
|
|
Qualifier == E->getQualifier() &&
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo.getName() == E->getMember() &&
|
2009-09-09 04:23:06 +04:00
|
|
|
FirstQualifierInScope == E->getFirstQualifierFoundInScope())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
|
2009-12-02 01:10:20 +03:00
|
|
|
BaseType,
|
2009-09-09 04:23:06 +04:00
|
|
|
E->isArrow(),
|
|
|
|
E->getOperatorLoc(),
|
|
|
|
Qualifier,
|
|
|
|
E->getQualifierRange(),
|
2009-12-01 01:42:35 +03:00
|
|
|
FirstQualifierInScope,
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo,
|
2009-12-01 01:42:35 +03:00
|
|
|
/*TemplateArgs*/ 0);
|
2009-09-09 04:23:06 +04:00
|
|
|
}
|
|
|
|
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
|
2009-09-09 04:23:06 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumTemplateArgs(); I != N; ++I) {
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(E->getTemplateArgs()[I], Loc))
|
2009-09-09 04:23:06 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-11-23 04:53:49 +03:00
|
|
|
TransArgs.addArgument(Loc);
|
2009-09-09 04:23:06 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
|
2009-12-02 01:10:20 +03:00
|
|
|
BaseType,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->isArrow(),
|
|
|
|
E->getOperatorLoc(),
|
2009-09-03 20:14:30 +04:00
|
|
|
Qualifier,
|
|
|
|
E->getQualifierRange(),
|
2009-09-09 04:23:06 +04:00
|
|
|
FirstQualifierInScope,
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo,
|
2009-12-01 01:42:35 +03:00
|
|
|
&TransArgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformUnresolvedMemberExpr(UnresolvedMemberExpr *Old) {
|
2009-12-01 01:42:35 +03:00
|
|
|
// Transform the base of the expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base((Expr*) 0);
|
2009-12-02 01:10:20 +03:00
|
|
|
QualType BaseType;
|
|
|
|
if (!Old->isImplicitAccess()) {
|
|
|
|
Base = getDerived().TransformExpr(Old->getBase());
|
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
BaseType = ((Expr*) Base.get())->getType();
|
|
|
|
} else {
|
|
|
|
BaseType = getDerived().TransformType(Old->getBaseType());
|
|
|
|
}
|
2009-12-01 01:42:35 +03:00
|
|
|
|
|
|
|
NestedNameSpecifier *Qualifier = 0;
|
|
|
|
if (Old->getQualifier()) {
|
|
|
|
Qualifier
|
|
|
|
= getDerived().TransformNestedNameSpecifier(Old->getQualifier(),
|
2010-02-25 07:46:04 +03:00
|
|
|
Old->getQualifierRange());
|
2009-12-01 01:42:35 +03:00
|
|
|
if (Qualifier == 0)
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
LookupResult R(SemaRef, Old->getMemberNameInfo(),
|
2009-12-01 01:42:35 +03:00
|
|
|
Sema::LookupOrdinaryName);
|
|
|
|
|
|
|
|
// Transform all the decls.
|
|
|
|
for (UnresolvedMemberExpr::decls_iterator I = Old->decls_begin(),
|
|
|
|
E = Old->decls_end(); I != E; ++I) {
|
2010-03-01 18:56:25 +03:00
|
|
|
NamedDecl *InstD = static_cast<NamedDecl*>(
|
|
|
|
getDerived().TransformDecl(Old->getMemberLoc(),
|
|
|
|
*I));
|
2009-12-10 12:41:52 +03:00
|
|
|
if (!InstD) {
|
|
|
|
// Silently ignore these if a UsingShadowDecl instantiated to nothing.
|
|
|
|
// This can happen because of dependent hiding.
|
|
|
|
if (isa<UsingShadowDecl>(*I))
|
|
|
|
continue;
|
|
|
|
else
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
}
|
2009-12-01 01:42:35 +03:00
|
|
|
|
|
|
|
// Expand using declarations.
|
|
|
|
if (isa<UsingDecl>(InstD)) {
|
|
|
|
UsingDecl *UD = cast<UsingDecl>(InstD);
|
|
|
|
for (UsingDecl::shadow_iterator I = UD->shadow_begin(),
|
|
|
|
E = UD->shadow_end(); I != E; ++I)
|
|
|
|
R.addDecl(*I);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
R.addDecl(InstD);
|
|
|
|
}
|
|
|
|
|
|
|
|
R.resolveKind();
|
|
|
|
|
2010-04-27 22:19:34 +04:00
|
|
|
// Determine the naming class.
|
2010-05-19 05:37:01 +04:00
|
|
|
if (Old->getNamingClass()) {
|
2010-05-05 19:23:54 +04:00
|
|
|
CXXRecordDecl *NamingClass
|
2010-04-27 22:19:34 +04:00
|
|
|
= cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
|
2010-04-27 20:10:10 +04:00
|
|
|
Old->getMemberLoc(),
|
|
|
|
Old->getNamingClass()));
|
|
|
|
if (!NamingClass)
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 20:10:10 +04:00
|
|
|
R.setNamingClass(NamingClass);
|
2010-04-27 22:19:34 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-12-01 01:42:35 +03:00
|
|
|
TemplateArgumentListInfo TransArgs;
|
|
|
|
if (Old->hasExplicitTemplateArgs()) {
|
|
|
|
TransArgs.setLAngleLoc(Old->getLAngleLoc());
|
|
|
|
TransArgs.setRAngleLoc(Old->getRAngleLoc());
|
|
|
|
for (unsigned I = 0, N = Old->getNumTemplateArgs(); I != N; ++I) {
|
|
|
|
TemplateArgumentLoc Loc;
|
|
|
|
if (getDerived().TransformTemplateArgument(Old->getTemplateArgs()[I],
|
|
|
|
Loc))
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
TransArgs.addArgument(Loc);
|
|
|
|
}
|
|
|
|
}
|
2010-01-15 11:34:02 +03:00
|
|
|
|
|
|
|
// FIXME: to do this check properly, we will need to preserve the
|
|
|
|
// first-qualifier-in-scope here, just in case we had a dependent
|
|
|
|
// base (and therefore couldn't do the check) and a
|
|
|
|
// nested-name-qualifier (and therefore could do the lookup).
|
|
|
|
NamedDecl *FirstQualifierInScope = 0;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildUnresolvedMemberExpr(Base.get(),
|
2009-12-02 01:10:20 +03:00
|
|
|
BaseType,
|
2009-12-01 01:42:35 +03:00
|
|
|
Old->getOperatorLoc(),
|
|
|
|
Old->isArrow(),
|
|
|
|
Qualifier,
|
|
|
|
Old->getQualifierRange(),
|
2010-01-15 11:34:02 +03:00
|
|
|
FirstQualifierInScope,
|
2009-12-01 01:42:35 +03:00
|
|
|
R,
|
|
|
|
(Old->hasExplicitTemplateArgs()
|
|
|
|
? &TransArgs : 0));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCStringLiteral(ObjCStringLiteral *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCEncodeExpr(ObjCEncodeExpr *E) {
|
2010-04-20 19:39:42 +04:00
|
|
|
TypeSourceInfo *EncodedTypeInfo
|
|
|
|
= getDerived().TransformType(E->getEncodedTypeSourceInfo());
|
|
|
|
if (!EncodedTypeInfo)
|
2009-08-11 09:31:07 +04:00
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-04-20 19:39:42 +04:00
|
|
|
EncodedTypeInfo == E->getEncodedTypeSourceInfo())
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
|
2010-04-20 19:39:42 +04:00
|
|
|
EncodedTypeInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCMessageExpr(ObjCMessageExpr *E) {
|
2010-04-22 20:44:27 +04:00
|
|
|
// Transform arguments.
|
|
|
|
bool ArgChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2010-04-22 20:44:27 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Arg = getDerived().TransformExpr(E->getArg(I));
|
2010-04-22 20:44:27 +04:00
|
|
|
if (Arg.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
ArgChanged = ArgChanged || Arg.get() != E->getArg(I);
|
2010-08-24 03:25:46 +04:00
|
|
|
Args.push_back(Arg.get());
|
2010-04-22 20:44:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (E->getReceiverKind() == ObjCMessageExpr::Class) {
|
|
|
|
// Class message: transform the receiver type.
|
|
|
|
TypeSourceInfo *ReceiverTypeInfo
|
|
|
|
= getDerived().TransformType(E->getClassReceiverTypeInfo());
|
|
|
|
if (!ReceiverTypeInfo)
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
// If nothing changed, just retain the existing message send.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
|
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
|
|
|
// Build a new class message send.
|
|
|
|
return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
|
|
|
|
E->getSelector(),
|
|
|
|
E->getMethodDecl(),
|
|
|
|
E->getLeftLoc(),
|
|
|
|
move_arg(Args),
|
|
|
|
E->getRightLoc());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instance message: transform the receiver
|
|
|
|
assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
|
|
|
|
"Only class and instance messages may be instantiated");
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Receiver
|
2010-04-22 20:44:27 +04:00
|
|
|
= getDerived().TransformExpr(E->getInstanceReceiver());
|
|
|
|
if (Receiver.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
// If nothing changed, just retain the existing message send.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
// Build a new instance message send.
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCMessageExpr(Receiver.get(),
|
2010-04-22 20:44:27 +04:00
|
|
|
E->getSelector(),
|
|
|
|
E->getMethodDecl(),
|
|
|
|
E->getLeftLoc(),
|
|
|
|
move_arg(Args),
|
|
|
|
E->getRightLoc());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCSelectorExpr(ObjCSelectorExpr *E) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCProtocolExpr(ObjCProtocolExpr *E) {
|
2010-04-22 21:28:13 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
|
2010-04-27 00:11:03 +04:00
|
|
|
// Transform the base expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2010-04-27 00:11:03 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
|
|
|
|
// We don't need to transform the ivar; it will never change.
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:11:03 +04:00
|
|
|
// If nothing changed, just retain the existing expression.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
|
2010-04-27 00:11:03 +04:00
|
|
|
E->getLocation(),
|
|
|
|
E->isArrow(), E->isFreeIvar());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
|
2010-04-27 00:47:02 +04:00
|
|
|
// Transform the base expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2010-04-27 00:47:02 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:47:02 +04:00
|
|
|
// We don't need to transform the property; it will never change.
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:47:02 +04:00
|
|
|
// If nothing changed, just retain the existing expression.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCPropertyRefExpr(Base.get(), E->getProperty(),
|
2010-04-27 00:47:02 +04:00
|
|
|
E->getLocation());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-20 21:02:02 +04:00
|
|
|
TreeTransform<Derived>::TransformObjCImplicitSetterGetterRefExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
ObjCImplicitSetterGetterRefExpr *E) {
|
2010-04-27 01:04:54 +04:00
|
|
|
// If this implicit setter/getter refers to class methods, it cannot have any
|
|
|
|
// dependent parts. Just retain the existing declaration.
|
|
|
|
if (E->getInterfaceDecl())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 01:04:54 +04:00
|
|
|
// Transform the base expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2010-04-27 01:04:54 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 01:04:54 +04:00
|
|
|
// We don't need to transform the getters/setters; they will never change.
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 01:04:54 +04:00
|
|
|
// If nothing changed, just retain the existing expression.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 01:04:54 +04:00
|
|
|
return getDerived().RebuildObjCImplicitSetterGetterRefExpr(
|
|
|
|
E->getGetterMethod(),
|
|
|
|
E->getType(),
|
|
|
|
E->getSetterMethod(),
|
|
|
|
E->getLocation(),
|
2010-08-24 03:25:46 +04:00
|
|
|
Base.get());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCSuperExpr(ObjCSuperExpr *E) {
|
2010-04-22 21:28:13 +04:00
|
|
|
// Can never occur in a dependent context.
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformObjCIsaExpr(ObjCIsaExpr *E) {
|
2010-04-27 00:11:03 +04:00
|
|
|
// Transform the base expression.
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Base = getDerived().TransformExpr(E->getBase());
|
2010-04-27 00:11:03 +04:00
|
|
|
if (Base.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-27 00:11:03 +04:00
|
|
|
// If nothing changed, just retain the existing expression.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase())
|
|
|
|
return SemaRef.Owned(E->Retain());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
|
2010-04-27 00:11:03 +04:00
|
|
|
E->isArrow());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformShuffleVectorExpr(ShuffleVectorExpr *E) {
|
2009-08-11 09:31:07 +04:00
|
|
|
bool ArgumentChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> SubExprs(SemaRef);
|
2009-08-11 09:31:07 +04:00
|
|
|
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getExpr(I));
|
2009-08-11 09:31:07 +04:00
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
ArgumentChanged = ArgumentChanged || SubExpr.get() != E->getExpr(I);
|
2010-08-24 03:25:46 +04:00
|
|
|
SubExprs.push_back(SubExpr.get());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
!ArgumentChanged)
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
|
|
|
|
move_arg(SubExprs),
|
|
|
|
E->getRParenLoc());
|
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformBlockExpr(BlockExpr *E) {
|
2010-07-09 22:44:02 +04:00
|
|
|
SourceLocation CaretLoc(E->getExprLoc());
|
|
|
|
|
|
|
|
SemaRef.ActOnBlockStart(CaretLoc, /*Scope=*/0);
|
|
|
|
BlockScopeInfo *CurBlock = SemaRef.getCurBlock();
|
|
|
|
CurBlock->TheDecl->setIsVariadic(E->getBlockDecl()->isVariadic());
|
|
|
|
llvm::SmallVector<ParmVarDecl*, 4> Params;
|
|
|
|
llvm::SmallVector<QualType, 4> ParamTypes;
|
|
|
|
|
|
|
|
// Parameter substitution.
|
|
|
|
const BlockDecl *BD = E->getBlockDecl();
|
|
|
|
for (BlockDecl::param_const_iterator P = BD->param_begin(),
|
|
|
|
EN = BD->param_end(); P != EN; ++P) {
|
|
|
|
ParmVarDecl *OldParm = (*P);
|
|
|
|
ParmVarDecl *NewParm = getDerived().TransformFunctionTypeParam(OldParm);
|
|
|
|
QualType NewType = NewParm->getType();
|
|
|
|
Params.push_back(NewParm);
|
|
|
|
ParamTypes.push_back(NewParm->getType());
|
|
|
|
}
|
|
|
|
|
|
|
|
const FunctionType *BExprFunctionType = E->getFunctionType();
|
|
|
|
QualType BExprResultType = BExprFunctionType->getResultType();
|
|
|
|
if (!BExprResultType.isNull()) {
|
|
|
|
if (!BExprResultType->isDependentType())
|
|
|
|
CurBlock->ReturnType = BExprResultType;
|
|
|
|
else if (BExprResultType != SemaRef.Context.DependentTy)
|
|
|
|
CurBlock->ReturnType = getDerived().TransformType(BExprResultType);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Transform the body
|
2010-08-24 10:29:42 +04:00
|
|
|
StmtResult Body = getDerived().TransformStmt(E->getBody());
|
2010-07-09 22:44:02 +04:00
|
|
|
if (Body.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
|
|
|
// Set the parameters on the block decl.
|
|
|
|
if (!Params.empty())
|
|
|
|
CurBlock->TheDecl->setParams(Params.data(), Params.size());
|
|
|
|
|
|
|
|
QualType FunctionType = getDerived().RebuildFunctionProtoType(
|
|
|
|
CurBlock->ReturnType,
|
|
|
|
ParamTypes.data(),
|
|
|
|
ParamTypes.size(),
|
|
|
|
BD->isVariadic(),
|
2010-08-05 06:54:05 +04:00
|
|
|
0,
|
|
|
|
BExprFunctionType->getExtInfo());
|
2010-07-09 22:44:02 +04:00
|
|
|
|
|
|
|
CurBlock->FunctionType = FunctionType;
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.ActOnBlockStmtExpr(CaretLoc, Body.get(), /*Scope=*/0);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-12-08 12:21:05 +03:00
|
|
|
TreeTransform<Derived>::TransformBlockDeclRefExpr(BlockDeclRefExpr *E) {
|
2010-07-09 22:44:02 +04:00
|
|
|
NestedNameSpecifier *Qualifier = 0;
|
|
|
|
|
|
|
|
ValueDecl *ND
|
|
|
|
= cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
|
|
|
|
E->getDecl()));
|
|
|
|
if (!ND)
|
|
|
|
return SemaRef.ExprError();
|
2010-08-12 02:01:17 +04:00
|
|
|
|
2010-07-09 22:44:02 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
ND == E->getDecl()) {
|
|
|
|
// Mark it referenced in the new context regardless.
|
|
|
|
// FIXME: this is a bit instantiation-specific.
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocation(), ND);
|
|
|
|
|
|
|
|
return SemaRef.Owned(E->Retain());
|
|
|
|
}
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo(E->getDecl()->getDeclName(), E->getLocation());
|
2010-07-09 22:44:02 +04:00
|
|
|
return getDerived().RebuildDeclRefExpr(Qualifier, SourceLocation(),
|
2010-08-12 02:01:17 +04:00
|
|
|
ND, NameInfo, 0);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Type reconstruction
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2009-10-30 03:06:24 +03:00
|
|
|
QualType TreeTransform<Derived>::RebuildPointerType(QualType PointeeType,
|
|
|
|
SourceLocation Star) {
|
2010-06-05 10:41:15 +04:00
|
|
|
return SemaRef.BuildPointerType(PointeeType, Star,
|
2009-08-11 09:31:07 +04:00
|
|
|
getDerived().getBaseEntity());
|
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
2009-10-30 03:06:24 +03:00
|
|
|
QualType TreeTransform<Derived>::RebuildBlockPointerType(QualType PointeeType,
|
|
|
|
SourceLocation Star) {
|
2010-06-05 10:41:15 +04:00
|
|
|
return SemaRef.BuildBlockPointerType(PointeeType, Star,
|
2009-08-11 09:31:07 +04:00
|
|
|
getDerived().getBaseEntity());
|
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
2009-10-30 03:06:24 +03:00
|
|
|
TreeTransform<Derived>::RebuildReferenceType(QualType ReferentType,
|
|
|
|
bool WrittenAsLValue,
|
|
|
|
SourceLocation Sigil) {
|
2010-06-05 10:41:15 +04:00
|
|
|
return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
|
2009-10-30 03:06:24 +03:00
|
|
|
Sigil, getDerived().getBaseEntity());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
2009-10-30 03:06:24 +03:00
|
|
|
TreeTransform<Derived>::RebuildMemberPointerType(QualType PointeeType,
|
|
|
|
QualType ClassType,
|
|
|
|
SourceLocation Sigil) {
|
2010-06-05 10:41:15 +04:00
|
|
|
return SemaRef.BuildMemberPointerType(PointeeType, ClassType,
|
2009-10-30 03:06:24 +03:00
|
|
|
Sigil, getDerived().getBaseEntity());
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
2009-08-04 20:50:30 +04:00
|
|
|
TreeTransform<Derived>::RebuildArrayType(QualType ElementType,
|
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
|
|
|
const llvm::APInt *Size,
|
|
|
|
Expr *SizeExpr,
|
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange) {
|
|
|
|
if (SizeExpr || !Size)
|
|
|
|
return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
|
|
|
|
IndexTypeQuals, BracketsRange,
|
|
|
|
getDerived().getBaseEntity());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
QualType Types[] = {
|
|
|
|
SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
|
|
|
|
SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
|
|
|
|
SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
|
2009-08-04 20:50:30 +04:00
|
|
|
};
|
|
|
|
const unsigned NumTypes = sizeof(Types) / sizeof(QualType);
|
|
|
|
QualType SizeType;
|
|
|
|
for (unsigned I = 0; I != NumTypes; ++I)
|
|
|
|
if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) {
|
|
|
|
SizeType = Types[I];
|
|
|
|
break;
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
IntegerLiteral ArraySize(*Size, SizeType, /*FIXME*/BracketsRange.getBegin());
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.BuildArrayType(ElementType, SizeMod, &ArraySize,
|
2009-08-04 20:50:30 +04:00
|
|
|
IndexTypeQuals, BracketsRange,
|
2009-09-09 19:08:12 +04:00
|
|
|
getDerived().getBaseEntity());
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::RebuildConstantArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
|
|
|
const llvm::APInt &Size,
|
2009-10-30 03:06:24 +03:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, 0,
|
2009-10-30 03:06:24 +03:00
|
|
|
IndexTypeQuals, BracketsRange);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::RebuildIncompleteArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
2009-10-30 03:06:24 +03:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getDerived().RebuildArrayType(ElementType, SizeMod, 0, 0,
|
2009-10-30 03:06:24 +03:00
|
|
|
IndexTypeQuals, BracketsRange);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::RebuildVariableArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getDerived().RebuildArrayType(ElementType, SizeMod, 0,
|
2010-08-24 03:25:46 +04:00
|
|
|
SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
IndexTypeQuals, BracketsRange);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::RebuildDependentSizedArrayType(QualType ElementType,
|
2009-08-04 20:50:30 +04:00
|
|
|
ArrayType::ArraySizeModifier SizeMod,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
unsigned IndexTypeQuals,
|
|
|
|
SourceRange BracketsRange) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return getDerived().RebuildArrayType(ElementType, SizeMod, 0,
|
2010-08-24 03:25:46 +04:00
|
|
|
SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
IndexTypeQuals, BracketsRange);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
|
2010-06-23 10:00:24 +04:00
|
|
|
unsigned NumElements,
|
|
|
|
VectorType::AltiVecSpecific AltiVecSpec) {
|
2009-08-04 20:50:30 +04:00
|
|
|
// FIXME: semantic checking!
|
2010-06-23 10:00:24 +04:00
|
|
|
return SemaRef.Context.getVectorType(ElementType, NumElements, AltiVecSpec);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildExtVectorType(QualType ElementType,
|
|
|
|
unsigned NumElements,
|
|
|
|
SourceLocation AttributeLoc) {
|
|
|
|
llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
|
|
|
|
NumElements, true);
|
|
|
|
IntegerLiteral *VectorSize
|
2009-09-09 19:08:12 +04:00
|
|
|
= new (SemaRef.Context) IntegerLiteral(numElements, SemaRef.Context.IntTy,
|
2009-08-04 20:50:30 +04:00
|
|
|
AttributeLoc);
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::RebuildDependentSizedExtVectorType(QualType ElementType,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *SizeExpr,
|
2009-08-04 20:50:30 +04:00
|
|
|
SourceLocation AttributeLoc) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildFunctionProtoType(QualType T,
|
2009-09-09 19:08:12 +04:00
|
|
|
QualType *ParamTypes,
|
2009-08-04 20:50:30 +04:00
|
|
|
unsigned NumParamTypes,
|
2009-09-09 19:08:12 +04:00
|
|
|
bool Variadic,
|
2010-08-05 06:54:05 +04:00
|
|
|
unsigned Quals,
|
|
|
|
const FunctionType::ExtInfo &Info) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic,
|
2009-08-04 20:50:30 +04:00
|
|
|
Quals,
|
|
|
|
getDerived().getBaseLocation(),
|
2010-08-05 06:54:05 +04:00
|
|
|
getDerived().getBaseEntity(),
|
|
|
|
Info);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildFunctionNoProtoType(QualType T) {
|
|
|
|
return SemaRef.Context.getFunctionNoProtoType(T);
|
|
|
|
}
|
|
|
|
|
2009-12-05 01:46:56 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildUnresolvedUsingType(Decl *D) {
|
|
|
|
assert(D && "no decl found");
|
|
|
|
if (D->isInvalidDecl()) return QualType();
|
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
// FIXME: Doesn't account for ObjCInterfaceDecl!
|
2009-12-05 01:46:56 +03:00
|
|
|
TypeDecl *Ty;
|
|
|
|
if (isa<UsingDecl>(D)) {
|
|
|
|
UsingDecl *Using = cast<UsingDecl>(D);
|
|
|
|
assert(Using->isTypeName() &&
|
|
|
|
"UnresolvedUsingTypenameDecl transformed to non-typename using");
|
|
|
|
|
|
|
|
// A valid resolved using typename decl points to exactly one type decl.
|
|
|
|
assert(++Using->shadow_begin() == Using->shadow_end());
|
|
|
|
Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-12-05 01:46:56 +03:00
|
|
|
} else {
|
|
|
|
assert(isa<UnresolvedUsingTypenameDecl>(D) &&
|
|
|
|
"UnresolvedUsingTypenameDecl transformed to non-using decl");
|
|
|
|
Ty = cast<UnresolvedUsingTypenameDecl>(D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return SemaRef.Context.getTypeDeclType(Ty);
|
|
|
|
}
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 03:25:46 +04:00
|
|
|
QualType TreeTransform<Derived>::RebuildTypeOfExprType(Expr *E) {
|
|
|
|
return SemaRef.BuildTypeofExprType(E);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildTypeOfType(QualType Underlying) {
|
|
|
|
return SemaRef.Context.getTypeOfType(Underlying);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-08-24 03:25:46 +04:00
|
|
|
QualType TreeTransform<Derived>::RebuildDecltypeType(Expr *E) {
|
|
|
|
return SemaRef.BuildDecltypeType(E);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildTemplateSpecializationType(
|
2009-10-29 11:12:44 +03:00
|
|
|
TemplateName Template,
|
|
|
|
SourceLocation TemplateNameLoc,
|
2009-11-23 04:53:49 +03:00
|
|
|
const TemplateArgumentListInfo &TemplateArgs) {
|
|
|
|
return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
NestedNameSpecifier *
|
|
|
|
TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
|
|
|
|
SourceRange Range,
|
2009-09-03 20:14:30 +04:00
|
|
|
IdentifierInfo &II,
|
2009-09-04 01:38:09 +04:00
|
|
|
QualType ObjectType,
|
2009-11-23 04:53:49 +03:00
|
|
|
NamedDecl *FirstQualifierInScope) {
|
2009-08-06 09:28:30 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
// FIXME: The source location information is all wrong.
|
|
|
|
SS.setRange(Range);
|
|
|
|
SS.setScopeRep(Prefix);
|
|
|
|
return static_cast<NestedNameSpecifier *>(
|
2009-09-09 19:08:12 +04:00
|
|
|
SemaRef.BuildCXXNestedNameSpecifier(0, SS, Range.getEnd(),
|
Improve support for out-of-line definitions of nested templates and
their members, including member class template, member function
templates, and member classes and functions of member templates.
To actually parse the nested-name-specifiers that qualify the name of
an out-of-line definition of a member template, e.g.,
template<typename X> template<typename Y>
X Outer<X>::Inner1<Y>::foo(Y) {
return X();
}
we need to look for the template names (e.g., "Inner1") as a member of
the current instantiation (Outer<X>), even before we have entered the
scope of the current instantiation. Since we can't do this in general
(i.e., we should not be looking into all dependent
nested-name-specifiers as if they were the current instantiation), we
rely on the parser to tell us when it is parsing a declaration
specifier sequence, and, therefore, when we should consider the
current scope specifier to be a current instantiation.
Printing of complicated, dependent nested-name-specifiers may be
somewhat broken by this commit; I'll add tests for this issue and fix
the problem (if it still exists) in a subsequent commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@80044 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-26 02:51:20 +04:00
|
|
|
Range.getEnd(), II,
|
2009-09-04 01:38:09 +04:00
|
|
|
ObjectType,
|
|
|
|
FirstQualifierInScope,
|
2009-12-07 04:36:53 +03:00
|
|
|
false, false));
|
2009-08-06 09:28:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
NestedNameSpecifier *
|
|
|
|
TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
|
|
|
|
SourceRange Range,
|
|
|
|
NamespaceDecl *NS) {
|
|
|
|
return NestedNameSpecifier::Create(SemaRef.Context, Prefix, NS);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
NestedNameSpecifier *
|
|
|
|
TreeTransform<Derived>::RebuildNestedNameSpecifier(NestedNameSpecifier *Prefix,
|
|
|
|
SourceRange Range,
|
|
|
|
bool TemplateKW,
|
2010-02-25 07:46:04 +03:00
|
|
|
QualType T) {
|
|
|
|
if (T->isDependentType() || T->isRecordType() ||
|
2009-08-06 09:28:30 +04:00
|
|
|
(SemaRef.getLangOptions().CPlusPlus0x && T->isEnumeralType())) {
|
First part of changes to eliminate problems with cv-qualifiers and
sugared types. The basic problem is that our qualifier accessors
(getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at
the current QualType and not at any qualifiers that come from sugared
types, meaning that we won't see these qualifiers through, e.g.,
typedefs:
typedef const int CInt;
typedef CInt Self;
Self.isConstQualified() currently returns false!
Various bugs (e.g., PR5383) have cropped up all over the front end due
to such problems. I'm addressing this problem by splitting each
qualifier accessor into two versions:
- the "local" version only returns qualifiers on this particular
QualType instance
- the "normal" version that will eventually combine qualifiers from this
QualType instance with the qualifiers on the canonical type to
produce the full set of qualifiers.
This commit adds the local versions and switches a few callers from
the "normal" version (e.g., isConstQualified) over to the "local"
version (e.g., isLocalConstQualified) when that is the right thing to
do, e.g., because we're printing or serializing the qualifiers. Also,
switch a bunch of
Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType()
expressions over to
Context.hasSameUnqualifiedType(T1, T2)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88969 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17 00:35:15 +03:00
|
|
|
assert(!T.hasLocalQualifiers() && "Can't get cv-qualifiers here");
|
2009-08-06 09:28:30 +04:00
|
|
|
return NestedNameSpecifier::Create(SemaRef.Context, Prefix, TemplateKW,
|
|
|
|
T.getTypePtr());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 09:28:30 +04:00
|
|
|
SemaRef.Diag(Range.getBegin(), diag::err_nested_name_spec_non_tag) << T;
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateName
|
2009-08-06 10:41:21 +04:00
|
|
|
TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
|
|
|
|
bool TemplateKW,
|
|
|
|
TemplateDecl *Template) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.Context.getQualifiedTemplateName(Qualifier, TemplateKW,
|
2009-08-06 10:41:21 +04:00
|
|
|
Template);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateName
|
2009-08-06 10:41:21 +04:00
|
|
|
TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
|
2009-09-09 04:23:06 +04:00
|
|
|
const IdentifierInfo &II,
|
|
|
|
QualType ObjectType) {
|
2009-08-06 10:41:21 +04:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.setRange(SourceRange(getDerived().getBaseLocation()));
|
2009-09-09 19:08:12 +04:00
|
|
|
SS.setScopeRep(Qualifier);
|
2009-11-04 02:16:33 +03:00
|
|
|
UnqualifiedId Name;
|
|
|
|
Name.setIdentifier(&II, /*FIXME:*/getDerived().getBaseLocation());
|
2010-06-17 03:00:59 +04:00
|
|
|
Sema::TemplateTy Template;
|
|
|
|
getSema().ActOnDependentTemplateName(/*Scope=*/0,
|
|
|
|
/*FIXME:*/getDerived().getBaseLocation(),
|
|
|
|
SS,
|
|
|
|
Name,
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(ObjectType),
|
2010-06-17 03:00:59 +04:00
|
|
|
/*EnteringContext=*/false,
|
|
|
|
Template);
|
|
|
|
return Template.template getAsVal<TemplateName>();
|
2009-08-06 10:41:21 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-04 03:56:37 +03:00
|
|
|
template<typename Derived>
|
|
|
|
TemplateName
|
|
|
|
TreeTransform<Derived>::RebuildTemplateName(NestedNameSpecifier *Qualifier,
|
|
|
|
OverloadedOperatorKind Operator,
|
|
|
|
QualType ObjectType) {
|
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.setRange(SourceRange(getDerived().getBaseLocation()));
|
|
|
|
SS.setScopeRep(Qualifier);
|
|
|
|
UnqualifiedId Name;
|
|
|
|
SourceLocation SymbolLocations[3]; // FIXME: Bogus location information.
|
|
|
|
Name.setOperatorFunctionId(/*FIXME:*/getDerived().getBaseLocation(),
|
|
|
|
Operator, SymbolLocations);
|
2010-06-17 03:00:59 +04:00
|
|
|
Sema::TemplateTy Template;
|
|
|
|
getSema().ActOnDependentTemplateName(/*Scope=*/0,
|
2009-11-04 03:56:37 +03:00
|
|
|
/*FIXME:*/getDerived().getBaseLocation(),
|
2010-06-17 03:00:59 +04:00
|
|
|
SS,
|
|
|
|
Name,
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(ObjectType),
|
2010-06-17 03:00:59 +04:00
|
|
|
/*EnteringContext=*/false,
|
|
|
|
Template);
|
|
|
|
return Template.template getAsVal<TemplateName>();
|
2009-11-04 03:56:37 +03:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2009-08-11 09:31:07 +04:00
|
|
|
TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
|
|
|
|
SourceLocation OpLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *OrigCallee,
|
|
|
|
Expr *First,
|
|
|
|
Expr *Second) {
|
|
|
|
Expr *Callee = OrigCallee->IgnoreParenCasts();
|
|
|
|
bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Determine whether this should be a builtin operation.
|
2009-10-29 23:17:01 +03:00
|
|
|
if (Op == OO_Subscript) {
|
2010-08-24 03:25:46 +04:00
|
|
|
if (!First->getType()->isOverloadableType() &&
|
|
|
|
!Second->getType()->isOverloadableType())
|
|
|
|
return getSema().CreateBuiltinArraySubscriptExpr(First,
|
|
|
|
Callee->getLocStart(),
|
|
|
|
Second, OpLoc);
|
2009-11-16 22:13:03 +03:00
|
|
|
} else if (Op == OO_Arrow) {
|
|
|
|
// -> is never a builtin operation.
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildOverloadedArrowExpr(0, First, OpLoc);
|
|
|
|
} else if (Second == 0 || isPostIncDec) {
|
|
|
|
if (!First->getType()->isOverloadableType()) {
|
2009-08-11 09:31:07 +04:00
|
|
|
// The argument is not of overloadable type, so try to create a
|
|
|
|
// built-in unary operation.
|
2010-08-25 15:45:40 +04:00
|
|
|
UnaryOperatorKind Opc
|
2009-08-11 09:31:07 +04:00
|
|
|
= UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
} else {
|
2010-08-24 03:25:46 +04:00
|
|
|
if (!First->getType()->isOverloadableType() &&
|
|
|
|
!Second->getType()->isOverloadableType()) {
|
2009-08-11 09:31:07 +04:00
|
|
|
// Neither of the arguments is an overloadable type, so try to
|
|
|
|
// create a built-in binary operation.
|
2010-08-25 15:45:40 +04:00
|
|
|
BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result
|
2010-08-24 03:25:46 +04:00
|
|
|
= SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return move(Result);
|
|
|
|
}
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
// Compute the transformed set of functions (and function templates) to be
|
2009-08-11 09:31:07 +04:00
|
|
|
// used during overload resolution.
|
2010-01-26 06:27:55 +03:00
|
|
|
UnresolvedSet<16> Functions;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
|
2009-11-21 11:51:07 +03:00
|
|
|
assert(ULE->requiresADL());
|
|
|
|
|
|
|
|
// FIXME: Do we have to check
|
|
|
|
// IsAcceptableNonMemberOperatorCandidate for each of these?
|
2010-01-26 06:27:55 +03:00
|
|
|
Functions.append(ULE->decls_begin(), ULE->decls_end());
|
2009-11-21 11:51:07 +03:00
|
|
|
} else {
|
2010-08-24 03:25:46 +04:00
|
|
|
Functions.addDecl(cast<DeclRefExpr>(Callee)->getDecl());
|
2009-11-21 11:51:07 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Add any functions found via argument-dependent lookup.
|
2010-08-24 03:25:46 +04:00
|
|
|
Expr *Args[2] = { First, Second };
|
|
|
|
unsigned NumArgs = 1 + (Second != 0);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Create the overloaded operator invocation for unary operators.
|
|
|
|
if (NumArgs == 1 || isPostIncDec) {
|
2010-08-25 15:45:40 +04:00
|
|
|
UnaryOperatorKind Opc
|
2009-08-11 09:31:07 +04:00
|
|
|
= UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-10-29 23:17:01 +03:00
|
|
|
if (Op == OO_Subscript)
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.CreateOverloadedArraySubscriptExpr(Callee->getLocStart(),
|
2009-11-21 11:51:07 +03:00
|
|
|
OpLoc,
|
2010-08-24 03:25:46 +04:00
|
|
|
First,
|
|
|
|
Second);
|
2009-10-29 23:17:01 +03:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Create the overloaded operator invocation for binary operators.
|
2010-08-25 15:45:40 +04:00
|
|
|
BinaryOperatorKind Opc = BinaryOperator::getOverloadedOpcode(Op);
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result
|
2009-08-11 09:31:07 +04:00
|
|
|
= SemaRef.CreateOverloadedBinOp(OpLoc, Opc, Functions, Args[0], Args[1]);
|
|
|
|
if (Result.isInvalid())
|
|
|
|
return SemaRef.ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
return move(Result);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-25 02:40:28 +03:00
|
|
|
template<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2010-08-24 03:25:46 +04:00
|
|
|
TreeTransform<Derived>::RebuildCXXPseudoDestructorExpr(Expr *Base,
|
2010-02-25 02:40:28 +03:00
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
bool isArrow,
|
|
|
|
NestedNameSpecifier *Qualifier,
|
|
|
|
SourceRange QualifierRange,
|
|
|
|
TypeSourceInfo *ScopeType,
|
|
|
|
SourceLocation CCLoc,
|
2010-02-25 02:50:37 +03:00
|
|
|
SourceLocation TildeLoc,
|
2010-02-25 04:56:36 +03:00
|
|
|
PseudoDestructorTypeStorage Destroyed) {
|
2010-02-25 02:40:28 +03:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
if (Qualifier) {
|
|
|
|
SS.setRange(QualifierRange);
|
|
|
|
SS.setScopeRep(Qualifier);
|
|
|
|
}
|
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
QualType BaseType = Base->getType();
|
|
|
|
if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
|
2010-02-25 02:40:28 +03:00
|
|
|
(!isArrow && !BaseType->getAs<RecordType>()) ||
|
2010-05-05 19:23:54 +04:00
|
|
|
(isArrow && BaseType->getAs<PointerType>() &&
|
2010-02-25 16:04:33 +03:00
|
|
|
!BaseType->getAs<PointerType>()->getPointeeType()
|
|
|
|
->template getAs<RecordType>())){
|
2010-02-25 02:40:28 +03:00
|
|
|
// This pseudo-destructor expression is still a pseudo-destructor.
|
2010-08-24 03:25:46 +04:00
|
|
|
return SemaRef.BuildPseudoDestructorExpr(Base, OperatorLoc,
|
2010-02-25 02:40:28 +03:00
|
|
|
isArrow? tok::arrow : tok::period,
|
2010-02-25 02:50:37 +03:00
|
|
|
SS, ScopeType, CCLoc, TildeLoc,
|
2010-02-25 04:56:36 +03:00
|
|
|
Destroyed,
|
2010-02-25 02:40:28 +03:00
|
|
|
/*FIXME?*/true);
|
|
|
|
}
|
2010-08-12 02:01:17 +04:00
|
|
|
|
2010-02-25 04:56:36 +03:00
|
|
|
TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
|
|
|
|
SemaRef.Context.getCanonicalType(DestroyedType->getType())));
|
|
|
|
DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
|
|
|
|
NameInfo.setNamedTypeInfo(DestroyedType);
|
|
|
|
|
2010-02-25 02:40:28 +03:00
|
|
|
// FIXME: the ScopeType should be tacked onto SS.
|
2010-08-12 02:01:17 +04:00
|
|
|
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base, BaseType,
|
2010-02-25 02:40:28 +03:00
|
|
|
OperatorLoc, isArrow,
|
|
|
|
SS, /*FIXME: FirstQualifier*/ 0,
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo,
|
2010-02-25 02:40:28 +03:00
|
|
|
/*TemplateArgs*/ 0);
|
|
|
|
}
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif // LLVM_CLANG_SEMA_TREETRANSFORM_H
|