[llvm] r219804 - Use 'auto' for easier reading; no functional change intended.

Sanjay Patel spatel at rotateright.com
Wed Oct 15 10:56:24 PDT 2014


Thanks, all - updated with r219817.

On Wed, Oct 15, 2014 at 11:39 AM, David Blaikie <dblaikie at gmail.com> wrote:

>
>
> On Wed, Oct 15, 2014 at 10:06 AM, Aaron Ballman <aaron at aaronballman.com>
> wrote:
>
>> On Wed, Oct 15, 2014 at 12:47 PM, David Blaikie <dblaikie at gmail.com>
>> wrote:
>> > I /think/ we generally like to still specify the 'const' when using auto
>> > (like we specify the '*') - though this probably isn't a hard-and-fast
>> rule,
>> > just a thought.
>>
>> I thought it was a hard-and-fast rule?
>
>
> I was mostly going off actual usage, rather than the style guide wording.
>
>
>> We sort of suggest it, but not
>> very explicitly, in our coding guidelines
>> (
>> http://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
>> )
>>
>
> But that sounds about consistent with usage/habits I've seen. Maybe we
> could call it out separately from for loops (and explicitly mention the
> 'const' part of it) as useful general auto guidance.
>
> Sometimes I think it's reasonable to not worry about the 'const' if I'm
> actually /adding/ const (eg: if a function returns a non-const pointer that
> I'm going to stuff in an "auto *" for a few lines as simple
> common-subexpression reuse, adding const to it isn't particularly
> important) and if I can't tell if I'm adding const or not, I probably don't
> care much... until I get a compilation error because I tried to call a
> non-const function on an "auto *" not realizing that it was actually
> pointer-to-const.
>
>
>>
>> ~Aaron
>>
>> >
>> > On Wed, Oct 15, 2014 at 9:21 AM, Sanjay Patel <spatel at rotateright.com>
>> > wrote:
>> >>
>> >> Author: spatel
>> >> Date: Wed Oct 15 11:21:37 2014
>> >> New Revision: 219804
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=219804&view=rev
>> >> Log:
>> >> Use 'auto' for easier reading; no functional change intended.
>> >>
>> >> Modified:
>> >>     llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
>> >>
>> >> Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
>> >> URL:
>> >>
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=219804&r1=219803&r2=219804&view=diff
>> >>
>> >>
>> ==============================================================================
>> >> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
>> >> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Wed Oct 15 11:21:37
>> >> 2014
>> >> @@ -710,18 +710,15 @@ static void WriteModuleInfo(const Module
>> >>  static uint64_t GetOptimizationFlags(const Value *V) {
>> >>    uint64_t Flags = 0;
>> >>
>> >> -  if (const OverflowingBinaryOperator *OBO =
>> >> -        dyn_cast<OverflowingBinaryOperator>(V)) {
>> >> +  if (auto *OBO = dyn_cast<OverflowingBinaryOperator>(V)) {
>> >>      if (OBO->hasNoSignedWrap())
>> >>        Flags |= 1 << bitc::OBO_NO_SIGNED_WRAP;
>> >>      if (OBO->hasNoUnsignedWrap())
>> >>        Flags |= 1 << bitc::OBO_NO_UNSIGNED_WRAP;
>> >> -  } else if (const PossiblyExactOperator *PEO =
>> >> -               dyn_cast<PossiblyExactOperator>(V)) {
>> >> +  } else if (auto *PEO = dyn_cast<PossiblyExactOperator>(V)) {
>> >>      if (PEO->isExact())
>> >>        Flags |= 1 << bitc::PEO_EXACT;
>> >> -  } else if (const FPMathOperator *FPMO =
>> >> -             dyn_cast<const FPMathOperator>(V)) {
>> >> +  } else if (auto *FPMO = dyn_cast<const FPMathOperator>(V)) {
>> >>      if (FPMO->hasUnsafeAlgebra())
>> >>        Flags |= FastMathFlags::UnsafeAlgebra;
>> >>      if (FPMO->hasNoNaNs())
>> >>
>> >>
>> >> _______________________________________________
>> >> llvm-commits mailing list
>> >> llvm-commits at cs.uiuc.edu
>> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >
>> >
>> >
>> > _______________________________________________
>> > llvm-commits mailing list
>> > llvm-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>> >
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141015/6c979903/attachment.html>


More information about the llvm-commits mailing list