Nathan-Huckleberry updated this revision to Diff 205642.
Nathan-Huckleberry added a comment.

- [analyzer] Revise test case and add TODO


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63533/new/

https://reviews.llvm.org/D63533

Files:
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
  clang/test/Analysis/egraph-asm-goto-no-crash.cpp


Index: clang/test/Analysis/egraph-asm-goto-no-crash.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/egraph-asm-goto-no-crash.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot 
%s
+// RUN: cat %t.dot | FileCheck %s
+
+void *target;
+int indirectBlockSuccessorDeterminism() {
+  int x = 0;
+  asm goto( "xor %0, %0\n je %l[label1]\n jl %l[label2]" : /* no outputs */ : 
/* inputs */ : /* clobbers */ : label1, label2 /* any labels used */ );
+
+  label1:
+  x++;
+  return x;
+
+  label2:
+  x--;
+  return x;
+}
+
+// CHECK: digraph "Exploded Graph" {
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -396,6 +396,11 @@
       case Stmt::WhileStmtClass:
         HandleBranch(cast<WhileStmt>(Term)->getCond(), Term, B, Pred);
         return;
+
+      case Stmt::GCCAsmStmtClass:
+        assert(cast<GCCAsmStmt>(Term)->isAsmGoto() == true);
+        // TODO: Handle jumping to labels
+        return;
     }
   }
 


Index: clang/test/Analysis/egraph-asm-goto-no-crash.cpp
===================================================================
--- /dev/null
+++ clang/test/Analysis/egraph-asm-goto-no-crash.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-dump-egraph=%t.dot %s
+// RUN: cat %t.dot | FileCheck %s
+
+void *target;
+int indirectBlockSuccessorDeterminism() {
+  int x = 0;
+  asm goto( "xor %0, %0\n je %l[label1]\n jl %l[label2]" : /* no outputs */ : /* inputs */ : /* clobbers */ : label1, label2 /* any labels used */ );
+
+  label1:
+  x++;
+  return x;
+
+  label2:
+  x--;
+  return x;
+}
+
+// CHECK: digraph "Exploded Graph" {
Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -396,6 +396,11 @@
       case Stmt::WhileStmtClass:
         HandleBranch(cast<WhileStmt>(Term)->getCond(), Term, B, Pred);
         return;
+
+      case Stmt::GCCAsmStmtClass:
+        assert(cast<GCCAsmStmt>(Term)->isAsmGoto() == true);
+        // TODO: Handle jumping to labels
+        return;
     }
   }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to