From 369e0367ff37a245b143d464228e7732871be89b Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Fri, 2 Aug 2019 16:01:39 -0700 Subject: [PATCH] Use stricter shadowing flags in Flutter targets. --- common/BUILD.gn | 14 +++++++++ runtime/dart_lifecycle_unittests.cc | 2 +- .../framework/Source/FlutterViewController.mm | 31 +++++++------------ third_party/txt/src/minikin/LineBreaker.cpp | 3 +- third_party/txt/tests/CmapCoverageTest.cpp | 2 -- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/common/BUILD.gn b/common/BUILD.gn index b9b05073501d2..d1e70e0514f37 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -5,7 +5,21 @@ import("config.gni") config("flutter_config") { + extra_warnings = [] + + if (is_clang) { + extra_warnings += [ + "-Wshadow-all", + "-Wno-shadow-uncaptured-local", + "-Wno-shadow-field-in-constructor", + ] + } + defines = feature_defines_list + + cflags = extra_warnings + cflags_cc = extra_warnings + cflags_objc = extra_warnings } source_set("common") { diff --git a/runtime/dart_lifecycle_unittests.cc b/runtime/dart_lifecycle_unittests.cc index 7ec1606fc0706..c587c450f0d2e 100644 --- a/runtime/dart_lifecycle_unittests.cc +++ b/runtime/dart_lifecycle_unittests.cc @@ -128,7 +128,7 @@ TEST_F(DartLifecycleTest, DISABLED_ShuttingDownTheVMShutsDownAllIsolates) { fml::CountDownLatch latch(isolate_count); auto vm_data = vm_ref.GetVMData(); auto thread_task_runner = GetThreadTaskRunner(); - for (size_t i = 0; i < isolate_count; ++i) { + for (size_t j = 0; j < isolate_count; ++j) { thread_task_runner->PostTask( [vm_data, &settings, &latch, thread_task_runner]() { ASSERT_TRUE(CreateAndRunRootIsolate(settings, *vm_data.get(), diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index f94593913b190..8f4ce280bd778 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -822,34 +822,25 @@ - (void)onAccessibilityStatusChanged:(NSNotification*)notification { #pragma mark - Locale updates - (void)onLocaleUpdated:(NSNotification*)notification { - NSArray* preferredLocales = [NSLocale preferredLanguages]; - NSMutableArray* data = [[NSMutableArray new] autorelease]; - + NSMutableArray* locales = [[[NSMutableArray alloc] init] autorelease]; // Force prepend the [NSLocale currentLocale] to the front of the list // to ensure we are including the full default locale. preferredLocales // is not guaranteed to include anything beyond the languageCode. - NSLocale* currentLocale = [NSLocale currentLocale]; - NSString* languageCode = [currentLocale objectForKey:NSLocaleLanguageCode]; - NSString* countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; - NSString* scriptCode = [currentLocale objectForKey:NSLocaleScriptCode]; - NSString* variantCode = [currentLocale objectForKey:NSLocaleVariantCode]; - if (languageCode) { - [data addObject:languageCode]; - [data addObject:(countryCode ? countryCode : @"")]; - [data addObject:(scriptCode ? scriptCode : @"")]; - [data addObject:(variantCode ? variantCode : @"")]; + [locales addObject:[NSLocale currentLocale]]; + // Add any secondary locales/languages to the list. + for (NSString* language : [NSLocale preferredLanguages]) { + [locales addObject:[[[NSLocale alloc] initWithLocaleIdentifier:language] autorelease]]; } - // Add any secondary locales/languages to the list. - for (NSString* localeID in preferredLocales) { - NSLocale* currentLocale = [[[NSLocale alloc] initWithLocaleIdentifier:localeID] autorelease]; - NSString* languageCode = [currentLocale objectForKey:NSLocaleLanguageCode]; - NSString* countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; - NSString* scriptCode = [currentLocale objectForKey:NSLocaleScriptCode]; - NSString* variantCode = [currentLocale objectForKey:NSLocaleVariantCode]; + NSMutableArray* data = [[NSMutableArray new] autorelease]; + for (NSLocale* locale in locales) { + NSString* languageCode = [locale objectForKey:NSLocaleLanguageCode]; if (!languageCode) { continue; } + NSString* countryCode = [locale objectForKey:NSLocaleCountryCode]; + NSString* scriptCode = [locale objectForKey:NSLocaleScriptCode]; + NSString* variantCode = [locale objectForKey:NSLocaleVariantCode]; [data addObject:languageCode]; [data addObject:(countryCode ? countryCode : @"")]; [data addObject:(scriptCode ? scriptCode : @"")]; diff --git a/third_party/txt/src/minikin/LineBreaker.cpp b/third_party/txt/src/minikin/LineBreaker.cpp index 52417d28e35df..5666e2bc10c97 100644 --- a/third_party/txt/src/minikin/LineBreaker.cpp +++ b/third_party/txt/src/minikin/LineBreaker.cpp @@ -437,8 +437,7 @@ void LineBreaker::computeBreaksOptimal(bool isRectangle) { size_t lineNumberLast = 0; if (!isRectangle) { - size_t lineNumberLast = mCandidates[active].lineNumber; - width = mLineWidths.getLineWidth(lineNumberLast); + width = mLineWidths.getLineWidth(mCandidates[active].lineNumber); } ParaWidth leftEdge = mCandidates[i].postBreak - width; float bestHope = 0; diff --git a/third_party/txt/tests/CmapCoverageTest.cpp b/third_party/txt/tests/CmapCoverageTest.cpp index b85a9e0777563..423524aa8b2f1 100644 --- a/third_party/txt/tests/CmapCoverageTest.cpp +++ b/third_party/txt/tests/CmapCoverageTest.cpp @@ -547,7 +547,6 @@ TEST(CmapCoverageTest, TableSelection_Priority) { } TEST(CmapCoverageTest, TableSelection_SkipBrokenFormat4Table) { - SparseBitSet coverage; bool has_cmap_format_14_subtable = false; std::vector validTable = buildCmapFormat4Table(std::vector({'a', 'a'})); @@ -602,7 +601,6 @@ TEST(CmapCoverageTest, TableSelection_SkipBrokenFormat4Table) { } TEST(CmapCoverageTest, TableSelection_SkipBrokenFormat12Table) { - SparseBitSet coverage; bool has_cmap_format_14_subtable = false; std::vector validTable = buildCmapFormat12Table(std::vector({'a', 'a'}));