Skip to content

Commit c938c92

Browse files
committed
Fix /W4 warnings for MSVC
1 parent 6e83d67 commit c938c92

File tree

9 files changed

+24
-26
lines changed

9 files changed

+24
-26
lines changed

samples/today/sample.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,21 @@ int main(int argc, char** argv)
6161

6262
try
6363
{
64-
peg::ast query;
64+
peg::ast ast;
6565

6666
if (argc > 1)
6767
{
68-
query = peg::parseFile(argv[1]);
68+
ast = peg::parseFile(argv[1]);
6969
}
7070
else
7171
{
7272
std::istream_iterator<char> start { std::cin >> std::noskipws }, end {};
7373
std::string input { start, end };
7474

75-
query = peg::parseString(std::move(input));
75+
ast = peg::parseString(std::move(input));
7676
}
7777

78-
if (!query.root)
78+
if (!ast.root)
7979
{
8080
std::cerr << "Unknown error!" << std::endl;
8181
std::cerr << std::endl;
@@ -85,7 +85,7 @@ int main(int argc, char** argv)
8585
std::cout << "Executing query..." << std::endl;
8686

8787
std::cout << response::toJSON(
88-
service->resolve({ query, ((argc > 2) ? argv[2] : "") }).get())
88+
service->resolve({ ast, ((argc > 2) ? argv[2] : "") }).get())
8989
<< std::endl;
9090
}
9191
catch (const std::runtime_error& ex)

src/ClientGenerator.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,6 @@ using namespace )cpp"
485485
{
486486
pendingSeparator.reset();
487487

488-
const auto& enumValues = enumType->enumValues();
489488
const auto cppType = _schemaLoader.getCppType(enumType->name());
490489

491490
if (!variables.empty())

src/GeneratorUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ IncludeGuardScope::IncludeGuardScope(
2121
return '_';
2222
}
2323

24-
return std::toupper(ch);
24+
return static_cast<char>(std::toupper(ch));
2525
});
2626

2727
_outputFile << R"cpp(// Copyright (c) Microsoft Corporation. All rights reserved.

