[PATCH] D63533: [analyzer] Fix clang-tidy crash on GCCAsmStmt

Nathan Huckleberry via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 19 11:06:39 PDT 2019


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;
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63533.205642.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190619/59dd7818/attachment.bin>


More information about the cfe-commits mailing list