diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-04-16 22:09:46 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-04-16 22:09:46 +0000 |
commit | d6e44a3c4193bd422bfa78c8086fb16bb2168e34 (patch) | |
tree | cb04261ecfa3a4512613d65fd851aae18dbad935 /lib/Sema/SemaInit.cpp | |
parent | e74ef1289d5fff0a6ea573198bf354fa8cd84d51 (diff) |
Collapse the three separate initialization paths in
TryStaticImplicitCast (for references, class types, and everything
else, respectively) into a single invocation of
InitializationSequence.
One of the paths (for class types) was the only client of
Sema::TryInitializationByConstructor, which I have eliminated. This
also simplified the interface for much of the cast-checking logic,
eliminating yet more code.
I've kept the representation of C++ functional casts with <> 1
arguments the same, despite the fact that I hate it. That fix will
come soon. To satisfy my paranoia, I've bootstrapped + tested Clang
with these changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101549 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index edff4a5396..e50a860265 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -2036,6 +2036,10 @@ bool InitializationSequence::isAmbiguous() const { return false; } +bool InitializationSequence::isConstructorInitialization() const { + return !Steps.empty() && Steps.back().Kind == SK_ConstructorInitialization; +} + void InitializationSequence::AddAddressOverloadResolutionStep( FunctionDecl *Function, DeclAccessPair Found) { @@ -3510,6 +3514,7 @@ InitializationSequence::Perform(Sema &S, } case SK_ConstructorInitialization: { + unsigned NumArgs = Args.size(); CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(Step->Function.Function); @@ -3523,8 +3528,9 @@ InitializationSequence::Perform(Sema &S, Loc, ConstructorArgs)) return S.ExprError(); - // Build the an expression that constructs a temporary. + // Build the expression that constructs a temporary. if (Entity.getKind() == InitializedEntity::EK_Temporary && + NumArgs != 1 && // FIXME: Hack to work around cast weirdness (Kind.getKind() == InitializationKind::IK_Direct || Kind.getKind() == InitializationKind::IK_Value)) { // An explicitly-constructed temporary, e.g., X(1, 2). |