]> granicus.if.org Git - clang/commitdiff
Dereferencing NULL pointers is such poor form.
authorDouglas Gregor <dgregor@apple.com>
Mon, 16 Aug 2010 16:46:30 +0000 (16:46 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 16 Aug 2010 16:46:30 +0000 (16:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111150 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/ASTUnit.h
lib/Frontend/ASTUnit.cpp

index f18e70e750272e739b79b1ff74792b271fe0e445..f8859425ff998a7ea59243023a93bdac82416920 100644 (file)
@@ -241,7 +241,8 @@ private:
   /// \brief The set of cached code-completion results.
   std::vector<CachedCodeCompletionResult> CachedCompletionResults;
   
-  /// \brief Cache any "global" code-completion results, so that we 
+  /// \brief Cache any "global" code-completion results, so that we can avoid
+  /// recomputing them with each completion.
   void CacheCodeCompletionResults();
   
   /// \brief Clear out and deallocate 
index a573fb41ab649a678fb61c895c705a925db240cf..b54162f8d7d89b210dc037eee659b195cfb16cbc 100644 (file)
@@ -191,10 +191,14 @@ void ASTUnit::CacheCodeCompletionResults() {
                                                         Ctx->getLangOptions());
       CachedResult.Priority = Results[I].Priority;
       CachedResult.Kind = Results[I].CursorKind;
-      CachedResult.TypeClass
-        = getSimplifiedTypeClass(
-              Ctx->getCanonicalType(getDeclUsageType(*Ctx, 
-                                                     Results[I].Declaration)));
+
+      QualType UsageType = getDeclUsageType(*Ctx, Results[I].Declaration);
+      if (UsageType.isNull())
+        CachedResult.TypeClass = STC_Void;
+      else {
+        CachedResult.TypeClass
+          = getSimplifiedTypeClass(Ctx->getCanonicalType(UsageType));
+      }
       CachedCompletionResults.push_back(CachedResult);
       break;
     }