diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-07-21 04:09:54 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-07-21 04:09:54 +0000 |
| commit | c47d930448b031b1bbd89ebe5a579e76ecdb7b2c (patch) | |
| tree | 5a291fe63a8e055c36532928dca1f6d7e276517c | |
| parent | 15727f69fa666d62431d26fcec4dc2c512666477 (diff) | |
| download | llvm-c47d930448b031b1bbd89ebe5a579e76ecdb7b2c.zip llvm-c47d930448b031b1bbd89ebe5a579e76ecdb7b2c.tar.gz llvm-c47d930448b031b1bbd89ebe5a579e76ecdb7b2c.tar.bz2 | |
Fix a crash that can happen when you have typedefs for pointers to
interfaces. Just because they x->isPointerType() doesn't mean it is
valid to just cast to a pointertype. We have to handle typedefs etc
as well.
llvm-svn: 53819
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 52858cb..4d1a053 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -35,13 +35,14 @@ bool Sema::isObjCObjectPointerType(QualType type) const { if (!type->isPointerType()) return false; + // Check to see if this is 'id' or 'Class', both of which are typedefs for + // pointer types. This looks for the typedef specifically, not for the + // underlying type. if (type == Context.getObjCIdType() || type == Context.getObjCClassType()) return true; - if (type->isPointerType()) { - PointerType *pointerType = static_cast<PointerType*>(type.getTypePtr()); - type = pointerType->getPointeeType(); - } + const PointerType *pointerType = type->getAsPointerType(); + type = pointerType->getPointeeType(); return type->isObjCInterfaceType() || type->isObjCQualifiedIdType(); } |
