summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZsolt Bölöny <bolony.zsolt@gmail.com>2018-06-24 14:34:26 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-06-25 09:37:54 -0700
commit7d450229bc23c10ff9fd2469764bf945cbab04d2 (patch)
tree6b90d7445981844591d2580dd25d9f7f656a33fa
parent279dd93f7cbd57adce60a97bdb760905e30f4580 (diff)
downloadqtlocation-mapboxgl-upstream/fix-gcc-wcatch-value.tar.gz
[core] Fix GCC8's new -Wcatch-value warningsupstream/fix-gcc-wcatch-value
Polymorphic types shouldn't be caught by value, as the warning message says. Catch them by constant reference instead.
-rw-r--r--bin/offline.cpp6
-rw-r--r--bin/render.cpp6
-rw-r--r--platform/default/mbgl/storage/offline_database.cpp2
-rw-r--r--platform/default/mbgl/storage/offline_download.cpp2
-rw-r--r--platform/glfw/main.cpp6
-rw-r--r--src/mbgl/style/expression/coercion.cpp2
-rw-r--r--test/storage/offline_database.test.cpp2
-rw-r--r--test/style/style.test.cpp2
-rw-r--r--test/style/style_layer.test.cpp2
9 files changed, 15 insertions, 15 deletions
diff --git a/bin/offline.cpp b/bin/offline.cpp
index 65396a88fb..8b42ab7b72 100644
--- a/bin/offline.cpp
+++ b/bin/offline.cpp
@@ -33,14 +33,14 @@ int main(int argc, char *argv[]) {
try {
argumentParser.ParseCLI(argc, argv);
- } catch (args::Help) {
+ } catch (const args::Help&) {
std::cout << argumentParser;
exit(0);
- } catch (args::ParseError e) {
+ } catch (const args::ParseError& e) {
std::cerr << e.what() << std::endl;
std::cerr << argumentParser;
exit(1);
- } catch (args::ValidationError e) {
+ } catch (const args::ValidationError& e) {
std::cerr << e.what() << std::endl;
std::cerr << argumentParser;
exit(2);
diff --git a/bin/render.cpp b/bin/render.cpp
index 6ceb32eb00..1e7b210a4c 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -39,14 +39,14 @@ int main(int argc, char *argv[]) {
try {
argumentParser.ParseCLI(argc, argv);
- } catch (args::Help) {
+ } catch (const args::Help&) {
std::cout << argumentParser;
exit(0);
- } catch (args::ParseError e) {
+ } catch (const args::ParseError& e) {
std::cerr << e.what() << std::endl;
std::cerr << argumentParser;
exit(1);
- } catch (args::ValidationError e) {
+ } catch (const args::ValidationError& e) {
std::cerr << e.what() << std::endl;
std::cerr << argumentParser;
exit(2);
diff --git a/platform/default/mbgl/storage/offline_database.cpp b/platform/default/mbgl/storage/offline_database.cpp
index 24fc0f2335..92e534634d 100644
--- a/platform/default/mbgl/storage/offline_database.cpp
+++ b/platform/default/mbgl/storage/offline_database.cpp
@@ -658,7 +658,7 @@ void OfflineDatabase::putRegionResources(int64_t regionID, const std::list<std::
status.completedTileCount += 1;
status.completedTileSize += resourceSize;
}
- } catch (MapboxTileLimitExceededException) {
+ } catch (const MapboxTileLimitExceededException&) {
// Commit the rest of the batch and retrow
transaction.commit();
throw;
diff --git a/platform/default/mbgl/storage/offline_download.cpp b/platform/default/mbgl/storage/offline_download.cpp
index 1bd29f031c..4da51db655 100644
--- a/platform/default/mbgl/storage/offline_download.cpp
+++ b/platform/default/mbgl/storage/offline_download.cpp
@@ -355,7 +355,7 @@ void OfflineDownload::ensureResource(const Resource& resource,
if (buffer.size() == 64 || resourcesRemaining.size() == 0) {
try {
offlineDatabase.putRegionResources(id, buffer, status);
- } catch (MapboxTileLimitExceededException) {
+ } catch (const MapboxTileLimitExceededException&) {
onMapboxTileCountLimitExceeded();
return;
}
diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp
index c4e0ecf692..8915f1d7f1 100644
--- a/platform/glfw/main.cpp
+++ b/platform/glfw/main.cpp
@@ -51,14 +51,14 @@ int main(int argc, char *argv[]) {
try {
argumentParser.ParseCLI(argc, argv);
- } catch (args::Help) {
+ } catch (const args::Help&) {
std::cout << argumentParser;
exit(0);
- } catch (args::ParseError e) {
+ } catch (const args::ParseError& e) {
std::cerr << e.what() << std::endl;
std::cerr << argumentParser;
exit(1);
- } catch (args::ValidationError e) {
+ } catch (const args::ValidationError& e) {
std::cerr << e.what() << std::endl;
std::cerr << argumentParser;
exit(2);
diff --git a/src/mbgl/style/expression/coercion.cpp b/src/mbgl/style/expression/coercion.cpp
index d9cd3ffdc9..0166d144e0 100644
--- a/src/mbgl/style/expression/coercion.cpp
+++ b/src/mbgl/style/expression/coercion.cpp
@@ -13,7 +13,7 @@ EvaluationResult toNumber(const Value& v) {
[](const std::string& s) -> optional<double> {
try {
return util::stof(s);
- } catch(std::exception) {
+ } catch (const std::exception&) {
return optional<double>();
}
},
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index 36b71bc4b4..10343ec305 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -631,7 +631,7 @@ TEST(OfflineDatabase, BatchInsertionMapboxTileCountExceeded) {
try {
db.putRegionResources(region.getID(), resources, status);
EXPECT_FALSE(true);
- } catch (MapboxTileLimitExceededException) {
+ } catch (const MapboxTileLimitExceededException&) {
// Expected
}
diff --git a/test/style/style.test.cpp b/test/style/style.test.cpp
index 9bdab37ac6..f2055c88f8 100644
--- a/test/style/style.test.cpp
+++ b/test/style/style.test.cpp
@@ -65,7 +65,7 @@ TEST(Style, DuplicateSource) {
try {
style.addSource(std::make_unique<VectorSource>("sourceId", "mapbox://mapbox.mapbox-terrain-v2"));
FAIL() << "Should not have been allowed to add a duplicate source id";
- } catch (std::runtime_error) {
+ } catch (const std::runtime_error&) {
// Expected
}
}
diff --git a/test/style/style_layer.test.cpp b/test/style/style_layer.test.cpp
index 624ed088c3..61516a2de9 100644
--- a/test/style/style_layer.test.cpp
+++ b/test/style/style_layer.test.cpp
@@ -285,7 +285,7 @@ TEST(Layer, DuplicateLayer) {
try {
style.addLayer(std::make_unique<LineLayer>("line", "unusedsource"));
FAIL() << "Should not have been allowed to add a duplicate layer id";
- } catch (const std::runtime_error e) {
+ } catch (const std::runtime_error& e) {
// Expected
ASSERT_STREQ("Layer line already exists", e.what());
}