[libcxx] r315874 - Silence clang's -Wtautological-constant-compare in last_write_time.pass.cpp

Roman Lebedev via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 16 10:21:18 PDT 2017


On Mon, Oct 16, 2017 at 8:09 PM, David Blaikie <dblaikie at gmail.com> wrote:
> Would it be better/possible to improve the warning to not have this false
> positive, rather than suppressing it?
I am willing to look into it, once there is a clear minimal test-case,
that does not boil down to completely ignoring std::numeric_limits<>.

Right now, sadly, i do not see any simple false-positive here.

Roman.

> On Sun, Oct 15, 2017 at 1:12 PM Roman Lebedev via cfe-commits
> <cfe-commits at lists.llvm.org> wrote:
>>
>> Author: lebedevri
>> Date: Sun Oct 15 13:12:42 2017
>> New Revision: 315874
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315874&view=rev
>> Log:
>> Silence clang's -Wtautological-constant-compare in
>> last_write_time.pass.cpp
>>
>> Previously this broke the builders, when D38101 was committed.
>> Silence the warning so that it can be re-landed.
>>
>> Modified:
>>
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>>
>> Modified:
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp?rev=315874&r1=315873&r2=315874&view=diff
>>
>> ==============================================================================
>> ---
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>> (original)
>> +++
>> libcxx/trunk/test/std/experimental/filesystem/fs.op.funcs/fs.op.last_write_time/last_write_time.pass.cpp
>> Sun Oct 15 13:12:42 2017
>> @@ -88,6 +88,13 @@ bool TestSupportsNegativeTimes() {
>>      return !ec && new_write_time <= -5;
>>  }
>>
>> +// In some configurations, the comparison is tautological and the test is
>> valid.
>> +// We disable the warning so that we can actually test it regardless.
>> +#if defined(__clang__)
>> +#pragma clang diagnostic push
>> +#pragma clang diagnostic ignored "-Wtautological-constant-compare"
>> +#endif
>> +
>>  bool TestSupportsMaxTime() {
>>      using namespace std::chrono;
>>      using Lim = std::numeric_limits<std::time_t>;
>> @@ -106,11 +113,22 @@ bool TestSupportsMaxTime() {
>>      return !ec && new_write_time > max_sec - 1;
>>  }
>>
>> +#if defined(__clang__)
>> +#pragma clang diagnostic pop
>> +#endif
>> +
>>  static const bool SupportsNegativeTimes = TestSupportsNegativeTimes();
>>  static const bool SupportsMaxTime = TestSupportsMaxTime();
>>
>>  } // end namespace
>>
>> +// In some configurations, the comparison is tautological and the test is
>> valid.
>> +// We disable the warning so that we can actually test it regardless.
>> +#if defined(__clang__)
>> +#pragma clang diagnostic push
>> +#pragma clang diagnostic ignored "-Wtautological-constant-compare"
>> +#endif
>> +
>>  // Check if a time point is representable on a given filesystem. Check
>> that:
>>  // (A) 'tp' is representable as a time_t
>>  // (B) 'tp' is non-negative or the filesystem supports negative times.
>> @@ -127,6 +145,10 @@ inline bool TimeIsRepresentableByFilesys
>>      return true;
>>  }
>>
>> +#if defined(__clang__)
>> +#pragma clang diagnostic pop
>> +#endif
>> +
>>  TEST_SUITE(exists_test_suite)
>>
>>  TEST_CASE(signature_test)
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


More information about the cfe-commits mailing list