src/GraphQLResponse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ Value::Value(const Value& other)
496496
std::transform(members.cbegin(),
497497
members.cend(),
498498
std::back_inserter(copy.members),
499-
[&copy](const auto& entry) noexcept {
499+
[](const auto& entry) noexcept {
500500
return entry.second;
501501
});
502502

src/GraphQLService.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ std::pair<std::string_view, const peg::ast_node*> Request::findOperationDefiniti
16311631
std::pair<std::string_view, const peg::ast_node*> result = { {}, nullptr };
16321632

16331633
peg::on_first_child_if<peg::operation_definition>(*query.root,
1634-
[this, &operationName, &result](const peg::ast_node& operationDefinition) noexcept -> bool {
1634+
[&operationName, &result](const peg::ast_node& operationDefinition) noexcept -> bool {
16351635
std::string_view operationType = strQuery;
16361636

16371637
peg::on_first_child<peg::operation_type>(operationDefinition,
@@ -1706,7 +1706,7 @@ response::AwaitableValue Request::resolve(RequestResolveParams params) const
17061706
const auto resolverContext =
17071707
isMutation ? ResolverContext::Mutation : ResolverContext::Query;
17081708
// https://spec.graphql.org/October2021/#sec-Normal-and-Serial-Execution
1709-
const auto operationLaunch = isMutation ? await_async {} : params.launch;
1709+
auto operationLaunch = isMutation ? await_async {} : params.launch;
17101710

17111711
OperationDefinitionVisitor operationVisitor(resolverContext,
17121712
std::move(operationLaunch),

src/RequestLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ void RequestLoader::addTypesToSchema()
473473
std::transform(objectType.interfaces.cbegin(),
474474
objectType.interfaces.cend(),
475475
interfaces.begin(),
476-
[this, &interfaceTypes](std::string_view interfaceName) noexcept {
476+
[&interfaceTypes](std::string_view interfaceName) noexcept {
477477
return interfaceTypes[interfaceName];
478478
});
479479

src/SchemaLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ void SchemaLoader::visitDirectiveDefinition(const peg::ast_node& directiveDefini
10971097
});
10981098

10991099
peg::on_first_child<peg::repeatable_keyword>(directiveDefinition,
1100-
[&directive](const peg::ast_node& child) {
1100+
[&directive](const peg::ast_node& /* child */) {
11011101
directive.isRepeatable = true;
11021102
});
11031103

src/Validation.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,12 @@ void ValidateArgumentValueVisitor::visitObjectValue(const peg::ast_node& objectV
244244
if (value.values.find(name) != value.values.end())
245245
{
246246
// https://spec.graphql.org/October2021/#sec-Input-Object-Field-Uniqueness
247-
auto position = field->begin();
247+
auto fieldPosition = field->begin();
248248
std::ostringstream message;
249249

250250
message << "Conflicting input field name: " << name;
251251

252-
_errors.push_back({ message.str(), { position.line, position.column } });
252+
_errors.push_back({ message.str(), { fieldPosition.line, fieldPosition.column } });
253253
continue;
254254
}
255255

@@ -567,7 +567,6 @@ void ValidateExecutableVisitor::visit(const peg::ast_node& root)
567567
if (!_fragmentDefinitions.empty())
568568
{
569569
// https://spec.graphql.org/October2021/#sec-Fragments-Must-Be-Used
570-
const size_t originalSize = _errors.size();
571570
auto unreferencedFragments = std::move(_fragmentDefinitions);
572571

573572
for (const auto& name : _referencedFragments)
@@ -920,7 +919,7 @@ bool ValidateExecutableVisitor::matchesScopedType(std::string_view name) const
920919
{
921920
const auto itrMatch = std::find_if(itrScoped->second.begin(),
922921
itrScoped->second.end(),
923-
[this, itrNamed](std::string_view matchingType) noexcept {
922+
[itrNamed](std::string_view matchingType) noexcept {
924923
return itrNamed->second.find(matchingType) != itrNamed->second.end();
925924
});
926925

test/TodayTests.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ TEST_F(TodayServiceCase, SubscribeNextAppointmentChangeOverride)
661661
response::Value variables(response::Type::Map);
662662
auto state = std::make_shared<today::RequestState>(7);
663663
auto subscriptionObject = std::make_shared<today::NextAppointmentChange>(
664-
[this](const std::shared_ptr<service::RequestState>& state)
664+
[](const std::shared_ptr<service::RequestState>& state)
665665
-> std::shared_ptr<today::Appointment> {
666666
EXPECT_EQ(7, std::static_pointer_cast<today::RequestState>(state)->requestId)
667667
<< "should pass the RequestState to the subscription resolvers";
@@ -1248,7 +1248,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingId)
12481248
response::Value variables(response::Type::Map);
12491249
auto state = std::make_shared<today::RequestState>(13);
12501250
auto subscriptionObject = std::make_shared<today::NodeChange>(
1251-
[this](const std::shared_ptr<service::RequestState>& state,
1251+
[](const std::shared_ptr<service::RequestState>& state,
12521252
response::IdType&& idArg) -> std::shared_ptr<today::object::Node> {
12531253
EXPECT_EQ(13, std::static_pointer_cast<today::RequestState>(state)->requestId)
12541254
<< "should pass the RequestState to the subscription resolvers";
@@ -1316,8 +1316,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMismatchedId)
13161316
response::Value variables(response::Type::Map);
13171317
bool calledResolver = false;
13181318
auto subscriptionObject = std::make_shared<today::NodeChange>(
1319-
[this, &calledResolver](const std::shared_ptr<service::RequestState>& state,
1320-
response::IdType&& idArg) -> std::shared_ptr<today::object::Node> {
1319+
[&calledResolver](const std::shared_ptr<service::RequestState>& /* state */,
1320+
response::IdType&& /* idArg */) -> std::shared_ptr<today::object::Node> {
13211321
calledResolver = true;
13221322
return nullptr;
13231323
});
@@ -1373,7 +1373,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyComparator)
13731373
return true;
13741374
};
13751375
auto subscriptionObject = std::make_shared<today::NodeChange>(
1376-
[this](const std::shared_ptr<service::RequestState>& state,
1376+
[](const std::shared_ptr<service::RequestState>& state,
13771377
response::IdType&& idArg) -> std::shared_ptr<today::object::Node> {
13781378
const response::IdType fuzzyId { 'f', 'a', 'k' };
13791379

@@ -1453,8 +1453,8 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeFuzzyMismatch)
14531453
};
14541454
bool calledResolver = false;
14551455
auto subscriptionObject = std::make_shared<today::NodeChange>(
1456-
[this, &calledResolver](const std::shared_ptr<service::RequestState>& state,
1457-
response::IdType&& idArg) -> std::shared_ptr<today::object::Node> {
1456+
[&calledResolver](const std::shared_ptr<service::RequestState>& /* state */,
1457+
response::IdType&& /* idArg */) -> std::shared_ptr<today::object::Node> {
14581458
calledResolver = true;
14591459
return nullptr;
14601460
});
@@ -1503,7 +1503,7 @@ TEST_F(TodayServiceCase, SubscribeNodeChangeMatchingVariable)
15031503
variables.emplace_back("taskId", response::Value("ZmFrZVRhc2tJZA=="s));
15041504
auto state = std::make_shared<today::RequestState>(14);
15051505
auto subscriptionObject = std::make_shared<today::NodeChange>(
1506-
[this](const std::shared_ptr<service::RequestState>& state,
1506+
[](const std::shared_ptr<service::RequestState>& state,
15071507
response::IdType&& idArg) -> std::shared_ptr<today::object::Node> {
15081508
EXPECT_EQ(14, std::static_pointer_cast<today::RequestState>(state)->requestId)
15091509
<< "should pass the RequestState to the subscription resolvers";
@@ -1917,7 +1917,7 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsAsync)
19171917
today::NextAppointmentChange::getCount(service::ResolverContext::NotifyUnsubscribe);
19181918
auto key = _service
19191919
->subscribe({
1920-
[&calledCallback](response::Value&& response) {
1920+
[&calledCallback](response::Value&& /* response */) {
19211921
calledCallback = true;
19221922
},
19231923
std::move(query),
@@ -1970,7 +1970,7 @@ TEST_F(TodayServiceCase, SubscribeUnsubscribeNotificationsDeferred)
19701970
const auto notifyUnsubscribeBegin =
19711971
today::NextAppointmentChange::getCount(service::ResolverContext::NotifyUnsubscribe);
19721972
auto key = _service
1973-
->subscribe({ [&calledCallback](response::Value&& response) {
1973+
->subscribe({ [&calledCallback](response::Value&& /* response */) {
19741974
calledCallback = true;
19751975
},
19761976
std::move(query),

0 commit comments

Comments
 (0)