Remove a header dependency from Sema.h at the cost of some type safety.

If someone wants to fix this some other way....

llvm-svn: 111905
This commit is contained in:
John McCall
2010-08-24 07:32:53 +00:00
parent de6836a384
commit bfd822ce64
6 changed files with 26 additions and 16 deletions

View File

@@ -24,7 +24,6 @@
#include "clang/Sema/AnalysisBasedWarnings.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "clang/AST/ExprCXX.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallPtrSet.h"
@@ -2301,21 +2300,20 @@ public:
/// BuildCXXConstructExpr - Creates a complete call to a constructor,
/// including handling of its default argument expressions.
///
/// \param ConstructKind - a CXXConstructExpr::ConstructionKind
ExprResult
BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
CXXConstructorDecl *Constructor, MultiExprArg Exprs,
bool RequiresZeroInit = false,
CXXConstructExpr::ConstructionKind ConstructKind =
CXXConstructExpr::CK_Complete);
bool RequiresZeroInit, unsigned ConstructKind);
// FIXME: Can re remove this and have the above BuildCXXConstructExpr check if
// the constructor can be elidable?
ExprResult
BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
CXXConstructorDecl *Constructor, bool Elidable,
MultiExprArg Exprs, bool RequiresZeroInit = false,
CXXConstructExpr::ConstructionKind ConstructKind =
CXXConstructExpr::CK_Complete);
MultiExprArg Exprs, bool RequiresZeroInit,
unsigned ConstructKind);
/// BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating
/// the default expr if needed.

View File

@@ -5398,7 +5398,7 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
CXXConstructorDecl *Constructor,
MultiExprArg ExprArgs,
bool RequiresZeroInit,
CXXConstructExpr::ConstructionKind ConstructKind) {
unsigned ConstructKind) {
bool Elidable = false;
// C++0x [class.copy]p34:
@@ -5431,14 +5431,15 @@ Sema::BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType,
CXXConstructorDecl *Constructor, bool Elidable,
MultiExprArg ExprArgs,
bool RequiresZeroInit,
CXXConstructExpr::ConstructionKind ConstructKind) {
unsigned ConstructKind) {
unsigned NumExprs = ExprArgs.size();
Expr **Exprs = (Expr **)ExprArgs.release();
MarkDeclarationReferenced(ConstructLoc, Constructor);
return Owned(CXXConstructExpr::Create(Context, DeclInitType, ConstructLoc,
Constructor, Elidable, Exprs, NumExprs,
RequiresZeroInit, ConstructKind));
RequiresZeroInit,
static_cast<CXXConstructExpr::ConstructionKind>(ConstructKind)));
}
bool Sema::InitializeVarWithConstructor(VarDecl *VD,
@@ -5446,7 +5447,7 @@ bool Sema::InitializeVarWithConstructor(VarDecl *VD,
MultiExprArg Exprs) {
ExprResult TempResult =
BuildCXXConstructExpr(VD->getLocation(), VD->getType(), Constructor,
move(Exprs));
move(Exprs), false, CXXConstructExpr::CK_Complete);
if (TempResult.isInvalid())
return true;

View File

@@ -1588,7 +1588,8 @@ static ExprResult BuildCXXCastArgument(Sema &S,
ExprResult Result =
S.BuildCXXConstructExpr(CastLoc, Ty, cast<CXXConstructorDecl>(Method),
move_arg(ConstructorArgs));
move_arg(ConstructorArgs),
/*ZeroInit*/ false, CXXConstructExpr::CK_Complete);
if (Result.isInvalid())
return S.ExprError();
@@ -1719,7 +1720,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
ExprResult FromResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
ToType, SCS.CopyConstructor,
move_arg(ConstructorArgs));
move_arg(ConstructorArgs),
/*ZeroInit*/ false,
CXXConstructExpr::CK_Complete);
if (FromResult.isInvalid())
return true;
From = FromResult.takeAs<Expr>();
@@ -1728,7 +1731,9 @@ Sema::PerformImplicitConversion(Expr *&From, QualType ToType,
ExprResult FromResult =
BuildCXXConstructExpr(/*FIXME:ConstructLoc*/SourceLocation(),
ToType, SCS.CopyConstructor,
MultiExprArg(*this, &From, 1));
MultiExprArg(*this, &From, 1),
/*ZeroInit*/ false,
CXXConstructExpr::CK_Complete);
if (FromResult.isInvalid())
return true;

View File

@@ -3454,7 +3454,9 @@ static ExprResult CopyObject(Sema &S,
// Actually perform the constructor call.
CurInit = S.BuildCXXConstructExpr(Loc, T, Constructor, Elidable,
move_arg(ConstructorArgs));
move_arg(ConstructorArgs),
/*ZeroInit*/ false,
CXXConstructExpr::CK_Complete);
// If we're supposed to bind temporaries, do so.
if (!CurInit.isInvalid() && shouldBindAsTemporary(Entity))
@@ -3715,7 +3717,9 @@ InitializationSequence::Perform(Sema &S,
// Build the an expression that constructs a temporary.
CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor,
move_arg(ConstructorArgs));
move_arg(ConstructorArgs),
/*ZeroInit*/ false,
CXXConstructExpr::CK_Complete);
if (CurInit.isInvalid())
return S.ExprError();

View File

@@ -20,6 +20,7 @@
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeLocVisitor.h"
#include "clang/Lex/MacroInfo.h"

View File

@@ -19,6 +19,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/DeclContextInternals.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeLocVisitor.h"
#include "clang/Serialization/ASTReader.h"