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:
@@ -212,7 +212,7 @@ class BinaryHeap
|
||||
void DeleteAll()
|
||||
{
|
||||
auto iend = heap.end();
|
||||
for (typename std::vector<HeapElement>::iterator i = heap.begin() + 1; i != iend; ++i)
|
||||
for (auto i = heap.begin() + 1; i != iend; ++i)
|
||||
{
|
||||
inserted_nodes[i->index].key = 0;
|
||||
}
|
||||
@@ -237,7 +237,9 @@ class BinaryHeap
|
||||
class HeapNode
|
||||
{
|
||||
public:
|
||||
HeapNode(NodeID n, Key k, Weight w, Data d) : node(n), key(k), weight(w), data(d) {}
|
||||
HeapNode(NodeID n, Key k, Weight w, Data d) : node(n), key(k), weight(w), data(std::move(d))
|
||||
{
|
||||
}
|
||||
|
||||
NodeID node;
|
||||
Key key;
|
||||
|
||||
@@ -58,7 +58,7 @@ struct QueryEdge
|
||||
QueryEdge() : source(SPECIAL_NODEID), target(SPECIAL_NODEID) {}
|
||||
|
||||
QueryEdge(NodeID source, NodeID target, EdgeData data)
|
||||
: source(source), target(target), data(data)
|
||||
: source(source), target(target), data(std::move(data))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../typedefs.h"
|
||||
|
||||
#include <osrm/coordinate.hpp>
|
||||
#include <utility>
|
||||
|
||||
// Struct fits everything in one cache line
|
||||
struct SegmentInformation
|
||||
@@ -48,7 +49,7 @@ struct SegmentInformation
|
||||
bool necessary;
|
||||
bool is_via_location;
|
||||
|
||||
explicit SegmentInformation(const FixedPointCoordinate &location,
|
||||
explicit SegmentInformation(FixedPointCoordinate location,
|
||||
const NodeID name_id,
|
||||
const EdgeWeight duration,
|
||||
const float length,
|
||||
@@ -56,20 +57,20 @@ struct SegmentInformation
|
||||
const bool necessary,
|
||||
const bool is_via_location,
|
||||
const TravelMode travel_mode)
|
||||
: location(location), name_id(name_id), duration(duration), length(length), bearing(0),
|
||||
turn_instruction(turn_instruction), travel_mode(travel_mode), necessary(necessary),
|
||||
is_via_location(is_via_location)
|
||||
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
||||
bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode),
|
||||
necessary(necessary), is_via_location(is_via_location)
|
||||
{
|
||||
}
|
||||
|
||||
explicit SegmentInformation(const FixedPointCoordinate &location,
|
||||
explicit SegmentInformation(FixedPointCoordinate location,
|
||||
const NodeID name_id,
|
||||
const EdgeWeight duration,
|
||||
const float length,
|
||||
const TurnInstruction turn_instruction,
|
||||
const TravelMode travel_mode)
|
||||
: location(location), name_id(name_id), duration(duration), length(length), bearing(0),
|
||||
turn_instruction(turn_instruction), travel_mode(travel_mode),
|
||||
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
||||
bearing(0), turn_instruction(turn_instruction), travel_mode(travel_mode),
|
||||
necessary(turn_instruction != TurnInstruction::NoTurn), is_via_location(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class SharedMemory
|
||||
shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_or_create, key,
|
||||
size);
|
||||
#ifdef __linux__
|
||||
if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, 0))
|
||||
if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, nullptr))
|
||||
{
|
||||
if (ENOMEM == errno)
|
||||
{
|
||||
|
||||
@@ -316,8 +316,8 @@ class StaticRTree
|
||||
using IncrementalQueryNodeType = mapbox::util::variant<TreeNode, EdgeDataT>;
|
||||
struct IncrementalQueryCandidate
|
||||
{
|
||||
explicit IncrementalQueryCandidate(const float dist, const IncrementalQueryNodeType &node)
|
||||
: min_dist(dist), node(node)
|
||||
explicit IncrementalQueryCandidate(const float dist, IncrementalQueryNodeType node)
|
||||
: min_dist(dist), node(std::move(node))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ class StaticRTree
|
||||
const boost::filesystem::path &leaf_file,
|
||||
std::shared_ptr<CoordinateListT> coordinate_list)
|
||||
: m_search_tree(tree_node_ptr, number_of_nodes), m_leaf_node_filename(leaf_file.string()),
|
||||
m_coordinate_list(coordinate_list)
|
||||
m_coordinate_list(std::move(coordinate_list))
|
||||
{
|
||||
// open leaf node file and store thread specific pointer
|
||||
if (!boost::filesystem::exists(leaf_file))
|
||||
|
||||
Reference in New Issue
Block a user