[cfe-commits] r39954 - in /cfe/trunk: AST/Type.cpp Sema/SemaExpr.cpp
Bill Wendling
isanbard at gmail.com
Mon Jul 16 21:16:47 PDT 2007
Author: void
Date: Mon Jul 16 23:16:47 2007
New Revision: 39954
URL: http://llvm.org/viewvc/llvm-project?rev=39954&view=rev
Log:
Change dyn_cast for reference types to be more like pointers and not need the canonical type. Also fix so that we're not expecting a return value from a void function
Modified:
cfe/trunk/AST/Type.cpp
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Type.cpp?rev=39954&r1=39953&r2=39954&view=diff
==============================================================================
--- cfe/trunk/AST/Type.cpp (original)
+++ cfe/trunk/AST/Type.cpp Mon Jul 16 23:16:47 2007
@@ -73,7 +73,15 @@
}
bool Type::isReferenceType() const {
- return isa<ReferenceType>(CanonicalType);
+ // If this is directly a reference type, return it.
+ if (const ReferenceType *RTy = dyn_cast<ReferenceType>(this))
+ return RTy;
+
+ // If this is a typedef for a reference type, strip the typedef off without
+ // losing all typedef information.
+ if (isa<ReferenceType>(CanonicalType))
+ return cast<ReferenceType>(cast<TypedefType>(this)->LookThroughTypedefs());
+ return 0;
}
bool Type::isArrayType() const {
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=39954&r1=39953&r2=39954&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Mon Jul 16 23:16:47 2007
@@ -597,8 +597,10 @@
QualType t = e->getType();
assert(!t.isNull() && "DefaultFunctionArrayConversion - missing type");
- if (const ReferenceType *ref = dyn_cast<ReferenceType>(t.getCanonicalType()))
- t = promoteExprToType(e, ref->getReferenceeType()); // C++ [expr]
+ if (const ReferenceType *ref = dyn_cast<ReferenceType>(t)) {
+ promoteExprToType(e, ref->getReferenceeType()); // C++ [expr]
+ t = e->getType();
+ }
if (t->isFunctionType())
promoteExprToType(e, Context.getPointerType(t));
else if (const ArrayType *ary = dyn_cast<ArrayType>(t.getCanonicalType()))
@@ -614,8 +616,10 @@
QualType t = expr->getType();
assert(!t.isNull() && "UsualUnaryConversions - missing type");
- if (const ReferenceType *ref = dyn_cast<ReferenceType>(t.getCanonicalType()))
- t = promoteExprToType(expr, ref->getReferenceeType()); // C++ [expr]
+ if (const ReferenceType *ref = dyn_cast<ReferenceType>(t)) {
+ promoteExprToType(expr, ref->getReferenceeType()); // C++ [expr]
+ t = expr->getType();
+ }
if (t->isPromotableIntegerType()) // C99 6.3.1.1p2
promoteExprToType(expr, Context.IntTy);
else
More information about the cfe-commits
mailing list