Skip to content
This repository has been archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Enable missing-prototypes compiler warning
Browse files Browse the repository at this point in the history
Enable Clang's and GCC's -Wmissing-prototypes diagnostic and
fix issues it catches. This unconcovered some dead code, so
delete the dead code.
  • Loading branch information
Matthew Glazar committed Jul 15, 2017
1 parent 32b9fbe commit c58a92a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 159 deletions.
4 changes: 4 additions & 0 deletions Libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
# of patent rights can be found in the PATENTS file in the same directory.
#

if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-Wmissing-prototypes)
endif ()

set(OLD_DEFAULT_COMPONENT ${CMAKE_INSTALL_DEFAULT_COMPONENT_NAME})
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME libraries)

Expand Down
2 changes: 1 addition & 1 deletion Libraries/libbom/Sources/bom.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct bom_context {
unsigned int iteration_count;
};

struct bom_context *
static struct bom_context *
_bom_alloc(struct bom_context_memory memory)
{
struct bom_context *context = malloc(sizeof(*context));
Expand Down
160 changes: 2 additions & 158 deletions Libraries/pbxproj/Tools/dump_xcodeproj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,164 +28,7 @@
using namespace pbxproj;
using namespace libutil;

void
DumpGroup(PBX::BaseGroup const *group, size_t indent = 0)
{
bool IsVariant = group->type() == PBX::GroupItem::Type::VariantGroup;
printf("%*s%c%s%c\n", (int)(indent * 2), "",
IsVariant ? '{' : '[',
group->name().c_str(),
IsVariant ? '}' : ']');
indent++;
for (auto child : group->children()) {
if (child->type() == PBX::GroupItem::Type::FileReference) {
printf("%*s%s [%s]\n", (int)(indent * 2), "",
child->name().c_str(),
child->path().c_str());
} else if (child->type() == PBX::GroupItem::Type::ReferenceProxy) {
printf("%*s%s [proxy]\n", (int)(indent * 2), "",
child->name().c_str());
} else {
DumpGroup(static_cast <PBX::BaseGroup const *> (child.get()), indent);
}
}
indent--;
}

std::unique_ptr<plist::Dictionary>
GenerateConfigurationSettings(Filesystem const *filesystem,
PBX::Project::shared_ptr const &project,
XC::BuildConfiguration const &BC,
bool isProjectBC = false)
{
std::unique_ptr<plist::Dictionary> settings = nullptr;

if (!isProjectBC) {
for (auto const &PBC : project->buildConfigurationList()->buildConfigurations()) {
if (BC.name() == PBC->name()) {
settings = GenerateConfigurationSettings(filesystem, project, *PBC, true);
break;
}
}
}

if (settings == nullptr) {
settings = plist::Dictionary::New();
}

for (pbxsetting::Setting const &setting : BC.buildSettings().settings()) {
std::string key = setting.name().c_str();
std::string value = setting.value().raw().c_str();
settings->set(key, plist::String::New(value));
}

if (auto baseConfigurationReference = BC.baseConfigurationReference()) {
auto environment = pbxsetting::Environment();
auto config = pbxsetting::XC::Config::Load(filesystem, environment, environment.expand(baseConfigurationReference->resolve()));
if (config) {
pbxsetting::Level level = config->level();
for (pbxsetting::Setting const &setting : level.settings()) {
std::string key = setting.name().c_str();
std::string value = setting.value().raw().c_str();
settings->set(key, plist::String::New(value));
}
}
}

if (settings->empty()) {
settings = nullptr;
}

return settings;
}

void
GetSourceFileReferences(PBX::Project::shared_ptr const &project,
std::string const &target, PBX::FileReference::vector &refs)
{
for (auto const &I : project->targets()) {
if (I->name() != target)
continue;

for (auto const &J : I->buildPhases()) {
switch (J->type()) {
case PBX::BuildPhase::Type::Sources:
{
auto BP = static_cast <PBX::SourcesBuildPhase *> (J.get());
if (BP) {
for (auto const &K : BP->files()) {
if (auto const &FR = K->fileRef()) {
if (FR->type() == PBX::GroupItem::Type::FileReference) {
refs.push_back(std::static_pointer_cast <PBX::FileReference> (FR));
}
}
}
}
}
break;
default:
break;
}
}
break;
}
}

void
GetSourceFilePaths(PBX::Project::shared_ptr const &project,
std::string const &target, std::set<std::string> &paths)
{
PBX::FileReference::vector refs;
GetSourceFileReferences(project, target, refs);

for (auto const &ref : refs) {
paths.insert(project->basePath() + "/" + ref->path());
}
}

void
GetHeaderFileReferences(PBX::Project::shared_ptr const &project,
std::string const &target, PBX::FileReference::vector &refs)
{
for (auto const &I : project->targets()) {
if (I->name() != target)
continue;

for (auto const &J : I->buildPhases()) {
switch (J->type()) {
case PBX::BuildPhase::Type::Headers:
{
auto BP = static_cast <PBX::HeadersBuildPhase *> (J.get());
if (BP) {
for (auto const &K : BP->files()) {
if (auto const &FR = K->fileRef()) {
if (FR->type() == PBX::GroupItem::Type::FileReference) {
refs.push_back(std::static_pointer_cast <PBX::FileReference> (FR));
}
}
}
}
}
break;
default:
break;
}
}
}
}

void
GetHeaderFilePaths(PBX::Project::shared_ptr const &project,
std::string const &target, std::set<std::string> &paths)
{
PBX::FileReference::vector refs;
GetHeaderFileReferences(project, target, refs);

for (auto const &ref : refs) {
paths.insert(project->basePath() + "/" + ref->path());
}
}

namespace {
void
CompleteDump(process::User const *user, Filesystem const *filesystem, PBX::Project::shared_ptr const &project)
{
Expand Down Expand Up @@ -396,6 +239,7 @@ CompleteDump(process::User const *user, Filesystem const *filesystem, PBX::Proje
}
}
}
}


int
Expand Down
3 changes: 3 additions & 0 deletions Libraries/plist/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ else ()
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
target_compile_definitions(linenoise PRIVATE _GNU_SOURCE)
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
target_compile_options(linenoise PRIVATE -Wno-missing-prototypes)
endif ()

target_link_libraries(PlistBuddy PRIVATE linenoise)
target_compile_definitions(PlistBuddy PRIVATE HAVE_LINENOISE)
Expand Down
2 changes: 2 additions & 0 deletions Libraries/xcworkspace/Tools/dump_xcworkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using namespace pbxproj;
using namespace libutil;

namespace {
void DumpItem(xcworkspace::XC::Workspace::shared_ptr const &W, xcworkspace::XC::GroupItem const *item, size_t indent);
void DumpItems(xcworkspace::XC::Workspace::shared_ptr const &W, xcworkspace::XC::GroupItem::vector const &items, size_t indent);

Expand Down Expand Up @@ -151,6 +152,7 @@ ForEachFileRef(xcworkspace::XC::Workspace::shared_ptr const &W,
{
ForEachItems(W, nullptr, W->items(), cb);
}
}

int
main(int argc, char **argv)
Expand Down

0 comments on commit c58a92a

Please sign in to comment.