Skip to content

Commit 13fde7a

Browse files
committed
[analyzer] Fix clang-tidy crash on GCCAsmStmt
Summary: Added entry in switch statement to recognize GCCAsmStmt as a possible block terminator. Handling to build CFG using GCCAsmStmt was already implemented. Reviewers: nickdesaulniers, george.karpenkov, NoQ Reviewed By: nickdesaulniers, NoQ Subscribers: xbolva00, tmroeder, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63533 llvm-svn: 364605
1 parent 29d05c0 commit 13fde7a

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

clang/lib/StaticAnalyzer/Core/CoreEngine.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,11 @@ void CoreEngine::HandleBlockExit(const CFGBlock * B, ExplodedNode *Pred) {
396396
case Stmt::WhileStmtClass:
397397
HandleBranch(cast<WhileStmt>(Term)->getCond(), Term, B, Pred);
398398
return;
399+
400+
case Stmt::GCCAsmStmtClass:
401+
assert(cast<GCCAsmStmt>(Term)->isAsmGoto() && "Encountered GCCAsmStmt without labels");
402+
// TODO: Handle jumping to labels
403+
return;
399404
}
400405
}
401406

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
2+
3+
// expected-no-diagnostics
4+
5+
void clang_analyzer_warnIfReached();
6+
7+
void testAsmGoto() {
8+
asm goto("xor %0, %0\n je %l[label1]\n jl %l[label2]"
9+
: /* no outputs */
10+
: /* inputs */
11+
: /* clobbers */
12+
: label1, label2 /* any labels used */);
13+
14+
// FIXME: Should be reachable.
15+
clang_analyzer_warnIfReached();
16+
17+
label1:
18+
// FIXME: Should be reachable.
19+
clang_analyzer_warnIfReached();
20+
return;
21+
22+
label2:
23+
// FIXME: Should be reachable.
24+
clang_analyzer_warnIfReached();
25+
return;
26+
}

0 commit comments

Comments
 (0)