[cfe-commits] r72304 - /cfe/trunk/include/clang/AST/Stmt.h

Fariborz Jahanian fjahanian at apple.com
Fri May 22 17:24:42 PDT 2009


On May 22, 2009, at 5:22 PM, Ted Kremenek wrote:

> Author: kremenek
> Date: Fri May 22 19:22:11 2009
> New Revision: 72304
>
> URL: http://llvm.org/viewvc/llvm-project?rev=72304&view=rev
> Log:
> Use 'Exprs.data()' instead of 'Exprs.empty() ? NULL : ...'
>
> 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=72304&r1=72303&r2=72304&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/include/clang/AST/Stmt.h (original)
> +++ cfe/trunk/include/clang/AST/Stmt.h Fri May 22 19:22:11 2009
> @@ -1161,19 +1161,19 @@
>   typedef ConstExprIterator const_inputs_iterator;
>
>   inputs_iterator begin_inputs() {
> -    return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
> +    return Exprs.data() + NumOutputs;
It is magic. But how can these two be equivalent? How can it return a  
NULL?

- Fariborz


>
>   }
>
>   inputs_iterator end_inputs() {
> -    return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs + NumInputs;
> +    return Exprs.data() + NumOutputs + NumInputs;
>   }
>
>   const_inputs_iterator begin_inputs() const {
> -    return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
> +    return Exprs.data() + NumOutputs;
>   }
>
>   const_inputs_iterator end_inputs() const {
> -    return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs + NumInputs;
> +    return Exprs.data() + NumOutputs + NumInputs;
>   }
>
>   // Output expr iterators.
> @@ -1182,17 +1182,17 @@
>   typedef ConstExprIterator const_outputs_iterator;
>
>   outputs_iterator begin_outputs() {
> -    return Exprs.empty() ? NULL : &Exprs[0];
> +    return Exprs.data();
>   }
>   outputs_iterator end_outputs() {
> -    return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
> +    return Exprs.data() + NumOutputs;
>   }
>
>   const_outputs_iterator begin_outputs() const {
> -    return Exprs.empty() ? NULL : &Exprs[0];
> +    return Exprs.data();
>   }
>   const_outputs_iterator end_outputs() const {
> -    return Exprs.empty() ? NULL : &Exprs[0] + NumOutputs;
> +    return Exprs.data() + NumOutputs;
>   }
>
>   // Input name iterator.
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list