Skip to content

Commit 4a1190b

Browse files
committed
[WebKit checkers] Treat asm brk as trivial (llvm#155046)
Like other functions which results in abort, treat asm brk instruction as trivial.
1 parent 8441808 commit 4a1190b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,11 @@ class TrivialFunctionAnalysisVisitor
681681
return IsFunctionTrivial(Callee);
682682
}
683683

684+
bool VisitGCCAsmStmt(const GCCAsmStmt *AS) {
685+
auto *AsmString = AS->getAsmString();
686+
return AsmString && AsmString->getString() == "brk #0xc471";
687+
}
688+
684689
bool
685690
VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E) {
686691
// Non-type template paramter is compile time constant and trivial.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang_analyze_cc1 -triple arm-darwin -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2+
// expected-no-diagnostics
3+
4+
void crash()
5+
{
6+
__asm__ volatile ("brk #0xc471");
7+
__builtin_unreachable();
8+
}
9+
10+
class SomeObj {
11+
public:
12+
void ref();
13+
void deref();
14+
15+
void someWork() { crash(); }
16+
};
17+
18+
SomeObj* provide();
19+
20+
void doSomeWork() {
21+
provide()->someWork();
22+
}

0 commit comments

Comments
 (0)