]> granicus.if.org Git - clang/commitdiff
Hack to hardwire in some panic functions that are not marked noreturn.
authorTed Kremenek <kremenek@apple.com>
Fri, 14 Mar 2008 21:58:42 +0000 (21:58 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 14 Mar 2008 21:58:42 +0000 (21:58 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48374 91177308-0d34-0410-b5e6-96231b3b80d8

Analysis/GRExprEngine.cpp

index 70cd1871bccadf63797abfe9d805c833a4eda4bf..0504e65abee831d0629dc6d8384ed3a2ecf9355f 100644 (file)
@@ -497,9 +497,29 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
     
     SaveAndRestore<bool> OldSink(Builder->BuildSinks);
     
-    if (isa<lval::FuncVal>(L))
-      if (cast<lval::FuncVal>(L).getDecl()->getAttr<NoReturnAttr>())
+    if (isa<lval::FuncVal>(L)) {      
+      
+      FunctionDecl* FD = cast<lval::FuncVal>(L).getDecl();
+      
+      if (FD->getAttr<NoReturnAttr>())
         Builder->BuildSinks = true;
+      else {
+        // HACK: Some functions are not marked noreturn, and don't return.
+        //  Here are a few hardwired ones.  If this takes too long, we can
+        //  potentially cache these results.
+        const char* s = FD->getIdentifier()->getName();
+        unsigned n = strlen(s);
+        
+        switch (n) {
+          default:
+            break;
+          case 4:
+            if (!memcmp(s, "exit", 4) || !memcmp(s, "panic", 4)) {
+              Builder->BuildSinks = true; break;
+            }
+        }
+      }
+    }
     
     // Evaluate the call.