[cfe-commits] r72286 - /cfe/trunk/include/clang/AST/Stmt.h
Ted Kremenek
kremenek at apple.com
Fri May 22 15:03:22 PDT 2009
Author: kremenek
Date: Fri May 22 17:03:22 2009
New Revision: 72286
URL: http://llvm.org/viewvc/llvm-project?rev=72286&view=rev
Log:
Modify begin()/end() for AsmStmt iterators to handle the case when Exprs.empty()
is true. Because of recent changes to llvm::SmallVector, using these iterators
when Exprs was empty would cause an assertion failure.
This fixes: PR 4245.
Modified:
cfe/trunk/include/clang/AST/Stmt.h
Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=72286&r1=72285&r2=72286&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Fri May 22 17:03:22 2009
@@ -1161,30 +1161,39 @@
typedef ConstExprIterator const_inputs_iterator;
inputs_iterator begin_inputs() {
- return &Exprs[0] + NumOutputs;
+ return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
}
inputs_iterator end_inputs() {
- return &Exprs[0] + NumOutputs + NumInputs;
+ return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs + NumInputs;
}
const_inputs_iterator begin_inputs() const {
- return &Exprs[0] + NumOutputs;
+ return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
}
const_inputs_iterator end_inputs() const {
- return &Exprs[0] + NumOutputs + NumInputs;}
+ return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs + NumInputs;
+ }
// Output expr iterators.
typedef ExprIterator outputs_iterator;
typedef ConstExprIterator const_outputs_iterator;
- outputs_iterator begin_outputs() { return &Exprs[0]; }
- outputs_iterator end_outputs() { return &Exprs[0] + NumOutputs; }
+ outputs_iterator begin_outputs() {
+ return Exprs.empty() ? NULL : &Exprs[0];
+ }
+ outputs_iterator end_outputs() {
+ return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
+ }
- const_outputs_iterator begin_outputs() const { return &Exprs[0]; }
- const_outputs_iterator end_outputs() const { return &Exprs[0] + NumOutputs; }
+ const_outputs_iterator begin_outputs() const {
+ return Exprs.empty() ? NULL : &Exprs[0];
+ }
+ const_outputs_iterator end_outputs() const {
+ return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
+ }
// Input name iterator.
More information about the cfe-commits
mailing list