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

Nathan Huckleberry via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 27 15:35:49 PDT 2019


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

- Minor style change on assert


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,26 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+void clang_analyzer_warnIfReached();
+
+void testAsmGoto() {
+  asm goto("xor %0, %0\n je %l[label1]\n jl %l[label2]"
+           : /* no outputs */
+           : /* inputs */
+           : /* clobbers */
+           : label1, label2 /* any labels used */);
+
+  // FIXME: Should be reachable.
+  clang_analyzer_warnIfReached();
+
+  label1:
+  // FIXME: Should be reachable.
+  clang_analyzer_warnIfReached();
+  return;
+
+  label2:
+  // FIXME: Should be reachable.
+  clang_analyzer_warnIfReached();
+  return;
+}
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() && "Encountered GCCAsmStmt without labels");
+        // TODO: Handle jumping to labels
+        return;
     }
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63533.206954.patch
Type: text/x-patch
Size: 1412 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190627/82388b51/attachment.bin>


More information about the cfe-commits mailing list