Permalink
Browse files

Sort headers according to IWYU conventions

A first step towards IWYU support.  Doing the sorting first because it
makes reviewing any additions or removals of headers much simpler.

The IWYU order is:
- Associated headers
- Misc system headers
- C++ STL headers
- Other project headers

The biggest change is moving system headers before project headers (they
are usually afterwards in Cata at the moment.

The associated header for a cpp file is the header file which declares
the functions defined in that cpp file.  Normally that's the one which
shares the same name (up to extension), and if so IWYU figures it out
automatically.

However, in this project there are many corner cases, so we need to use
IWYU pragma: associated to tell it which header (or, in some cases,
which headers) is the associated header.  We are unusual in having
multiple associated headers for some files, which might lead to
discovering some interesting IWYU bugs later, but in theory it is
supported.
  • Loading branch information...
jbytheway committed Jan 5, 2019
1 parent ebc77e3 commit b0576393e371e351f3e98e720319dc4ca742755b
Showing 386 changed files with 1,343 additions and 1,342 deletions.
@@ -1,5 +1,9 @@
#include "action.h"

#include <algorithm>
#include <istream>
#include <iterator>

#include "cata_utility.h"
#include "debug.h"
#include "game.h"
@@ -19,10 +23,6 @@
#include "vehicle.h"
#include "vpart_position.h"

#include <algorithm>
#include <istream>
#include <iterator>

extern bool tile_iso;

void parse_keymap( std::istream &keymap_txt, std::map<char, action_id> &kmap,
@@ -1,10 +1,10 @@
#include "active_item_cache.h"

#include <algorithm>

#include "debug.h"
#include "item.h"

#include <algorithm>

void active_item_cache::remove( std::list<item>::iterator it, point location )
{
const auto predicate = [&]( const item_reference & active_item ) {
@@ -2,11 +2,11 @@
#ifndef ACTIVE_ITEM_CACHE_H
#define ACTIVE_ITEM_CACHE_H

#include "enums.h"

#include <list>
#include <unordered_map>

#include "enums.h"

class item;

// A struct used to uniquely identify an item within a submap or vehicle.
@@ -1,5 +1,8 @@
#include "activity_handlers.h"

#include <algorithm>
#include <cmath>

#include "action.h"
#include "catalua.h"
#include "clzones.h"
@@ -36,9 +39,6 @@
#include "vpart_position.h"
#include "map_selector.h"

#include <algorithm>
#include <cmath>

#define dbg(x) DebugLog((DebugLevel)(x),D_GAME) << __FILE__ << ":" << __LINE__ << ": "

const skill_id skill_survival( "survival" );
@@ -2,13 +2,13 @@
#ifndef ACTIVITY_HANDLERS_H
#define ACTIVITY_HANDLERS_H

#include "player_activity.h"

#include <functional>
#include <map>
#include <unordered_set>
#include <vector>

#include "player_activity.h"

class player;

std::vector<tripoint> get_sorted_tiles_by_distance( const tripoint abspos,
@@ -1,4 +1,9 @@
#include "activity_handlers.h"
#include "activity_handlers.h" // IWYU pragma: associated

#include <algorithm>
#include <cassert>
#include <list>
#include <vector>

#include "action.h"
#include "clzones.h"
@@ -29,11 +34,6 @@
#include "vpart_position.h"
#include "vpart_reference.h"

#include <algorithm>
#include <cassert>
#include <list>
#include <vector>

void cancel_aim_processing();

const efftype_id effect_controlled( "controlled" );
@@ -1,14 +1,14 @@
#include "activity_type.h"

#include <map>
#include <unordered_map>

#include "activity_handlers.h"
#include "assign.h"
#include "debug.h"
#include "json.h"
#include "translations.h"

#include <map>
#include <unordered_map>

// activity_type functions
static std::map< activity_id, activity_type > activity_type_all;

@@ -2,17 +2,17 @@
#ifndef ADVANCED_INV_H
#define ADVANCED_INV_H

#include "cursesdef.h"
#include "enums.h"
#include "units.h"

#include <array>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <vector>

#include "cursesdef.h"
#include "enums.h"
#include "units.h"

class uilist;
class vehicle;
class item;
@@ -1,12 +1,12 @@
#include "ammo.h"

#include <unordered_map>

#include "debug.h"
#include "item.h"
#include "json.h"
#include "translations.h"

#include <unordered_map>

namespace
{
using ammo_map_t = std::unordered_map<ammotype, ammunition_type>;
@@ -1,16 +1,16 @@
#include "anatomy.h"

#include <array>
#include <cmath>
#include <numeric>

#include "cata_utility.h"
#include "generic_factory.h"
#include "messages.h"
#include "output.h"
#include "rng.h"
#include "weighted_list.h"

#include <array>
#include <cmath>
#include <numeric>

anatomy_id human_anatomy( "human_anatomy" );

namespace
@@ -2,11 +2,11 @@
#ifndef ANATOMY_H
#define ANATOMY_H

#include <vector>

#include "bodypart.h"
#include "string_id.h"

#include <vector>

class anatomy;
using anatomy_id = string_id<anatomy>;

@@ -11,10 +11,10 @@
#include "weather.h"

#ifdef TILES
#include "cata_tiles.h" // all animation functions will be pushed out to a cata_tiles function in some manner

#include <memory>

#include "cata_tiles.h" // all animation functions will be pushed out to a cata_tiles function in some manner

extern std::unique_ptr<cata_tiles> tilecontext; // obtained from sdltiles.cpp
#endif

@@ -1,3 +1,9 @@
#include "player.h" // IWYU pragma: associated

#include <algorithm>
#include <string>
#include <vector>

#include "cata_utility.h"
#include "catacharset.h" // used for utf8_width()
#include "game.h"
@@ -6,14 +12,9 @@
#include "item.h"
#include "line.h"
#include "output.h"
#include "player.h"
#include "string_formatter.h"
#include "translations.h"

#include <algorithm>
#include <string>
#include <vector>

namespace
{
std::string clothing_layer( const item &worn_item );
@@ -1,16 +1,16 @@
#include "artifact.h"

#include <array>
#include <cmath>
#include <sstream>

#include "cata_utility.h"
#include "item_factory.h"
#include "json.h"
#include "rng.h"
#include "string_formatter.h"
#include "translations.h"

#include <array>
#include <cmath>
#include <sstream>

template<typename V, typename B>
inline units::quantity<V, B> rng( const units::quantity<V, B> &min,
const units::quantity<V, B> &max )
@@ -2,11 +2,11 @@
#ifndef ARTIFACT_H
#define ARTIFACT_H

#include <string>

#include "enums.h"
#include "itype.h"

#include <string>

class JsonObject;
class JsonOut;

@@ -2,18 +2,18 @@
#ifndef ASSIGN_H
#define ASSIGN_H

#include "color.h"
#include "debug.h"
#include "json.h"
#include "units.h"

#include <algorithm>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <vector>

#include "color.h"
#include "debug.h"
#include "json.h"
#include "units.h"

namespace cata
{
template<typename T>
@@ -1,5 +1,8 @@
#include "auto_pickup.h"

#include <algorithm>
#include <sstream>

#include "cata_utility.h"
#include "debug.h"
#include "filesystem.h"
@@ -18,9 +21,6 @@
#include "string_input_popup.h"
#include "translations.h"

#include <algorithm>
#include <sstream>

auto_pickup &get_auto_pickup()
{
static auto_pickup single_instance;
@@ -2,15 +2,15 @@
#ifndef AUTO_PICKUP_H
#define AUTO_PICKUP_H

#include "enums.h"
#include "material.h"

#include <array>
#include <iosfwd>
#include <string>
#include <unordered_map>
#include <vector>

#include "enums.h"
#include "material.h"

class JsonOut;
class JsonIn;
class item;
@@ -1,5 +1,7 @@
#include "ballistics.h"

#include <algorithm>

#include "creature.h"
#include "dispersion.h"
#include "explosion.h"
@@ -18,8 +20,6 @@
#include "vehicle.h"
#include "vpart_position.h"

#include <algorithm>

const efftype_id effect_bounced( "bounced" );

static void drop_or_embed_projectile( const dealt_projectile_attack &attack )
@@ -1,5 +1,12 @@
#include "basecamp.h"

#include <algorithm>
#include <array>
#include <sstream>
#include <map>
#include <string>
#include <vector>

#include "output.h"
#include "string_formatter.h"
#include "translations.h"
@@ -17,16 +24,8 @@
#include "recipe_groups.h"
#include "requirements.h"
#include "skill.h"

#include "faction_camp.h"

#include <algorithm>
#include <array>
#include <sstream>
#include <map>
#include <string>
#include <vector>

static const std::string base_dir = "[B]";
static const std::string prefix = "faction_base_";
static const int prefix_len = 13;
@@ -2,13 +2,13 @@
#ifndef BASECAMP_H
#define BASECAMP_H

#include "enums.h"

#include <memory>
#include <vector>
#include <map>
#include <string>

#include "enums.h"

class JsonIn;
class JsonOut;
class npc;
Oops, something went wrong.

0 comments on commit b057639

Please sign in to comment.