r186302 - Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).

Craig Topper craig.topper at gmail.com
Sun Jul 14 22:46:05 PDT 2013


Yeah it doesn't like that the element type for the array is unnamed. I just
reverted in 186305.


On Sun, Jul 14, 2013 at 10:43 PM, Serge Pavlov <sepavloff at gmail.com> wrote:

> gcc 4.6.3 also cannot build trunk.
>
> --Serge
>
>
> 2013/7/15 Hal Finkel <hfinkel at anl.gov>
>
>> ----- Original Message -----
>> > Author: ctopper
>> > Date: Sun Jul 14 23:28:48 2013
>> > New Revision: 186302
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=186302&view=rev
>> > Log:
>> > Use llvm::array_lengthof to replace sizeof(array)/sizeof(array[0]).
>> >
>> > Modified:
>> >     cfe/trunk/tools/driver/driver.cpp
>>
>> FWIW, this seems to break compilation with gcc 4.4.7:
>>
>> llvm-trunk/tools/clang/tools/driver/driver.cpp: In function ‘void
>> ParseProgName(llvm::SmallVectorImpl<const char*>&,
>> std::set<std::basic_string<char, std::char_traits<char>,
>> std::allocator<char> >, std::less<std::basic_string<char,
>> std::char_traits<char>, std::allocator<char> > >,
>> std::allocator<std::basic_string<char, std::char_traits<char>,
>> std::allocator<char> > > >&, clang::driver::Driver&)’:
>>
>> /llvm-trunk/tools/clang/tools/driver/driver.cpp:306: error: no matching
>> function for call to ‘array_lengthof(const
>> ParseProgName(llvm::SmallVectorImpl<const char*>&,
>> std::set<std::basic_string<char, std::char_traits<char>,
>> std::allocator<char> >, std::less<std::basic_string<char,
>> std::char_traits<char>, std::allocator<char> > >,
>> std::allocator<std::basic_string<char, std::char_traits<char>,
>> std::allocator<char> > > >&, clang::driver::Driver&)::<anonymous struct>
>> [10])’
>> make[4]: ***
>> [/llvm-trunk-build/tools/clang/tools/driver/Release+Asserts/driver.o] Error
>> 1
>>
>>  -Hal
>>
>> >
>> > Modified: cfe/trunk/tools/driver/driver.cpp
>> > URL:
>> >
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=186302&r1=186301&r2=186302&view=diff
>> >
>> ==============================================================================
>> > --- cfe/trunk/tools/driver/driver.cpp (original)
>> > +++ cfe/trunk/tools/driver/driver.cpp Sun Jul 14 23:28:48 2013
>> > @@ -25,6 +25,7 @@
>> >  #include "llvm/ADT/OwningPtr.h"
>> >  #include "llvm/ADT/SmallString.h"
>> >  #include "llvm/ADT/SmallVector.h"
>> > +#include "llvm/ADT/STLExtras.h"
>> >  #include "llvm/Option/ArgList.h"
>> >  #include "llvm/Option/OptTable.h"
>> >  #include "llvm/Option/Option.h"
>> > @@ -302,7 +303,7 @@ static void ParseProgName(SmallVectorImp
>> >      bool FoundMatch = false;
>> >      size_t i;
>> >
>> > -    for (i = 0; i < sizeof(suffixes) / sizeof(suffixes[0]); ++i) {
>> > +    for (i = 0; i < llvm::array_lengthof(suffixes); ++i) {
>> >        if (ProgNameRef.endswith(suffixes[i].Suffix)) {
>> >          FoundMatch = true;
>> >          if (suffixes[i].IsCXX)
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>> >
>>
>> --
>> Hal Finkel
>> Assistant Computational Scientist
>> Leadership Computing Facility
>> Argonne National Laboratory
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
>
> --
> Thanks,
> --Serge
>



-- 
~Craig
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130714/c32ad052/attachment.html>


More information about the cfe-commits mailing list