Skip to content

Commit

Permalink
Issue#655 support for building with Clang (vesoft-inc#700)
Browse files Browse the repository at this point in the history
* Issue#655 support for building with Clang

Compiled by clang 7.0.1((Fedora 7.0.1-6.fc29)

* Modified some of the code according to sherman's comments.
  • Loading branch information
monadbobo authored and dutor committed Aug 20, 2019
1 parent 545b868 commit 58cacc9
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 39 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,18 @@ add_compile_options(-Werror)
add_compile_options(-Wunused-parameter)
add_compile_options(-Wshadow)

# This requries GCC 5.1+
add_compile_options(-Wsuggest-override)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# This requries GCC 5.1+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.1)
add_compile_options(-Wsuggest-override)
endif()
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wno-overloaded-virtual)
add_compile_options(-Wno-self-assign-overloaded)
add_compile_options(-Wno-self-move)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -latomic")
endif()


if(ENABLE_ASAN)
add_definitions(-DBUILT_WITH_SANITIZER)
Expand Down
1 change: 0 additions & 1 deletion src/common/base/test/EitherOrTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,3 @@ TEST(EitherOr, Destruct) {
}

} // namespace nebula

1 change: 0 additions & 1 deletion src/console/CliManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace graph {
const int32_t kMaxAuthInfoRetries = 3;
const int32_t kMaxUsernameLen = 16;
const int32_t kMaxPasswordLen = 24;
const int32_t kMaxCommandLineLen = 1024;

CliManager::CliManager() {
curSpaceName_ = std::string("(none)");
Expand Down
3 changes: 1 addition & 2 deletions src/dataman/RowUpdater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ ResultType RowUpdater::setString(const folly::StringPiece name,
switch (type.get_type()) {
case cpp2::SupportedType::STRING:
hash = SpookyHashV2::Hash64(name.begin(), name.size(), 0);
updatedFields_[hash] = std::move(v.toString());
updatedFields_[hash] = v.toString();
break;
default:
return ResultType::E_INCOMPATIBLE_TYPE;
Expand Down Expand Up @@ -317,4 +317,3 @@ ResultType RowUpdater::getTimestamp(const folly::StringPiece name,
#undef CHECK_UPDATED_FIELDS

} // namespace nebula

3 changes: 1 addition & 2 deletions src/dataman/RowWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void RowWriter::encodeTo(std::string& encoded) noexcept {

Schema RowWriter::moveSchema() {
if (schemaWriter_) {
return std::move(schemaWriter_->moveSchema());
return schemaWriter_->moveSchema();
} else {
return Schema();
}
Expand Down Expand Up @@ -263,4 +263,3 @@ RowWriter& RowWriter::operator<<(Skip&& skip) noexcept {
}

} // namespace nebula

4 changes: 2 additions & 2 deletions src/graph/GoExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ StatusOr<std::vector<storage::cpp2::PropDef>> GoExecutor::getStepOutProps() {
for (auto &tagIt : tagProps) {
auto status = ectx()->schemaManager()->toTagID(spaceId, tagIt.first);
if (!status.ok()) {
return Status::Error("No schema found for '%s'", tagIt.first);
return Status::Error("No schema found for '%s'", tagIt.first.c_str());
}
auto tagId = status.value();
for (auto &prop : tagIt.second) {
Expand Down Expand Up @@ -511,7 +511,7 @@ StatusOr<std::vector<storage::cpp2::PropDef>> GoExecutor::getDstProps() {
for (auto &tagIt : tagProps) {
auto status = ectx()->schemaManager()->toTagID(spaceId, tagIt.first);
if (!status.ok()) {
return Status::Error("No schema found for '%s'", tagIt.first);
return Status::Error("No schema found for '%s'", tagIt.first.c_str());
}
auto tagId = status.value();
for (auto &prop : tagIt.second) {
Expand Down
1 change: 0 additions & 1 deletion src/graph/ShowExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class ShowExecutor final : public Executor {
private:
ShowSentence *sentence_{nullptr};
std::unique_ptr<cpp2::ExecutionResponse> resp_;
ConfigRowItem *configItem_{nullptr};
};

} // namespace graph
Expand Down
5 changes: 4 additions & 1 deletion src/interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
add_compile_options(-Wno-maybe-uninitialized)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-Wno-maybe-uninitialized)
endif()

set(THRIFT1 ${Fbthrift_BIN})
set(THRIFT_TEMPLATES ${Fbthrift_INCLUDE_DIR}/thrift/templates)
Expand Down
4 changes: 1 addition & 3 deletions src/kvstore/raftex/test/LogAppendTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TEST(LogAppend, MultiThreadAppend) {
FLAGS_max_batch_size = numThreads * numLogs + 1;
std::vector<std::thread> threads;
for (int i = 0; i < numThreads; ++i) {
threads.emplace_back(std::thread([i, numLogs, leader] {
threads.emplace_back(std::thread([i, leader] {
for (int j = 1; j <= numLogs; ++j) {
do {
auto fut = leader->appendAsync(
Expand Down Expand Up @@ -151,5 +151,3 @@ int main(int argc, char** argv) {

return RUN_ALL_TESTS();
}


8 changes: 4 additions & 4 deletions src/meta/client/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ MetaClient::regConfig(const std::vector<cpp2::ConfigItem>& items) {
req.set_items(items);
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_regConfig(request);
}, [this] (cpp2::ExecResp&& resp) -> decltype(auto) {
}, [] (cpp2::ExecResp&& resp) -> decltype(auto) {
return resp.code == cpp2::ErrorCode::SUCCEEDED;
}, true);
}
Expand All @@ -1063,7 +1063,7 @@ MetaClient::getConfig(const cpp2::ConfigModule& module, const std::string& name)
req.set_item(item);
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_getConfig(request);
}, [this] (cpp2::GetConfigResp&& resp) -> decltype(auto) {
}, [] (cpp2::GetConfigResp&& resp) -> decltype(auto) {
return std::move(resp).get_items();
});
}
Expand All @@ -1082,7 +1082,7 @@ MetaClient::setConfig(const cpp2::ConfigModule& module, const std::string& name,
req.set_item(item);
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_setConfig(request);
}, [this] (cpp2::ExecResp&& resp) -> decltype(auto) {
}, [] (cpp2::ExecResp&& resp) -> decltype(auto) {
return resp.code == cpp2::ErrorCode::SUCCEEDED;
}, true);
}
Expand All @@ -1093,7 +1093,7 @@ MetaClient::listConfigs(const cpp2::ConfigModule& module) {
req.set_module(module);
return getResponse(std::move(req), [] (auto client, auto request) {
return client->future_listConfigs(request);
}, [this] (cpp2::ListConfigsResp&& resp) -> decltype(auto) {
}, [] (cpp2::ListConfigsResp&& resp) -> decltype(auto) {
return std::move(resp).get_items();
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/meta/processors/BaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ int32_t BaseProcessor<RESP>::autoIncrementId() {
kvstore_->asyncMultiPut(kDefaultSpaceId,
kDefaultPartId,
std::move(data),
[this] (kvstore::ResultCode code) {
[] (kvstore::ResultCode code) {
CHECK_EQ(code, kvstore::ResultCode::SUCCEEDED);
});
return id;
Expand Down
12 changes: 5 additions & 7 deletions src/meta/processors/admin/AdminClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ folly::Future<Status> AdminClient::transLeader(GraphSpaceID spaceId,
req.set_new_leader(to(dst));
return getResponse(leader, std::move(req), [] (auto client, auto request) {
return client->future_transLeader(request);
}, [this] (auto&& resp) -> Status {
}, [] (auto&& resp) -> Status {
switch (resp.get_code()) {
case storage::cpp2::ErrorCode::SUCCEEDED:
case storage::cpp2::ErrorCode::E_LEADER_CHANGED: {
Expand All @@ -52,7 +52,7 @@ folly::Future<Status> AdminClient::addPart(GraphSpaceID spaceId,
req.set_as_learner(asLearner);
return getResponse(host, std::move(req), [] (auto client, auto request) {
return client->future_addPart(request);
}, [this] (auto&& resp) -> Status {
}, [] (auto&& resp) -> Status {
if (resp.get_code() == storage::cpp2::ErrorCode::SUCCEEDED) {
return Status::OK();
} else {
Expand Down Expand Up @@ -150,7 +150,7 @@ folly::Future<Status> AdminClient::updateMeta(GraphSpaceID spaceId,
kv_->asyncMultiPut(kDefaultSpaceId,
kDefaultPartId,
std::move(data),
[this, p = std::move(pro)] (kvstore::ResultCode code) mutable {
[p = std::move(pro)] (kvstore::ResultCode code) mutable {
if (code == kvstore::ResultCode::SUCCEEDED) {
p.setValue(Status::OK());
} else {
Expand All @@ -171,7 +171,7 @@ folly::Future<Status> AdminClient::removePart(GraphSpaceID spaceId,
req.set_part_id(partId);
return getResponse(host, std::move(req), [] (auto client, auto request) {
return client->future_removePart(request);
}, [this] (auto&& resp) -> Status {
}, [] (auto&& resp) -> Status {
if (resp.get_code() == storage::cpp2::ErrorCode::SUCCEEDED) {
return Status::OK();
} else {
Expand All @@ -195,8 +195,7 @@ folly::Future<Status> AdminClient::getResponse(
auto client = clientsMan_->client(host, evb);
remoteFunc(client, std::move(req))
.then(evb, [p = std::move(pro),
respGen,
this] (folly::Try<storage::cpp2::AdminExecResp>&& t) mutable {
respGen] (folly::Try<storage::cpp2::AdminExecResp>&& t) mutable {
// exception occurred during RPC
if (t.hasException()) {
p.setValue(Status::Error(folly::stringPrintf("RPC failure in MetaClient: %s",
Expand Down Expand Up @@ -337,4 +336,3 @@ StatusOr<std::vector<HostAddr>> AdminClient::getPeers(GraphSpaceID spaceId, Part

} // namespace meta
} // namespace nebula

3 changes: 1 addition & 2 deletions src/meta/processors/admin/BalancePlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool BalancePlan::saveInStore(bool onlyPlan) {
kv_->asyncMultiPut(kDefaultSpaceId,
kDefaultPartId,
std::move(data),
[this, &baton, &ret] (kvstore::ResultCode code) {
[&baton, &ret] (kvstore::ResultCode code) {
if (kvstore::ResultCode::SUCCEEDED == code) {
ret = true;
} else {
Expand Down Expand Up @@ -195,4 +195,3 @@ BalancePlan::Status BalancePlan::status(const folly::StringPiece& rawVal) {

} // namespace meta
} // namespace nebula

4 changes: 1 addition & 3 deletions src/meta/test/AdminClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ TEST(AdminClientTest, RetryTest) {
kv->asyncMultiPut(kDefaultSpaceId,
kDefaultPartId,
std::move(data),
[this, &baton] (kvstore::ResultCode code) {
[&baton] (kvstore::ResultCode code) {
CHECK_EQ(kvstore::ResultCode::SUCCEEDED, code);
baton.post();
});
Expand Down Expand Up @@ -259,5 +259,3 @@ int main(int argc, char** argv) {
google::SetStderrLogging(google::INFO);
return RUN_ALL_TESTS();
}


1 change: 0 additions & 1 deletion src/meta/test/MetaHttpDownloadHandlerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,3 @@ int main(int argc, char** argv) {

return RUN_ALL_TESTS();
}

3 changes: 1 addition & 2 deletions src/parser/TraverseSentences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,7 @@ StatusOr<std::string> EdgeKeyRef::varname() const {
}

if (uniqVar_.size() != 1) {
return Status::SyntaxError(
"Near %s, Only support single data source.", toString());
return Status::SyntaxError("Near %s, Only support single data source.", toString().c_str());
}

for (auto &var : uniqVar_) {
Expand Down
4 changes: 2 additions & 2 deletions src/storage/QueryBaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ kvstore::ResultCode QueryBaseProcessor<REQ, RESP>::collectEdgeProps(
getters.getEdgeRank = [&] () -> VariantType {
return rank;
};
getters.getSrcTagProp = [&, this] (const std::string& tag,
const std::string& prop) -> OptVariantType {
getters.getSrcTagProp = [&fcontext] (const std::string& tag,
const std::string& prop) -> OptVariantType {
auto it = fcontext->tagFilters_.find(std::make_pair(tag, prop));
if (it == fcontext->tagFilters_.end()) {
return Status::Error("Invalid Tag Filter");
Expand Down
3 changes: 1 addition & 2 deletions src/storage/client/StorageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class StorageClient {
public:
StorageClient(std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool,
meta::MetaClient *client);
~StorageClient();
virtual ~StorageClient();

folly::SemiFuture<StorageRpcResponse<storage::cpp2::ExecResponse>> addVertices(
GraphSpaceID space,
Expand Down Expand Up @@ -220,4 +220,3 @@ class StorageClient {
#include "storage/client/StorageClient.inl"

#endif // STORAGE_CLIENT_STORAGECLIENT_H_

0 comments on commit 58cacc9

Please sign in to comment.