[Lldb-commits] [lldb] r124051 - /lldb/trunk/source/Expression/ClangASTSource.cpp

Greg Clayton gclayton at apple.com
Sat Jan 22 16:34:52 PST 2011


Author: gclayton
Date: Sat Jan 22 18:34:52 2011
New Revision: 124051

URL: http://llvm.org/viewvc/llvm-project?rev=124051&view=rev
Log:
Watch out for NULL types in NameSearchContext::AddTypeDecl or we crash.


Modified:
    lldb/trunk/source/Expression/ClangASTSource.cpp

Modified: lldb/trunk/source/Expression/ClangASTSource.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangASTSource.cpp?rev=124051&r1=124050&r2=124051&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangASTSource.cpp (original)
+++ lldb/trunk/source/Expression/ClangASTSource.cpp Sat Jan 22 18:34:52 2011
@@ -240,26 +240,26 @@
 clang::NamedDecl *
 NameSearchContext::AddTypeDecl(void *type)
 {
-    QualType qual_type = QualType::getFromOpaquePtr(type);
-
-    if (TagType *tag_type = dyn_cast<clang::TagType>(qual_type))
-    {
-        TagDecl *tag_decl = tag_type->getDecl();
-        
-        m_decls.push_back(tag_decl);
-        
-        return tag_decl;
-    }
-    else if (ObjCObjectType *objc_object_type = dyn_cast<clang::ObjCObjectType>(qual_type))
+    if (type)
     {
-        ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface();
-        
-        m_decls.push_back((NamedDecl*)interface_decl);
-        
-        return (NamedDecl*)interface_decl;
-    }
-    else
-    {
-        return NULL;
+        QualType qual_type = QualType::getFromOpaquePtr(type);
+
+        if (TagType *tag_type = dyn_cast<clang::TagType>(qual_type))
+        {
+            TagDecl *tag_decl = tag_type->getDecl();
+            
+            m_decls.push_back(tag_decl);
+            
+            return tag_decl;
+        }
+        else if (ObjCObjectType *objc_object_type = dyn_cast<clang::ObjCObjectType>(qual_type))
+        {
+            ObjCInterfaceDecl *interface_decl = objc_object_type->getInterface();
+            
+            m_decls.push_back((NamedDecl*)interface_decl);
+            
+            return (NamedDecl*)interface_decl;
+        }
     }
+    return NULL;
 }





More information about the lldb-commits mailing list