Modernize the code base to C++11 standards and beyond.

Apply `clang-modernize` (based on Clang 3.6) transformations to the
codebase while making sure to support Clang>=3.4 and GCC>=4.8.

We apply the transformations in parallel to speed up the quite
time consuming process, and use our `clang-format` style file
to automatically format the code respecting our coding conventions.

We use the following self-explanatory transformations:

* AddOverride
* LoopConvert
* PassByValue
* ReplaceAutoPtr
* UseAuto
* UseNullptr

This required a `compile_commands.json` compilation database, e.g.

    ccmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1

for CMake or check Bear for a Makefile based solution (or even Ninja).

    git ls-files -x '*.cpp|*.h' | \
      xargs -I{} -P $(nproc) clang-modernize -p build -final-syntax-check -format -style=file -summary -for-compilers=clang-3.4,gcc-4.8 -include . -exclude third_party {}

Boom!

References:

* http://clang.llvm.org/extra/clang-modernize.html
* http://clang.llvm.org/extra/ModernizerUsage.html
This commit is contained in:
Daniel J. Hofmann
2015-08-18 12:56:34 +02:00
parent 84e72ede72
commit 62b20769ee
24 changed files with 88 additions and 76 deletions
+1 -1
View File
@@ -50,7 +50,7 @@ struct String
{
String() {}
String(const char *value) : value(value) {}
String(const std::string &value) : value(value) {}
String(std::string value) : value(std::move(value)) {}
std::string value;
};
+5 -2
View File
@@ -39,8 +39,11 @@ struct libosrm_config
{
}
libosrm_config(const ServerPaths &paths, const bool sharedmemory_flag, const int max_table, const int max_matching)
: server_paths(paths), max_locations_distance_table(max_table),
libosrm_config(ServerPaths paths,
const bool sharedmemory_flag,
const int max_table,
const int max_matching)
: server_paths(std::move(paths)), max_locations_distance_table(max_table),
max_locations_map_matching(max_matching), use_shared_memory(sharedmemory_flag)
{
}