[cfe-commits] r111150 - in /cfe/trunk: include/clang/Frontend/ASTUnit.h lib/Frontend/ASTUnit.cpp

Douglas Gregor dgregor at apple.com
Mon Aug 16 09:46:30 PDT 2010


Author: dgregor
Date: Mon Aug 16 11:46:30 2010
New Revision: 111150

URL: http://llvm.org/viewvc/llvm-project?rev=111150&view=rev
Log:
Dereferencing NULL pointers is such poor form.

Modified:
    cfe/trunk/include/clang/Frontend/ASTUnit.h
    cfe/trunk/lib/Frontend/ASTUnit.cpp

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=111150&r1=111149&r2=111150&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Mon Aug 16 11:46:30 2010
@@ -241,7 +241,8 @@
   /// \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 

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=111150&r1=111149&r2=111150&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Aug 16 11:46:30 2010
@@ -191,10 +191,14 @@
                                                         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;
     }





More information about the cfe-commits mailing list