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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@39954 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Type.cpp b/AST/Type.cpp
index 7b999fa..f083a73 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -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 {