[cfe-commits] r47690 - in /cfe/trunk: Analysis/GRExprEngine.cpp include/clang/Analysis/PathSensitive/GRExprEngine.h
Ted Kremenek
kremenek at apple.com
Wed Feb 27 12:43:44 PST 2008
Author: kremenek
Date: Wed Feb 27 14:43:44 2008
New Revision: 47690
URL: http://llvm.org/viewvc/llvm-project?rev=47690&view=rev
Log:
End paths when calling a function marked "noreturn."
Modified:
cfe/trunk/Analysis/GRExprEngine.cpp
cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
Modified: cfe/trunk/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Analysis/GRExprEngine.cpp?rev=47690&r1=47689&r2=47690&view=diff
==============================================================================
--- cfe/trunk/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/Analysis/GRExprEngine.cpp Wed Feb 27 14:43:44 2008
@@ -550,6 +550,21 @@
else
St = EvalCall(CE, cast<LVal>(L), (*DI)->getState());
+ // Check for the "noreturn" attribute.
+
+ if (isa<lval::FuncVal>(L))
+ if (cast<lval::FuncVal>(L).getDecl()->getAttr<NoReturnAttr>()) {
+
+ NodeTy* N = Builder->generateNode(CE, St, *DI);
+
+ if (N) {
+ N->markAsSink();
+ NoReturnCalls.insert(N);
+ }
+
+ continue;
+ }
+
Nodify(Dst, CE, *DI, St);
}
}
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h?rev=47690&r1=47689&r2=47690&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/GRExprEngine.h Wed Feb 27 14:43:44 2008
@@ -87,20 +87,25 @@
/// CurrentStmt - The current block-level statement.
Stmt* CurrentStmt;
+
+ typedef llvm::SmallPtrSet<NodeTy*,2> UninitBranchesTy;
+ typedef llvm::SmallPtrSet<NodeTy*,2> UninitStoresTy;
+ typedef llvm::SmallPtrSet<NodeTy*,2> BadDerefTy;
+ typedef llvm::SmallPtrSet<NodeTy*,2> BadDividesTy;
+ typedef llvm::SmallPtrSet<NodeTy*,2> NoReturnCallsTy;
/// UninitBranches - Nodes in the ExplodedGraph that result from
/// taking a branch based on an uninitialized value.
- typedef llvm::SmallPtrSet<NodeTy*,5> UninitBranchesTy;
UninitBranchesTy UninitBranches;
-
- typedef llvm::SmallPtrSet<NodeTy*,5> UninitStoresTy;
- typedef llvm::SmallPtrSet<NodeTy*,5> BadDerefTy;
- typedef llvm::SmallPtrSet<NodeTy*,5> BadDividesTy;
/// UninitStores - Sinks in the ExplodedGraph that result from
/// making a store to an uninitialized lvalue.
UninitStoresTy UninitStores;
+ /// NoReturnCalls - Sinks in the ExplodedGraph that result from
+ // calling a function with the attribute "noreturn".
+ NoReturnCallsTy NoReturnCalls;
+
/// ImplicitNullDeref - Nodes in the ExplodedGraph that result from
/// taking a dereference on a symbolic pointer that MAY be NULL.
BadDerefTy ImplicitNullDeref;
@@ -176,6 +181,10 @@
return N->isSink() && BadDivides.count(const_cast<NodeTy*>(N)) != 0;
}
+ bool isNoReturnCall(const NodeTy* N) const {
+ return N->isSink() && NoReturnCalls.count(const_cast<NodeTy*>(N)) != 0;
+ }
+
typedef BadDerefTy::iterator null_deref_iterator;
null_deref_iterator null_derefs_begin() { return ExplicitNullDeref.begin(); }
null_deref_iterator null_derefs_end() { return ExplicitNullDeref.end(); }
More information about the cfe-commits
mailing list