]> granicus.if.org Git - clang/commitdiff
Refactor some function name -> summary lookup using a switch statement.
authorTed Kremenek <kremenek@apple.com>
Thu, 11 Jun 2009 18:10:48 +0000 (18:10 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 11 Jun 2009 18:10:48 +0000 (18:10 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73197 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp

index 532d16da0f0e8149afbc91b6439af653af83b023..2053d2c86c04dd78c92dff390fc6e4d1a4bb7e85 100644 (file)
@@ -971,15 +971,31 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
     
     // FIXME: This should all be refactored into a chain of "summary lookup"
     //  filters.
-    if (strcmp(FName, "IOServiceGetMatchingServices") == 0) {
-      // FIXES: <rdar://problem/6326900>
-      // This should be addressed using a API table.  This strcmp is also
-      // a little gross, but there is no need to super optimize here.
-      assert (ScratchArgs.isEmpty());
-      ScratchArgs = AF.Add(ScratchArgs, 1, DecRef);
-      S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
-      break;
-    }
+               switch (strlen(FName)) {
+                       default: break;
+                       case 17:
+                               // Handle: id NSMakeCollectable(CFTypeRef)
+                               if (!memcmp(FName, "NSMakeCollectable", 17)) {
+                                       S = (RetTy == Ctx.getObjCIdType())
+                                                       ? getUnarySummary(FT, cfmakecollectable)
+                                                       : getPersistentStopSummary();
+                               }
+                               break;
+                       case 28:
+                               if (!memcmp(FName, "IOServiceGetMatchingServices", 28)) {
+                                       // FIXES: <rdar://problem/6326900>
+                                       // This should be addressed using a API table.  This strcmp is also
+                                       // a little gross, but there is no need to super optimize here.
+                                       assert (ScratchArgs.isEmpty());
+                                       ScratchArgs = AF.Add(ScratchArgs, 1, DecRef);
+                                       S = getPersistentSummary(RetEffect::MakeNoRet(), DoNothing, DoNothing);
+                               }
+                               break;
+               }
+               
+               // Did we get a summary?
+               if (S)
+                       break;
 
     // Enable this code once the semantics of NSDeallocateObject are resolved
     // for GC.  <rdar://problem/6619988>
@@ -992,15 +1008,6 @@ RetainSummary* RetainSummaryManager::getSummary(FunctionDecl* FD) {
         : getPersistentStopSummary();
     }
 #endif
-    
-    // Handle: id NSMakeCollectable(CFTypeRef)
-    if (strcmp(FName, "NSMakeCollectable") == 0) {
-      S = (RetTy == Ctx.getObjCIdType())
-          ? getUnarySummary(FT, cfmakecollectable)
-          : getPersistentStopSummary();
-        
-      break;
-    }
 
     if (RetTy->isPointerType()) {
       // For CoreFoundation ('CF') types.