Bug 185631 - TestWebKitAPI: Fix warnings found by new clang compiler
Summary: TestWebKitAPI: Fix warnings found by new clang compiler
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-14 14:52 PDT by David Kilzer (:ddkilzer)
Modified: 2018-05-15 09:45 PDT (History)
8 users (show)

See Also:


Attachments
Patch v1 (6.76 KB, patch)
2018-05-14 15:10 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff
Patch v2 (6.62 KB, patch)
2018-05-14 20:11 PDT, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2018-05-14 14:52:45 PDT
Building WebKit with a newer clang compiler emits a few new warnings in various TestWebKitAPI sources:


Tools/TestWebKitAPI/Tests/WebKit/FindMatches.mm:88:18: error: explicitly assigning value of variable of type 'WKRect' to itself [-Werror,-Wself-assign-overloaded]
            rect = rect;
            ~~~~ ^ ~~~~
1 error generated.


In file included from Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:26:
In file included from Tools/TestWebKitAPI/config.h:59:
Debug/gtest.framework/Headers/gtest.h:1263:16: error: comparison of integers of different signs: 'const long' and 'const (anonymous enum at Debug/WebKit.framework/PrivateHeaders/WKWebViewPrivate.h:88:9)' [-Werror,-Wsign-compare]
  if (expected == actual) {
      ~~~~~~~~ ^  ~~~~~~
Debug/gtest.framework/Headers/gtest.h:1299:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<long, (anonymous enum at Debug/WebKit.framework/PrivateHeaders/WKWebViewPrivate.h:88:9)>' requested here
    return CmpHelperEQ(expected_expression, actual_expression, expected,
           ^
Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:663:5: note: in instantiation of function template specialization 'testing::internal::EqHelper<false>::Compare<long, (anonymous enum at Debug/WebKit.framework/PrivateHeaders/WKWebViewPrivate.h:88:9)>' requested here
    EXPECT_EQ([[change objectForKey:NSKeyValueChangeOldKey] integerValue], _WKRectEdgeAll);
    ^
In file included from Tools/TestWebKitAPI/Tests/WebKitCocoa/UIDelegate.mm:26:
In file included from Tools/TestWebKitAPI/config.h:59:
Debug/gtest.framework/Headers/gtest.h:1761:67: note: expanded from macro 'EXPECT_EQ'
                      EqHelper<GTEST_IS_NULL_LITERAL_(expected)>::Compare, \
                                                                  ^
1 error generated.


Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp:175:13: error: explicitly assigning value of variable of type 'NakedPtr<TestWebKitAPI::RefLogger>' to itself [-Werror,-Wself-assign-overloaded]
        ptr = ptr;
        ~~~ ^ ~~~
1 error generated.


Tools/TestWebKitAPI/Tests/WTF/Poisoned.cpp:482:13: error: explicitly assigning value of variable of type 'Poisoned<TestWebKitAPI::(anonymous namespace)::TestPoisonA, TestWebKitAPI::RefLogger *>' (aka 'Poisoned<Poison<g_testPoisonA>, TestWebKitAPI::RefLogger *>') to itself [-Werror,-Wself-assign-overloaded]
        ptr = ptr;
        ~~~ ^ ~~~
1 error generated.


Tools/TestWebKitAPI/Tests/WTF/PoisonedRefPtr.cpp:307:13: error: explicitly assigning value of variable of type 'PoisonedRefPtr<TestWebKitAPI::(anonymous namespace)::PoisonE, TestWebKitAPI::RefLogger>' (aka 'WTF::RefPtr<TestWebKitAPI::RefLogger, WTF::PoisonedPtrTraits<WTF::Poison<&TestWebKitAPI::(anonymous namespace)::g_poisonE>, TestWebKitAPI::RefLogger> >') to itself [-Werror,-Wself-assign-overloaded]
        ptr = ptr;
        ~~~ ^ ~~~


Tools/TestWebKitAPI/Tests/WTF/RefPtr.cpp:263:13: error: explicitly assigning value of variable of type 'RefPtr<TestWebKitAPI::RefLogger>' to itself [-Werror,-Wself-assign-overloaded]
        ptr = ptr;
        ~~~ ^ ~~~
1 error generated.
Comment 1 Radar WebKit Bug Importer 2018-05-14 14:53:01 PDT
<rdar://problem/40234123>
Comment 2 David Kilzer (:ddkilzer) 2018-05-14 15:10:59 PDT
Created attachment 340365 [details]
Patch v1
Comment 3 Michael Catanzaro 2018-05-14 15:33:21 PDT
Comment on attachment 340365 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=340365&action=review

> Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp:178
> +#pragma clang diagnostic ignored "-Wunknown-pragmas"
> +#pragma clang diagnostic ignored "-Wself-assign-overloaded"

I think it would be good form to use two pops now to return the diagnostic stack to its original state, not that it matters.

> Tools/TestWebKitAPI/Tests/WebKit/FindMatches.mm:88
> +            unusedRect = WKRectGetValue(reinterpret_cast<WKRectRef>(items));

Can you not just drop the return value? Or cast the result to void?
Comment 4 David Kilzer (:ddkilzer) 2018-05-14 15:40:56 PDT
Comment on attachment 340365 [details]
Patch v1

Oops, need to fix the pragmas.
Comment 5 David Kilzer (:ddkilzer) 2018-05-14 15:44:06 PDT
Comment on attachment 340365 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=340365&action=review

>> Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp:178
>> +#pragma clang diagnostic ignored "-Wself-assign-overloaded"
> 
> I think it would be good form to use two pops now to return the diagnostic stack to its original state, not that it matters.

That's not how #pragma clang diagnostic push works.   See the next function below this.

>> Tools/TestWebKitAPI/Tests/WebKit/FindMatches.mm:88
>> +            unusedRect = WKRectGetValue(reinterpret_cast<WKRectRef>(items));
> 
> Can you not just drop the return value? Or cast the result to void?

Since it returns a struct, I didn't check whether I could cast to void.

I also toyed with adding some assertions (like EXPECT_TRUE(rect.size.width != 0 && rect.size.height != 0).  Maybe I'll do that instead.
Comment 6 Michael Catanzaro 2018-05-14 18:41:45 PDT
Comment on attachment 340365 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=340365&action=review

>>> Tools/TestWebKitAPI/Tests/WTF/NakedPtr.cpp:178
>>> +#pragma clang diagnostic ignored "-Wself-assign-overloaded"
>> 
>> I think it would be good form to use two pops now to return the diagnostic stack to its original state, not that it matters.
> 
> That's not how #pragma clang diagnostic push works.   See the next function below this.

Whoops, yes... one push, one pop, of course.
Comment 7 David Kilzer (:ddkilzer) 2018-05-14 20:11:16 PDT
Created attachment 340390 [details]
Patch v2
Comment 8 WebKit Commit Bot 2018-05-15 09:45:03 PDT
Comment on attachment 340390 [details]
Patch v2

Clearing flags on attachment: 340390

Committed r231806: <https://trac.webkit.org/changeset/231806>
Comment 9 WebKit Commit Bot 2018-05-15 09:45:05 PDT
All reviewed patches have been landed.  Closing bug.