mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 00:20:14 +00:00
[analyzer] Treat @throw as a sink (stop processing).
The CFG approximates @throw as a return statement, but that's not good enough in inlined functions. Moreover, since Objective-C exceptions are usually considered fatal, we should be suppressing leak warnings like we do for calls to noreturn functions (like abort()). The comments indicate that we were probably intending to do this all along; it may have been inadvertantly changed during a refactor at one point. llvm-svn: 162156
This commit is contained in:
parent
9f61f8a966
commit
a97a99736e
@ -889,7 +889,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
|
||||
case Stmt::ObjCAtThrowStmtClass: {
|
||||
// FIXME: This is not complete. We basically treat @throw as
|
||||
// an abort.
|
||||
Bldr.generateNode(S, Pred, Pred->getState());
|
||||
Bldr.generateNode(S, Pred, Pred->getState(), /*IsSink=*/true);
|
||||
break;
|
||||
}
|
||||
|
||||
|
23
clang/test/Analysis/exceptions.mm
Normal file
23
clang/test/Analysis/exceptions.mm
Normal file
@ -0,0 +1,23 @@
|
||||
// RUN: %clang_cc1 -analyze -fexceptions -fobjc-exceptions -fcxx-exceptions -analyzer-ipa=inlining -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s
|
||||
|
||||
void clang_analyzer_checkInlined(bool);
|
||||
|
||||
typedef typeof(sizeof(int)) size_t;
|
||||
void *malloc(size_t);
|
||||
void free(void *);
|
||||
|
||||
|
||||
id getException();
|
||||
void inlinedObjC() {
|
||||
clang_analyzer_checkInlined(true); // expected-warning{{TRUE}}
|
||||
@throw getException();
|
||||
}
|
||||
|
||||
int testObjC() {
|
||||
int a; // uninitialized
|
||||
void *mem = malloc(4); // no-warning (ObjC exceptions are usually fatal)
|
||||
inlinedObjC();
|
||||
free(mem);
|
||||
return a; // no-warning
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user