aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaType.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-10-21 23:43:52 +0000
committerDouglas Gregor <dgregor@apple.com>2008-10-21 23:43:52 +0000
commit98cd599ee8a9b259ed7388ee2921a20d97658864 (patch)
treea03f423533e8e714dacd90d133e4e72f9edd81b5 /lib/Sema/SemaType.cpp
parentcabeeed9cc2bfca73e3d629fd263e697164aa453 (diff)
Initial step toward supporting qualification conversions (C++ 4.4).
Changes: - Sema::IsQualificationConversion determines whether we have a qualification conversion. - Sema::CheckSingleAssignment constraints now follows the C++ rules in C++, performing an implicit conversion from the right-hand side to the type of the left-hand side rather than checking based on the C notion of "compatibility". We now rely on the implicit-conversion code to determine whether the conversion can happen or not. Sema::TryCopyInitialization has an ugly reference-related hack to cope with the initialization of references, for now. - When building DeclRefExprs, strip away the reference type, since there are no expressions whose type is a reference. We'll need to do this throughout Sema. - Expr::isLvalue now permits functions to be lvalues in C++ (but not in C). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57935 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaType.cpp')
-rw-r--r--lib/Sema/SemaType.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index f1edabfa7e..942d7063a1 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -500,6 +500,23 @@ QualType Sema::GetTypeForDeclarator(Declarator &D, Scope *S) {
return T;
}
+/// GetNonReferenceType - If Type is a reference type (e.g., const
+/// int&), returns the type that the reference refers to ("const
+/// int"). Otherwise, returns the type itself. This routine is used
+/// throughout to implement C++ 5p6:
+///
+/// If an expression initially has the type "reference to T" (8.3.2,
+/// 8.5.3), the type is adjusted to "T" prior to any further
+/// analysis, the expression designates the object or function
+/// denoted by the reference, and the expression is an lvalue.
+QualType Sema::GetNonReferenceType(QualType Type)
+{
+ if (const ReferenceType *RefType = Type->getAsReferenceType())
+ return RefType->getPointeeType();
+ else
+ return Type;
+}
+
/// ObjCGetTypeForMethodDefinition - Builds the type for a method definition
/// declarator
QualType Sema::ObjCGetTypeForMethodDefinition(DeclTy *D) {