Implement initialization of a reference (C++ [dcl.init.ref]) as part
of copy initialization. Other pieces of the puzzle:
- Try/Perform-ImplicitConversion now handles implicit conversions
that don't involve references.
- Try/Perform-CopyInitialization uses
CheckSingleAssignmentConstraints for C. PerformCopyInitialization
is now used for all argument passing and returning values from a
function.
- Diagnose errors with declaring references and const values without
an initializer. (Uses a new Action callback, ActOnUninitializedDecl).
We do not yet have implicit conversion sequences for reference
binding, which means that we don't have any overloading support for
reference parameters yet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58353 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp
index a676b64..ce48a43 100644
--- a/lib/Sema/SemaInherit.cpp
+++ b/lib/Sema/SemaInherit.cpp
@@ -44,33 +44,32 @@
ScratchPath.clear();
}
-/// IsDerivedFrom - Determine whether the class type Derived is
-/// derived from the class type Base, ignoring qualifiers on Base and
-/// Derived. This routine does not assess whether an actual conversion
-/// from a Derived* to a Base* is legal, because it does not account
-/// for ambiguous conversions or conversions to private/protected bases.
+/// IsDerivedFrom - Determine whether the type Derived is derived from
+/// the type Base, ignoring qualifiers on Base and Derived. This
+/// routine does not assess whether an actual conversion from a
+/// Derived* to a Base* is legal, because it does not account for
+/// ambiguous conversions or conversions to private/protected bases.
bool Sema::IsDerivedFrom(QualType Derived, QualType Base) {
BasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false);
return IsDerivedFrom(Derived, Base, Paths);
}
-/// IsDerivedFrom - Determine whether the class type Derived is
-/// derived from the class type Base, ignoring qualifiers on Base and
-/// Derived. This routine does not assess whether an actual conversion
-/// from a Derived* to a Base* is legal, because it does not account
-/// for ambiguous conversions or conversions to private/protected
+/// IsDerivedFrom - Determine whether the type Derived is derived from
+/// the type Base, ignoring qualifiers on Base and Derived. This
+/// routine does not assess whether an actual conversion from a
+/// Derived* to a Base* is legal, because it does not account for
+/// ambiguous conversions or conversions to private/protected
/// bases. This routine will use Paths to determine if there are
/// ambiguous paths (if @c Paths.isFindingAmbiguities()) and record
-/// information about all of the paths (if
-/// @c Paths.isRecordingPaths()).
+/// information about all of the paths (if @c Paths.isRecordingPaths()).
bool Sema::IsDerivedFrom(QualType Derived, QualType Base, BasePaths &Paths) {
bool FoundPath = false;
Derived = Context.getCanonicalType(Derived).getUnqualifiedType();
Base = Context.getCanonicalType(Base).getUnqualifiedType();
- assert(Derived->isRecordType() && "IsDerivedFrom requires a class type");
- assert(Base->isRecordType() && "IsDerivedFrom requires a class type");
+ if (!Derived->isRecordType() || !Base->isRecordType())
+ return false;
if (Derived == Base)
return false;