2011-02-17 23:34:02 +03: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.
|
2011-02-17 23:34:02 +03:00
|
|
|
//===----------------------------------------------------------------------===//
|
2009-08-04 20:50:30 +04:00
|
|
|
//
|
|
|
|
// This file implements a semantic tree transformation that takes a given
|
|
|
|
// AST and rebuilds it, possibly transforming some nodes in the process.
|
|
|
|
//
|
2011-02-17 23:34:02 +03:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
#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"
|
2010-12-21 01:05:00 +03:00
|
|
|
#include "clang/Sema/ParsedTemplate.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"
|
2011-05-06 01:57:07 +04:00
|
|
|
#include "clang/AST/DeclTemplate.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"
|
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"
|
2011-09-22 06:34:54 +04:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2009-10-21 04:40:46 +04:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2010-12-02 03:05:49 +03:00
|
|
|
#include "TypeLocBuilder.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(),
|
2011-03-02 21:50:38 +03:00
|
|
|
/// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
|
2009-08-04 20:50:30 +04:00
|
|
|
/// 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 {
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
/// \brief Private RAII object that helps us forget and then re-remember
|
|
|
|
/// the template argument corresponding to a partially-substituted parameter
|
|
|
|
/// pack.
|
|
|
|
class ForgetPartiallySubstitutedPackRAII {
|
|
|
|
Derived &Self;
|
|
|
|
TemplateArgument Old;
|
|
|
|
|
|
|
|
public:
|
|
|
|
ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
|
|
|
|
Old = Self.ForgetPartiallySubstitutedPack();
|
|
|
|
}
|
|
|
|
|
|
|
|
~ForgetPartiallySubstitutedPackRAII() {
|
|
|
|
Self.RememberPartiallySubstitutedPack(Old);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
protected:
|
|
|
|
Sema &SemaRef;
|
2010-12-21 01:05:00 +03:00
|
|
|
|
2009-09-09 19:08:12 +04:00
|
|
|
public:
|
2009-08-04 20:50:30 +04:00
|
|
|
/// \brief Initializes a new tree transformer.
|
2010-12-21 03:52:54 +03:00
|
|
|
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();
|
2011-01-25 20:51:48 +03:00
|
|
|
|
|
|
|
if (Location.isValid())
|
|
|
|
Self.getDerived().setBase(Location, Entity);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
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
|
|
|
|
2010-12-21 01:05:00 +03:00
|
|
|
/// \brief Determine whether we should expand a pack expansion with the
|
|
|
|
/// given set of parameter packs into separate arguments by repeatedly
|
|
|
|
/// transforming the pattern.
|
|
|
|
///
|
2010-12-21 03:52:54 +03:00
|
|
|
/// By default, the transformer never tries to expand pack expansions.
|
2010-12-21 01:05:00 +03:00
|
|
|
/// Subclasses can override this routine to provide different behavior.
|
|
|
|
///
|
|
|
|
/// \param EllipsisLoc The location of the ellipsis that identifies the
|
|
|
|
/// pack expansion.
|
|
|
|
///
|
|
|
|
/// \param PatternRange The source range that covers the entire pattern of
|
|
|
|
/// the pack expansion.
|
|
|
|
///
|
|
|
|
/// \param Unexpanded The set of unexpanded parameter packs within the
|
|
|
|
/// pattern.
|
|
|
|
///
|
|
|
|
/// \param NumUnexpanded The number of unexpanded parameter packs in
|
|
|
|
/// \p Unexpanded.
|
|
|
|
///
|
|
|
|
/// \param ShouldExpand Will be set to \c true if the transformer should
|
|
|
|
/// expand the corresponding pack expansions into separate arguments. When
|
|
|
|
/// set, \c NumExpansions must also be set.
|
|
|
|
///
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
/// \param RetainExpansion Whether the caller should add an unexpanded
|
|
|
|
/// pack expansion after all of the expanded arguments. This is used
|
|
|
|
/// when extending explicitly-specified template argument packs per
|
|
|
|
/// C++0x [temp.arg.explicit]p9.
|
|
|
|
///
|
2010-12-21 01:05:00 +03:00
|
|
|
/// \param NumExpansions The number of separate arguments that will be in
|
2011-01-14 20:04:44 +03:00
|
|
|
/// the expanded form of the corresponding pack expansion. This is both an
|
|
|
|
/// input and an output parameter, which can be set by the caller if the
|
|
|
|
/// number of expansions is known a priori (e.g., due to a prior substitution)
|
|
|
|
/// and will be set by the callee when the number of expansions is known.
|
|
|
|
/// The callee must set this value when \c ShouldExpand is \c true; it may
|
|
|
|
/// set this value in other cases.
|
2010-12-21 01:05:00 +03:00
|
|
|
///
|
|
|
|
/// \returns true if an error occurred (e.g., because the parameter packs
|
|
|
|
/// are to be instantiated with arguments of different lengths), false
|
|
|
|
/// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
|
|
|
|
/// must be set.
|
|
|
|
bool TryExpandParameterPacks(SourceLocation EllipsisLoc,
|
|
|
|
SourceRange PatternRange,
|
2011-09-22 06:34:54 +04:00
|
|
|
llvm::ArrayRef<UnexpandedParameterPack> Unexpanded,
|
2010-12-21 01:05:00 +03:00
|
|
|
bool &ShouldExpand,
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
bool &RetainExpansion,
|
2011-01-14 20:04:44 +03:00
|
|
|
llvm::Optional<unsigned> &NumExpansions) {
|
2010-12-21 01:05:00 +03:00
|
|
|
ShouldExpand = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
/// \brief "Forget" about the partially-substituted pack template argument,
|
|
|
|
/// when performing an instantiation that must preserve the parameter pack
|
|
|
|
/// use.
|
|
|
|
///
|
|
|
|
/// This routine is meant to be overridden by the template instantiator.
|
|
|
|
TemplateArgument ForgetPartiallySubstitutedPack() {
|
|
|
|
return TemplateArgument();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief "Remember" the partially-substituted pack template argument
|
|
|
|
/// after performing an instantiation that must preserve the parameter pack
|
|
|
|
/// use.
|
|
|
|
///
|
|
|
|
/// This routine is meant to be overridden by the template instantiator.
|
|
|
|
void RememberPartiallySubstitutedPack(TemplateArgument Arg) { }
|
|
|
|
|
Implement substitution of a function parameter pack for its set of
instantiated function parameters, enabling instantiation of arbitrary
pack expansions involving function parameter packs. At this point, we
can now correctly compile a simple, variadic print() example:
#include <iostream>
#include <string>
void print() {}
template<typename Head, typename ...Tail>
void print(const Head &head, const Tail &...tail) {
std::cout << head;
print(tail...);
}
int main() {
std::string hello = "Hello";
print(hello, ", world!", " ", 2011, '\n');
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123000 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 19:43:16 +03:00
|
|
|
/// \brief Note to the derived class when a function parameter pack is
|
|
|
|
/// being expanded.
|
|
|
|
void ExpandingFunctionParameterPack(ParmVarDecl *Pack) { }
|
|
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
QualType TransformType(QualType T);
|
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-11-12 11:19:04 +03:00
|
|
|
TypeSourceInfo *TransformType(TypeSourceInfo *DI);
|
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-11-12 11:19:04 +03:00
|
|
|
QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL);
|
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
|
|
|
|
2011-01-03 22:04:46 +03:00
|
|
|
/// \brief Transform the given list of expressions.
|
|
|
|
///
|
|
|
|
/// This routine transforms a list of expressions by invoking
|
|
|
|
/// \c TransformExpr() for each subexpression. However, it also provides
|
|
|
|
/// support for variadic templates by expanding any pack expansions (if the
|
|
|
|
/// derived class permits such expansion) along the way. When pack expansions
|
|
|
|
/// are present, the number of outputs may not equal the number of inputs.
|
|
|
|
///
|
|
|
|
/// \param Inputs The set of expressions to be transformed.
|
|
|
|
///
|
|
|
|
/// \param NumInputs The number of expressions in \c Inputs.
|
|
|
|
///
|
|
|
|
/// \param IsCall If \c true, then this transform is being performed on
|
|
|
|
/// function-call arguments, and any arguments that should be dropped, will
|
|
|
|
/// be.
|
|
|
|
///
|
|
|
|
/// \param Outputs The transformed input expressions will be added to this
|
|
|
|
/// vector.
|
|
|
|
///
|
|
|
|
/// \param ArgChanged If non-NULL, will be set \c true if any argument changed
|
|
|
|
/// due to transformation.
|
|
|
|
///
|
|
|
|
/// \returns true if an error occurred, false otherwise.
|
|
|
|
bool TransformExprs(Expr **Inputs, unsigned NumInputs, bool IsCall,
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVectorImpl<Expr *> &Outputs,
|
2011-01-03 22:04:46 +03:00
|
|
|
bool *ArgChanged = 0);
|
|
|
|
|
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
|
|
|
|
2011-02-25 05:25:35 +03:00
|
|
|
/// \brief Transform the given nested-name-specifier with source-location
|
|
|
|
/// information.
|
|
|
|
///
|
|
|
|
/// By default, transforms all of the types and declarations within the
|
|
|
|
/// nested-name-specifier. Subclasses may override this function to provide
|
|
|
|
/// alternate behavior.
|
|
|
|
NestedNameSpecifierLoc TransformNestedNameSpecifierLoc(
|
|
|
|
NestedNameSpecifierLoc NNS,
|
|
|
|
QualType ObjectType = QualType(),
|
|
|
|
NamedDecl *FirstQualifierInScope = 0);
|
|
|
|
|
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
|
2010-11-12 11:19:04 +03:00
|
|
|
TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-03-02 21:07:45 +03:00
|
|
|
/// \brief Transform the given template name.
|
|
|
|
///
|
|
|
|
/// \param SS The nested-name-specifier that qualifies the template
|
|
|
|
/// name. This nested-name-specifier must already have been transformed.
|
|
|
|
///
|
|
|
|
/// \param Name The template name to transform.
|
|
|
|
///
|
|
|
|
/// \param NameLoc The source location of the template name.
|
|
|
|
///
|
|
|
|
/// \param ObjectType If we're translating a template name within a member
|
|
|
|
/// access expression, this is the type of the object whose member template
|
|
|
|
/// is being referenced.
|
|
|
|
///
|
|
|
|
/// \param FirstQualifierInScope If the first part of a nested-name-specifier
|
|
|
|
/// also refers to a name within the current (lexical) scope, this is the
|
|
|
|
/// declaration it refers to.
|
|
|
|
///
|
|
|
|
/// By default, transforms the template name by transforming the declarations
|
|
|
|
/// and nested-name-specifiers that occur within the template name.
|
|
|
|
/// Subclasses may override this function to provide alternate behavior.
|
|
|
|
TemplateName TransformTemplateName(CXXScopeSpec &SS,
|
|
|
|
TemplateName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
QualType ObjectType = QualType(),
|
|
|
|
NamedDecl *FirstQualifierInScope = 0);
|
|
|
|
|
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);
|
|
|
|
|
2010-12-20 20:31:10 +03:00
|
|
|
/// \brief Transform the given set of template arguments.
|
|
|
|
///
|
|
|
|
/// By default, this operation transforms all of the template arguments
|
|
|
|
/// in the input set using \c TransformTemplateArgument(), and appends
|
|
|
|
/// the transformed arguments to the output list.
|
|
|
|
///
|
2010-12-21 02:36:19 +03:00
|
|
|
/// Note that this overload of \c TransformTemplateArguments() is merely
|
|
|
|
/// a convenience function. Subclasses that wish to override this behavior
|
|
|
|
/// should override the iterator-based member template version.
|
|
|
|
///
|
2010-12-20 20:31:10 +03:00
|
|
|
/// \param Inputs The set of template arguments to be transformed.
|
|
|
|
///
|
|
|
|
/// \param NumInputs The number of template arguments in \p Inputs.
|
|
|
|
///
|
|
|
|
/// \param Outputs The set of transformed template arguments output by this
|
|
|
|
/// routine.
|
|
|
|
///
|
|
|
|
/// Returns true if an error occurred.
|
|
|
|
bool TransformTemplateArguments(const TemplateArgumentLoc *Inputs,
|
|
|
|
unsigned NumInputs,
|
2010-12-21 02:36:19 +03:00
|
|
|
TemplateArgumentListInfo &Outputs) {
|
|
|
|
return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs);
|
|
|
|
}
|
2010-12-20 20:42:22 +03:00
|
|
|
|
|
|
|
/// \brief Transform the given set of template arguments.
|
|
|
|
///
|
|
|
|
/// By default, this operation transforms all of the template arguments
|
|
|
|
/// in the input set using \c TransformTemplateArgument(), and appends
|
|
|
|
/// the transformed arguments to the output list.
|
|
|
|
///
|
2010-12-21 02:36:19 +03:00
|
|
|
/// \param First An iterator to the first template argument.
|
|
|
|
///
|
|
|
|
/// \param Last An iterator one step past the last template argument.
|
2010-12-20 20:42:22 +03:00
|
|
|
///
|
|
|
|
/// \param Outputs The set of transformed template arguments output by this
|
|
|
|
/// routine.
|
|
|
|
///
|
|
|
|
/// Returns true if an error occurred.
|
2010-12-21 02:36:19 +03:00
|
|
|
template<typename InputIterator>
|
|
|
|
bool TransformTemplateArguments(InputIterator First,
|
|
|
|
InputIterator Last,
|
|
|
|
TemplateArgumentListInfo &Outputs);
|
2010-12-20 20:42:22 +03:00
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
/// \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-11-12 11:19:04 +03:00
|
|
|
QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
|
2009-10-21 04:40:46 +04:00
|
|
|
#include "clang/AST/TypeLocNodes.def"
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2011-04-28 05:08:34 +04:00
|
|
|
StmtResult
|
|
|
|
TransformSEHHandler(Stmt *Handler);
|
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType
|
|
|
|
TransformTemplateSpecializationType(TypeLocBuilder &TLB,
|
|
|
|
TemplateSpecializationTypeLoc TL,
|
|
|
|
TemplateName Template);
|
|
|
|
|
2011-02-28 20:23:35 +03:00
|
|
|
QualType
|
|
|
|
TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
|
|
|
|
DependentTemplateSpecializationTypeLoc TL,
|
2011-03-04 21:53:13 +03:00
|
|
|
TemplateName Template,
|
|
|
|
CXXScopeSpec &SS);
|
2011-02-28 20:23:35 +03:00
|
|
|
|
2011-03-01 23:11:18 +03:00
|
|
|
QualType
|
|
|
|
TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
|
|
|
|
DependentTemplateSpecializationTypeLoc TL,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc);
|
|
|
|
|
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.
|
2011-01-07 03:20:55 +03:00
|
|
|
bool TransformFunctionTypeParams(SourceLocation Loc,
|
|
|
|
ParmVarDecl **Params, unsigned NumParams,
|
|
|
|
const QualType *ParamTypes,
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVectorImpl<QualType> &PTypes,
|
|
|
|
SmallVectorImpl<ParmVarDecl*> *PVars);
|
2010-03-11 12:03:00 +03:00
|
|
|
|
|
|
|
/// \brief Transforms a single function-type parameter. Return null
|
|
|
|
/// on error.
|
2011-05-02 02:35:37 +04:00
|
|
|
///
|
|
|
|
/// \param indexAdjustment - A number to add to the parameter's
|
|
|
|
/// scope index; can be negative
|
2011-01-15 01:40:04 +03:00
|
|
|
ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
|
2011-05-02 02:35:37 +04:00
|
|
|
int indexAdjustment,
|
2011-01-15 01:40:04 +03:00
|
|
|
llvm::Optional<unsigned> NumExpansions);
|
2010-03-11 12:03:00 +03:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL);
|
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-11-11 00:56:12 +03:00
|
|
|
VectorType::VectorKind VecKind);
|
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,
|
2011-01-26 08:01:58 +03:00
|
|
|
RefQualifierKind RefQualifier,
|
2010-08-05 06:54:05 +04:00
|
|
|
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.
|
2011-04-15 18:24:37 +04:00
|
|
|
QualType RebuildTypedefType(TypedefNameDecl *Typedef) {
|
2009-08-04 20:50:30 +04:00
|
|
|
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-10-12 04:20:44 +04:00
|
|
|
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc);
|
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);
|
|
|
|
|
2011-05-25 02:41:36 +04:00
|
|
|
/// \brief Build a new unary transform type.
|
|
|
|
QualType RebuildUnaryTransformType(QualType BaseType,
|
|
|
|
UnaryTransformType::UTTKind UKind,
|
|
|
|
SourceLocation Loc);
|
|
|
|
|
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-10-12 04:20:44 +04:00
|
|
|
QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-02-20 06:19:35 +03:00
|
|
|
/// \brief Build a new C++0x auto type.
|
|
|
|
///
|
|
|
|
/// By default, builds a new AutoType with the given deduced type.
|
|
|
|
QualType RebuildAutoType(QualType Deduced) {
|
|
|
|
return SemaRef.Context.getAutoType(Deduced);
|
|
|
|
}
|
|
|
|
|
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,
|
2011-03-03 05:41:12 +03:00
|
|
|
TemplateArgumentListInfo &Args);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-12-10 19:29:40 +03:00
|
|
|
/// \brief Build a new parenthesized type.
|
|
|
|
///
|
|
|
|
/// By default, builds a new ParenType type from the inner type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
QualType RebuildParenType(QualType InnerType) {
|
|
|
|
return SemaRef.Context.getParenType(InnerType);
|
|
|
|
}
|
|
|
|
|
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.
|
2010-11-04 22:04:38 +03:00
|
|
|
QualType RebuildElaboratedType(SourceLocation KeywordLoc,
|
|
|
|
ElaboratedTypeKeyword Keyword,
|
2011-03-01 21:12:44 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
|
|
|
QualType Named) {
|
|
|
|
return SemaRef.Context.getElaboratedType(Keyword,
|
|
|
|
QualifierLoc.getNestedNameSpecifier(),
|
|
|
|
Named);
|
2009-09-09 19:08:12 +04:00
|
|
|
}
|
2009-08-04 20:50:30 +04:00
|
|
|
|
2011-03-01 23:11:18 +03:00
|
|
|
/// \brief Build a new typename type that refers to a template-id.
|
|
|
|
///
|
|
|
|
/// 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.
|
|
|
|
QualType RebuildDependentTemplateSpecializationType(
|
|
|
|
ElaboratedTypeKeyword Keyword,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
|
|
|
const IdentifierInfo *Name,
|
|
|
|
SourceLocation NameLoc,
|
2011-03-03 05:41:12 +03:00
|
|
|
TemplateArgumentListInfo &Args) {
|
2011-03-01 23:11:18 +03:00
|
|
|
// Rebuild the template name.
|
|
|
|
// TODO: avoid TemplateName abstraction
|
2011-03-02 21:07:45 +03:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.Adopt(QualifierLoc);
|
2011-03-01 23:11:18 +03:00
|
|
|
TemplateName InstName
|
2011-03-02 21:07:45 +03:00
|
|
|
= getDerived().RebuildTemplateName(SS, *Name, NameLoc, QualType(), 0);
|
2011-03-01 23:11:18 +03:00
|
|
|
|
|
|
|
if (InstName.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
// If it's still dependent, make a dependent specialization.
|
|
|
|
if (InstName.getAsDependentTemplateName())
|
|
|
|
return SemaRef.Context.getDependentTemplateSpecializationType(Keyword,
|
|
|
|
QualifierLoc.getNestedNameSpecifier(),
|
|
|
|
Name,
|
|
|
|
Args);
|
|
|
|
|
|
|
|
// Otherwise, make an elaborated type wrapping a non-dependent
|
|
|
|
// specialization.
|
|
|
|
QualType T =
|
|
|
|
getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
|
|
|
|
if (T.isNull()) return QualType();
|
|
|
|
|
|
|
|
if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == 0)
|
|
|
|
return T;
|
|
|
|
|
|
|
|
return SemaRef.Context.getElaboratedType(Keyword,
|
|
|
|
QualifierLoc.getNestedNameSpecifier(),
|
|
|
|
T);
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
SourceLocation KeywordLoc,
|
2011-03-01 04:34:45 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
|
|
|
const IdentifierInfo *Id,
|
2010-05-20 01:37:53 +04:00
|
|
|
SourceLocation IdLoc) {
|
2010-04-01 02:19:08 +04:00
|
|
|
CXXScopeSpec SS;
|
2011-03-01 04:34:45 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
2010-05-20 01:37:53 +04:00
|
|
|
|
2011-03-01 04:34:45 +03:00
|
|
|
if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
|
2010-04-01 02:19:08 +04:00
|
|
|
// If the name is still dependent, just build a new dependent name type.
|
|
|
|
if (!SemaRef.computeDeclContext(SS))
|
2011-03-01 04:34:45 +03:00
|
|
|
return SemaRef.Context.getDependentNameType(Keyword,
|
|
|
|
QualifierLoc.getNestedNameSpecifier(),
|
|
|
|
Id);
|
2010-04-01 02:19:08 +04:00
|
|
|
}
|
|
|
|
|
2010-05-12 01:36:43 +04:00
|
|
|
if (Keyword == ETK_None || Keyword == ETK_Typename)
|
2011-03-01 04:34:45 +03:00
|
|
|
return SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
|
2011-03-01 01:42:13 +03:00
|
|
|
*Id, 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) {
|
2011-01-24 22:01:04 +03:00
|
|
|
// Check where the name exists but isn't a tag type and use that to emit
|
|
|
|
// better diagnostics.
|
|
|
|
LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
|
|
|
|
SemaRef.LookupQualifiedName(Result, DC);
|
|
|
|
switch (Result.getResultKind()) {
|
|
|
|
case LookupResult::Found:
|
|
|
|
case LookupResult::FoundOverloaded:
|
|
|
|
case LookupResult::FoundUnresolvedValue: {
|
2011-05-06 01:57:07 +04:00
|
|
|
NamedDecl *SomeDecl = Result.getRepresentativeDecl();
|
2011-01-24 22:01:04 +03:00
|
|
|
unsigned Kind = 0;
|
|
|
|
if (isa<TypedefDecl>(SomeDecl)) Kind = 1;
|
2011-04-15 18:24:37 +04:00
|
|
|
else if (isa<TypeAliasDecl>(SomeDecl)) Kind = 2;
|
|
|
|
else if (isa<ClassTemplateDecl>(SomeDecl)) Kind = 3;
|
2011-01-24 22:01:04 +03:00
|
|
|
SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << Kind;
|
|
|
|
SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
|
|
|
|
break;
|
2011-05-06 01:57:07 +04:00
|
|
|
}
|
2011-01-24 22:01:04 +03:00
|
|
|
default:
|
|
|
|
// FIXME: Would be nice to highlight just the source range.
|
|
|
|
SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
|
|
|
|
<< Kind << Id << DC;
|
|
|
|
break;
|
|
|
|
}
|
2010-04-01 02:19:08 +04:00
|
|
|
return QualType();
|
|
|
|
}
|
2010-05-12 01:36:43 +04:00
|
|
|
|
2011-06-10 07:11:26 +04:00
|
|
|
if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
|
|
|
|
IdLoc, *Id)) {
|
2010-05-20 01:37:53 +04:00
|
|
|
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);
|
2011-03-01 04:34:45 +03:00
|
|
|
return SemaRef.Context.getElaboratedType(Keyword,
|
|
|
|
QualifierLoc.getNestedNameSpecifier(),
|
|
|
|
T);
|
2009-08-06 09:28:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-01-12 20:07:58 +03:00
|
|
|
/// \brief Build a new pack expansion type.
|
|
|
|
///
|
|
|
|
/// By default, builds a new PackExpansionType type from the given pattern.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
QualType RebuildPackExpansionType(QualType Pattern,
|
|
|
|
SourceRange PatternRange,
|
2011-01-14 20:04:44 +03:00
|
|
|
SourceLocation EllipsisLoc,
|
|
|
|
llvm::Optional<unsigned> NumExpansions) {
|
|
|
|
return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
|
|
|
|
NumExpansions);
|
2011-01-12 20:07:58 +03:00
|
|
|
}
|
|
|
|
|
2011-10-07 03:00:33 +04:00
|
|
|
/// \brief Build a new atomic type given its value type.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis when building the atomic type.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc);
|
|
|
|
|
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.
|
2011-03-02 21:07:45 +03:00
|
|
|
TemplateName RebuildTemplateName(CXXScopeSpec &SS,
|
2009-08-06 10:41:21 +04:00
|
|
|
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.
|
2011-03-02 21:07:45 +03:00
|
|
|
TemplateName RebuildTemplateName(CXXScopeSpec &SS,
|
|
|
|
const IdentifierInfo &Name,
|
|
|
|
SourceLocation NameLoc,
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope);
|
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.
|
2011-03-02 21:07:45 +03:00
|
|
|
TemplateName RebuildTemplateName(CXXScopeSpec &SS,
|
2009-11-04 03:56:37 +03:00
|
|
|
OverloadedOperatorKind Operator,
|
2011-03-02 21:07:45 +03:00
|
|
|
SourceLocation NameLoc,
|
2009-11-04 03:56:37 +03:00
|
|
|
QualType ObjectType);
|
2011-01-15 09:45:20 +03:00
|
|
|
|
|
|
|
/// \brief Build a new template name given a template template parameter pack
|
|
|
|
/// and the
|
|
|
|
///
|
|
|
|
/// 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(TemplateTemplateParmDecl *Param,
|
|
|
|
const TemplateArgument &ArgPack) {
|
|
|
|
return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack);
|
|
|
|
}
|
|
|
|
|
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.
|
2011-02-17 23:34:02 +03:00
|
|
|
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L,
|
|
|
|
SourceLocation ColonLoc, Stmt *SubStmt) {
|
|
|
|
return SemaRef.ActOnLabelStmt(IdentLoc, L, 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,
|
2011-02-17 23:34:02 +03:00
|
|
|
VarDecl *CondVar, Stmt *Then,
|
|
|
|
SourceLocation ElseLoc, Stmt *Else) {
|
2010-11-20 05:04:01 +03:00
|
|
|
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,
|
2011-02-17 23:34:02 +03:00
|
|
|
Expr *Cond, VarDecl *CondVar) {
|
2010-08-24 03:25:46 +04:00
|
|
|
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,
|
2011-02-17 23:34:02 +03:00
|
|
|
Stmt *Switch, Stmt *Body) {
|
2010-08-24 03:25:46 +04:00
|
|
|
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.
|
2011-02-17 23:34:02 +03:00
|
|
|
StmtResult RebuildWhileStmt(SourceLocation WhileLoc, Sema::FullExprArg Cond,
|
|
|
|
VarDecl *CondVar, Stmt *Body) {
|
2010-08-24 03:25:46 +04:00
|
|
|
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,
|
2011-02-17 10:39:24 +03:00
|
|
|
SourceLocation WhileLoc, SourceLocation LParenLoc,
|
|
|
|
Expr *Cond, 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.
|
2011-02-17 10:39:24 +03:00
|
|
|
StmtResult RebuildForStmt(SourceLocation ForLoc, SourceLocation LParenLoc,
|
|
|
|
Stmt *Init, Sema::FullExprArg Cond,
|
|
|
|
VarDecl *CondVar, Sema::FullExprArg Inc,
|
|
|
|
SourceLocation RParenLoc, Stmt *Body) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
|
2011-02-17 10:39:24 +03:00
|
|
|
CondVar, 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.
|
2011-02-17 10:39:24 +03:00
|
|
|
StmtResult RebuildGotoStmt(SourceLocation GotoLoc, SourceLocation LabelLoc,
|
|
|
|
LabelDecl *Label) {
|
2011-02-17 23:34:02 +03:00
|
|
|
return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \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,
|
2011-02-17 10:39:24 +03:00
|
|
|
SourceLocation StarLoc,
|
|
|
|
Expr *Target) {
|
2010-08-24 03:25:46 +04:00
|
|
|
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.
|
2011-02-17 10:39:24 +03:00
|
|
|
StmtResult RebuildReturnStmt(SourceLocation ReturnLoc, Expr *Result) {
|
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) {
|
2011-02-23 03:37:57 +03:00
|
|
|
Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls, NumDecls);
|
|
|
|
return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
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) {
|
2011-03-08 11:55:46 +03:00
|
|
|
return getSema().BuildObjCExceptionDecl(TInfo, T,
|
|
|
|
ExceptionDecl->getInnerLocStart(),
|
|
|
|
ExceptionDecl->getLocation(),
|
|
|
|
ExceptionDecl->getIdentifier());
|
2010-04-26 21:57:08 +04:00
|
|
|
}
|
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
|
|
|
|
2011-07-28 01:50:02 +04:00
|
|
|
/// \brief Rebuild the operand to an Objective-C @synchronized statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildObjCAtSynchronizedOperand(SourceLocation atLoc,
|
|
|
|
Expr *object) {
|
|
|
|
return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
|
|
|
|
}
|
|
|
|
|
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,
|
2011-07-28 01:50:02 +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
|
|
|
|
2011-06-16 03:02:42 +04:00
|
|
|
/// \brief Build a new Objective-C @autoreleasepool statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc,
|
|
|
|
Stmt *Body) {
|
|
|
|
return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
|
|
|
|
}
|
2011-07-27 05:07:15 +04:00
|
|
|
|
|
|
|
/// \brief Build the collection operand to 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.
|
|
|
|
ExprResult RebuildObjCForCollectionOperand(SourceLocation forLoc,
|
|
|
|
Expr *collection) {
|
|
|
|
return getSema().ActOnObjCForCollectionOperand(forLoc, collection);
|
|
|
|
}
|
2011-06-16 03:02:42 +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-08-27 03:41:50 +04:00
|
|
|
SourceLocation LParenLoc,
|
|
|
|
Stmt *Element,
|
|
|
|
Expr *Collection,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
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.
|
2011-03-08 11:55:46 +03:00
|
|
|
VarDecl *RebuildExceptionDecl(VarDecl *ExceptionDecl,
|
2009-12-07 05:54:59 +03:00
|
|
|
TypeSourceInfo *Declarator,
|
2011-03-08 11:55:46 +03:00
|
|
|
SourceLocation StartLoc,
|
|
|
|
SourceLocation IdLoc,
|
|
|
|
IdentifierInfo *Id) {
|
2011-04-15 02:32:28 +04:00
|
|
|
VarDecl *Var = getSema().BuildExceptionDeclaration(0, Declarator,
|
|
|
|
StartLoc, IdLoc, Id);
|
|
|
|
if (Var)
|
|
|
|
getSema().CurContext->addDecl(Var);
|
|
|
|
return Var;
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \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,
|
2010-08-27 03:41:50 +04:00
|
|
|
VarDecl *ExceptionDecl,
|
|
|
|
Stmt *Handler) {
|
2010-08-24 03:25:46 +04:00
|
|
|
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-27 03:41:50 +04:00
|
|
|
Stmt *TryBlock,
|
|
|
|
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
|
|
|
|
2011-04-15 02:09:26 +04:00
|
|
|
/// \brief Build a new C++0x range-based for statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
StmtResult RebuildCXXForRangeStmt(SourceLocation ForLoc,
|
|
|
|
SourceLocation ColonLoc,
|
|
|
|
Stmt *Range, Stmt *BeginEnd,
|
|
|
|
Expr *Cond, Expr *Inc,
|
|
|
|
Stmt *LoopVar,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXForRangeStmt(ForLoc, ColonLoc, Range, BeginEnd,
|
|
|
|
Cond, Inc, LoopVar, RParenLoc);
|
|
|
|
}
|
2011-10-25 05:33:02 +04:00
|
|
|
|
|
|
|
/// \brief Build a new C++0x range-based for statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc,
|
|
|
|
bool IsIfExists,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
|
|
|
DeclarationNameInfo NameInfo,
|
|
|
|
Stmt *Nested) {
|
|
|
|
return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
|
|
|
|
QualifierLoc, NameInfo, Nested);
|
|
|
|
}
|
|
|
|
|
2011-04-15 02:09:26 +04:00
|
|
|
/// \brief Attach body to a C++0x range-based for statement.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to finish the new statement.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body) {
|
|
|
|
return getSema().FinishCXXForRangeStmt(ForRange, Body);
|
|
|
|
}
|
|
|
|
|
2011-04-28 05:08:34 +04:00
|
|
|
StmtResult RebuildSEHTryStmt(bool IsCXXTry,
|
|
|
|
SourceLocation TryLoc,
|
|
|
|
Stmt *TryBlock,
|
|
|
|
Stmt *Handler) {
|
|
|
|
return getSema().ActOnSEHTryBlock(IsCXXTry,TryLoc,TryBlock,Handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
StmtResult RebuildSEHExceptStmt(SourceLocation Loc,
|
|
|
|
Expr *FilterExpr,
|
|
|
|
Stmt *Block) {
|
|
|
|
return getSema().ActOnSEHExceptBlock(Loc,FilterExpr,Block);
|
|
|
|
}
|
|
|
|
|
|
|
|
StmtResult RebuildSEHFinallyStmt(SourceLocation Loc,
|
|
|
|
Stmt *Block) {
|
|
|
|
return getSema().ActOnSEHFinallyBlock(Loc,Block);
|
|
|
|
}
|
|
|
|
|
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,
|
2010-08-27 03:41:50 +04:00
|
|
|
LookupResult &R,
|
|
|
|
bool RequiresADL) {
|
2009-11-24 22:00:30 +03:00
|
|
|
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.
|
2011-03-01 00:54:11 +03:00
|
|
|
ExprResult RebuildDeclRefExpr(NestedNameSpecifierLoc QualifierLoc,
|
2010-08-27 03:41:50 +04:00
|
|
|
ValueDecl *VD,
|
|
|
|
const DeclarationNameInfo &NameInfo,
|
|
|
|
TemplateArgumentListInfo *TemplateArgs) {
|
2009-10-23 22:54:35 +04:00
|
|
|
CXXScopeSpec SS;
|
2011-03-01 00:54:11 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
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,
|
2011-02-25 21:19:59 +03:00
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
bool isArrow,
|
|
|
|
CXXScopeSpec &SS,
|
|
|
|
TypeSourceInfo *ScopeType,
|
|
|
|
SourceLocation CCLoc,
|
|
|
|
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,
|
2010-08-27 03:41:50 +04:00
|
|
|
Sema::OffsetOfComponent *Components,
|
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
|
|
|
unsigned NumComponents,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
|
|
|
|
NumComponents, RParenLoc);
|
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2011-03-11 22:24:49 +03:00
|
|
|
/// \brief Build a new sizeof, alignof or vec_step 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.
|
2011-03-11 22:24:49 +03:00
|
|
|
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo,
|
|
|
|
SourceLocation OpLoc,
|
|
|
|
UnaryExprOrTypeTrait ExprKind,
|
|
|
|
SourceRange R) {
|
|
|
|
return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2011-03-11 22:24:49 +03:00
|
|
|
/// \brief Build a new sizeof, alignof or vec step expression with an
|
|
|
|
/// expression 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.
|
2011-03-11 22:24:49 +03:00
|
|
|
ExprResult RebuildUnaryExprOrTypeTrait(Expr *SubExpr, SourceLocation OpLoc,
|
|
|
|
UnaryExprOrTypeTrait ExprKind,
|
|
|
|
SourceRange R) {
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult Result
|
2011-05-29 11:32:14 +04:00
|
|
|
= getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
|
2009-08-11 09:31:07 +04:00
|
|
|
if (Result.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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,
|
2011-02-10 00:07:24 +03:00
|
|
|
SourceLocation RParenLoc,
|
|
|
|
Expr *ExecConfig = 0) {
|
2010-08-24 03:25:46 +04:00
|
|
|
return getSema().ActOnCallExpr(/*Scope=*/0, Callee, LParenLoc,
|
2011-02-10 00:07:24 +03:00
|
|
|
move(Args), RParenLoc, ExecConfig);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \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,
|
2010-11-18 09:31:45 +03:00
|
|
|
bool isArrow,
|
2011-03-01 00:54:11 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
2010-11-18 09:31:45 +03:00
|
|
|
const DeclarationNameInfo &MemberNameInfo,
|
|
|
|
ValueDecl *Member,
|
|
|
|
NamedDecl *FoundDecl,
|
2009-11-23 04:53:49 +03:00
|
|
|
const TemplateArgumentListInfo *ExplicitTemplateArgs,
|
2010-11-18 09:31:45 +03:00
|
|
|
NamedDecl *FirstQualifierInScope) {
|
2011-10-26 23:06:56 +04:00
|
|
|
ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
|
|
|
|
isArrow);
|
2009-09-01 08:26:58 +04:00
|
|
|
if (!Member->getDeclName()) {
|
2010-11-18 09:31:45 +03:00
|
|
|
// We have a reference to an unnamed field. This is always the
|
|
|
|
// base of an anonymous struct/union member access, i.e. the
|
|
|
|
// field is always of record type.
|
2011-03-01 00:54:11 +03:00
|
|
|
assert(!QualifierLoc && "Can't have an unnamed field with a qualifier!");
|
2010-11-18 09:31:45 +03:00
|
|
|
assert(Member->getType()->isRecordType() &&
|
|
|
|
"unnamed member not of record type?");
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-10-26 23:06:56 +04:00
|
|
|
BaseResult =
|
|
|
|
getSema().PerformObjectMemberConversion(BaseResult.take(),
|
2011-04-08 22:41:53 +04:00
|
|
|
QualifierLoc.getNestedNameSpecifier(),
|
|
|
|
FoundDecl, Member);
|
|
|
|
if (BaseResult.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2011-04-08 22:41:53 +04:00
|
|
|
Base = BaseResult.take();
|
2010-11-18 09:31:45 +03:00
|
|
|
ExprValueKind VK = isArrow ? VK_LValue : Base->getValueKind();
|
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,
|
2010-11-18 09:31:45 +03:00
|
|
|
cast<FieldDecl>(Member)->getType(),
|
|
|
|
VK, OK_Ordinary);
|
2009-09-01 08:26:58 +04:00
|
|
|
return getSema().Owned(ME);
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-09-01 03:41:50 +04:00
|
|
|
CXXScopeSpec SS;
|
2011-03-01 00:54:11 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
2009-09-01 03:41:50 +04:00
|
|
|
|
2011-04-08 22:41:53 +04:00
|
|
|
Base = BaseResult.take();
|
2010-08-24 03:25:46 +04:00
|
|
|
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,
|
2011-02-17 13:25:35 +03:00
|
|
|
SourceLocation QuestionLoc,
|
|
|
|
Expr *LHS,
|
|
|
|
SourceLocation ColonLoc,
|
|
|
|
Expr *RHS) {
|
2010-08-24 03:25:46 +04:00
|
|
|
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,
|
2011-07-06 11:30:07 +04:00
|
|
|
MultiExprArg Inits,
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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,
|
2011-02-17 10:39:24 +03:00
|
|
|
SourceLocation LabelLoc, LabelDecl *Label) {
|
2011-02-17 23:34:02 +03:00
|
|
|
return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
|
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 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_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
|
|
|
|
2011-04-15 04:35:48 +04:00
|
|
|
/// \brief Build a new generic selection expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildGenericSelectionExpr(SourceLocation KeyLoc,
|
|
|
|
SourceLocation DefaultLoc,
|
|
|
|
SourceLocation RParenLoc,
|
|
|
|
Expr *ControllingExpr,
|
|
|
|
TypeSourceInfo **Types,
|
|
|
|
Expr **Exprs,
|
|
|
|
unsigned NumAssocs) {
|
|
|
|
return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
|
|
|
|
ControllingExpr, Types, Exprs,
|
|
|
|
NumAssocs);
|
|
|
|
}
|
|
|
|
|
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:
|
2011-09-23 09:06:16 +04:00
|
|
|
llvm_unreachable("Invalid C++ named cast");
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
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++ 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-09-08 04:15:04 +04:00
|
|
|
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
Expr *Sub,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
|
2010-08-27 03:41:50 +04:00
|
|
|
MultiExprArg(&Sub, 1),
|
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
|
|
|
|
2010-09-08 16:20:18 +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
|
|
|
}
|
|
|
|
|
2010-09-08 16:20:18 +04:00
|
|
|
/// \brief Build a new C++ __uuidof(type) expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType,
|
|
|
|
SourceLocation TypeidLoc,
|
|
|
|
TypeSourceInfo *Operand,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
|
|
|
|
RParenLoc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Build a new C++ __uuidof(expr) expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildCXXUuidofExpr(QualType TypeInfoType,
|
|
|
|
SourceLocation TypeidLoc,
|
|
|
|
Expr *Operand,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXUuidof(TypeInfoType, TypeidLoc, Operand,
|
|
|
|
RParenLoc);
|
|
|
|
}
|
|
|
|
|
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-09-09 20:55:46 +04: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.
|
2011-07-07 02:04:06 +04:00
|
|
|
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub,
|
|
|
|
bool IsThrownVariableInScope) {
|
|
|
|
return getSema().BuildCXXThrow(ThrowLoc, Sub, IsThrownVariableInScope);
|
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-09-08 04:15:04 +04:00
|
|
|
ExprResult RebuildCXXScalarValueInitExpr(TypeSourceInfo *TSInfo,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc,
|
2009-09-09 19:08:12 +04:00
|
|
|
MultiExprArg(getSema(), 0, 0),
|
2010-09-08 04:15:04 +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++ "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,
|
2010-09-08 01:49:58 +04:00
|
|
|
bool UseGlobal,
|
|
|
|
SourceLocation PlacementLParen,
|
|
|
|
MultiExprArg PlacementArgs,
|
|
|
|
SourceLocation PlacementRParen,
|
|
|
|
SourceRange TypeIdParens,
|
|
|
|
QualType AllocatedType,
|
|
|
|
TypeSourceInfo *AllocatedTypeInfo,
|
|
|
|
Expr *ArraySize,
|
|
|
|
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,
|
2010-09-08 01:49:58 +04:00
|
|
|
AllocatedType,
|
|
|
|
AllocatedTypeInfo,
|
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,
|
2010-09-09 20:14:44 +04:00
|
|
|
SourceLocation StartLoc,
|
|
|
|
TypeSourceInfo *T,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildUnaryTypeTrait(Trait, StartLoc, T, RParenLoc);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
|
|
|
|
2010-12-07 03:08:36 +03:00
|
|
|
/// \brief Build a new binary type trait expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildBinaryTypeTrait(BinaryTypeTrait Trait,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
TypeSourceInfo *LhsT,
|
|
|
|
TypeSourceInfo *RhsT,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildBinaryTypeTrait(Trait, StartLoc, LhsT, RhsT, RParenLoc);
|
|
|
|
}
|
|
|
|
|
2011-04-28 04:16:57 +04:00
|
|
|
/// \brief Build a new array type trait expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildArrayTypeTrait(ArrayTypeTrait Trait,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
TypeSourceInfo *TSInfo,
|
|
|
|
Expr *DimExpr,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildArrayTypeTrait(Trait, StartLoc, TSInfo, DimExpr, RParenLoc);
|
|
|
|
}
|
|
|
|
|
2011-04-25 10:54:41 +04:00
|
|
|
/// \brief Build a new expression trait expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildExpressionTrait(ExpressionTrait Trait,
|
|
|
|
SourceLocation StartLoc,
|
|
|
|
Expr *Queried,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildExpressionTrait(Trait, StartLoc, Queried, RParenLoc);
|
|
|
|
}
|
|
|
|
|
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.
|
2011-02-25 23:49:16 +03:00
|
|
|
ExprResult RebuildDependentScopeDeclRefExpr(
|
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
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;
|
2011-02-25 23:49:16 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
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,
|
2011-10-05 11:56:41 +04:00
|
|
|
SourceLocation Loc,
|
|
|
|
CXXConstructorDecl *Constructor,
|
|
|
|
bool IsElidable,
|
|
|
|
MultiExprArg Args,
|
|
|
|
bool HadMultipleCandidates,
|
|
|
|
bool RequiresZeroInit,
|
2010-10-25 12:47:36 +04:00
|
|
|
CXXConstructExpr::ConstructionKind ConstructKind,
|
2011-10-05 11:56:41 +04:00
|
|
|
SourceRange ParenRange) {
|
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))
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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),
|
2011-10-05 11:56:41 +04:00
|
|
|
HadMultipleCandidates,
|
2010-10-25 12:47:36 +04:00
|
|
|
RequiresZeroInit, ConstructKind,
|
|
|
|
ParenRange);
|
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-09-08 04:15:04 +04:00
|
|
|
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXTypeConstructExpr(TSInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
LParenLoc,
|
|
|
|
move(Args),
|
|
|
|
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-09-08 04:15:04 +04:00
|
|
|
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo,
|
|
|
|
SourceLocation LParenLoc,
|
|
|
|
MultiExprArg Args,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
return getSema().BuildCXXTypeConstructExpr(TSInfo,
|
2009-08-11 09:31:07 +04:00
|
|
|
LParenLoc,
|
|
|
|
move(Args),
|
|
|
|
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,
|
2011-02-28 21:50:33 +03:00
|
|
|
QualType BaseType,
|
|
|
|
bool IsArrow,
|
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
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;
|
2011-02-28 21:50:33 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
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.
|
2011-10-26 23:06:56 +04:00
|
|
|
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType,
|
|
|
|
SourceLocation OperatorLoc,
|
|
|
|
bool IsArrow,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc,
|
|
|
|
NamedDecl *FirstQualifierInScope,
|
|
|
|
LookupResult &R,
|
2009-12-01 01:42:35 +03:00
|
|
|
const TemplateArgumentListInfo *TemplateArgs) {
|
2009-09-09 04:23:06 +04:00
|
|
|
CXXScopeSpec SS;
|
2011-02-28 23:01:57 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
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
|
|
|
|
2010-09-11 00:55:43 +04:00
|
|
|
/// \brief Build a new noexcept expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg) {
|
|
|
|
return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
|
|
|
|
}
|
|
|
|
|
2011-01-04 20:33:58 +03:00
|
|
|
/// \brief Build a new expression to compute the length of a parameter pack.
|
|
|
|
ExprResult RebuildSizeOfPackExpr(SourceLocation OperatorLoc, NamedDecl *Pack,
|
|
|
|
SourceLocation PackLoc,
|
|
|
|
SourceLocation RParenLoc,
|
2011-10-10 22:59:29 +04:00
|
|
|
llvm::Optional<unsigned> Length) {
|
|
|
|
if (Length)
|
|
|
|
return new (SemaRef.Context) SizeOfPackExpr(SemaRef.Context.getSizeType(),
|
|
|
|
OperatorLoc, Pack, PackLoc,
|
|
|
|
RParenLoc, *Length);
|
|
|
|
|
2011-01-04 20:33:58 +03:00
|
|
|
return new (SemaRef.Context) SizeOfPackExpr(SemaRef.Context.getSizeType(),
|
|
|
|
OperatorLoc, Pack, PackLoc,
|
2011-10-10 22:59:29 +04:00
|
|
|
RParenLoc);
|
2011-01-04 20:33:58 +03: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,
|
2011-10-03 10:36:51 +04:00
|
|
|
ArrayRef<SourceLocation> SelectorLocs,
|
2010-04-22 20:44:27 +04:00
|
|
|
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(),
|
2011-10-03 10:36:51 +04:00
|
|
|
Sel, Method, LBracLoc, SelectorLocs,
|
2010-12-10 23:08:27 +03:00
|
|
|
RBracLoc, move(Args));
|
2010-04-22 20:44:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \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,
|
2011-10-03 10:36:51 +04:00
|
|
|
ArrayRef<SourceLocation> SelectorLocs,
|
2010-04-22 20:44:27 +04:00
|
|
|
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(),
|
2011-10-03 10:36:51 +04:00
|
|
|
Sel, Method, LBracLoc, SelectorLocs,
|
2010-12-10 23:08:27 +03:00
|
|
|
RBracLoc, move(Args));
|
2010-04-22 20:44:27 +04:00
|
|
|
}
|
|
|
|
|
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;
|
2011-04-08 22:41:53 +04:00
|
|
|
ExprResult Base = getSema().Owned(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);
|
2011-04-08 22:41:53 +04:00
|
|
|
if (Result.isInvalid() || Base.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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
|
|
|
|
2011-04-08 22:41:53 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base.get(), Base.get()->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,
|
2011-10-25 21:37:35 +04:00
|
|
|
ObjCPropertyDecl *Property,
|
|
|
|
SourceLocation PropertyLoc) {
|
2010-04-27 00:47:02 +04:00
|
|
|
CXXScopeSpec SS;
|
2011-04-08 22:41:53 +04:00
|
|
|
ExprResult Base = getSema().Owned(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);
|
2011-04-08 22:41:53 +04:00
|
|
|
if (Result.isInvalid() || Base.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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
|
|
|
|
2011-04-08 22:41:53 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base.get(), Base.get()->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
|
|
|
|
2010-12-02 04:19:52 +03:00
|
|
|
/// \brief Build a new Objective-C property reference expression.
|
2010-04-27 01:04:54 +04:00
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
2010-12-02 04:19:52 +03:00
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildObjCPropertyRefExpr(Expr *Base, QualType T,
|
|
|
|
ObjCMethodDecl *Getter,
|
|
|
|
ObjCMethodDecl *Setter,
|
|
|
|
SourceLocation PropertyLoc) {
|
|
|
|
// Since these expressions can only be value-dependent, we do not
|
|
|
|
// need to perform semantic analysis again.
|
|
|
|
return Owned(
|
|
|
|
new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
|
|
|
|
VK_LValue, OK_ObjCProperty,
|
|
|
|
PropertyLoc, 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;
|
2011-04-08 22:41:53 +04:00
|
|
|
ExprResult Base = getSema().Owned(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);
|
2011-04-08 22:41:53 +04:00
|
|
|
if (Result.isInvalid() || Base.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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
|
|
|
|
2011-04-08 22:41:53 +04:00
|
|
|
return getSema().BuildMemberReferenceExpr(Base.get(), Base.get()->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,
|
2010-11-18 09:31:45 +03:00
|
|
|
MultiExprArg SubExprs,
|
|
|
|
SourceLocation RParenLoc) {
|
2009-08-11 09:31:07 +04:00
|
|
|
// 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);
|
2011-04-08 22:41:53 +04:00
|
|
|
ExprResult Callee
|
|
|
|
= SemaRef.Owned(new (SemaRef.Context) DeclRefExpr(Builtin, Builtin->getType(),
|
|
|
|
VK_LValue, BuiltinLoc));
|
|
|
|
Callee = SemaRef.UsualUnaryConversions(Callee.take());
|
|
|
|
if (Callee.isInvalid())
|
|
|
|
return ExprError();
|
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();
|
2011-04-08 22:41:53 +04:00
|
|
|
ExprResult TheCall = SemaRef.Owned(
|
|
|
|
new (SemaRef.Context) CallExpr(SemaRef.Context, Callee.take(),
|
2009-08-11 09:31:07 +04:00
|
|
|
Subs, NumSubExprs,
|
2010-07-13 12:18:22 +04:00
|
|
|
Builtin->getCallResultType(),
|
2010-11-18 09:31:45 +03:00
|
|
|
Expr::getValueKindForType(Builtin->getResultType()),
|
2011-04-08 22:41:53 +04:00
|
|
|
RParenLoc));
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// Type-check the __builtin_shufflevector expression.
|
2011-04-08 22:41:53 +04:00
|
|
|
return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.take()));
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2010-11-12 11:19:04 +03:00
|
|
|
|
2010-12-21 01:05:00 +03:00
|
|
|
/// \brief Build a new template argument pack expansion.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build a new pack expansion
|
|
|
|
/// for a template argument. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
|
|
|
TemplateArgumentLoc RebuildPackExpansion(TemplateArgumentLoc Pattern,
|
2011-01-14 20:04:44 +03:00
|
|
|
SourceLocation EllipsisLoc,
|
|
|
|
llvm::Optional<unsigned> NumExpansions) {
|
2010-12-21 01:05:00 +03:00
|
|
|
switch (Pattern.getArgument().getKind()) {
|
2011-01-04 00:37:45 +03:00
|
|
|
case TemplateArgument::Expression: {
|
|
|
|
ExprResult Result
|
2011-01-15 00:20:45 +03:00
|
|
|
= getSema().CheckPackExpansion(Pattern.getSourceExpression(),
|
|
|
|
EllipsisLoc, NumExpansions);
|
2011-01-04 00:37:45 +03:00
|
|
|
if (Result.isInvalid())
|
|
|
|
return TemplateArgumentLoc();
|
|
|
|
|
|
|
|
return TemplateArgumentLoc(Result.get(), Result.get());
|
|
|
|
}
|
2011-01-03 22:31:53 +03:00
|
|
|
|
2010-12-21 01:05:00 +03:00
|
|
|
case TemplateArgument::Template:
|
2011-01-05 21:58:31 +03:00
|
|
|
return TemplateArgumentLoc(TemplateArgument(
|
|
|
|
Pattern.getArgument().getAsTemplate(),
|
2011-01-15 02:41:42 +03:00
|
|
|
NumExpansions),
|
2011-03-02 20:09:35 +03:00
|
|
|
Pattern.getTemplateQualifierLoc(),
|
2011-01-05 21:58:31 +03:00
|
|
|
Pattern.getTemplateNameLoc(),
|
|
|
|
EllipsisLoc);
|
2010-12-21 01:05:00 +03:00
|
|
|
|
|
|
|
case TemplateArgument::Null:
|
|
|
|
case TemplateArgument::Integral:
|
|
|
|
case TemplateArgument::Declaration:
|
|
|
|
case TemplateArgument::Pack:
|
2011-01-05 21:58:31 +03:00
|
|
|
case TemplateArgument::TemplateExpansion:
|
2010-12-21 01:05:00 +03:00
|
|
|
llvm_unreachable("Pack expansion pattern has no parameter packs");
|
|
|
|
|
|
|
|
case TemplateArgument::Type:
|
|
|
|
if (TypeSourceInfo *Expansion
|
|
|
|
= getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
|
2011-01-14 20:04:44 +03:00
|
|
|
EllipsisLoc,
|
|
|
|
NumExpansions))
|
2010-12-21 01:05:00 +03:00
|
|
|
return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
|
|
|
|
Expansion);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TemplateArgumentLoc();
|
|
|
|
}
|
|
|
|
|
2011-01-03 22:31:53 +03:00
|
|
|
/// \brief Build a new expression pack expansion.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build a new pack expansion
|
|
|
|
/// for an expression. Subclasses may override this routine to provide
|
|
|
|
/// different behavior.
|
2011-01-15 00:20:45 +03:00
|
|
|
ExprResult RebuildPackExpansion(Expr *Pattern, SourceLocation EllipsisLoc,
|
|
|
|
llvm::Optional<unsigned> NumExpansions) {
|
|
|
|
return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
|
2011-01-03 22:31:53 +03:00
|
|
|
}
|
2011-10-15 02:48:56 +04:00
|
|
|
|
|
|
|
/// \brief Build a new atomic operation expression.
|
|
|
|
///
|
|
|
|
/// By default, performs semantic analysis to build the new expression.
|
|
|
|
/// Subclasses may override this routine to provide different behavior.
|
|
|
|
ExprResult RebuildAtomicExpr(SourceLocation BuiltinLoc,
|
|
|
|
MultiExprArg SubExprs,
|
|
|
|
QualType RetTy,
|
|
|
|
AtomicExpr::AtomicOp Op,
|
|
|
|
SourceLocation RParenLoc) {
|
|
|
|
// Just create the expression; there is not any interesting semantic
|
|
|
|
// analysis here because we can't actually build an AtomicExpr until
|
|
|
|
// we are sure it is semantically sound.
|
|
|
|
unsigned NumSubExprs = SubExprs.size();
|
|
|
|
Expr **Subs = (Expr **)SubExprs.release();
|
|
|
|
return new (SemaRef.Context) AtomicExpr(BuiltinLoc, Subs,
|
|
|
|
NumSubExprs, RetTy, Op,
|
|
|
|
RParenLoc);
|
|
|
|
}
|
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
private:
|
2011-02-25 05:25:35 +03:00
|
|
|
TypeLoc TransformTypeInObjectScope(TypeLoc TL,
|
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope,
|
|
|
|
CXXScopeSpec &SS);
|
2011-03-02 21:32:08 +03:00
|
|
|
|
|
|
|
TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
|
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope,
|
|
|
|
CXXScopeSpec &SS);
|
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));
|
2011-02-09 11:16:59 +03:00
|
|
|
#define ABSTRACT_STMT(Node)
|
2009-08-20 11:17:43 +04:00
|
|
|
#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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-08-07 02:17:10 +04:00
|
|
|
}
|
|
|
|
|
2011-01-03 22:04:46 +03:00
|
|
|
template<typename Derived>
|
|
|
|
bool TreeTransform<Derived>::TransformExprs(Expr **Inputs,
|
|
|
|
unsigned NumInputs,
|
|
|
|
bool IsCall,
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVectorImpl<Expr *> &Outputs,
|
2011-01-03 22:04:46 +03:00
|
|
|
bool *ArgChanged) {
|
|
|
|
for (unsigned I = 0; I != NumInputs; ++I) {
|
|
|
|
// If requested, drop call arguments that need to be dropped.
|
|
|
|
if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
|
|
|
|
if (ArgChanged)
|
|
|
|
*ArgChanged = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-01-03 22:31:53 +03:00
|
|
|
if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
|
|
|
|
Expr *Pattern = Expansion->getPattern();
|
|
|
|
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
|
2011-01-03 22:31:53 +03:00
|
|
|
getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
|
|
|
|
assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
|
|
|
|
|
|
|
|
// Determine whether the set of unexpanded parameter packs can and should
|
|
|
|
// be expanded.
|
|
|
|
bool Expand = true;
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
bool RetainExpansion = false;
|
2011-01-15 00:20:45 +03:00
|
|
|
llvm::Optional<unsigned> OrigNumExpansions
|
|
|
|
= Expansion->getNumExpansions();
|
|
|
|
llvm::Optional<unsigned> NumExpansions = OrigNumExpansions;
|
2011-01-03 22:31:53 +03:00
|
|
|
if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
|
|
|
|
Pattern->getSourceRange(),
|
2011-09-22 06:34:54 +04:00
|
|
|
Unexpanded,
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
Expand, RetainExpansion,
|
|
|
|
NumExpansions))
|
2011-01-03 22:31:53 +03:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!Expand) {
|
|
|
|
// The transform has determined that we should perform a simple
|
|
|
|
// transformation on the pack expansion, producing another pack
|
|
|
|
// expansion.
|
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
|
|
|
|
ExprResult OutPattern = getDerived().TransformExpr(Pattern);
|
|
|
|
if (OutPattern.isInvalid())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
|
2011-01-15 00:20:45 +03:00
|
|
|
Expansion->getEllipsisLoc(),
|
|
|
|
NumExpansions);
|
2011-01-03 22:31:53 +03:00
|
|
|
if (Out.isInvalid())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (ArgChanged)
|
|
|
|
*ArgChanged = true;
|
|
|
|
Outputs.push_back(Out.get());
|
|
|
|
continue;
|
|
|
|
}
|
2011-07-06 11:30:07 +04:00
|
|
|
|
|
|
|
// Record right away that the argument was changed. This needs
|
|
|
|
// to happen even if the array expands to nothing.
|
|
|
|
if (ArgChanged) *ArgChanged = true;
|
2011-01-03 22:31:53 +03:00
|
|
|
|
|
|
|
// The transform has determined that we should perform an elementwise
|
|
|
|
// expansion of the pattern. Do so.
|
2011-01-14 20:04:44 +03:00
|
|
|
for (unsigned I = 0; I != *NumExpansions; ++I) {
|
2011-01-03 22:31:53 +03:00
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
|
|
|
|
ExprResult Out = getDerived().TransformExpr(Pattern);
|
|
|
|
if (Out.isInvalid())
|
|
|
|
return true;
|
|
|
|
|
2011-01-12 01:21:24 +03:00
|
|
|
if (Out.get()->containsUnexpandedParameterPack()) {
|
2011-01-15 00:20:45 +03:00
|
|
|
Out = RebuildPackExpansion(Out.get(), Expansion->getEllipsisLoc(),
|
|
|
|
OrigNumExpansions);
|
2011-01-12 01:21:24 +03:00
|
|
|
if (Out.isInvalid())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-01-03 22:31:53 +03:00
|
|
|
Outputs.push_back(Out.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-01-03 22:04:46 +03:00
|
|
|
ExprResult Result = getDerived().TransformExpr(Inputs[I]);
|
|
|
|
if (Result.isInvalid())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (Result.get() != Inputs[I] && ArgChanged)
|
|
|
|
*ArgChanged = true;
|
|
|
|
|
|
|
|
Outputs.push_back(Result.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-02-25 05:25:35 +03:00
|
|
|
template<typename Derived>
|
|
|
|
NestedNameSpecifierLoc
|
|
|
|
TreeTransform<Derived>::TransformNestedNameSpecifierLoc(
|
|
|
|
NestedNameSpecifierLoc NNS,
|
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope) {
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<NestedNameSpecifierLoc, 4> Qualifiers;
|
2011-02-25 05:25:35 +03:00
|
|
|
for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
|
|
|
|
Qualifier = Qualifier.getPrefix())
|
|
|
|
Qualifiers.push_back(Qualifier);
|
|
|
|
|
|
|
|
CXXScopeSpec SS;
|
|
|
|
while (!Qualifiers.empty()) {
|
|
|
|
NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
|
|
|
|
NestedNameSpecifier *QNNS = Q.getNestedNameSpecifier();
|
|
|
|
|
|
|
|
switch (QNNS->getKind()) {
|
|
|
|
case NestedNameSpecifier::Identifier:
|
|
|
|
if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/0,
|
|
|
|
*QNNS->getAsIdentifier(),
|
|
|
|
Q.getLocalBeginLoc(),
|
|
|
|
Q.getLocalEndLoc(),
|
|
|
|
ObjectType, false, SS,
|
|
|
|
FirstQualifierInScope, false))
|
|
|
|
return NestedNameSpecifierLoc();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NestedNameSpecifier::Namespace: {
|
|
|
|
NamespaceDecl *NS
|
|
|
|
= cast_or_null<NamespaceDecl>(
|
|
|
|
getDerived().TransformDecl(
|
|
|
|
Q.getLocalBeginLoc(),
|
|
|
|
QNNS->getAsNamespace()));
|
|
|
|
SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NestedNameSpecifier::NamespaceAlias: {
|
|
|
|
NamespaceAliasDecl *Alias
|
|
|
|
= cast_or_null<NamespaceAliasDecl>(
|
|
|
|
getDerived().TransformDecl(Q.getLocalBeginLoc(),
|
|
|
|
QNNS->getAsNamespaceAlias()));
|
|
|
|
SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
|
|
|
|
Q.getLocalEndLoc());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case NestedNameSpecifier::Global:
|
|
|
|
// There is no meaningful transformation that one could perform on the
|
|
|
|
// global scope.
|
|
|
|
SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NestedNameSpecifier::TypeSpecWithTemplate:
|
|
|
|
case NestedNameSpecifier::TypeSpec: {
|
|
|
|
TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
|
|
|
|
FirstQualifierInScope, SS);
|
|
|
|
|
|
|
|
if (!TL)
|
|
|
|
return NestedNameSpecifierLoc();
|
|
|
|
|
|
|
|
if (TL.getType()->isDependentType() || TL.getType()->isRecordType() ||
|
|
|
|
(SemaRef.getLangOptions().CPlusPlus0x &&
|
|
|
|
TL.getType()->isEnumeralType())) {
|
|
|
|
assert(!TL.getType().hasLocalQualifiers() &&
|
|
|
|
"Can't get cv-qualifiers here");
|
2011-10-20 07:28:47 +04:00
|
|
|
if (TL.getType()->isEnumeralType())
|
|
|
|
SemaRef.Diag(TL.getBeginLoc(),
|
|
|
|
diag::warn_cxx98_compat_enum_nested_name_spec);
|
2011-02-25 05:25:35 +03:00
|
|
|
SS.Extend(SemaRef.Context, /*FIXME:*/SourceLocation(), TL,
|
|
|
|
Q.getLocalEndLoc());
|
|
|
|
break;
|
|
|
|
}
|
2011-05-07 05:36:37 +04:00
|
|
|
// If the nested-name-specifier is an invalid type def, don't emit an
|
|
|
|
// error because a previous error should have already been emitted.
|
|
|
|
TypedefTypeLoc* TTL = dyn_cast<TypedefTypeLoc>(&TL);
|
|
|
|
if (!TTL || !TTL->getTypedefNameDecl()->isInvalidDecl()) {
|
|
|
|
SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
|
|
|
|
<< TL.getType() << SS.getRange();
|
|
|
|
}
|
2011-02-25 05:25:35 +03:00
|
|
|
return NestedNameSpecifierLoc();
|
|
|
|
}
|
2011-02-28 21:50:33 +03:00
|
|
|
}
|
2011-02-25 05:25:35 +03:00
|
|
|
|
2011-02-28 21:50:33 +03:00
|
|
|
// The qualifier-in-scope and object type only apply to the leftmost entity.
|
2011-02-25 05:25:35 +03:00
|
|
|
FirstQualifierInScope = 0;
|
2011-02-28 21:50:33 +03:00
|
|
|
ObjectType = QualType();
|
2011-02-25 05:25:35 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Don't rebuild the nested-name-specifier if we don't have to.
|
|
|
|
if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
|
|
|
|
!getDerived().AlwaysRebuild())
|
|
|
|
return NNS;
|
|
|
|
|
|
|
|
// If we can re-use the source-location data from the original
|
|
|
|
// nested-name-specifier, do so.
|
|
|
|
if (SS.location_size() == NNS.getDataLength() &&
|
|
|
|
memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
|
|
|
|
return NestedNameSpecifierLoc(SS.getScopeRep(), NNS.getOpaqueData());
|
|
|
|
|
|
|
|
// Allocate new nested-name-specifier location information.
|
|
|
|
return SS.getWithLocInContext(SemaRef.Context);
|
|
|
|
}
|
|
|
|
|
2009-09-04 02:13:48 +04:00
|
|
|
template<typename Derived>
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo
|
|
|
|
TreeTransform<Derived>
|
2010-11-12 11:19:04 +03:00
|
|
|
::TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo) {
|
2010-08-12 02:01:17 +04:00
|
|
|
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()) {
|
2010-11-12 11:19:04 +03:00
|
|
|
NewTInfo = getDerived().TransformType(OldTInfo);
|
|
|
|
if (!NewTInfo)
|
|
|
|
return DeclarationNameInfo();
|
|
|
|
NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
|
2010-08-12 02:01:17 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NewTInfo = 0;
|
|
|
|
TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType NewT = getDerived().TransformType(Name.getCXXNameType());
|
2010-08-12 02:01:17 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2011-09-23 09:06:16 +04:00
|
|
|
llvm_unreachable("Unknown name kind.");
|
2009-09-04 02:13:48 +04:00
|
|
|
}
|
|
|
|
|
2011-03-02 21:07:45 +03:00
|
|
|
template<typename Derived>
|
|
|
|
TemplateName
|
|
|
|
TreeTransform<Derived>::TransformTemplateName(CXXScopeSpec &SS,
|
|
|
|
TemplateName Name,
|
|
|
|
SourceLocation NameLoc,
|
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope) {
|
|
|
|
if (QualifiedTemplateName *QTN = Name.getAsQualifiedTemplateName()) {
|
|
|
|
TemplateDecl *Template = QTN->getTemplateDecl();
|
|
|
|
assert(Template && "qualified template name must refer to a template");
|
|
|
|
|
|
|
|
TemplateDecl *TransTemplate
|
|
|
|
= cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
|
|
|
|
Template));
|
|
|
|
if (!TransTemplate)
|
|
|
|
return TemplateName();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SS.getScopeRep() == QTN->getQualifier() &&
|
|
|
|
TransTemplate == Template)
|
|
|
|
return Name;
|
|
|
|
|
|
|
|
return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
|
|
|
|
TransTemplate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (DependentTemplateName *DTN = Name.getAsDependentTemplateName()) {
|
|
|
|
if (SS.getScopeRep()) {
|
|
|
|
// These apply to the scope specifier, not the template.
|
|
|
|
ObjectType = QualType();
|
|
|
|
FirstQualifierInScope = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SS.getScopeRep() == DTN->getQualifier() &&
|
|
|
|
ObjectType.isNull())
|
|
|
|
return Name;
|
|
|
|
|
|
|
|
if (DTN->isIdentifier()) {
|
|
|
|
return getDerived().RebuildTemplateName(SS,
|
|
|
|
*DTN->getIdentifier(),
|
|
|
|
NameLoc,
|
|
|
|
ObjectType,
|
|
|
|
FirstQualifierInScope);
|
|
|
|
}
|
|
|
|
|
|
|
|
return getDerived().RebuildTemplateName(SS, DTN->getOperator(), NameLoc,
|
|
|
|
ObjectType);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
|
|
|
|
TemplateDecl *TransTemplate
|
|
|
|
= cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
|
|
|
|
Template));
|
|
|
|
if (!TransTemplate)
|
|
|
|
return TemplateName();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TransTemplate == Template)
|
|
|
|
return Name;
|
|
|
|
|
|
|
|
return TemplateName(TransTemplate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SubstTemplateTemplateParmPackStorage *SubstPack
|
|
|
|
= Name.getAsSubstTemplateTemplateParmPack()) {
|
|
|
|
TemplateTemplateParmDecl *TransParam
|
|
|
|
= cast_or_null<TemplateTemplateParmDecl>(
|
|
|
|
getDerived().TransformDecl(NameLoc, SubstPack->getParameterPack()));
|
|
|
|
if (!TransParam)
|
|
|
|
return TemplateName();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TransParam == SubstPack->getParameterPack())
|
|
|
|
return Name;
|
|
|
|
|
|
|
|
return getDerived().RebuildTemplateName(TransParam,
|
|
|
|
SubstPack->getArgumentPack());
|
|
|
|
}
|
|
|
|
|
|
|
|
// These should be getting filtered out before they reach the AST.
|
|
|
|
llvm_unreachable("overloaded function decl survived to here");
|
|
|
|
return TemplateName();
|
|
|
|
}
|
|
|
|
|
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:
|
2011-03-02 20:09:35 +03:00
|
|
|
case TemplateArgument::TemplateExpansion: {
|
|
|
|
NestedNameSpecifierLocBuilder Builder;
|
|
|
|
TemplateName Template = Arg.getAsTemplate();
|
|
|
|
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
|
|
|
|
Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc);
|
|
|
|
else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
|
|
|
|
Builder.MakeTrivial(SemaRef.Context, QTN->getQualifier(), Loc);
|
|
|
|
|
|
|
|
if (Arg.getKind() == TemplateArgument::Template)
|
|
|
|
Output = TemplateArgumentLoc(Arg,
|
|
|
|
Builder.getWithLocInContext(SemaRef.Context),
|
|
|
|
Loc);
|
|
|
|
else
|
|
|
|
Output = TemplateArgumentLoc(Arg,
|
|
|
|
Builder.getWithLocInContext(SemaRef.Context),
|
|
|
|
Loc, Loc);
|
|
|
|
|
2011-01-05 21:58:31 +03:00
|
|
|
break;
|
2011-03-02 20:09:35 +03:00
|
|
|
}
|
2011-01-05 21:58:31 +03: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(),
|
2010-08-27 03:41:50 +04:00
|
|
|
Sema::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: {
|
2011-03-02 20:09:35 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
|
|
|
|
if (QualifierLoc) {
|
|
|
|
QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
|
|
|
|
if (!QualifierLoc)
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-03-02 21:46:51 +03:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.Adopt(QualifierLoc);
|
2009-11-11 04:00:40 +03:00
|
|
|
TemplateName Template
|
2011-03-02 21:46:51 +03:00
|
|
|
= getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
|
|
|
|
Input.getTemplateNameLoc());
|
2009-11-11 04:00:40 +03:00
|
|
|
if (Template.isNull())
|
|
|
|
return true;
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2011-03-02 20:09:35 +03:00
|
|
|
Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc,
|
2009-11-11 04:00:40 +03:00
|
|
|
Input.getTemplateNameLoc());
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-05 21:58:31 +03:00
|
|
|
|
|
|
|
case TemplateArgument::TemplateExpansion:
|
|
|
|
llvm_unreachable("Caller should expand pack expansions");
|
|
|
|
|
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(),
|
2010-08-27 03:41:50 +04:00
|
|
|
Sema::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();
|
|
|
|
|
2011-04-26 00:37:58 +04:00
|
|
|
ExprResult E = getDerived().TransformExpr(InputExpr);
|
2009-10-29 11:12:44 +03:00
|
|
|
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: {
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<TemplateArgument, 4> TransformedArgs;
|
2009-08-05 02:27:00 +04:00
|
|
|
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
|
|
|
}
|
2010-11-08 02:05:16 +03:00
|
|
|
|
|
|
|
TemplateArgument *TransformedArgsPtr
|
|
|
|
= new (getSema().Context) TemplateArgument[TransformedArgs.size()];
|
|
|
|
std::copy(TransformedArgs.begin(), TransformedArgs.end(),
|
|
|
|
TransformedArgsPtr);
|
|
|
|
Output = TemplateArgumentLoc(TemplateArgument(TransformedArgsPtr,
|
|
|
|
TransformedArgs.size()),
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2010-12-21 02:36:19 +03:00
|
|
|
/// \brief Iterator adaptor that invents template argument location information
|
|
|
|
/// for each of the template arguments in its underlying iterator.
|
|
|
|
template<typename Derived, typename InputIterator>
|
|
|
|
class TemplateArgumentLocInventIterator {
|
|
|
|
TreeTransform<Derived> &Self;
|
|
|
|
InputIterator Iter;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef TemplateArgumentLoc value_type;
|
|
|
|
typedef TemplateArgumentLoc reference;
|
|
|
|
typedef typename std::iterator_traits<InputIterator>::difference_type
|
|
|
|
difference_type;
|
|
|
|
typedef std::input_iterator_tag iterator_category;
|
|
|
|
|
|
|
|
class pointer {
|
|
|
|
TemplateArgumentLoc Arg;
|
2010-12-20 20:31:10 +03:00
|
|
|
|
2010-12-21 02:36:19 +03:00
|
|
|
public:
|
|
|
|
explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
|
|
|
|
|
|
|
|
const TemplateArgumentLoc *operator->() const { return &Arg; }
|
|
|
|
};
|
|
|
|
|
|
|
|
TemplateArgumentLocInventIterator() { }
|
|
|
|
|
|
|
|
explicit TemplateArgumentLocInventIterator(TreeTransform<Derived> &Self,
|
|
|
|
InputIterator Iter)
|
|
|
|
: Self(Self), Iter(Iter) { }
|
|
|
|
|
|
|
|
TemplateArgumentLocInventIterator &operator++() {
|
|
|
|
++Iter;
|
|
|
|
return *this;
|
2010-12-20 20:31:10 +03:00
|
|
|
}
|
|
|
|
|
2010-12-21 02:36:19 +03:00
|
|
|
TemplateArgumentLocInventIterator operator++(int) {
|
|
|
|
TemplateArgumentLocInventIterator Old(*this);
|
|
|
|
++(*this);
|
|
|
|
return Old;
|
|
|
|
}
|
|
|
|
|
|
|
|
reference operator*() const {
|
|
|
|
TemplateArgumentLoc Result;
|
|
|
|
Self.InventTemplateArgumentLoc(*Iter, Result);
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
pointer operator->() const { return pointer(**this); }
|
|
|
|
|
|
|
|
friend bool operator==(const TemplateArgumentLocInventIterator &X,
|
|
|
|
const TemplateArgumentLocInventIterator &Y) {
|
|
|
|
return X.Iter == Y.Iter;
|
|
|
|
}
|
2010-12-20 20:31:10 +03:00
|
|
|
|
2010-12-21 02:36:19 +03:00
|
|
|
friend bool operator!=(const TemplateArgumentLocInventIterator &X,
|
|
|
|
const TemplateArgumentLocInventIterator &Y) {
|
|
|
|
return X.Iter != Y.Iter;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-12-20 20:42:22 +03:00
|
|
|
template<typename Derived>
|
2010-12-21 02:36:19 +03:00
|
|
|
template<typename InputIterator>
|
|
|
|
bool TreeTransform<Derived>::TransformTemplateArguments(InputIterator First,
|
|
|
|
InputIterator Last,
|
2010-12-20 20:42:22 +03:00
|
|
|
TemplateArgumentListInfo &Outputs) {
|
2010-12-21 02:36:19 +03:00
|
|
|
for (; First != Last; ++First) {
|
2010-12-20 20:42:22 +03:00
|
|
|
TemplateArgumentLoc Out;
|
2010-12-21 02:36:19 +03:00
|
|
|
TemplateArgumentLoc In = *First;
|
2010-12-21 01:05:00 +03:00
|
|
|
|
|
|
|
if (In.getArgument().getKind() == TemplateArgument::Pack) {
|
|
|
|
// Unpack argument packs, which we translate them into separate
|
|
|
|
// arguments.
|
2010-12-21 02:36:19 +03:00
|
|
|
// FIXME: We could do much better if we could guarantee that the
|
|
|
|
// TemplateArgumentLocInfo for the pack expansion would be usable for
|
|
|
|
// all of the template arguments in the argument pack.
|
|
|
|
typedef TemplateArgumentLocInventIterator<Derived,
|
|
|
|
TemplateArgument::pack_iterator>
|
|
|
|
PackLocIterator;
|
|
|
|
if (TransformTemplateArguments(PackLocIterator(*this,
|
|
|
|
In.getArgument().pack_begin()),
|
|
|
|
PackLocIterator(*this,
|
|
|
|
In.getArgument().pack_end()),
|
|
|
|
Outputs))
|
|
|
|
return true;
|
2010-12-21 01:05:00 +03:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (In.getArgument().isPackExpansion()) {
|
|
|
|
// We have a pack expansion, for which we will be substituting into
|
|
|
|
// the pattern.
|
|
|
|
SourceLocation Ellipsis;
|
2011-01-14 20:04:44 +03:00
|
|
|
llvm::Optional<unsigned> OrigNumExpansions;
|
2010-12-21 01:05:00 +03:00
|
|
|
TemplateArgumentLoc Pattern
|
2011-01-14 20:04:44 +03:00
|
|
|
= In.getPackExpansionPattern(Ellipsis, OrigNumExpansions,
|
|
|
|
getSema().Context);
|
2010-12-21 01:05:00 +03:00
|
|
|
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
|
2010-12-21 01:05:00 +03:00
|
|
|
getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
|
|
|
|
assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
|
|
|
|
|
|
|
|
// Determine whether the set of unexpanded parameter packs can and should
|
|
|
|
// be expanded.
|
|
|
|
bool Expand = true;
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
bool RetainExpansion = false;
|
2011-01-14 20:04:44 +03:00
|
|
|
llvm::Optional<unsigned> NumExpansions = OrigNumExpansions;
|
2010-12-21 01:05:00 +03:00
|
|
|
if (getDerived().TryExpandParameterPacks(Ellipsis,
|
|
|
|
Pattern.getSourceRange(),
|
2011-09-22 06:34:54 +04:00
|
|
|
Unexpanded,
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
Expand,
|
|
|
|
RetainExpansion,
|
|
|
|
NumExpansions))
|
2010-12-21 01:05:00 +03:00
|
|
|
return true;
|
|
|
|
|
|
|
|
if (!Expand) {
|
|
|
|
// The transform has determined that we should perform a simple
|
|
|
|
// transformation on the pack expansion, producing another pack
|
|
|
|
// expansion.
|
|
|
|
TemplateArgumentLoc OutPattern;
|
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
|
|
|
|
if (getDerived().TransformTemplateArgument(Pattern, OutPattern))
|
|
|
|
return true;
|
|
|
|
|
2011-01-14 20:04:44 +03:00
|
|
|
Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
|
|
|
|
NumExpansions);
|
2010-12-21 01:05:00 +03:00
|
|
|
if (Out.getArgument().isNull())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Outputs.addArgument(Out);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The transform has determined that we should perform an elementwise
|
|
|
|
// expansion of the pattern. Do so.
|
2011-01-14 20:04:44 +03:00
|
|
|
for (unsigned I = 0; I != *NumExpansions; ++I) {
|
2010-12-21 01:05:00 +03:00
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
|
|
|
|
|
|
|
|
if (getDerived().TransformTemplateArgument(Pattern, Out))
|
|
|
|
return true;
|
|
|
|
|
2011-01-12 01:21:24 +03:00
|
|
|
if (Out.getArgument().containsUnexpandedParameterPack()) {
|
2011-01-14 20:04:44 +03:00
|
|
|
Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
|
|
|
|
OrigNumExpansions);
|
2011-01-12 01:21:24 +03:00
|
|
|
if (Out.getArgument().isNull())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-12-21 01:05:00 +03:00
|
|
|
Outputs.addArgument(Out);
|
|
|
|
}
|
|
|
|
|
2011-01-10 23:53:55 +03:00
|
|
|
// If we're supposed to retain a pack expansion, do so by temporarily
|
|
|
|
// forgetting the partially-substituted parameter pack.
|
|
|
|
if (RetainExpansion) {
|
|
|
|
ForgetPartiallySubstitutedPackRAII Forget(getDerived());
|
|
|
|
|
|
|
|
if (getDerived().TransformTemplateArgument(Pattern, Out))
|
|
|
|
return true;
|
|
|
|
|
2011-01-14 20:04:44 +03:00
|
|
|
Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
|
|
|
|
OrigNumExpansions);
|
2011-01-10 23:53:55 +03:00
|
|
|
if (Out.getArgument().isNull())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
Outputs.addArgument(Out);
|
|
|
|
}
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
|
2010-12-21 01:05:00 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The simple case:
|
|
|
|
if (getDerived().TransformTemplateArgument(In, Out))
|
2010-12-20 20:42:22 +03:00
|
|
|
return true;
|
|
|
|
|
|
|
|
Outputs.addArgument(Out);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-04 20:50:30 +04:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Type transformation
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
template<typename Derived>
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType TreeTransform<Derived>::TransformType(QualType T) {
|
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.
|
2011-01-25 22:13:18 +03:00
|
|
|
TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
|
|
|
|
getDerived().getBaseLocation());
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
TypeSourceInfo *NewDI = getDerived().TransformType(DI);
|
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-11-12 11:19:04 +03:00
|
|
|
TypeSourceInfo *TreeTransform<Derived>::TransformType(TypeSourceInfo *DI) {
|
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-11-12 11:19:04 +03:00
|
|
|
QualType Result = getDerived().TransformType(TLB, TL);
|
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-11-12 11:19:04 +03:00
|
|
|
TreeTransform<Derived>::TransformType(TypeLocBuilder &TLB, TypeLoc T) {
|
2009-10-21 04:40:46 +04:00
|
|
|
switch (T.getTypeLocClass()) {
|
|
|
|
#define ABSTRACT_TYPELOC(CLASS, PARENT)
|
|
|
|
#define TYPELOC(CLASS, PARENT) \
|
|
|
|
case TypeLoc::CLASS: \
|
2010-11-12 11:19:04 +03:00
|
|
|
return getDerived().Transform##CLASS##Type(TLB, cast<CLASS##TypeLoc>(T));
|
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-11-12 11:19:04 +03:00
|
|
|
QualifiedTypeLoc T) {
|
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-11-12 11:19:04 +03:00
|
|
|
QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc());
|
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
|
|
|
|
2011-06-16 03:02:42 +04:00
|
|
|
// Suppress Objective-C lifetime qualifiers if they don't make sense for the
|
2011-06-18 02:11:49 +04:00
|
|
|
// resulting type.
|
|
|
|
if (Quals.hasObjCLifetime()) {
|
|
|
|
if (!Result->isObjCLifetimeType() && !Result->isDependentType())
|
|
|
|
Quals.removeObjCLifetime();
|
2011-06-18 03:16:24 +04:00
|
|
|
else if (Result.getObjCLifetime()) {
|
2011-06-18 02:11:49 +04:00
|
|
|
// Objective-C ARC:
|
|
|
|
// A lifetime qualifier applied to a substituted template parameter
|
|
|
|
// overrides the lifetime qualifier from the template argument.
|
|
|
|
if (const SubstTemplateTypeParmType *SubstTypeParam
|
|
|
|
= dyn_cast<SubstTemplateTypeParmType>(Result)) {
|
|
|
|
QualType Replacement = SubstTypeParam->getReplacementType();
|
|
|
|
Qualifiers Qs = Replacement.getQualifiers();
|
|
|
|
Qs.removeObjCLifetime();
|
|
|
|
Replacement
|
|
|
|
= SemaRef.Context.getQualifiedType(Replacement.getUnqualifiedType(),
|
|
|
|
Qs);
|
|
|
|
Result = SemaRef.Context.getSubstTemplateTypeParmType(
|
|
|
|
SubstTypeParam->getReplacedParameter(),
|
|
|
|
Replacement);
|
|
|
|
TLB.TypeWasModifiedSafely(Result);
|
|
|
|
} else {
|
2011-06-18 03:16:24 +04:00
|
|
|
// Otherwise, complain about the addition of a qualifier to an
|
|
|
|
// already-qualified type.
|
|
|
|
SourceRange R = TLB.getTemporaryTypeLoc(Result).getSourceRange();
|
2011-06-24 04:08:59 +04:00
|
|
|
SemaRef.Diag(R.getBegin(), diag::err_attr_objc_ownership_redundant)
|
2011-06-18 03:16:24 +04:00
|
|
|
<< Result << R;
|
|
|
|
|
2011-06-18 02:11:49 +04:00
|
|
|
Quals.removeObjCLifetime();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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;
|
|
|
|
}
|
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
template<typename Derived>
|
2011-03-02 21:32:08 +03:00
|
|
|
TypeLoc
|
|
|
|
TreeTransform<Derived>::TransformTypeInObjectScope(TypeLoc TL,
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *UnqualLookup,
|
2011-03-02 21:32:08 +03:00
|
|
|
CXXScopeSpec &SS) {
|
|
|
|
QualType T = TL.getType();
|
2010-11-12 11:19:04 +03:00
|
|
|
if (getDerived().AlreadyTransformed(T))
|
2011-03-02 21:32:08 +03:00
|
|
|
return TL;
|
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
TypeLocBuilder TLB;
|
|
|
|
QualType Result;
|
2011-03-02 21:32:08 +03:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
if (isa<TemplateSpecializationType>(T)) {
|
2011-03-02 21:32:08 +03:00
|
|
|
TemplateSpecializationTypeLoc SpecTL
|
|
|
|
= cast<TemplateSpecializationTypeLoc>(TL);
|
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
TemplateName Template =
|
2011-03-02 21:32:08 +03:00
|
|
|
getDerived().TransformTemplateName(SS,
|
|
|
|
SpecTL.getTypePtr()->getTemplateName(),
|
|
|
|
SpecTL.getTemplateNameLoc(),
|
2010-11-12 11:19:04 +03:00
|
|
|
ObjectType, UnqualLookup);
|
2011-03-02 21:32:08 +03:00
|
|
|
if (Template.isNull())
|
|
|
|
return TypeLoc();
|
|
|
|
|
|
|
|
Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
|
|
|
|
Template);
|
2010-11-12 11:19:04 +03:00
|
|
|
} else if (isa<DependentTemplateSpecializationType>(T)) {
|
2011-03-02 21:32:08 +03:00
|
|
|
DependentTemplateSpecializationTypeLoc SpecTL
|
|
|
|
= cast<DependentTemplateSpecializationTypeLoc>(TL);
|
2011-02-28 20:23:35 +03:00
|
|
|
|
2011-03-02 21:32:08 +03:00
|
|
|
TemplateName Template
|
|
|
|
= getDerived().RebuildTemplateName(SS,
|
|
|
|
*SpecTL.getTypePtr()->getIdentifier(),
|
|
|
|
SpecTL.getNameLoc(),
|
|
|
|
ObjectType, UnqualLookup);
|
2011-02-28 20:23:35 +03:00
|
|
|
if (Template.isNull())
|
2011-03-02 21:32:08 +03:00
|
|
|
return TypeLoc();
|
|
|
|
|
|
|
|
Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
|
|
|
|
SpecTL,
|
2011-03-04 21:53:13 +03:00
|
|
|
Template,
|
|
|
|
SS);
|
2010-11-12 11:19:04 +03:00
|
|
|
} else {
|
|
|
|
// Nothing special needs to be done for these.
|
2011-03-02 21:32:08 +03:00
|
|
|
Result = getDerived().TransformType(TLB, TL);
|
2010-11-12 11:19:04 +03:00
|
|
|
}
|
2011-03-02 21:32:08 +03:00
|
|
|
|
|
|
|
if (Result.isNull())
|
|
|
|
return TypeLoc();
|
|
|
|
|
|
|
|
return TLB.getTypeSourceInfo(SemaRef.Context, Result)->getTypeLoc();
|
2010-11-12 11:19:04 +03:00
|
|
|
}
|
|
|
|
|
2011-02-25 05:25:35 +03:00
|
|
|
template<typename Derived>
|
2011-03-02 21:32:08 +03:00
|
|
|
TypeSourceInfo *
|
|
|
|
TreeTransform<Derived>::TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
|
2011-02-25 05:25:35 +03:00
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *UnqualLookup,
|
|
|
|
CXXScopeSpec &SS) {
|
|
|
|
// FIXME: Painfully copy-paste from the above!
|
|
|
|
|
2011-03-02 21:32:08 +03:00
|
|
|
QualType T = TSInfo->getType();
|
2011-02-25 05:25:35 +03:00
|
|
|
if (getDerived().AlreadyTransformed(T))
|
2011-03-02 21:32:08 +03:00
|
|
|
return TSInfo;
|
2011-02-25 05:25:35 +03:00
|
|
|
|
|
|
|
TypeLocBuilder TLB;
|
|
|
|
QualType Result;
|
|
|
|
|
2011-03-02 21:32:08 +03:00
|
|
|
TypeLoc TL = TSInfo->getTypeLoc();
|
2011-02-25 05:25:35 +03:00
|
|
|
if (isa<TemplateSpecializationType>(T)) {
|
|
|
|
TemplateSpecializationTypeLoc SpecTL
|
|
|
|
= cast<TemplateSpecializationTypeLoc>(TL);
|
|
|
|
|
2011-03-02 21:32:08 +03:00
|
|
|
TemplateName Template
|
|
|
|
= getDerived().TransformTemplateName(SS,
|
2011-03-02 21:07:45 +03:00
|
|
|
SpecTL.getTypePtr()->getTemplateName(),
|
|
|
|
SpecTL.getTemplateNameLoc(),
|
2011-02-25 05:25:35 +03:00
|
|
|
ObjectType, UnqualLookup);
|
|
|
|
if (Template.isNull())
|
2011-03-02 21:32:08 +03:00
|
|
|
return 0;
|
2011-02-25 05:25:35 +03:00
|
|
|
|
|
|
|
Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
|
|
|
|
Template);
|
|
|
|
} else if (isa<DependentTemplateSpecializationType>(T)) {
|
|
|
|
DependentTemplateSpecializationTypeLoc SpecTL
|
|
|
|
= cast<DependentTemplateSpecializationTypeLoc>(TL);
|
|
|
|
|
2011-02-28 20:23:35 +03:00
|
|
|
TemplateName Template
|
2011-03-02 21:07:45 +03:00
|
|
|
= getDerived().RebuildTemplateName(SS,
|
2011-02-28 21:50:33 +03:00
|
|
|
*SpecTL.getTypePtr()->getIdentifier(),
|
2011-03-02 21:07:45 +03:00
|
|
|
SpecTL.getNameLoc(),
|
2011-02-28 21:50:33 +03:00
|
|
|
ObjectType, UnqualLookup);
|
2011-02-28 20:23:35 +03:00
|
|
|
if (Template.isNull())
|
2011-03-02 21:32:08 +03:00
|
|
|
return 0;
|
2011-02-28 20:23:35 +03:00
|
|
|
|
2011-02-25 05:25:35 +03:00
|
|
|
Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
|
2011-02-28 20:23:35 +03:00
|
|
|
SpecTL,
|
2011-03-04 21:53:13 +03:00
|
|
|
Template,
|
|
|
|
SS);
|
2011-02-25 05:25:35 +03:00
|
|
|
} else {
|
|
|
|
// Nothing special needs to be done for these.
|
|
|
|
Result = getDerived().TransformType(TLB, TL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Result.isNull())
|
2011-03-02 21:32:08 +03:00
|
|
|
return 0;
|
2011-02-25 05:25:35 +03:00
|
|
|
|
2011-03-02 21:32:08 +03:00
|
|
|
return TLB.getTypeSourceInfo(SemaRef.Context, Result);
|
2011-02-25 05:25:35 +03:00
|
|
|
}
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
BuiltinTypeLoc T) {
|
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-11-12 11:19:04 +03:00
|
|
|
ComplexTypeLoc T) {
|
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-11-12 11:19:04 +03:00
|
|
|
PointerTypeLoc TL) {
|
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-11-12 11:19:04 +03: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();
|
|
|
|
}
|
2011-06-16 03:02:42 +04:00
|
|
|
|
|
|
|
// Objective-C ARC can add lifetime qualifiers to the type that we're
|
|
|
|
// pointing to.
|
|
|
|
TLB.TypeWasModifiedSafely(Result->getPointeeType());
|
|
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
BlockPointerTypeLoc TL) {
|
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-11-12 11:19:04 +03:00
|
|
|
ReferenceTypeLoc TL) {
|
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();
|
|
|
|
}
|
|
|
|
|
2011-06-16 03:02:42 +04:00
|
|
|
// Objective-C ARC can add lifetime qualifiers to the type that we're
|
|
|
|
// referring to.
|
|
|
|
TLB.TypeWasModifiedSafely(
|
|
|
|
Result->getAs<ReferenceType>()->getPointeeTypeAsWritten());
|
|
|
|
|
2009-10-30 03:06:24 +03:00
|
|
|
// 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-11-12 11:19:04 +03:00
|
|
|
LValueReferenceTypeLoc TL) {
|
|
|
|
return TransformReferenceType(TLB, TL);
|
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-11-12 11:19:04 +03:00
|
|
|
RValueReferenceTypeLoc TL) {
|
|
|
|
return TransformReferenceType(TLB, TL);
|
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-11-12 11:19:04 +03:00
|
|
|
MemberPointerTypeLoc TL) {
|
2009-10-21 04:40:46 +04:00
|
|
|
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
|
|
|
|
2011-03-05 17:42:21 +03:00
|
|
|
TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
|
|
|
|
TypeSourceInfo* NewClsTInfo = 0;
|
|
|
|
if (OldClsTInfo) {
|
|
|
|
NewClsTInfo = getDerived().TransformType(OldClsTInfo);
|
|
|
|
if (!NewClsTInfo)
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
const MemberPointerType *T = TL.getTypePtr();
|
|
|
|
QualType OldClsType = QualType(T->getClass(), 0);
|
|
|
|
QualType NewClsType;
|
|
|
|
if (NewClsTInfo)
|
|
|
|
NewClsType = NewClsTInfo->getType();
|
|
|
|
else {
|
|
|
|
NewClsType = getDerived().TransformType(OldClsType);
|
|
|
|
if (NewClsType.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() ||
|
2011-03-05 17:42:21 +03:00
|
|
|
NewClsType != OldClsType) {
|
|
|
|
Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
|
2009-10-30 03:06:24 +03:00
|
|
|
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());
|
2011-03-05 17:42:21 +03:00
|
|
|
NewTL.setClassTInfo(NewClsTInfo);
|
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>
|
|
|
|
QualType
|
2009-10-21 04:40:46 +04:00
|
|
|
TreeTransform<Derived>::TransformConstantArrayType(TypeLocBuilder &TLB,
|
2010-11-12 11:19:04 +03:00
|
|
|
ConstantArrayTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const ConstantArrayType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
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) {
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
2009-10-21 04:40:46 +04:00
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
IncompleteArrayTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const IncompleteArrayType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
VariableArrayTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const VariableArrayType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
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
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
2009-08-05 02:27:00 +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
|
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
DependentSizedArrayTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const DependentSizedArrayType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
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
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-01-19 13:06:00 +03:00
|
|
|
// Prefer the expression from the TypeLoc; the other may have been uniqued.
|
|
|
|
Expr *origSize = TL.getSizeExpr();
|
|
|
|
if (!origSize) origSize = T->getSizeExpr();
|
|
|
|
|
|
|
|
ExprResult sizeResult
|
|
|
|
= getDerived().TransformExpr(origSize);
|
|
|
|
if (sizeResult.isInvalid())
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-01-19 13:06:00 +03:00
|
|
|
Expr *size = sizeResult.get();
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ElementType != T->getElementType() ||
|
2011-01-19 13:06:00 +03:00
|
|
|
size != origSize) {
|
2009-10-21 04:40:46 +04:00
|
|
|
Result = getDerived().RebuildDependentSizedArrayType(ElementType,
|
|
|
|
T->getSizeModifier(),
|
2011-01-19 13:06:00 +03: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-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());
|
2011-01-19 13:06:00 +03:00
|
|
|
NewTL.setSizeExpr(size);
|
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-08-04 20:50:30 +04:00
|
|
|
QualType TreeTransform<Derived>::TransformDependentSizedExtVectorType(
|
2009-10-21 04:40:46 +04:00
|
|
|
TypeLocBuilder &TLB,
|
2010-11-12 11:19:04 +03:00
|
|
|
DependentSizedExtVectorTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const DependentSizedExtVectorType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
// 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
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
2009-08-05 02:27:00 +04:00
|
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
VectorTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const 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-11-11 00:56:12 +03:00
|
|
|
T->getVectorKind());
|
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-11-12 11:19:04 +03:00
|
|
|
ExtVectorTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const 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 *
|
2011-01-15 01:40:04 +03:00
|
|
|
TreeTransform<Derived>::TransformFunctionTypeParam(ParmVarDecl *OldParm,
|
2011-05-02 02:35:37 +04:00
|
|
|
int indexAdjustment,
|
2011-01-15 01:40:04 +03:00
|
|
|
llvm::Optional<unsigned> NumExpansions) {
|
2010-03-11 12:03:00 +03:00
|
|
|
TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
|
2011-01-15 01:40:04 +03:00
|
|
|
TypeSourceInfo *NewDI = 0;
|
|
|
|
|
|
|
|
if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
|
|
|
|
// If we're substituting into a pack expansion type and we know the
|
|
|
|
TypeLoc OldTL = OldDI->getTypeLoc();
|
|
|
|
PackExpansionTypeLoc OldExpansionTL = cast<PackExpansionTypeLoc>(OldTL);
|
|
|
|
|
|
|
|
TypeLocBuilder TLB;
|
|
|
|
TypeLoc NewTL = OldDI->getTypeLoc();
|
|
|
|
TLB.reserve(NewTL.getFullDataSize());
|
|
|
|
|
|
|
|
QualType Result = getDerived().TransformType(TLB,
|
|
|
|
OldExpansionTL.getPatternLoc());
|
|
|
|
if (Result.isNull())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
Result = RebuildPackExpansionType(Result,
|
|
|
|
OldExpansionTL.getPatternLoc().getSourceRange(),
|
|
|
|
OldExpansionTL.getEllipsisLoc(),
|
|
|
|
NumExpansions);
|
|
|
|
if (Result.isNull())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
PackExpansionTypeLoc NewExpansionTL
|
|
|
|
= TLB.push<PackExpansionTypeLoc>(Result);
|
|
|
|
NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
|
|
|
|
NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
|
|
|
|
} else
|
|
|
|
NewDI = getDerived().TransformType(OldDI);
|
2010-03-11 12:03:00 +03:00
|
|
|
if (!NewDI)
|
|
|
|
return 0;
|
|
|
|
|
2011-05-02 02:35:37 +04:00
|
|
|
if (NewDI == OldDI && indexAdjustment == 0)
|
2010-03-11 12:03:00 +03:00
|
|
|
return OldParm;
|
2011-05-02 02:35:37 +04:00
|
|
|
|
|
|
|
ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
|
|
|
|
OldParm->getDeclContext(),
|
|
|
|
OldParm->getInnerLocStart(),
|
|
|
|
OldParm->getLocation(),
|
|
|
|
OldParm->getIdentifier(),
|
|
|
|
NewDI->getType(),
|
|
|
|
NewDI,
|
|
|
|
OldParm->getStorageClass(),
|
|
|
|
OldParm->getStorageClassAsWritten(),
|
|
|
|
/* DefArg */ NULL);
|
|
|
|
newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
|
|
|
|
OldParm->getFunctionScopeIndex() + indexAdjustment);
|
|
|
|
return newParm;
|
2010-03-11 12:03:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
bool TreeTransform<Derived>::
|
2011-01-07 03:20:55 +03:00
|
|
|
TransformFunctionTypeParams(SourceLocation Loc,
|
|
|
|
ParmVarDecl **Params, unsigned NumParams,
|
|
|
|
const QualType *ParamTypes,
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVectorImpl<QualType> &OutParamTypes,
|
|
|
|
SmallVectorImpl<ParmVarDecl*> *PVars) {
|
2011-05-02 02:35:37 +04:00
|
|
|
int indexAdjustment = 0;
|
|
|
|
|
2011-01-07 03:20:55 +03:00
|
|
|
for (unsigned i = 0; i != NumParams; ++i) {
|
|
|
|
if (ParmVarDecl *OldParm = Params[i]) {
|
2011-05-02 02:35:37 +04:00
|
|
|
assert(OldParm->getFunctionScopeIndex() == i);
|
|
|
|
|
2011-01-15 01:40:04 +03:00
|
|
|
llvm::Optional<unsigned> NumExpansions;
|
2011-03-02 05:04:06 +03:00
|
|
|
ParmVarDecl *NewParm = 0;
|
2011-01-06 02:12:31 +03:00
|
|
|
if (OldParm->isParameterPack()) {
|
|
|
|
// We have a function parameter pack that may need to be expanded.
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
|
2011-01-06 02:12:31 +03:00
|
|
|
|
|
|
|
// Find the parameter packs that could be expanded.
|
2011-01-06 02:16:57 +03:00
|
|
|
TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
|
|
|
|
PackExpansionTypeLoc ExpansionTL = cast<PackExpansionTypeLoc>(TL);
|
|
|
|
TypeLoc Pattern = ExpansionTL.getPatternLoc();
|
|
|
|
SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
|
2011-03-02 05:04:06 +03:00
|
|
|
assert(Unexpanded.size() > 0 && "Could not find parameter packs!");
|
|
|
|
|
2011-01-06 02:12:31 +03:00
|
|
|
// Determine whether we should expand the parameter packs.
|
|
|
|
bool ShouldExpand = false;
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
bool RetainExpansion = false;
|
2011-01-15 01:40:04 +03:00
|
|
|
llvm::Optional<unsigned> OrigNumExpansions
|
|
|
|
= ExpansionTL.getTypePtr()->getNumExpansions();
|
|
|
|
NumExpansions = OrigNumExpansions;
|
2011-01-06 02:16:57 +03:00
|
|
|
if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
|
|
|
|
Pattern.getSourceRange(),
|
2011-09-22 06:34:54 +04:00
|
|
|
Unexpanded,
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
ShouldExpand,
|
|
|
|
RetainExpansion,
|
|
|
|
NumExpansions)) {
|
2011-01-06 02:12:31 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ShouldExpand) {
|
|
|
|
// Expand the function parameter pack into multiple, separate
|
|
|
|
// parameters.
|
Implement substitution of a function parameter pack for its set of
instantiated function parameters, enabling instantiation of arbitrary
pack expansions involving function parameter packs. At this point, we
can now correctly compile a simple, variadic print() example:
#include <iostream>
#include <string>
void print() {}
template<typename Head, typename ...Tail>
void print(const Head &head, const Tail &...tail) {
std::cout << head;
print(tail...);
}
int main() {
std::string hello = "Hello";
print(hello, ", world!", " ", 2011, '\n');
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123000 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-07 19:43:16 +03:00
|
|
|
getDerived().ExpandingFunctionParameterPack(OldParm);
|
2011-01-14 20:04:44 +03:00
|
|
|
for (unsigned I = 0; I != *NumExpansions; ++I) {
|
2011-01-06 02:12:31 +03:00
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
|
|
|
|
ParmVarDecl *NewParm
|
2011-01-15 01:40:04 +03:00
|
|
|
= getDerived().TransformFunctionTypeParam(OldParm,
|
2011-05-02 02:35:37 +04:00
|
|
|
indexAdjustment++,
|
2011-01-15 01:40:04 +03:00
|
|
|
OrigNumExpansions);
|
2011-01-06 02:12:31 +03:00
|
|
|
if (!NewParm)
|
|
|
|
return true;
|
|
|
|
|
2011-01-07 03:20:55 +03:00
|
|
|
OutParamTypes.push_back(NewParm->getType());
|
|
|
|
if (PVars)
|
|
|
|
PVars->push_back(NewParm);
|
2011-01-06 02:12:31 +03:00
|
|
|
}
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
|
|
|
|
// If we're supposed to retain a pack expansion, do so by temporarily
|
|
|
|
// forgetting the partially-substituted parameter pack.
|
|
|
|
if (RetainExpansion) {
|
|
|
|
ForgetPartiallySubstitutedPackRAII Forget(getDerived());
|
|
|
|
ParmVarDecl *NewParm
|
2011-01-15 01:40:04 +03:00
|
|
|
= getDerived().TransformFunctionTypeParam(OldParm,
|
2011-05-02 02:35:37 +04:00
|
|
|
indexAdjustment++,
|
2011-01-15 01:40:04 +03:00
|
|
|
OrigNumExpansions);
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
if (!NewParm)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
OutParamTypes.push_back(NewParm->getType());
|
|
|
|
if (PVars)
|
|
|
|
PVars->push_back(NewParm);
|
|
|
|
}
|
|
|
|
|
2011-05-02 02:35:37 +04:00
|
|
|
// The next parameter should have the same adjustment as the
|
|
|
|
// last thing we pushed, but we post-incremented indexAdjustment
|
|
|
|
// on every push. Also, if we push nothing, the adjustment should
|
|
|
|
// go down by one.
|
|
|
|
indexAdjustment--;
|
|
|
|
|
2011-01-06 02:12:31 +03:00
|
|
|
// We're done with the pack expansion.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We'll substitute the parameter now without expanding the pack
|
|
|
|
// expansion.
|
2011-03-02 05:04:06 +03:00
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
|
|
|
|
NewParm = getDerived().TransformFunctionTypeParam(OldParm,
|
2011-05-02 02:35:37 +04:00
|
|
|
indexAdjustment,
|
2011-03-02 05:04:06 +03:00
|
|
|
NumExpansions);
|
|
|
|
} else {
|
|
|
|
NewParm = getDerived().TransformFunctionTypeParam(OldParm,
|
2011-05-02 02:35:37 +04:00
|
|
|
indexAdjustment,
|
2011-03-02 05:04:06 +03:00
|
|
|
llvm::Optional<unsigned>());
|
2011-01-06 02:12:31 +03:00
|
|
|
}
|
2011-03-02 05:04:06 +03:00
|
|
|
|
2010-03-11 12:03:00 +03:00
|
|
|
if (!NewParm)
|
|
|
|
return true;
|
2011-01-06 02:12:31 +03:00
|
|
|
|
2011-01-07 03:20:55 +03:00
|
|
|
OutParamTypes.push_back(NewParm->getType());
|
|
|
|
if (PVars)
|
|
|
|
PVars->push_back(NewParm);
|
2011-01-06 02:12:31 +03:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-21 04:40:46 +04:00
|
|
|
|
|
|
|
// Deal with the possibility that we don't have a parameter
|
|
|
|
// declaration for this parameter.
|
2011-01-07 03:20:55 +03:00
|
|
|
QualType OldType = ParamTypes[i];
|
2011-01-06 02:12:31 +03:00
|
|
|
bool IsPackExpansion = false;
|
2011-01-14 20:04:44 +03:00
|
|
|
llvm::Optional<unsigned> NumExpansions;
|
2011-03-02 05:04:06 +03:00
|
|
|
QualType NewType;
|
2011-01-06 02:12:31 +03:00
|
|
|
if (const PackExpansionType *Expansion
|
|
|
|
= dyn_cast<PackExpansionType>(OldType)) {
|
|
|
|
// We have a function parameter pack that may need to be expanded.
|
|
|
|
QualType Pattern = Expansion->getPattern();
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<UnexpandedParameterPack, 2> Unexpanded;
|
2011-01-06 02:12:31 +03:00
|
|
|
getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
|
|
|
|
|
|
|
|
// Determine whether we should expand the parameter packs.
|
|
|
|
bool ShouldExpand = false;
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
bool RetainExpansion = false;
|
2011-01-07 03:20:55 +03:00
|
|
|
if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
|
2011-09-22 06:34:54 +04:00
|
|
|
Unexpanded,
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
ShouldExpand,
|
|
|
|
RetainExpansion,
|
|
|
|
NumExpansions)) {
|
2010-03-11 12:03:00 +03:00
|
|
|
return true;
|
2011-01-06 02:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ShouldExpand) {
|
|
|
|
// Expand the function parameter pack into multiple, separate
|
|
|
|
// parameters.
|
2011-01-14 20:04:44 +03:00
|
|
|
for (unsigned I = 0; I != *NumExpansions; ++I) {
|
2011-01-06 02:12:31 +03:00
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
|
|
|
|
QualType NewType = getDerived().TransformType(Pattern);
|
|
|
|
if (NewType.isNull())
|
|
|
|
return true;
|
|
|
|
|
2011-01-07 03:20:55 +03:00
|
|
|
OutParamTypes.push_back(NewType);
|
|
|
|
if (PVars)
|
|
|
|
PVars->push_back(0);
|
2011-01-06 02:12:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// We're done with the pack expansion.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-01-10 23:53:55 +03:00
|
|
|
// If we're supposed to retain a pack expansion, do so by temporarily
|
|
|
|
// forgetting the partially-substituted parameter pack.
|
|
|
|
if (RetainExpansion) {
|
|
|
|
ForgetPartiallySubstitutedPackRAII Forget(getDerived());
|
|
|
|
QualType NewType = getDerived().TransformType(Pattern);
|
|
|
|
if (NewType.isNull())
|
|
|
|
return true;
|
|
|
|
|
|
|
|
OutParamTypes.push_back(NewType);
|
|
|
|
if (PVars)
|
|
|
|
PVars->push_back(0);
|
|
|
|
}
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
|
2011-01-06 02:12:31 +03:00
|
|
|
// We'll substitute the parameter now without expanding the pack
|
|
|
|
// expansion.
|
|
|
|
OldType = Expansion->getPattern();
|
|
|
|
IsPackExpansion = true;
|
2011-03-02 05:04:06 +03:00
|
|
|
Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
|
|
|
|
NewType = getDerived().TransformType(OldType);
|
|
|
|
} else {
|
|
|
|
NewType = getDerived().TransformType(OldType);
|
2009-10-21 04:40:46 +04:00
|
|
|
}
|
2011-01-06 02:12:31 +03:00
|
|
|
|
|
|
|
if (NewType.isNull())
|
|
|
|
return true;
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-01-06 02:12:31 +03:00
|
|
|
if (IsPackExpansion)
|
2011-01-14 20:04:44 +03:00
|
|
|
NewType = getSema().Context.getPackExpansionType(NewType,
|
|
|
|
NumExpansions);
|
2011-01-06 02:12:31 +03:00
|
|
|
|
2011-01-07 03:20:55 +03:00
|
|
|
OutParamTypes.push_back(NewType);
|
|
|
|
if (PVars)
|
|
|
|
PVars->push_back(0);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-05-02 02:35:37 +04:00
|
|
|
#ifndef NDEBUG
|
|
|
|
if (PVars) {
|
|
|
|
for (unsigned i = 0, e = PVars->size(); i != e; ++i)
|
|
|
|
if (ParmVarDecl *parm = (*PVars)[i])
|
|
|
|
assert(parm->getFunctionScopeIndex() == i);
|
2011-01-06 02:12:31 +03:00
|
|
|
}
|
2011-05-02 02:35:37 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2010-03-11 12:03:00 +03:00
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformFunctionProtoType(TypeLocBuilder &TLB,
|
2010-11-12 11:19:04 +03:00
|
|
|
FunctionProtoTypeLoc TL) {
|
When instantiating a function type, instantiate the return type before
instantiating the parameters. In a perfect world, this wouldn't
matter, and compilers are free to instantiate in any order they
want. However, every other compiler seems to instantiate the return
type first, and some code (in this case, Boost.Polygon) depends on
this and SFINAE to avoid instantiating something that shouldn't be
instantiated.
We could fight this battle, and insist that Clang is allowed to do
what it does, but it's not beneficial: it's more predictable to
instantiate this way, in source order. When we implement
late-specified return types, we'll need to instantiate the return type
last when it was late-specified, hence the FIXME.
We now compile Boost.Polygon properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 04:26:14 +04:00
|
|
|
// Transform the parameters and return type.
|
|
|
|
//
|
|
|
|
// We instantiate in source order, with the return type first followed by
|
|
|
|
// the parameters, because users tend to expect this (even if they shouldn't
|
|
|
|
// rely on it!).
|
|
|
|
//
|
2010-10-01 22:44:50 +04:00
|
|
|
// When the function has a trailing return type, we instantiate the
|
|
|
|
// parameters before the return type, since the return type can then refer
|
|
|
|
// to the parameters themselves (via decltype, sizeof, etc.).
|
|
|
|
//
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<QualType, 4> ParamTypes;
|
|
|
|
SmallVector<ParmVarDecl*, 4> ParamDecls;
|
2011-01-19 09:33:43 +03:00
|
|
|
const FunctionProtoType *T = TL.getTypePtr();
|
When instantiating a function type, instantiate the return type before
instantiating the parameters. In a perfect world, this wouldn't
matter, and compilers are free to instantiate in any order they
want. However, every other compiler seems to instantiate the return
type first, and some code (in this case, Boost.Polygon) depends on
this and SFINAE to avoid instantiating something that shouldn't be
instantiated.
We could fight this battle, and insist that Clang is allowed to do
what it does, but it's not beneficial: it's more predictable to
instantiate this way, in source order. When we implement
late-specified return types, we'll need to instantiate the return type
last when it was late-specified, hence the FIXME.
We now compile Boost.Polygon properly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-08-31 04:26:14 +04:00
|
|
|
|
2010-10-01 22:44:50 +04:00
|
|
|
QualType ResultType;
|
|
|
|
|
|
|
|
if (TL.getTrailingReturn()) {
|
2011-01-07 03:20:55 +03:00
|
|
|
if (getDerived().TransformFunctionTypeParams(TL.getBeginLoc(),
|
|
|
|
TL.getParmArray(),
|
|
|
|
TL.getNumArgs(),
|
|
|
|
TL.getTypePtr()->arg_type_begin(),
|
|
|
|
ParamTypes, &ParamDecls))
|
2010-10-01 22:44:50 +04:00
|
|
|
return QualType();
|
|
|
|
|
|
|
|
ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
|
|
|
|
if (ResultType.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ResultType = getDerived().TransformType(TLB, TL.getResultLoc());
|
|
|
|
if (ResultType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
2011-01-07 03:20:55 +03:00
|
|
|
if (getDerived().TransformFunctionTypeParams(TL.getBeginLoc(),
|
|
|
|
TL.getParmArray(),
|
|
|
|
TL.getNumArgs(),
|
|
|
|
TL.getTypePtr()->arg_type_begin(),
|
|
|
|
ParamTypes, &ParamDecls))
|
2010-10-01 22:44:50 +04:00
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ResultType != T->getResultType() ||
|
2011-01-07 22:27:47 +03:00
|
|
|
T->getNumArgs() != ParamTypes.size() ||
|
2009-10-21 04:40:46 +04:00
|
|
|
!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(),
|
2011-01-26 08:01:58 +03:00
|
|
|
T->getRefQualifier(),
|
2010-08-05 06:54:05 +04:00
|
|
|
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);
|
2011-03-12 14:17:06 +03:00
|
|
|
NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
|
|
|
|
NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
|
2010-10-01 22:44:50 +04:00
|
|
|
NewTL.setTrailingReturn(TL.getTrailingReturn());
|
2009-10-21 04:40:46 +04:00
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
FunctionNoProtoTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const FunctionNoProtoType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
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);
|
2011-03-12 14:17:06 +03:00
|
|
|
NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
|
|
|
|
NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
|
2010-10-01 22:44:50 +04:00
|
|
|
NewTL.setTrailingReturn(false);
|
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-12-05 01:46:56 +03:00
|
|
|
template<typename Derived> QualType
|
|
|
|
TreeTransform<Derived>::TransformUnresolvedUsingType(TypeLocBuilder &TLB,
|
2010-11-12 11:19:04 +03:00
|
|
|
UnresolvedUsingTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const 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-11-12 11:19:04 +03:00
|
|
|
TypedefTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const TypedefType *T = TL.getTypePtr();
|
2011-04-15 18:24:37 +04:00
|
|
|
TypedefNameDecl *Typedef
|
|
|
|
= cast_or_null<TypedefNameDecl>(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-11-12 11:19:04 +03:00
|
|
|
TypeOfExprTypeLoc TL) {
|
2009-08-05 02:27:00 +04:00
|
|
|
// typeof expressions are not potentially evaluated contexts
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::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-10-12 04:20:44 +04:00
|
|
|
Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc());
|
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-11-12 11:19:04 +03:00
|
|
|
TypeOfTypeLoc TL) {
|
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-11-12 11:19:04 +03:00
|
|
|
DecltypeTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const DecltypeType *T = TL.getTypePtr();
|
2009-10-21 04:40:46 +04:00
|
|
|
|
2009-08-05 02:27:00 +04:00
|
|
|
// decltype expressions are not potentially evaluated contexts
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::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-10-12 04:20:44 +04:00
|
|
|
Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc());
|
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
|
|
|
}
|
|
|
|
|
2011-05-25 02:41:36 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformUnaryTransformType(
|
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
UnaryTransformTypeLoc TL) {
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (Result->isDependentType()) {
|
|
|
|
const UnaryTransformType *T = TL.getTypePtr();
|
|
|
|
QualType NewBase =
|
|
|
|
getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
|
|
|
|
Result = getDerived().RebuildUnaryTransformType(NewBase,
|
|
|
|
T->getUTTKind(),
|
|
|
|
TL.getKWLoc());
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
|
|
|
|
NewTL.setKWLoc(TL.getKWLoc());
|
|
|
|
NewTL.setParensRange(TL.getParensRange());
|
|
|
|
NewTL.setUnderlyingTInfo(TL.getUnderlyingTInfo());
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2011-02-20 06:19:35 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformAutoType(TypeLocBuilder &TLB,
|
|
|
|
AutoTypeLoc TL) {
|
|
|
|
const AutoType *T = TL.getTypePtr();
|
|
|
|
QualType OldDeduced = T->getDeducedType();
|
|
|
|
QualType NewDeduced;
|
|
|
|
if (!OldDeduced.isNull()) {
|
|
|
|
NewDeduced = getDerived().TransformType(OldDeduced);
|
|
|
|
if (NewDeduced.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced) {
|
|
|
|
Result = getDerived().RebuildAutoType(NewDeduced);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(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>::TransformRecordType(TypeLocBuilder &TLB,
|
2010-11-12 11:19:04 +03:00
|
|
|
RecordTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const 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-11-12 11:19:04 +03:00
|
|
|
EnumTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const 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,
|
2010-11-12 11:19:04 +03:00
|
|
|
InjectedClassNameTypeLoc TL) {
|
2010-03-10 06:28:59 +03:00
|
|
|
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-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-11-12 11:19:04 +03:00
|
|
|
TemplateTypeParmTypeLoc TL) {
|
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-11-12 11:19:04 +03:00
|
|
|
SubstTemplateTypeParmTypeLoc TL) {
|
2011-03-05 20:19:27 +03:00
|
|
|
const SubstTemplateTypeParmType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
// Substitute into the replacement type, which itself might involve something
|
|
|
|
// that needs to be transformed. This only tends to occur with default
|
|
|
|
// template arguments of template template parameters.
|
|
|
|
TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
|
|
|
|
QualType Replacement = getDerived().TransformType(T->getReplacementType());
|
|
|
|
if (Replacement.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
// Always canonicalize the replacement type.
|
|
|
|
Replacement = SemaRef.Context.getCanonicalType(Replacement);
|
|
|
|
QualType Result
|
|
|
|
= SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
|
|
|
|
Replacement);
|
|
|
|
|
|
|
|
// Propagate type-source information.
|
|
|
|
SubstTemplateTypeParmTypeLoc NewTL
|
|
|
|
= TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
|
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
return Result;
|
|
|
|
|
2009-10-18 13:09:24 +04:00
|
|
|
}
|
|
|
|
|
2011-01-14 05:55:32 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformSubstTemplateTypeParmPackType(
|
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
SubstTemplateTypeParmPackTypeLoc TL) {
|
|
|
|
return TransformTypeSpecType(TLB, TL);
|
|
|
|
}
|
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformTemplateSpecializationType(
|
2010-11-12 11:19:04 +03:00
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
TemplateSpecializationTypeLoc TL) {
|
|
|
|
const TemplateSpecializationType *T = TL.getTypePtr();
|
2009-10-29 21:45:58 +03:00
|
|
|
|
2011-03-02 21:46:51 +03:00
|
|
|
// The nested-name-specifier never matters in a TemplateSpecializationType,
|
|
|
|
// because we can't have a dependent nested-name-specifier anyway.
|
|
|
|
CXXScopeSpec SS;
|
2010-11-12 11:19:04 +03:00
|
|
|
TemplateName Template
|
2011-03-02 21:46:51 +03:00
|
|
|
= getDerived().TransformTemplateName(SS, T->getTemplateName(),
|
|
|
|
TL.getTemplateNameLoc());
|
2010-11-12 11:19:04 +03:00
|
|
|
if (Template.isNull())
|
|
|
|
return QualType();
|
2009-10-29 11:12:44 +03:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
|
2009-10-20 02:04:39 +04:00
|
|
|
}
|
2010-11-12 11:19:04 +03:00
|
|
|
|
2011-10-07 03:00:33 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformAtomicType(TypeLocBuilder &TLB,
|
|
|
|
AtomicTypeLoc TL) {
|
|
|
|
QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
|
|
|
|
if (ValueType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
ValueType != TL.getValueLoc().getType()) {
|
|
|
|
Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
|
|
|
|
NewTL.setKWLoc(TL.getKWLoc());
|
|
|
|
NewTL.setLParenLoc(TL.getLParenLoc());
|
|
|
|
NewTL.setRParenLoc(TL.getRParenLoc());
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2010-12-21 02:36:19 +03:00
|
|
|
namespace {
|
|
|
|
/// \brief Simple iterator that traverses the template arguments in a
|
|
|
|
/// container that provides a \c getArgLoc() member function.
|
|
|
|
///
|
|
|
|
/// This iterator is intended to be used with the iterator form of
|
|
|
|
/// \c TreeTransform<Derived>::TransformTemplateArguments().
|
|
|
|
template<typename ArgLocContainer>
|
|
|
|
class TemplateArgumentLocContainerIterator {
|
|
|
|
ArgLocContainer *Container;
|
|
|
|
unsigned Index;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef TemplateArgumentLoc value_type;
|
|
|
|
typedef TemplateArgumentLoc reference;
|
|
|
|
typedef int difference_type;
|
|
|
|
typedef std::input_iterator_tag iterator_category;
|
|
|
|
|
|
|
|
class pointer {
|
|
|
|
TemplateArgumentLoc Arg;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
|
|
|
|
|
|
|
|
const TemplateArgumentLoc *operator->() const {
|
|
|
|
return &Arg;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
TemplateArgumentLocContainerIterator() {}
|
|
|
|
|
|
|
|
TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
|
|
|
|
unsigned Index)
|
|
|
|
: Container(&Container), Index(Index) { }
|
|
|
|
|
|
|
|
TemplateArgumentLocContainerIterator &operator++() {
|
|
|
|
++Index;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateArgumentLocContainerIterator operator++(int) {
|
|
|
|
TemplateArgumentLocContainerIterator Old(*this);
|
|
|
|
++(*this);
|
|
|
|
return Old;
|
|
|
|
}
|
|
|
|
|
|
|
|
TemplateArgumentLoc operator*() const {
|
|
|
|
return Container->getArgLoc(Index);
|
|
|
|
}
|
|
|
|
|
|
|
|
pointer operator->() const {
|
|
|
|
return pointer(Container->getArgLoc(Index));
|
|
|
|
}
|
|
|
|
|
|
|
|
friend bool operator==(const TemplateArgumentLocContainerIterator &X,
|
2010-12-22 00:51:48 +03:00
|
|
|
const TemplateArgumentLocContainerIterator &Y) {
|
2010-12-21 02:36:19 +03:00
|
|
|
return X.Container == Y.Container && X.Index == Y.Index;
|
|
|
|
}
|
|
|
|
|
|
|
|
friend bool operator!=(const TemplateArgumentLocContainerIterator &X,
|
2010-12-22 00:51:48 +03:00
|
|
|
const TemplateArgumentLocContainerIterator &Y) {
|
2010-12-21 02:36:19 +03:00
|
|
|
return !(X == Y);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-11-12 11:19:04 +03: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,
|
2010-11-12 11:19:04 +03:00
|
|
|
TemplateName Template) {
|
2009-11-23 04:53:49 +03:00
|
|
|
TemplateArgumentListInfo NewTemplateArgs;
|
|
|
|
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
|
2010-12-21 02:36:19 +03:00
|
|
|
typedef TemplateArgumentLocContainerIterator<TemplateSpecializationTypeLoc>
|
|
|
|
ArgIterator;
|
|
|
|
if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
|
|
|
|
ArgIterator(TL, TL.getNumArgs()),
|
|
|
|
NewTemplateArgs))
|
2010-12-20 20:42:22 +03:00
|
|
|
return QualType();
|
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()) {
|
2011-05-06 01:57:07 +04:00
|
|
|
// Specializations of template template parameters are represented as
|
|
|
|
// TemplateSpecializationTypes, and substitution of type alias templates
|
|
|
|
// within a dependent context can transform them into
|
|
|
|
// DependentTemplateSpecializationTypes.
|
|
|
|
if (isa<DependentTemplateSpecializationType>(Result)) {
|
|
|
|
DependentTemplateSpecializationTypeLoc NewTL
|
|
|
|
= TLB.push<DependentTemplateSpecializationTypeLoc>(Result);
|
|
|
|
NewTL.setKeywordLoc(TL.getTemplateNameLoc());
|
|
|
|
NewTL.setQualifierLoc(NestedNameSpecifierLoc());
|
|
|
|
NewTL.setNameLoc(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());
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2009-10-29 11:12:44 +03:00
|
|
|
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
|
|
|
|
2011-02-28 20:23:35 +03:00
|
|
|
template <typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformDependentTemplateSpecializationType(
|
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
DependentTemplateSpecializationTypeLoc TL,
|
2011-03-04 21:53:13 +03:00
|
|
|
TemplateName Template,
|
|
|
|
CXXScopeSpec &SS) {
|
2011-02-28 20:23:35 +03:00
|
|
|
TemplateArgumentListInfo NewTemplateArgs;
|
|
|
|
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
typedef TemplateArgumentLocContainerIterator<
|
|
|
|
DependentTemplateSpecializationTypeLoc> ArgIterator;
|
|
|
|
if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
|
|
|
|
ArgIterator(TL, TL.getNumArgs()),
|
|
|
|
NewTemplateArgs))
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
// FIXME: maybe don't rebuild if all the template arguments are the same.
|
|
|
|
|
|
|
|
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
|
|
|
|
QualType Result
|
|
|
|
= getSema().Context.getDependentTemplateSpecializationType(
|
|
|
|
TL.getTypePtr()->getKeyword(),
|
|
|
|
DTN->getQualifier(),
|
|
|
|
DTN->getIdentifier(),
|
|
|
|
NewTemplateArgs);
|
|
|
|
|
|
|
|
DependentTemplateSpecializationTypeLoc NewTL
|
|
|
|
= TLB.push<DependentTemplateSpecializationTypeLoc>(Result);
|
|
|
|
NewTL.setKeywordLoc(TL.getKeywordLoc());
|
2011-03-01 23:11:18 +03:00
|
|
|
|
|
|
|
NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
|
2011-02-28 20:23:35 +03:00
|
|
|
NewTL.setNameLoc(TL.getNameLoc());
|
|
|
|
NewTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTL.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
|
|
|
|
NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
QualType Result
|
|
|
|
= getDerived().RebuildTemplateSpecializationType(Template,
|
|
|
|
TL.getNameLoc(),
|
|
|
|
NewTemplateArgs);
|
|
|
|
|
|
|
|
if (!Result.isNull()) {
|
|
|
|
/// FIXME: Wrap this in an elaborated-type-specifier?
|
|
|
|
TemplateSpecializationTypeLoc NewTL
|
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(Result);
|
|
|
|
NewTL.setTemplateNameLoc(TL.getNameLoc());
|
|
|
|
NewTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTL.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
|
|
|
|
NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
|
|
|
|
}
|
|
|
|
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
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,
|
2010-11-12 11:19:04 +03:00
|
|
|
ElaboratedTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const ElaboratedType *T = TL.getTypePtr();
|
2010-05-12 01:36:43 +04:00
|
|
|
|
2011-03-01 21:12:44 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
2010-05-12 01:36:43 +04:00
|
|
|
// NOTE: the qualifier in an ElaboratedType is optional.
|
2011-03-01 21:12:44 +03:00
|
|
|
if (TL.getQualifierLoc()) {
|
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2010-05-12 01:36:43 +04:00
|
|
|
return QualType();
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
|
|
|
|
if (NamedT.isNull())
|
|
|
|
return QualType();
|
2010-05-14 20:34:09 +04:00
|
|
|
|
2011-05-06 01:57:07 +04:00
|
|
|
// C++0x [dcl.type.elab]p2:
|
|
|
|
// If the identifier resolves to a typedef-name or the simple-template-id
|
|
|
|
// resolves to an alias template specialization, the
|
|
|
|
// elaborated-type-specifier is ill-formed.
|
2011-05-14 19:04:18 +04:00
|
|
|
if (T->getKeyword() != ETK_None && T->getKeyword() != ETK_Typename) {
|
|
|
|
if (const TemplateSpecializationType *TST =
|
|
|
|
NamedT->getAs<TemplateSpecializationType>()) {
|
|
|
|
TemplateName Template = TST->getTemplateName();
|
|
|
|
if (TypeAliasTemplateDecl *TAT =
|
|
|
|
dyn_cast_or_null<TypeAliasTemplateDecl>(Template.getAsTemplateDecl())) {
|
|
|
|
SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
|
|
|
|
diag::err_tag_reference_non_tag) << 4;
|
|
|
|
SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
|
|
|
|
}
|
2011-05-06 01:57:07 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-21 04:40:46 +04:00
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
2011-03-01 21:12:44 +03:00
|
|
|
QualifierLoc != TL.getQualifierLoc() ||
|
2010-05-20 01:37:53 +04:00
|
|
|
NamedT != T->getNamedType()) {
|
2010-11-04 22:04:38 +03:00
|
|
|
Result = getDerived().RebuildElaboratedType(TL.getKeywordLoc(),
|
2011-03-01 21:12:44 +03:00
|
|
|
T->getKeyword(),
|
|
|
|
QualifierLoc, 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());
|
2011-03-01 21:12:44 +03:00
|
|
|
NewTL.setQualifierLoc(QualifierLoc);
|
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
|
|
|
|
2011-01-06 04:58:22 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformAttributedType(
|
|
|
|
TypeLocBuilder &TLB,
|
|
|
|
AttributedTypeLoc TL) {
|
|
|
|
const AttributedType *oldType = TL.getTypePtr();
|
|
|
|
QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
|
|
|
|
if (modifiedType.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType result = TL.getType();
|
|
|
|
|
|
|
|
// FIXME: dependent operand expressions?
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
modifiedType != oldType->getModifiedType()) {
|
|
|
|
// TODO: this is really lame; we should really be rebuilding the
|
|
|
|
// equivalent type from first principles.
|
|
|
|
QualType equivalentType
|
|
|
|
= getDerived().TransformType(oldType->getEquivalentType());
|
|
|
|
if (equivalentType.isNull())
|
|
|
|
return QualType();
|
|
|
|
result = SemaRef.Context.getAttributedType(oldType->getAttrKind(),
|
|
|
|
modifiedType,
|
|
|
|
equivalentType);
|
|
|
|
}
|
|
|
|
|
|
|
|
AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
|
|
|
|
newTL.setAttrNameLoc(TL.getAttrNameLoc());
|
|
|
|
if (TL.hasAttrOperand())
|
|
|
|
newTL.setAttrOperandParensRange(TL.getAttrOperandParensRange());
|
|
|
|
if (TL.hasAttrExprOperand())
|
|
|
|
newTL.setAttrExprOperand(TL.getAttrExprOperand());
|
|
|
|
else if (TL.hasAttrEnumOperand())
|
|
|
|
newTL.setAttrEnumOperandLoc(TL.getAttrEnumOperandLoc());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-12-10 19:29:40 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType
|
|
|
|
TreeTransform<Derived>::TransformParenType(TypeLocBuilder &TLB,
|
|
|
|
ParenTypeLoc TL) {
|
|
|
|
QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
|
|
|
|
if (Inner.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
Inner != TL.getInnerLoc().getType()) {
|
|
|
|
Result = getDerived().RebuildParenType(Inner);
|
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
|
|
|
|
NewTL.setLParenLoc(TL.getLParenLoc());
|
|
|
|
NewTL.setRParenLoc(TL.getRParenLoc());
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
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,
|
2010-11-12 11:19:04 +03:00
|
|
|
DependentNameTypeLoc TL) {
|
2011-01-19 09:33:43 +03:00
|
|
|
const DependentNameType *T = TL.getTypePtr();
|
2009-10-29 11:12:44 +03:00
|
|
|
|
2011-03-01 04:34:45 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2009-08-04 20:50:30 +04:00
|
|
|
return QualType();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-06-11 04:33:02 +04:00
|
|
|
QualType Result
|
2011-03-01 04:34:45 +03:00
|
|
|
= getDerived().RebuildDependentNameType(T->getKeyword(),
|
2010-06-11 04:33:02 +04:00
|
|
|
TL.getKeywordLoc(),
|
2011-03-01 04:34:45 +03:00
|
|
|
QualifierLoc,
|
|
|
|
T->getIdentifier(),
|
2010-06-11 04:33:02 +04:00
|
|
|
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());
|
2011-03-01 21:12:44 +03:00
|
|
|
NewTL.setQualifierLoc(QualifierLoc);
|
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());
|
2011-03-01 04:34:45 +03:00
|
|
|
NewTL.setQualifierLoc(QualifierLoc);
|
2010-05-20 01:37:53 +04:00
|
|
|
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,
|
2010-11-12 11:19:04 +03:00
|
|
|
DependentTemplateSpecializationTypeLoc TL) {
|
2011-03-01 23:11:18 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
|
|
|
if (TL.getQualifierLoc()) {
|
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2011-02-28 20:23:35 +03:00
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
return getDerived()
|
2011-03-01 23:11:18 +03:00
|
|
|
.TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
|
2010-11-12 11:19:04 +03:00
|
|
|
}
|
|
|
|
|
2011-03-01 23:11:18 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::
|
|
|
|
TransformDependentTemplateSpecializationType(TypeLocBuilder &TLB,
|
|
|
|
DependentTemplateSpecializationTypeLoc TL,
|
|
|
|
NestedNameSpecifierLoc QualifierLoc) {
|
|
|
|
const DependentTemplateSpecializationType *T = TL.getTypePtr();
|
|
|
|
|
|
|
|
TemplateArgumentListInfo NewTemplateArgs;
|
|
|
|
NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
|
|
|
|
|
|
|
|
typedef TemplateArgumentLocContainerIterator<
|
|
|
|
DependentTemplateSpecializationTypeLoc> ArgIterator;
|
|
|
|
if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
|
|
|
|
ArgIterator(TL, TL.getNumArgs()),
|
|
|
|
NewTemplateArgs))
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result
|
|
|
|
= getDerived().RebuildDependentTemplateSpecializationType(T->getKeyword(),
|
|
|
|
QualifierLoc,
|
|
|
|
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
|
2011-03-07 05:33:33 +03:00
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(NamedT);
|
2011-04-01 06:03:23 +04:00
|
|
|
NamedTL.setTemplateNameLoc(TL.getNameLoc());
|
2011-03-01 23:11:18 +03:00
|
|
|
NamedTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
NamedTL.setRAngleLoc(TL.getRAngleLoc());
|
2011-03-07 18:13:34 +03:00
|
|
|
for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
|
2011-03-07 05:33:33 +03:00
|
|
|
NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
|
2011-03-01 23:11:18 +03:00
|
|
|
|
|
|
|
// Copy information relevant to the elaborated type.
|
|
|
|
ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
|
|
|
|
NewTL.setKeywordLoc(TL.getKeywordLoc());
|
|
|
|
NewTL.setQualifierLoc(QualifierLoc);
|
2011-03-07 05:33:33 +03:00
|
|
|
} else if (isa<DependentTemplateSpecializationType>(Result)) {
|
|
|
|
DependentTemplateSpecializationTypeLoc SpecTL
|
|
|
|
= TLB.push<DependentTemplateSpecializationTypeLoc>(Result);
|
2011-03-07 18:13:34 +03:00
|
|
|
SpecTL.setKeywordLoc(TL.getKeywordLoc());
|
2011-03-07 05:33:33 +03:00
|
|
|
SpecTL.setQualifierLoc(QualifierLoc);
|
2011-04-01 06:03:23 +04:00
|
|
|
SpecTL.setNameLoc(TL.getNameLoc());
|
2011-03-07 05:33:33 +03:00
|
|
|
SpecTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
SpecTL.setRAngleLoc(TL.getRAngleLoc());
|
2011-03-07 18:13:34 +03:00
|
|
|
for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
|
2011-03-07 05:33:33 +03:00
|
|
|
SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
|
2011-03-01 23:11:18 +03:00
|
|
|
} else {
|
2011-03-07 05:33:33 +03:00
|
|
|
TemplateSpecializationTypeLoc SpecTL
|
|
|
|
= TLB.push<TemplateSpecializationTypeLoc>(Result);
|
2011-04-01 06:03:23 +04:00
|
|
|
SpecTL.setTemplateNameLoc(TL.getNameLoc());
|
2011-03-07 05:33:33 +03:00
|
|
|
SpecTL.setLAngleLoc(TL.getLAngleLoc());
|
|
|
|
SpecTL.setRAngleLoc(TL.getRAngleLoc());
|
2011-03-07 18:13:34 +03:00
|
|
|
for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
|
2011-03-07 05:33:33 +03:00
|
|
|
SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
|
2011-03-01 23:11:18 +03:00
|
|
|
}
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|
2010-12-20 05:24:11 +03:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::TransformPackExpansionType(TypeLocBuilder &TLB,
|
|
|
|
PackExpansionTypeLoc TL) {
|
2011-01-12 20:07:58 +03:00
|
|
|
QualType Pattern
|
|
|
|
= getDerived().TransformType(TLB, TL.getPatternLoc());
|
|
|
|
if (Pattern.isNull())
|
|
|
|
return QualType();
|
|
|
|
|
|
|
|
QualType Result = TL.getType();
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
Pattern != TL.getPatternLoc().getType()) {
|
|
|
|
Result = getDerived().RebuildPackExpansionType(Pattern,
|
|
|
|
TL.getPatternLoc().getSourceRange(),
|
2011-01-14 20:04:44 +03:00
|
|
|
TL.getEllipsisLoc(),
|
|
|
|
TL.getTypePtr()->getNumExpansions());
|
2011-01-12 20:07:58 +03:00
|
|
|
if (Result.isNull())
|
|
|
|
return QualType();
|
|
|
|
}
|
|
|
|
|
|
|
|
PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
|
|
|
|
NewT.setEllipsisLoc(TL.getEllipsisLoc());
|
|
|
|
return Result;
|
2010-12-20 05:24:11 +03:00
|
|
|
}
|
|
|
|
|
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-11-12 11:19:04 +03:00
|
|
|
ObjCInterfaceTypeLoc TL) {
|
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,
|
2010-11-12 11:19:04 +03:00
|
|
|
ObjCObjectTypeLoc TL) {
|
2010-05-15 15:32:37 +04:00
|
|
|
// 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-11-12 11:19:04 +03:00
|
|
|
ObjCObjectPointerTypeLoc TL) {
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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) {
|
2010-08-27 23:56:05 +04:00
|
|
|
bool SubStmtInvalid = false;
|
2009-08-20 11:17:43 +04:00
|
|
|
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);
|
2010-08-27 23:56:05 +04:00
|
|
|
if (Result.isInvalid()) {
|
|
|
|
// Immediately fail if this was a DeclStmt, since it's very
|
|
|
|
// likely that this will cause problems for future statements.
|
|
|
|
if (isa<DeclStmt>(*B))
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
// Otherwise, just keep processing substatements and fail later.
|
|
|
|
SubStmtInvalid = true;
|
|
|
|
continue;
|
|
|
|
}
|
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
|
|
|
|
2010-08-27 23:56:05 +04:00
|
|
|
if (SubStmtInvalid)
|
|
|
|
return StmtError();
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
!SubStmtChanged)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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.
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-11-19 06:14:00 +03:00
|
|
|
}
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-02-17 23:34:02 +03:00
|
|
|
Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
|
|
|
|
S->getDecl());
|
|
|
|
if (!LD)
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
// FIXME: Pass the real colon location in.
|
2011-02-17 10:39:24 +03:00
|
|
|
return getDerived().RebuildLabelStmt(S->getIdentLoc(),
|
2011-02-17 23:34:02 +03:00
|
|
|
cast<LabelDecl>(LD), SourceLocation(),
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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-12-21 01:05:00 +03:00
|
|
|
ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getIfLoc(),
|
|
|
|
Cond.get());
|
2010-05-09 03:34:38 +04:00
|
|
|
if (CondE.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-05-09 02:20:28 +04:00
|
|
|
return getDerived().RebuildIfStmt(S->getIfLoc(), FullCond, ConditionVar,
|
2010-11-20 05:04:01 +03:00
|
|
|
Then.get(),
|
2010-08-24 03:25:46 +04:00
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-11-25 03:27:52 +03:00
|
|
|
}
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 03:34:38 +04:00
|
|
|
|
|
|
|
if (S->getCond()) {
|
|
|
|
// Convert the condition to a boolean value.
|
2010-12-21 01:05:00 +03:00
|
|
|
ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getWhileLoc(),
|
|
|
|
Cond.get());
|
2010-05-09 03:34:38 +04:00
|
|
|
if (CondE.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Cond.get() == S->getCond() &&
|
|
|
|
Body.get() == S->getBody())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-11-25 03:27:52 +03:00
|
|
|
} 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 03:34:38 +04:00
|
|
|
|
|
|
|
if (S->getCond()) {
|
|
|
|
// Convert the condition to a boolean value.
|
2010-12-21 01:05:00 +03:00
|
|
|
ExprResult CondE = getSema().ActOnBooleanCondition(0, S->getForLoc(),
|
|
|
|
Cond.get());
|
2010-05-09 03:34:38 +04:00
|
|
|
if (CondE.isInvalid())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 03:34:38 +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
|
|
|
}
|
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-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-05-09 02:20:28 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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) {
|
2011-02-17 23:34:02 +03:00
|
|
|
Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
|
|
|
|
S->getLabel());
|
|
|
|
if (!LD)
|
|
|
|
return StmtError();
|
|
|
|
|
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(),
|
2011-02-17 23:34:02 +03:00
|
|
|
cast<LabelDecl>(LD));
|
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>::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-20 11:17:43 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Target.get() == S->getTarget())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(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
|
|
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(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
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-08-20 11:17:43 +04:00
|
|
|
|
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;
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<Decl *, 4> Decls;
|
2009-08-20 11:17:43 +04:00
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
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-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());
|
2011-07-20 10:58:45 +04:00
|
|
|
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.
|
2010-10-26 11:05:15 +04:00
|
|
|
Constraints.push_back(S->getOutputConstraintLiteral(I));
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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.
|
2010-10-26 11:05:15 +04:00
|
|
|
Constraints.push_back(S->getInputConstraintLiteral(I));
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2010-01-24 08:50:09 +03:00
|
|
|
|
|
|
|
// Go through the clobbers.
|
|
|
|
for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
|
2010-10-26 11:05:15 +04:00
|
|
|
Clobbers.push_back(S->getClobber(I));
|
2010-01-24 08:50:09 +03:00
|
|
|
|
|
|
|
// 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-04-23 03:59:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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
|
|
|
QualType T;
|
|
|
|
if (TSInfo)
|
|
|
|
T = TSInfo->getType();
|
|
|
|
else {
|
|
|
|
T = getDerived().TransformType(FromVar->getType());
|
|
|
|
if (T.isNull())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-04-26 21:57:08 +04:00
|
|
|
}
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2010-04-23 03:59:56 +04:00
|
|
|
|
|
|
|
// 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2010-04-23 01:44:01 +04:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-23 01:44:01 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Operand.get() == S->getThrowExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return getSema().Owned(S);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2011-07-28 01:50:02 +04:00
|
|
|
Object =
|
|
|
|
getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
|
|
|
|
Object.get());
|
|
|
|
if (Object.isInvalid())
|
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
2010-04-23 02:01:21 +04:00
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
2011-06-16 03:02:42 +04:00
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformObjCAutoreleasePoolStmt(
|
|
|
|
ObjCAutoreleasePoolStmt *S) {
|
|
|
|
// Transform the body.
|
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
|
|
|
|
if (Body.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
// If nothing changed, just retain this statement.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Body.get() == S->getSubStmt())
|
|
|
|
return SemaRef.Owned(S);
|
|
|
|
|
|
|
|
// Build a new statement.
|
|
|
|
return getDerived().RebuildObjCAutoreleasePoolStmt(
|
|
|
|
S->getAtLoc(), 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2011-07-27 05:07:15 +04:00
|
|
|
Collection = getDerived().RebuildObjCForCollectionOperand(S->getForLoc(),
|
|
|
|
Collection.take());
|
|
|
|
if (Collection.isInvalid())
|
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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();
|
2010-09-09 21:09:21 +04:00
|
|
|
TypeSourceInfo *T = getDerived().TransformType(
|
|
|
|
ExceptionDecl->getTypeSourceInfo());
|
|
|
|
if (!T)
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-09-09 21:09:21 +04:00
|
|
|
Var = getDerived().RebuildExceptionDecl(ExceptionDecl, T,
|
2011-03-08 11:55:46 +03:00
|
|
|
ExceptionDecl->getInnerLocStart(),
|
|
|
|
ExceptionDecl->getLocation(),
|
|
|
|
ExceptionDecl->getIdentifier());
|
2010-07-25 22:17:45 +04:00
|
|
|
if (!Var || Var->isInvalidDecl())
|
2010-08-27 03:41:50 +04:00
|
|
|
return StmtError();
|
2009-08-20 11:17:43 +04:00
|
|
|
}
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(S);
|
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
|
|
|
|
2011-04-15 02:09:26 +04:00
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformCXXForRangeStmt(CXXForRangeStmt *S) {
|
|
|
|
StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
|
|
|
|
if (Range.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
StmtResult BeginEnd = getDerived().TransformStmt(S->getBeginEndStmt());
|
|
|
|
if (BeginEnd.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
ExprResult Cond = getDerived().TransformExpr(S->getCond());
|
|
|
|
if (Cond.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
ExprResult Inc = getDerived().TransformExpr(S->getInc());
|
|
|
|
if (Inc.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
|
|
|
|
if (LoopVar.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
StmtResult NewStmt = S;
|
|
|
|
if (getDerived().AlwaysRebuild() ||
|
|
|
|
Range.get() != S->getRangeStmt() ||
|
|
|
|
BeginEnd.get() != S->getBeginEndStmt() ||
|
|
|
|
Cond.get() != S->getCond() ||
|
|
|
|
Inc.get() != S->getInc() ||
|
|
|
|
LoopVar.get() != S->getLoopVarStmt())
|
|
|
|
NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
|
|
|
|
S->getColonLoc(), Range.get(),
|
|
|
|
BeginEnd.get(), Cond.get(),
|
|
|
|
Inc.get(), LoopVar.get(),
|
|
|
|
S->getRParenLoc());
|
|
|
|
|
|
|
|
StmtResult Body = getDerived().TransformStmt(S->getBody());
|
|
|
|
if (Body.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
// Body has changed but we didn't rebuild the for-range statement. Rebuild
|
|
|
|
// it now so we have a new statement to attach the body to.
|
|
|
|
if (Body.get() != S->getBody() && NewStmt.get() == S)
|
|
|
|
NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
|
|
|
|
S->getColonLoc(), Range.get(),
|
|
|
|
BeginEnd.get(), Cond.get(),
|
|
|
|
Inc.get(), LoopVar.get(),
|
|
|
|
S->getRParenLoc());
|
|
|
|
|
|
|
|
if (NewStmt.get() == S)
|
|
|
|
return SemaRef.Owned(S);
|
|
|
|
|
|
|
|
return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
|
|
|
|
}
|
|
|
|
|
2011-10-25 05:33:02 +04:00
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformMSDependentExistsStmt(
|
|
|
|
MSDependentExistsStmt *S) {
|
|
|
|
// Transform the nested-name-specifier, if any.
|
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
|
|
|
if (S->getQualifierLoc()) {
|
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
|
|
|
return StmtError();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Transform the declaration name.
|
|
|
|
DeclarationNameInfo NameInfo = S->getNameInfo();
|
|
|
|
if (NameInfo.getName()) {
|
|
|
|
NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
|
|
|
|
if (!NameInfo.getName())
|
|
|
|
return StmtError();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check whether anything changed.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
QualifierLoc == S->getQualifierLoc() &&
|
|
|
|
NameInfo.getName() == S->getNameInfo().getName())
|
|
|
|
return S;
|
|
|
|
|
|
|
|
// Determine whether this name exists, if we can.
|
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.Adopt(QualifierLoc);
|
|
|
|
bool Dependent = false;
|
|
|
|
switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/0, SS, NameInfo)) {
|
|
|
|
case Sema::IER_Exists:
|
|
|
|
if (S->isIfExists())
|
|
|
|
break;
|
|
|
|
|
|
|
|
return new (getSema().Context) NullStmt(S->getKeywordLoc());
|
|
|
|
|
|
|
|
case Sema::IER_DoesNotExist:
|
|
|
|
if (S->isIfNotExists())
|
|
|
|
break;
|
|
|
|
|
|
|
|
return new (getSema().Context) NullStmt(S->getKeywordLoc());
|
|
|
|
|
|
|
|
case Sema::IER_Dependent:
|
|
|
|
Dependent = true;
|
|
|
|
break;
|
2011-10-25 07:44:56 +04:00
|
|
|
|
|
|
|
case Sema::IER_Error:
|
|
|
|
return StmtError();
|
2011-10-25 05:33:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// We need to continue with the instantiation, so do so now.
|
|
|
|
StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
|
|
|
|
if (SubStmt.isInvalid())
|
|
|
|
return StmtError();
|
|
|
|
|
|
|
|
// If we have resolved the name, just transform to the substatement.
|
|
|
|
if (!Dependent)
|
|
|
|
return SubStmt;
|
|
|
|
|
|
|
|
// The name is still dependent, so build a dependent expression again.
|
|
|
|
return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
|
|
|
|
S->isIfExists(),
|
|
|
|
QualifierLoc,
|
|
|
|
NameInfo,
|
|
|
|
SubStmt.get());
|
|
|
|
}
|
|
|
|
|
2011-04-28 05:08:34 +04:00
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformSEHTryStmt(SEHTryStmt *S) {
|
|
|
|
StmtResult TryBlock; // = getDerived().TransformCompoundStmt(S->getTryBlock());
|
|
|
|
if(TryBlock.isInvalid()) return StmtError();
|
|
|
|
|
|
|
|
StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
|
|
|
|
if(!getDerived().AlwaysRebuild() &&
|
|
|
|
TryBlock.get() == S->getTryBlock() &&
|
|
|
|
Handler.get() == S->getHandler())
|
|
|
|
return SemaRef.Owned(S);
|
|
|
|
|
|
|
|
return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(),
|
|
|
|
S->getTryLoc(),
|
|
|
|
TryBlock.take(),
|
|
|
|
Handler.take());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformSEHFinallyStmt(SEHFinallyStmt *S) {
|
|
|
|
StmtResult Block; // = getDerived().TransformCompoundStatement(S->getBlock());
|
|
|
|
if(Block.isInvalid()) return StmtError();
|
|
|
|
|
|
|
|
return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(),
|
|
|
|
Block.take());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformSEHExceptStmt(SEHExceptStmt *S) {
|
|
|
|
ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
|
|
|
|
if(FilterExpr.isInvalid()) return StmtError();
|
|
|
|
|
|
|
|
StmtResult Block; // = getDerived().TransformCompoundStatement(S->getBlock());
|
|
|
|
if(Block.isInvalid()) return StmtError();
|
|
|
|
|
|
|
|
return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(),
|
|
|
|
FilterExpr.take(),
|
|
|
|
Block.take());
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
StmtResult
|
|
|
|
TreeTransform<Derived>::TransformSEHHandler(Stmt *Handler) {
|
|
|
|
if(isa<SEHFinallyStmt>(Handler))
|
|
|
|
return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
|
|
|
|
else
|
|
|
|
return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
|
|
|
|
}
|
|
|
|
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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>::TransformDeclRefExpr(DeclRefExpr *E) {
|
2011-03-01 00:54:11 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
|
|
|
if (E->getQualifierLoc()) {
|
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-10-23 22:54:35 +04:00
|
|
|
}
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-08-18 01:27:17 +04:00
|
|
|
}
|
2010-08-12 02:01:17 +04:00
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2011-03-01 00:54:11 +03:00
|
|
|
QualifierLoc == E->getQualifierLoc() &&
|
2009-10-23 22:54:35 +04:00
|
|
|
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
|
|
|
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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());
|
2010-12-20 20:31:10 +03:00
|
|
|
if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
|
|
|
|
E->getNumTemplateArgs(),
|
|
|
|
TransArgs))
|
|
|
|
return ExprError();
|
2009-12-08 12:08:17 +03:00
|
|
|
}
|
|
|
|
|
2011-03-01 00:54:11 +03:00
|
|
|
return getDerived().RebuildDeclRefExpr(QualifierLoc, 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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(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>::TransformImaginaryLiteral(ImaginaryLiteral *E) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(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>::TransformCharacterLiteral(CharacterLiteral *E) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-04-15 04:35:48 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformGenericSelectionExpr(GenericSelectionExpr *E) {
|
|
|
|
ExprResult ControllingExpr =
|
|
|
|
getDerived().TransformExpr(E->getControllingExpr());
|
|
|
|
if (ControllingExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<Expr *, 4> AssocExprs;
|
|
|
|
SmallVector<TypeSourceInfo *, 4> AssocTypes;
|
2011-04-15 04:35:48 +04:00
|
|
|
for (unsigned i = 0; i != E->getNumAssocs(); ++i) {
|
|
|
|
TypeSourceInfo *TS = E->getAssocTypeSourceInfo(i);
|
|
|
|
if (TS) {
|
|
|
|
TypeSourceInfo *AssocType = getDerived().TransformType(TS);
|
|
|
|
if (!AssocType)
|
|
|
|
return ExprError();
|
|
|
|
AssocTypes.push_back(AssocType);
|
|
|
|
} else {
|
|
|
|
AssocTypes.push_back(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
ExprResult AssocExpr = getDerived().TransformExpr(E->getAssocExpr(i));
|
|
|
|
if (AssocExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
AssocExprs.push_back(AssocExpr.release());
|
|
|
|
}
|
|
|
|
|
|
|
|
return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
|
|
|
|
E->getDefaultLoc(),
|
|
|
|
E->getRParenLoc(),
|
|
|
|
ControllingExpr.release(),
|
|
|
|
AssocTypes.data(),
|
|
|
|
AssocExprs.data(),
|
|
|
|
E->getNumAssocs());
|
|
|
|
}
|
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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;
|
2010-08-27 03:41:50 +04:00
|
|
|
typedef Sema::OffsetOfComponent Component;
|
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
|
|
|
typedef OffsetOfExpr::OffsetOfNode Node;
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<Component, 4> Components;
|
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
|
|
|
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;
|
2011-03-12 12:45:03 +03:00
|
|
|
Comp.LocStart = ON.getSourceRange().getBegin();
|
|
|
|
Comp.LocEnd = ON.getSourceRange().getEnd();
|
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
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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());
|
2010-11-16 02:31:06 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
|
|
|
|
assert(getDerived().AlreadyTransformed(E->getType()) &&
|
|
|
|
"opaque value expression requires transformation");
|
|
|
|
return SemaRef.Owned(E);
|
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
|
|
|
}
|
|
|
|
|
2011-11-06 13:01:30 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformPseudoObjectExpr(PseudoObjectExpr *E) {
|
|
|
|
// Rebuild the syntactic form.
|
|
|
|
ExprResult result = getDerived().TransformExpr(E->getSyntacticForm());
|
|
|
|
if (result.isInvalid()) return ExprError();
|
|
|
|
|
|
|
|
// If that gives us a pseudo-object result back, the pseudo-object
|
|
|
|
// expression must have been an lvalue-to-rvalue conversion which we
|
|
|
|
// should reapply.
|
|
|
|
if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
|
|
|
|
result = SemaRef.checkPseudoObjectRValue(result.take());
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
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<typename Derived>
|
2010-08-24 10:29:42 +04:00
|
|
|
ExprResult
|
2011-03-11 22:24:49 +03:00
|
|
|
TreeTransform<Derived>::TransformUnaryExprOrTypeTraitExpr(
|
|
|
|
UnaryExprOrTypeTraitExpr *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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-04 10:28:41 +03:00
|
|
|
if (!getDerived().AlwaysRebuild() && OldT == NewT)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-03-11 22:24:49 +03:00
|
|
|
return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
|
|
|
|
E->getKind(),
|
|
|
|
E->getSourceRange());
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
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
|
|
|
|
// [...]
|
2010-08-27 03:41:50 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-03-11 22:24:49 +03:00
|
|
|
return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
|
|
|
|
E->getOperatorLoc(),
|
|
|
|
E->getKind(),
|
|
|
|
E->getSourceRange());
|
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>::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-08-11 09:31:07 +04:00
|
|
|
|
|
|
|
// Transform arguments.
|
|
|
|
bool ArgChanged = false;
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
2011-01-03 22:04:46 +03:00
|
|
|
if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
|
|
|
|
&ArgChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Callee.get() == E->getCallee() &&
|
|
|
|
!ArgChanged)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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),
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-03-01 00:54:11 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
2009-09-01 03:41:50 +04:00
|
|
|
if (E->hasQualifier()) {
|
2011-03-01 00:54:11 +03:00
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
|
|
|
|
|
|
|
|
if (!QualifierLoc)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-01 03:41:50 +04:00
|
|
|
}
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-03-31 01:47:33 +04:00
|
|
|
}
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase() &&
|
2011-03-01 00:54:11 +03:00
|
|
|
QualifierLoc == E->getQualifierLoc() &&
|
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);
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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());
|
2010-12-20 20:31:10 +03:00
|
|
|
if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
|
|
|
|
E->getNumTemplateArgs(),
|
|
|
|
TransArgs))
|
|
|
|
return ExprError();
|
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(),
|
2011-03-01 00:54:11 +03:00
|
|
|
QualifierLoc,
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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
|
|
|
|
2011-02-17 13:25:35 +03:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult TreeTransform<Derived>::
|
|
|
|
TransformBinaryConditionalOperator(BinaryConditionalOperator *e) {
|
|
|
|
// Just rebuild the common and RHS expressions and see whether we
|
|
|
|
// get any changes.
|
|
|
|
|
|
|
|
ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
|
|
|
|
if (commonExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
|
|
|
|
if (rhs.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
commonExpr.get() == e->getCommon() &&
|
|
|
|
rhs.get() == e->getFalseExpr())
|
|
|
|
return SemaRef.Owned(e);
|
|
|
|
|
|
|
|
return getDerived().RebuildConditionalOperator(commonExpr.take(),
|
|
|
|
e->getQuestionLoc(),
|
|
|
|
0,
|
|
|
|
e->getColonLoc(),
|
|
|
|
rhs.get());
|
|
|
|
}
|
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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-09-09 20:55:46 +04:00
|
|
|
TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
|
|
|
|
if (!Type)
|
|
|
|
return ExprError();
|
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-09 20:55:46 +04:00
|
|
|
Type == E->getTypeInfoAsWritten() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-01-15 21:39:57 +03:00
|
|
|
return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
|
2010-09-09 20:55:46 +04:00
|
|
|
Type,
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Base.get() == E->getBase())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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);
|
2011-01-03 22:04:46 +03:00
|
|
|
if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
|
|
|
|
Inits, &InitChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && !InitChanged)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getType())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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);
|
2011-01-03 22:04:46 +03:00
|
|
|
if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
|
|
|
|
&ArgumentChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
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) {
|
2011-02-17 23:34:02 +03:00
|
|
|
Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
|
|
|
|
E->getLabel());
|
|
|
|
if (!LD)
|
|
|
|
return ExprError();
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
|
2011-02-17 23:34:02 +03:00
|
|
|
cast<LabelDecl>(LD));
|
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>::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubStmt.get() == E->getSubStmt())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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>::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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");
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-12-13 23:44:55 +03:00
|
|
|
|
|
|
|
// 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);
|
2011-01-03 22:04:46 +03:00
|
|
|
if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
|
|
|
|
Args))
|
|
|
|
return ExprError();
|
2009-12-13 23:44:55 +03:00
|
|
|
|
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),
|
|
|
|
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");
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-12-13 23:44:55 +03:00
|
|
|
|
|
|
|
case OO_None:
|
|
|
|
case NUM_OVERLOADED_OPERATORS:
|
|
|
|
llvm_unreachable("not an overloaded operator?");
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-12-13 23:44:55 +03:00
|
|
|
}
|
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-08-11 09:31:07 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
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() &&
|
|
|
|
First.get() == E->getArg(0) &&
|
2009-09-09 19:08:12 +04:00
|
|
|
(E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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>
|
2011-02-10 00:07:24 +03:00
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
|
|
|
|
// Transform the callee.
|
|
|
|
ExprResult Callee = getDerived().TransformExpr(E->getCallee());
|
|
|
|
if (Callee.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
// Transform exec config.
|
|
|
|
ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
|
|
|
|
if (EC.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
// Transform arguments.
|
|
|
|
bool ArgChanged = false;
|
|
|
|
ASTOwningVector<Expr*> Args(SemaRef);
|
|
|
|
if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
|
|
|
|
&ArgChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Callee.get() == E->getCallee() &&
|
|
|
|
!ArgChanged)
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
// FIXME: Wrong source location information for the '('.
|
|
|
|
SourceLocation FakeLParenLoc
|
|
|
|
= ((Expr *)Callee.get())->getSourceRange().getBegin();
|
|
|
|
return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
|
|
|
|
move_arg(Args),
|
|
|
|
E->getRParenLoc(), EC.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
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-09-09 20:55:46 +04:00
|
|
|
TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
|
|
|
|
if (!Type)
|
|
|
|
return ExprError();
|
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-09 20:55:46 +04:00
|
|
|
Type == E->getTypeInfoAsWritten() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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-09-09 20:55:46 +04:00
|
|
|
Type,
|
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-09-09 20:55:46 +04:00
|
|
|
TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
|
|
|
|
if (!Type)
|
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-09 20:55:46 +04:00
|
|
|
Type == E->getTypeInfoAsWritten() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
SubExpr.get() == E->getSubExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-09-09 20:55:46 +04:00
|
|
|
return getDerived().RebuildCXXFunctionalCastExpr(Type,
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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,
|
2010-08-27 03:41:50 +04:00
|
|
|
Sema::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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubExpr.get() == E->getExprOperand())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2010-09-08 16:20:18 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformCXXUuidofExpr(CXXUuidofExpr *E) {
|
|
|
|
if (E->isTypeOperand()) {
|
|
|
|
TypeSourceInfo *TInfo
|
|
|
|
= getDerived().TransformType(E->getTypeOperandSourceInfo());
|
|
|
|
if (!TInfo)
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TInfo == E->getTypeOperandSourceInfo())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-09-08 16:20:18 +04:00
|
|
|
|
2011-03-06 20:40:41 +03:00
|
|
|
return getDerived().RebuildCXXUuidofExpr(E->getType(),
|
2010-09-08 16:20:18 +04:00
|
|
|
E->getLocStart(),
|
|
|
|
TInfo,
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
|
|
|
// We don't know whether the expression is potentially evaluated until
|
|
|
|
// after we perform semantic analysis, so the expression is potentially
|
|
|
|
// potentially evaluated.
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
|
|
|
|
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
|
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubExpr.get() == E->getExprOperand())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-09-08 16:20:18 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildCXXUuidofExpr(E->getType(),
|
|
|
|
E->getLocStart(),
|
|
|
|
SubExpr.get(),
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
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>::TransformCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(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>::TransformCXXNullPtrLiteralExpr(
|
2009-12-08 12:21:05 +03:00
|
|
|
CXXNullPtrLiteralExpr *E) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(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>::TransformCXXThisExpr(CXXThisExpr *E) {
|
2010-09-09 20:55:46 +04:00
|
|
|
DeclContext *DC = getSema().getFunctionLevelDeclContext();
|
2011-06-11 21:19:42 +04:00
|
|
|
QualType T;
|
|
|
|
if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC))
|
|
|
|
T = MD->getThisType(getSema().Context);
|
|
|
|
else
|
|
|
|
T = getSema().Context.getPointerType(
|
|
|
|
getSema().Context.getRecordType(cast<CXXRecordDecl>(DC)));
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-09-09 20:55:46 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() && T == E->getType())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
SubExpr.get() == E->getSubExpr())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2011-07-07 02:04:06 +04:00
|
|
|
return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
|
|
|
|
E->isThrownVariableInScope());
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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-09-08 04:15:04 +04:00
|
|
|
TreeTransform<Derived>::TransformCXXScalarValueInitExpr(
|
|
|
|
CXXScalarValueInitExpr *E) {
|
|
|
|
TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
|
|
|
|
if (!T)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-09-08 04:15:04 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-08 04:15:04 +04:00
|
|
|
T == E->getTypeSourceInfo())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-09-08 04:15:04 +04:00
|
|
|
return getDerived().RebuildCXXScalarValueInitExpr(T,
|
|
|
|
/*FIXME:*/T->getTypeLoc().getEndLoc(),
|
2010-07-08 10:14:04 +04:00
|
|
|
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
|
2010-09-08 01:49:58 +04:00
|
|
|
TypeSourceInfo *AllocTypeInfo
|
|
|
|
= getDerived().TransformType(E->getAllocatedTypeSourceInfo());
|
|
|
|
if (!AllocTypeInfo)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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);
|
2011-01-03 22:04:46 +03:00
|
|
|
if (getDerived().TransformExprs(E->getPlacementArgs(),
|
|
|
|
E->getNumPlacementArgs(), true,
|
|
|
|
PlacementArgs, &ArgumentChanged))
|
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-10-18 06:43:19 +04:00
|
|
|
// Transform the constructor arguments (if any).
|
|
|
|
// As an annoying corner case, we may have introduced an implicit value-
|
|
|
|
// initialization expression when allocating a new array, which we implicitly
|
|
|
|
// drop. It will be re-created during type checking.
|
2010-08-23 10:44:23 +04:00
|
|
|
ASTOwningVector<Expr*> ConstructorArgs(SemaRef);
|
2011-10-18 06:43:19 +04:00
|
|
|
if (!(E->isArray() && E->getNumConstructorArgs() == 1 &&
|
|
|
|
isa<ImplicitValueInitExpr>(E->getConstructorArgs()[0])) &&
|
|
|
|
TransformExprs(E->getConstructorArgs(), E->getNumConstructorArgs(), true,
|
2011-01-03 22:04:46 +03:00
|
|
|
ConstructorArgs, &ArgumentChanged))
|
|
|
|
return ExprError();
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-08 01:49:58 +04:00
|
|
|
AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
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);
|
2011-07-26 19:11:03 +04:00
|
|
|
|
|
|
|
if (E->isArray() && Constructor &&
|
|
|
|
!E->getAllocatedType()->isDependentType()) {
|
|
|
|
QualType ElementType
|
|
|
|
= SemaRef.Context.getBaseElementType(E->getAllocatedType());
|
|
|
|
if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
|
|
|
|
if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), Destructor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-09-08 01:49:58 +04:00
|
|
|
QualType AllocType = AllocTypeInfo->getType();
|
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
|
2010-08-28 13:06:06 +04:00
|
|
|
= SemaRef.Owned(IntegerLiteral::Create(SemaRef.Context,
|
|
|
|
ConsArrayT->getSize(),
|
|
|
|
SemaRef.Context.getSizeType(),
|
|
|
|
/*FIXME:*/E->getLocStart()));
|
2009-12-22 20:13:37 +03:00
|
|
|
AllocType = ConsArrayT->getElementType();
|
|
|
|
} else if (const DependentSizedArrayType *DepArrayT
|
|
|
|
= dyn_cast<DependentSizedArrayType>(ArrayT)) {
|
|
|
|
if (DepArrayT->getSizeExpr()) {
|
2010-10-26 11:05:15 +04:00
|
|
|
ArraySize = SemaRef.Owned(DepArrayT->getSizeExpr());
|
2009-12-22 20:13:37 +03:00
|
|
|
AllocType = DepArrayT->getElementType();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-09-08 01:49:58 +04:00
|
|
|
|
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,
|
2010-09-08 01:49:58 +04:00
|
|
|
AllocTypeInfo,
|
2010-08-24 03:25:46 +04:00
|
|
|
ArraySize.get(),
|
2011-10-18 06:43:19 +04:00
|
|
|
E->getConstructorLParen(),
|
2009-08-11 09:31:07 +04:00
|
|
|
move_arg(ConstructorArgs),
|
2011-10-18 06:43:19 +04:00
|
|
|
E->getConstructorRParen());
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-02-26 03:38:10 +03:00
|
|
|
}
|
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);
|
2010-09-15 02:55:20 +04:00
|
|
|
|
|
|
|
if (!E->getArgument()->isTypeDependent()) {
|
|
|
|
QualType Destroyed = SemaRef.Context.getBaseElementType(
|
|
|
|
E->getDestroyedType());
|
|
|
|
if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
|
|
|
|
CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
|
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(),
|
|
|
|
SemaRef.LookupDestructor(Record));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-08-24 09:47:05 +04:00
|
|
|
QualType ObjectType = ObjectTypePtr.get();
|
2011-02-25 21:19:59 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
|
|
|
|
if (QualifierLoc) {
|
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
|
|
|
|
if (!QualifierLoc)
|
2010-11-12 11:19:04 +03:00
|
|
|
return ExprError();
|
|
|
|
}
|
2011-02-25 21:19:59 +03:00
|
|
|
CXXScopeSpec SS;
|
|
|
|
SS.Adopt(QualifierLoc);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-02-25 04:56:36 +03:00
|
|
|
PseudoDestructorTypeStorage Destroyed;
|
|
|
|
if (E->getDestroyedTypeInfo()) {
|
|
|
|
TypeSourceInfo *DestroyedTypeInfo
|
2010-11-12 11:19:04 +03:00
|
|
|
= getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
|
2011-03-02 21:32:08 +03:00
|
|
|
ObjectType, 0, SS);
|
2010-02-25 04:56:36 +03:00
|
|
|
if (!DestroyedTypeInfo)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-02-25 04:56:36 +03:00
|
|
|
Destroyed = DestroyedTypeInfo;
|
2011-11-09 06:19:47 +04:00
|
|
|
} else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
|
2010-02-25 04:56:36 +03:00
|
|
|
// 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.
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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-11-12 11:19:04 +03:00
|
|
|
ScopeTypeInfo = getDerived().TransformType(E->getScopeTypeInfo());
|
2010-02-25 02:40:28 +03:00
|
|
|
if (!ScopeTypeInfo)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-04 21:36:40 +04:00
|
|
|
}
|
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(),
|
2011-02-25 21:19:59 +03:00
|
|
|
SS,
|
2010-02-25 02:40:28 +03:00
|
|
|
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
|
|
|
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
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-12-10 12:41:52 +03:00
|
|
|
}
|
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;
|
2011-02-28 23:01:57 +03:00
|
|
|
if (Old->getQualifierLoc()) {
|
|
|
|
NestedNameSpecifierLoc QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2011-02-28 23:01:57 +03:00
|
|
|
SS.Adopt(QualifierLoc);
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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());
|
2010-12-20 20:31:10 +03:00
|
|
|
if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
|
|
|
|
Old->getNumTemplateArgs(),
|
|
|
|
TransArgs))
|
|
|
|
return ExprError();
|
2009-11-24 22:00:30 +03:00
|
|
|
|
|
|
|
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) {
|
2010-09-09 20:14:44 +04:00
|
|
|
TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
|
|
|
|
if (!T)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-09 20:14:44 +04:00
|
|
|
T == E->getQueriedTypeSourceInfo())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildUnaryTypeTrait(E->getTrait(),
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getLocStart(),
|
|
|
|
T,
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-12-07 03:08:36 +03:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformBinaryTypeTraitExpr(BinaryTypeTraitExpr *E) {
|
|
|
|
TypeSourceInfo *LhsT = getDerived().TransformType(E->getLhsTypeSourceInfo());
|
|
|
|
if (!LhsT)
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
TypeSourceInfo *RhsT = getDerived().TransformType(E->getRhsTypeSourceInfo());
|
|
|
|
if (!RhsT)
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
LhsT == E->getLhsTypeSourceInfo() && RhsT == E->getRhsTypeSourceInfo())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
return getDerived().RebuildBinaryTypeTrait(E->getTrait(),
|
|
|
|
E->getLocStart(),
|
|
|
|
LhsT, RhsT,
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
2011-04-28 04:16:57 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
|
|
|
|
TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
|
|
|
|
if (!T)
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
T == E->getQueriedTypeSourceInfo())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
ExprResult SubExpr;
|
|
|
|
{
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
|
|
|
SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
|
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
}
|
|
|
|
|
|
|
|
return getDerived().RebuildArrayTypeTrait(E->getTrait(),
|
|
|
|
E->getLocStart(),
|
|
|
|
T,
|
|
|
|
SubExpr.get(),
|
|
|
|
E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
2011-04-25 10:54:41 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformExpressionTraitExpr(ExpressionTraitExpr *E) {
|
|
|
|
ExprResult SubExpr;
|
|
|
|
{
|
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
|
|
|
SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
|
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
}
|
|
|
|
|
|
|
|
return getDerived().RebuildExpressionTrait(
|
|
|
|
E->getTrait(), E->getLocStart(), SubExpr.get(), E->getLocEnd());
|
|
|
|
}
|
|
|
|
|
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) {
|
2011-02-25 23:49:16 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
// TODO: If this is a conversion-function-id, verify that the
|
|
|
|
// destination type name (if present) resolves the same way after
|
|
|
|
// instantiation as it did in the local scope.
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo
|
|
|
|
= getDerived().TransformDeclarationNameInfo(E->getNameInfo());
|
|
|
|
if (!NameInfo.getName())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-11-24 22:00:30 +03:00
|
|
|
if (!E->hasExplicitTemplateArgs()) {
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2011-02-25 23:49:16 +03:00
|
|
|
QualifierLoc == E->getQualifierLoc() &&
|
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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-02-25 23:49:16 +03:00
|
|
|
return getDerived().RebuildDependentScopeDeclRefExpr(QualifierLoc,
|
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());
|
2010-12-20 20:31:10 +03:00
|
|
|
if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
|
|
|
|
E->getNumTemplateArgs(),
|
|
|
|
TransArgs))
|
|
|
|
return ExprError();
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2011-02-25 23:49:16 +03:00
|
|
|
return getDerived().RebuildDependentScopeDeclRefExpr(QualifierLoc,
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-08-11 09:31:07 +04:00
|
|
|
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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);
|
2011-01-03 22:04:46 +03:00
|
|
|
if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
|
|
|
|
&ArgumentChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
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);
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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),
|
2011-10-05 11:56:41 +04:00
|
|
|
E->hadMultipleCandidates(),
|
2010-08-22 21:20:18 +04:00
|
|
|
E->requiresZeroInitialization(),
|
2010-10-25 12:47:36 +04:00
|
|
|
E->getConstructionKind(),
|
|
|
|
E->getParenRange());
|
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-12-06 11:20:24 +03:00
|
|
|
/// \brief Transform a C++ expression that contains cleanups that should
|
|
|
|
/// be run after the expression is evaluated.
|
2009-08-11 09:31:07 +04:00
|
|
|
///
|
2010-12-06 11:20:24 +03:00
|
|
|
/// Since ExprWithCleanups nodes are implicitly generated, we
|
2009-12-24 21:51:59 +03:00
|
|
|
/// 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
|
2010-12-06 11:20:24 +03:00
|
|
|
TreeTransform<Derived>::TransformExprWithCleanups(ExprWithCleanups *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
|
|
|
|
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(
|
2010-09-08 04:15:04 +04:00
|
|
|
CXXTemporaryObjectExpr *E) {
|
|
|
|
TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
|
|
|
|
if (!T)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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());
|
2011-01-03 22:04:46 +03:00
|
|
|
if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
|
|
|
|
&ArgumentChanged))
|
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-08 04:15:04 +04:00
|
|
|
T == E->getTypeSourceInfo() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
Constructor == E->getConstructor() &&
|
2010-03-02 20:18:33 +03:00
|
|
|
!ArgumentChanged) {
|
|
|
|
// FIXME: Instantiation-specific
|
2010-09-08 04:15:04 +04:00
|
|
|
SemaRef.MarkDeclarationReferenced(E->getLocStart(), Constructor);
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.MaybeBindToTemporary(E);
|
2010-03-02 20:18:33 +03:00
|
|
|
}
|
2010-09-08 04:15:04 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildCXXTemporaryObjectExpr(T,
|
|
|
|
/*FIXME:*/T->getTypeLoc().getEndLoc(),
|
2009-08-11 09:31:07 +04:00
|
|
|
move_arg(Args),
|
|
|
|
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) {
|
2010-09-08 04:15:04 +04:00
|
|
|
TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
|
|
|
|
if (!T)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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);
|
2011-01-03 22:04:46 +03:00
|
|
|
Args.reserve(E->arg_size());
|
|
|
|
if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args,
|
|
|
|
&ArgumentChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
2010-09-08 04:15:04 +04:00
|
|
|
T == E->getTypeSourceInfo() &&
|
2009-08-11 09:31:07 +04:00
|
|
|
!ArgumentChanged)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
// FIXME: we're faking the locations of the commas
|
2010-09-08 04:15:04 +04:00
|
|
|
return getDerived().RebuildCXXUnresolvedConstructExpr(T,
|
2009-08-11 09:31:07 +04:00
|
|
|
E->getLParenLoc(),
|
|
|
|
move_arg(Args),
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-12-02 01:10:20 +03:00
|
|
|
|
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(
|
2011-02-28 21:50:33 +03:00
|
|
|
E->getFirstQualifierFoundInScope(),
|
|
|
|
E->getQualifierLoc().getBeginLoc());
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-02-28 21:50:33 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
2009-09-03 20:14:30 +04:00
|
|
|
if (E->getQualifier()) {
|
2011-02-28 21:50:33 +03:00
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
|
|
|
|
ObjectType,
|
|
|
|
FirstQualifierInScope);
|
|
|
|
if (!QualifierLoc)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-09-03 20:14:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2010-11-12 11:19:04 +03:00
|
|
|
// TODO: If this is a conversion-function-id, verify that the
|
|
|
|
// destination type name (if present) resolves the same way after
|
|
|
|
// instantiation as it did in the local scope.
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo
|
2010-11-12 11:19:04 +03:00
|
|
|
= getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
|
2010-08-12 02:01:17 +04:00
|
|
|
if (!NameInfo.getName())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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() &&
|
2011-02-28 21:50:33 +03:00
|
|
|
QualifierLoc == E->getQualifierLoc() &&
|
2010-08-12 02:01:17 +04:00
|
|
|
NameInfo.getName() == E->getMember() &&
|
2009-09-09 04:23:06 +04:00
|
|
|
FirstQualifierInScope == E->getFirstQualifierFoundInScope())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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-09-09 04:23:06 +04:00
|
|
|
E->isArrow(),
|
|
|
|
E->getOperatorLoc(),
|
2011-02-28 21:50:33 +03:00
|
|
|
QualifierLoc,
|
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());
|
2010-12-20 20:31:10 +03:00
|
|
|
if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
|
|
|
|
E->getNumTemplateArgs(),
|
|
|
|
TransArgs))
|
|
|
|
return ExprError();
|
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(),
|
2011-02-28 21:50:33 +03:00
|
|
|
QualifierLoc,
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2011-10-26 23:06:56 +04:00
|
|
|
Base = getSema().PerformMemberExprBaseConversion(Base.take(),
|
|
|
|
Old->isArrow());
|
|
|
|
if (Base.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
BaseType = Base.get()->getType();
|
2009-12-02 01:10:20 +03:00
|
|
|
} else {
|
|
|
|
BaseType = getDerived().TransformType(Old->getBaseType());
|
|
|
|
}
|
2009-12-01 01:42:35 +03:00
|
|
|
|
2011-02-28 23:01:57 +03:00
|
|
|
NestedNameSpecifierLoc QualifierLoc;
|
|
|
|
if (Old->getQualifierLoc()) {
|
|
|
|
QualifierLoc
|
|
|
|
= getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
|
|
|
|
if (!QualifierLoc)
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2009-12-01 01:42:35 +03:00
|
|
|
}
|
|
|
|
|
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;
|
2011-04-22 05:18:40 +04:00
|
|
|
else {
|
|
|
|
R.clear();
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2011-04-22 05:18:40 +04:00
|
|
|
}
|
2009-12-10 12:41:52 +03:00
|
|
|
}
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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());
|
2010-12-20 20:31:10 +03:00
|
|
|
if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
|
|
|
|
Old->getNumTemplateArgs(),
|
|
|
|
TransArgs))
|
|
|
|
return ExprError();
|
2009-12-01 01:42:35 +03:00
|
|
|
}
|
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(),
|
2011-02-28 23:01:57 +03:00
|
|
|
QualifierLoc,
|
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
|
|
|
}
|
|
|
|
|
2010-09-11 00:55:43 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformCXXNoexceptExpr(CXXNoexceptExpr *E) {
|
2011-05-31 23:54:49 +04:00
|
|
|
EnterExpressionEvaluationContext Unevaluated(SemaRef, Sema::Unevaluated);
|
2010-09-11 00:55:43 +04:00
|
|
|
ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
|
|
|
|
if (SubExpr.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-09-11 00:55:43 +04:00
|
|
|
|
|
|
|
return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
|
|
|
|
}
|
|
|
|
|
2011-01-03 20:17:50 +03:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformPackExpansionExpr(PackExpansionExpr *E) {
|
2011-01-13 03:19:55 +03:00
|
|
|
ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
|
|
|
|
if (Pattern.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
2011-01-15 00:20:45 +03:00
|
|
|
return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
|
|
|
|
E->getNumExpansions());
|
2011-01-03 20:17:50 +03:00
|
|
|
}
|
2011-01-04 20:33:58 +03:00
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformSizeOfPackExpr(SizeOfPackExpr *E) {
|
|
|
|
// If E is not value-dependent, then nothing will change when we transform it.
|
|
|
|
// Note: This is an instantiation-centric view.
|
|
|
|
if (!E->isValueDependent())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
// Note: None of the implementations of TryExpandParameterPacks can ever
|
|
|
|
// produce a diagnostic when given only a single unexpanded parameter pack,
|
|
|
|
// so
|
|
|
|
UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
|
|
|
|
bool ShouldExpand = false;
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
bool RetainExpansion = false;
|
2011-01-14 20:04:44 +03:00
|
|
|
llvm::Optional<unsigned> NumExpansions;
|
2011-01-04 20:33:58 +03:00
|
|
|
if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
|
2011-09-22 06:34:54 +04:00
|
|
|
Unexpanded,
|
Work-in-progress implementation of C++0x [temp.arg.explicit]p9, which
allows an argument pack determines via explicit specification of
function template arguments to be extended by further, deduced
arguments. For example:
template<class ... Types> void f(Types ... values);
void g() {
f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int
}
There are a number of FIXMEs in here that indicate places where we
need to implement + test retained expansions, plus a number of other
places in deduction where we need to correctly cope with the
explicitly-specified arguments when deducing an argument
pack. Furthermore, it appears that the RecursiveASTVisitor needs to be
auditied; it's missing some traversals (especially w.r.t. template
arguments) that cause it not to find unexpanded parameter packs when
it should.
The good news, however, is that the tr1::tuple implementation now
works fully, and the tr1::bind example (both from N2080) is actually
working now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@123163 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-10 10:32:04 +03:00
|
|
|
ShouldExpand, RetainExpansion,
|
|
|
|
NumExpansions))
|
2011-01-04 20:33:58 +03:00
|
|
|
return ExprError();
|
|
|
|
|
2011-10-10 22:59:29 +04:00
|
|
|
if (RetainExpansion)
|
2011-01-04 20:33:58 +03:00
|
|
|
return SemaRef.Owned(E);
|
2011-10-10 22:59:29 +04:00
|
|
|
|
|
|
|
NamedDecl *Pack = E->getPack();
|
|
|
|
if (!ShouldExpand) {
|
|
|
|
Pack = cast_or_null<NamedDecl>(getDerived().TransformDecl(E->getPackLoc(),
|
|
|
|
Pack));
|
|
|
|
if (!Pack)
|
|
|
|
return ExprError();
|
|
|
|
}
|
|
|
|
|
2011-01-03 20:17:50 +03:00
|
|
|
|
2011-01-04 20:33:58 +03:00
|
|
|
// We now know the length of the parameter pack, so build a new expression
|
|
|
|
// that stores that length.
|
2011-10-10 22:59:29 +04:00
|
|
|
return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack,
|
2011-01-04 20:33:58 +03:00
|
|
|
E->getPackLoc(), E->getRParenLoc(),
|
2011-10-10 22:59:29 +04:00
|
|
|
NumExpansions);
|
2011-01-04 20:33:58 +03:00
|
|
|
}
|
|
|
|
|
2011-01-15 04:15:58 +03:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformSubstNonTypeTemplateParmPackExpr(
|
|
|
|
SubstNonTypeTemplateParmPackExpr *E) {
|
|
|
|
// Default behavior is to do nothing with this transformation.
|
2011-07-15 09:09:51 +04:00
|
|
|
return SemaRef.Owned(E);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformSubstNonTypeTemplateParmExpr(
|
|
|
|
SubstNonTypeTemplateParmExpr *E) {
|
|
|
|
// Default behavior is to do nothing with this transformation.
|
2011-01-15 04:15:58 +03:00
|
|
|
return SemaRef.Owned(E);
|
|
|
|
}
|
|
|
|
|
2011-06-21 21:03:29 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformMaterializeTemporaryExpr(
|
|
|
|
MaterializeTemporaryExpr *E) {
|
|
|
|
return getDerived().TransformExpr(E->GetTemporaryExpr());
|
|
|
|
}
|
|
|
|
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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
|
|
|
|
2011-06-16 03:02:42 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult TreeTransform<Derived>::
|
|
|
|
TransformObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
|
|
|
|
ExprResult result = getDerived().TransformExpr(E->getSubExpr());
|
|
|
|
if (result.isInvalid()) return ExprError();
|
|
|
|
Expr *subExpr = result.take();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
subExpr == E->getSubExpr())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
return SemaRef.Owned(new(SemaRef.Context)
|
|
|
|
ObjCIndirectCopyRestoreExpr(subExpr, E->getType(), E->shouldCopy()));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
ExprResult TreeTransform<Derived>::
|
|
|
|
TransformObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
|
|
|
|
TypeSourceInfo *TSInfo
|
|
|
|
= getDerived().TransformType(E->getTypeInfoAsWritten());
|
|
|
|
if (!TSInfo)
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
|
|
|
|
if (Result.isInvalid())
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
TSInfo == E->getTypeInfoAsWritten() &&
|
|
|
|
Result.get() == E->getSubExpr())
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(),
|
|
|
|
E->getBridgeKeywordLoc(), TSInfo,
|
|
|
|
Result.get());
|
|
|
|
}
|
|
|
|
|
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);
|
2011-01-03 22:04:46 +03:00
|
|
|
Args.reserve(E->getNumArgs());
|
|
|
|
if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
|
|
|
|
&ArgChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
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)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-04-22 20:44:27 +04:00
|
|
|
|
|
|
|
// Build a new class message send.
|
2011-10-03 10:36:51 +04:00
|
|
|
SmallVector<SourceLocation, 16> SelLocs;
|
|
|
|
E->getSelectorLocs(SelLocs);
|
2010-04-22 20:44:27 +04:00
|
|
|
return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
|
|
|
|
E->getSelector(),
|
2011-10-03 10:36:51 +04:00
|
|
|
SelLocs,
|
2010-04-22 20:44:27 +04:00
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-04-22 20:44:27 +04:00
|
|
|
|
|
|
|
// If nothing changed, just retain the existing message send.
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-05-05 19:23:54 +04:00
|
|
|
|
2010-04-22 20:44:27 +04:00
|
|
|
// Build a new instance message send.
|
2011-10-03 10:36:51 +04:00
|
|
|
SmallVector<SourceLocation, 16> SelLocs;
|
|
|
|
E->getSelectorLocs(SelLocs);
|
2010-08-24 03:25:46 +04:00
|
|
|
return getDerived().RebuildObjCMessageExpr(Receiver.get(),
|
2010-04-22 20:44:27 +04:00
|
|
|
E->getSelector(),
|
2011-10-03 10:36:51 +04:00
|
|
|
SelLocs,
|
2010-04-22 20:44:27 +04:00
|
|
|
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) {
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return ExprError();
|
2010-04-27 00:11:03 +04:00
|
|
|
|
|
|
|
// 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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-12-02 04:19:52 +03:00
|
|
|
// 'super' and types never change. Property never changes. Just
|
|
|
|
// retain the existing expression.
|
|
|
|
if (!E->isObjectReceiver())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-10-14 20:04:05 +04:00
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-08-11 09:31:07 +04:00
|
|
|
|
2010-12-02 04:19:52 +03:00
|
|
|
if (E->isExplicitProperty())
|
|
|
|
return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
|
|
|
|
E->getExplicitProperty(),
|
|
|
|
E->getLocation());
|
|
|
|
|
|
|
|
return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
|
2011-10-25 21:37:35 +04:00
|
|
|
SemaRef.Context.PseudoObjectTy,
|
2010-12-02 04:19:52 +03:00
|
|
|
E->getImplicitPropertyGetter(),
|
|
|
|
E->getImplicitPropertySetter(),
|
|
|
|
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-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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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())
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
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);
|
2011-01-03 22:04:46 +03:00
|
|
|
SubExprs.reserve(E->getNumSubExprs());
|
|
|
|
if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
|
|
|
|
SubExprs, &ArgumentChanged))
|
|
|
|
return ExprError();
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2009-08-11 09:31:07 +04:00
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
!ArgumentChanged)
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2009-09-09 19:08:12 +04:00
|
|
|
|
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) {
|
2011-02-04 21:33:18 +03:00
|
|
|
BlockDecl *oldBlock = E->getBlockDecl();
|
2010-07-09 22:44:02 +04:00
|
|
|
|
2011-02-04 21:33:18 +03:00
|
|
|
SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/0);
|
|
|
|
BlockScopeInfo *blockScope = SemaRef.getCurBlock();
|
|
|
|
|
|
|
|
blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
|
2011-05-05 21:18:12 +04:00
|
|
|
// We built a new blockScopeInfo in call to ActOnBlockStart
|
|
|
|
// in above, CapturesCXXThis need be set here from the block
|
|
|
|
// expression.
|
|
|
|
blockScope->CapturesCXXThis = oldBlock->capturesCXXThis();
|
|
|
|
|
2011-07-20 10:58:45 +04:00
|
|
|
SmallVector<ParmVarDecl*, 4> params;
|
|
|
|
SmallVector<QualType, 4> paramTypes;
|
2010-07-09 22:44:02 +04:00
|
|
|
|
|
|
|
// Parameter substitution.
|
2011-02-04 21:33:18 +03:00
|
|
|
if (getDerived().TransformFunctionTypeParams(E->getCaretLocation(),
|
|
|
|
oldBlock->param_begin(),
|
|
|
|
oldBlock->param_size(),
|
|
|
|
0, paramTypes, ¶ms))
|
2011-01-20 00:32:01 +03:00
|
|
|
return true;
|
2011-02-04 21:33:18 +03:00
|
|
|
|
|
|
|
const FunctionType *exprFunctionType = E->getFunctionType();
|
|
|
|
QualType exprResultType = exprFunctionType->getResultType();
|
|
|
|
if (!exprResultType.isNull()) {
|
|
|
|
if (!exprResultType->isDependentType())
|
|
|
|
blockScope->ReturnType = exprResultType;
|
|
|
|
else if (exprResultType != getSema().Context.DependentTy)
|
|
|
|
blockScope->ReturnType = getDerived().TransformType(exprResultType);
|
2010-07-09 22:44:02 +04:00
|
|
|
}
|
2011-01-20 00:32:01 +03:00
|
|
|
|
|
|
|
// If the return type has not been determined yet, leave it as a dependent
|
|
|
|
// type; it'll get set when we process the body.
|
2011-02-04 21:33:18 +03:00
|
|
|
if (blockScope->ReturnType.isNull())
|
|
|
|
blockScope->ReturnType = getSema().Context.DependentTy;
|
2011-01-20 00:32:01 +03:00
|
|
|
|
|
|
|
// Don't allow returning a objc interface by value.
|
2011-02-04 21:33:18 +03:00
|
|
|
if (blockScope->ReturnType->isObjCObjectType()) {
|
|
|
|
getSema().Diag(E->getCaretLocation(),
|
2011-01-20 00:32:01 +03:00
|
|
|
diag::err_object_cannot_be_passed_returned_by_value)
|
2011-02-04 21:33:18 +03:00
|
|
|
<< 0 << blockScope->ReturnType;
|
2011-01-20 00:32:01 +03:00
|
|
|
return ExprError();
|
|
|
|
}
|
2011-01-05 15:14:39 +03:00
|
|
|
|
2011-02-04 21:33:18 +03:00
|
|
|
QualType functionType = getDerived().RebuildFunctionProtoType(
|
|
|
|
blockScope->ReturnType,
|
|
|
|
paramTypes.data(),
|
|
|
|
paramTypes.size(),
|
|
|
|
oldBlock->isVariadic(),
|
2011-01-26 08:01:58 +03:00
|
|
|
0, RQ_None,
|
2011-02-04 21:33:18 +03:00
|
|
|
exprFunctionType->getExtInfo());
|
|
|
|
blockScope->FunctionType = functionType;
|
2011-01-05 15:14:39 +03:00
|
|
|
|
|
|
|
// Set the parameters on the block decl.
|
2011-02-04 21:33:18 +03:00
|
|
|
if (!params.empty())
|
2011-09-21 22:16:56 +04:00
|
|
|
blockScope->TheDecl->setParams(params);
|
2011-01-20 00:32:01 +03:00
|
|
|
|
|
|
|
// If the return type wasn't explicitly set, it will have been marked as a
|
|
|
|
// dependent type (DependentTy); clear out the return type setting so
|
|
|
|
// we will deduce the return type when type-checking the block's body.
|
2011-02-04 21:33:18 +03:00
|
|
|
if (blockScope->ReturnType == getSema().Context.DependentTy)
|
|
|
|
blockScope->ReturnType = QualType();
|
2011-01-20 00:32:01 +03:00
|
|
|
|
2011-01-05 15:14:39 +03:00
|
|
|
// Transform the body
|
2011-02-04 21:33:18 +03:00
|
|
|
StmtResult body = getDerived().TransformStmt(E->getBody());
|
|
|
|
if (body.isInvalid())
|
2011-01-05 15:14:39 +03:00
|
|
|
return ExprError();
|
|
|
|
|
2011-02-04 21:33:18 +03:00
|
|
|
#ifndef NDEBUG
|
|
|
|
// In builds with assertions, make sure that we captured everything we
|
|
|
|
// captured before.
|
2011-05-20 19:32:55 +04:00
|
|
|
if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
|
|
|
|
for (BlockDecl::capture_iterator i = oldBlock->capture_begin(),
|
|
|
|
e = oldBlock->capture_end(); i != e; ++i) {
|
|
|
|
VarDecl *oldCapture = i->getVariable();
|
|
|
|
|
|
|
|
// Ignore parameter packs.
|
|
|
|
if (isa<ParmVarDecl>(oldCapture) &&
|
|
|
|
cast<ParmVarDecl>(oldCapture)->isParameterPack())
|
|
|
|
continue;
|
2011-02-04 21:33:18 +03:00
|
|
|
|
2011-05-20 19:32:55 +04:00
|
|
|
VarDecl *newCapture =
|
|
|
|
cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
|
|
|
|
oldCapture));
|
|
|
|
assert(blockScope->CaptureMap.count(newCapture));
|
|
|
|
}
|
2011-02-04 21:33:18 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), 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
|
|
|
ValueDecl *ND
|
|
|
|
= cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
|
|
|
|
E->getDecl()));
|
|
|
|
if (!ND)
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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);
|
|
|
|
|
2010-10-26 11:05:15 +04:00
|
|
|
return SemaRef.Owned(E);
|
2010-07-09 22:44:02 +04:00
|
|
|
}
|
|
|
|
|
2010-08-12 02:01:17 +04:00
|
|
|
DeclarationNameInfo NameInfo(E->getDecl()->getDeclName(), E->getLocation());
|
2011-03-01 00:54:11 +03:00
|
|
|
return getDerived().RebuildDeclRefExpr(NestedNameSpecifierLoc(),
|
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
|
|
|
|
2011-06-04 04:47:47 +04:00
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformAsTypeExpr(AsTypeExpr *E) {
|
2011-09-23 09:06:16 +04:00
|
|
|
llvm_unreachable("Cannot transform asType expressions yet");
|
2011-06-04 04:47:47 +04:00
|
|
|
}
|
2011-10-11 06:20:01 +04:00
|
|
|
|
|
|
|
template<typename Derived>
|
|
|
|
ExprResult
|
|
|
|
TreeTransform<Derived>::TransformAtomicExpr(AtomicExpr *E) {
|
2011-10-15 02:48:56 +04:00
|
|
|
QualType RetTy = getDerived().TransformType(E->getType());
|
|
|
|
bool ArgumentChanged = false;
|
|
|
|
ASTOwningVector<Expr*> SubExprs(SemaRef);
|
|
|
|
SubExprs.reserve(E->getNumSubExprs());
|
|
|
|
if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
|
|
|
|
SubExprs, &ArgumentChanged))
|
|
|
|
return ExprError();
|
|
|
|
|
|
|
|
if (!getDerived().AlwaysRebuild() &&
|
|
|
|
!ArgumentChanged)
|
|
|
|
return SemaRef.Owned(E);
|
|
|
|
|
|
|
|
return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), move_arg(SubExprs),
|
|
|
|
RetTy, E->getOp(), E->getRParenLoc());
|
2011-10-11 06:20:01 +04:00
|
|
|
}
|
2011-06-04 04:47:47 +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
|
|
|
|
2010-08-28 13:06:06 +04:00
|
|
|
IntegerLiteral ArraySize(SemaRef.Context, *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-11-11 00:56:12 +03:00
|
|
|
unsigned NumElements,
|
|
|
|
VectorType::VectorKind VecKind) {
|
2009-08-04 20:50:30 +04:00
|
|
|
// FIXME: semantic checking!
|
2010-11-11 00:56:12 +03:00
|
|
|
return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
|
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
|
2010-08-28 13:06:06 +04:00
|
|
|
= IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
|
|
|
|
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,
|
2011-01-26 08:01:58 +03:00
|
|
|
RefQualifierKind RefQualifier,
|
2010-08-05 06:54:05 +04:00
|
|
|
const FunctionType::ExtInfo &Info) {
|
2009-09-09 19:08:12 +04:00
|
|
|
return SemaRef.BuildFunctionType(T, ParamTypes, NumParamTypes, Variadic,
|
2011-01-26 08:01:58 +03:00
|
|
|
Quals, RefQualifier,
|
2009-08-04 20:50:30 +04:00
|
|
|
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-10-12 04:20:44 +04:00
|
|
|
QualType TreeTransform<Derived>::RebuildTypeOfExprType(Expr *E,
|
|
|
|
SourceLocation Loc) {
|
|
|
|
return SemaRef.BuildTypeofExprType(E, Loc);
|
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-10-12 04:20:44 +04:00
|
|
|
QualType TreeTransform<Derived>::RebuildDecltypeType(Expr *E,
|
|
|
|
SourceLocation Loc) {
|
|
|
|
return SemaRef.BuildDecltypeType(E, Loc);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
|
|
|
|
2011-05-25 02:41:36 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildUnaryTransformType(QualType BaseType,
|
|
|
|
UnaryTransformType::UTTKind UKind,
|
|
|
|
SourceLocation Loc) {
|
|
|
|
return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
|
|
|
|
}
|
|
|
|
|
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,
|
2011-03-03 05:41:12 +03:00
|
|
|
TemplateArgumentListInfo &TemplateArgs) {
|
2009-11-23 04:53:49 +03:00
|
|
|
return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
|
2009-08-04 20:50:30 +04:00
|
|
|
}
|
2009-09-09 19:08:12 +04:00
|
|
|
|
2011-10-07 03:00:33 +04:00
|
|
|
template<typename Derived>
|
|
|
|
QualType TreeTransform<Derived>::RebuildAtomicType(QualType ValueType,
|
|
|
|
SourceLocation KWLoc) {
|
|
|
|
return SemaRef.BuildAtomicType(ValueType, KWLoc);
|
|
|
|
}
|
|
|
|
|
2009-08-06 10:41:21 +04:00
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateName
|
2011-03-02 21:07:45 +03:00
|
|
|
TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS,
|
2009-08-06 10:41:21 +04:00
|
|
|
bool TemplateKW,
|
|
|
|
TemplateDecl *Template) {
|
2011-03-02 21:07:45 +03:00
|
|
|
return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
|
2009-08-06 10:41:21 +04:00
|
|
|
Template);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename Derived>
|
2009-09-09 19:08:12 +04:00
|
|
|
TemplateName
|
2011-03-02 21:07:45 +03:00
|
|
|
TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS,
|
|
|
|
const IdentifierInfo &Name,
|
|
|
|
SourceLocation NameLoc,
|
2010-11-12 11:19:04 +03:00
|
|
|
QualType ObjectType,
|
|
|
|
NamedDecl *FirstQualifierInScope) {
|
2011-03-02 21:07:45 +03:00
|
|
|
UnqualifiedId TemplateName;
|
|
|
|
TemplateName.setIdentifier(&Name, NameLoc);
|
2010-06-17 03:00:59 +04:00
|
|
|
Sema::TemplateTy Template;
|
|
|
|
getSema().ActOnDependentTemplateName(/*Scope=*/0,
|
2011-03-02 21:07:45 +03:00
|
|
|
/*FIXME:*/SourceLocation(),
|
2010-06-17 03:00:59 +04:00
|
|
|
SS,
|
2011-03-02 21:07:45 +03:00
|
|
|
TemplateName,
|
2010-08-24 09:47:05 +04:00
|
|
|
ParsedType::make(ObjectType),
|
2010-06-17 03:00:59 +04:00
|
|
|
/*EnteringContext=*/false,
|
|
|
|
Template);
|
2010-11-12 11:19:04 +03:00
|
|
|
return Template.get();
|
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
|
2011-03-02 21:07:45 +03:00
|
|
|
TreeTransform<Derived>::RebuildTemplateName(CXXScopeSpec &SS,
|
2009-11-04 03:56:37 +03:00
|
|
|
OverloadedOperatorKind Operator,
|
2011-03-02 21:07:45 +03:00
|
|
|
SourceLocation NameLoc,
|
2009-11-04 03:56:37 +03:00
|
|
|
QualType ObjectType) {
|
|
|
|
UnqualifiedId Name;
|
2011-03-02 21:07:45 +03:00
|
|
|
// FIXME: Bogus location information.
|
|
|
|
SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
|
|
|
|
Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
|
2010-06-17 03:00:59 +04:00
|
|
|
Sema::TemplateTy Template;
|
|
|
|
getSema().ActOnDependentTemplateName(/*Scope=*/0,
|
2011-03-02 21:07:45 +03:00
|
|
|
/*FIXME:*/SourceLocation(),
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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
|
|
|
|
2011-07-15 20:25:15 +04:00
|
|
|
if (Op == OO_Subscript) {
|
|
|
|
SourceLocation LBrace;
|
|
|
|
SourceLocation RBrace;
|
|
|
|
|
|
|
|
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) {
|
|
|
|
DeclarationNameLoc &NameLoc = DRE->getNameInfo().getInfo();
|
|
|
|
LBrace = SourceLocation::getFromRawEncoding(
|
|
|
|
NameLoc.CXXOperatorName.BeginOpNameLoc);
|
|
|
|
RBrace = SourceLocation::getFromRawEncoding(
|
|
|
|
NameLoc.CXXOperatorName.EndOpNameLoc);
|
|
|
|
} else {
|
|
|
|
LBrace = Callee->getLocStart();
|
|
|
|
RBrace = OpLoc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace,
|
|
|
|
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())
|
2010-08-27 03:41:50 +04:00
|
|
|
return 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,
|
2011-02-25 21:19:59 +03:00
|
|
|
CXXScopeSpec &SS,
|
2010-02-25 02:40:28 +03:00
|
|
|
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-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
|