From 539c7796060ff70ed54d23207d11c430c30e44f6 Mon Sep 17 00:00:00 2001 From: Jacob Dufault Date: Wed, 22 Mar 2017 10:16:09 -0700 Subject: [PATCH] fix some warnings --- indexer.cpp | 4 ++-- indexer.h | 20 +++++++++----------- src/message_queue.cc | 15 +++++++++------ src/message_queue.h | 4 ++-- wscript | 2 +- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/indexer.cpp b/indexer.cpp index 8e5a6f03..6414a3b0 100644 --- a/indexer.cpp +++ b/indexer.cpp @@ -77,7 +77,7 @@ std::string IndexedFile::ToString() { } IndexedTypeDef::IndexedTypeDef(TypeId id, const std::string& usr) - : id(id), def(usr) { + : def(usr), id(id) { assert(usr.size() > 0); // std::cerr << "Creating type with usr " << usr << std::endl; } @@ -1267,4 +1267,4 @@ IndexedFile Parse(std::string filename, clang_IndexAction_dispose(index_action); return db; -} \ No newline at end of file +} diff --git a/indexer.h b/indexer.h index 5d101bd5..caaac345 100644 --- a/indexer.h +++ b/indexer.h @@ -60,10 +60,11 @@ using VarId = Id; struct IdCache; struct Location { + // TODO: cleanup types (make this type smaller). bool interesting; - int raw_file_id; - int line; - int column; + int64_t raw_file_id; + int32_t line; + int32_t column; Location() { interesting = false; @@ -72,7 +73,7 @@ struct Location { column = -1; } - Location(bool interesting, FileId file, uint32_t line, uint32_t column) { + Location(bool interesting, FileId file, int32_t line, int32_t column) { this->interesting = interesting; this->raw_file_id = file.id; this->line = line; @@ -82,16 +83,13 @@ struct Location { FileId file_id() const { return FileId(raw_file_id); } explicit Location(const char* encoded) : Location() { - int len = strlen(encoded); - assert(len >= 0); - if (*encoded == '*') { interesting = true; ++encoded; } assert(encoded); - raw_file_id = atoi(encoded); + raw_file_id = strtol(encoded, nullptr, 10); while (*encoded && *encoded != ':') ++encoded; if (*encoded == ':') @@ -442,7 +440,7 @@ struct IndexedFuncDef { bool is_bad_def = true; IndexedFuncDef() {} // For reflection. - IndexedFuncDef(FuncId id, const std::string& usr) : id(id), def(usr) { + IndexedFuncDef(FuncId id, const std::string& usr) : def(usr), id(id) { // assert(usr.size() > 0); } @@ -526,7 +524,7 @@ struct IndexedVarDef { IndexedVarDef() : def("") {} // For serialization - IndexedVarDef(VarId id, const std::string& usr) : id(id), def(usr) { + IndexedVarDef(VarId id, const std::string& usr) : def(usr), id(id) { // assert(usr.size() > 0); } @@ -587,4 +585,4 @@ struct IndexedFile { IndexedFile Parse(std::string filename, std::vector args, - bool dump_ast = false); \ No newline at end of file + bool dump_ast = false); diff --git a/src/message_queue.cc b/src/message_queue.cc index a6479d23..b6f62a11 100644 --- a/src/message_queue.cc +++ b/src/message_queue.cc @@ -82,18 +82,20 @@ enum class RepeatResult { RunAgain, Break }; // Run |action| an arbitrary number of times. void Repeat(std::function action) { bool first = true; +#if defined(MESSAGE_QUEUE_LOG) int log_iteration_count = 0; int log_count = 0; +#endif while (true) { if (!first) { +#if defined(MESSAGE_QUEUE_LOG) if (log_iteration_count > 1000) { log_iteration_count = 0; -#if defined(MESSAGE_QUEUE_LOG) std::cerr << "[info]: Buffer full, waiting (" << log_count++ << ")" << std::endl; -#endif } ++log_iteration_count; +#endif // TODO: See if we can figure out a way to use condition variables // cross-process. std::this_thread::sleep_for(std::chrono::microseconds(0)); @@ -107,7 +109,7 @@ void Repeat(std::function action) { } ResizableBuffer* CreateOrFindResizableBuffer( - std::unordered_map>& + std::unordered_map>& resizable_buffers, uint32_t id) { auto it = resizable_buffers.find(id); @@ -119,7 +121,7 @@ ResizableBuffer* CreateOrFindResizableBuffer( std::unique_ptr MakeBuffer(void* content, size_t size) { auto buffer = Buffer::Create(size); memcpy(buffer->data, content, size); - return std::move(buffer); + return buffer; } } // namespace @@ -227,7 +229,8 @@ void MessageQueue::Enqueue(const Message& message) { } std::vector> MessageQueue::DequeueAll() { - std::unordered_map> resizable_buffers; + std::unordered_map> + resizable_buffers; std::vector> result; @@ -408,4 +411,4 @@ TEST_CASE("large payload") { free(sent_ints); } -TEST_SUITE_END(); \ No newline at end of file +TEST_SUITE_END(); diff --git a/src/message_queue.h b/src/message_queue.h index 5b55426f..ce4aa6b3 100644 --- a/src/message_queue.h +++ b/src/message_queue.h @@ -6,7 +6,7 @@ #include "buffer.h" -class ResizableBuffer; +struct ResizableBuffer; struct Message { Message(void* data, size_t size); @@ -77,4 +77,4 @@ struct IpcMessage { virtual void Serialize(Writer& writer) = 0; virtual void Deserialize(Reader& reader) = 0; }; -*/ \ No newline at end of file +*/ diff --git a/wscript b/wscript index ff9cb462..5b483a7c 100644 --- a/wscript +++ b/wscript @@ -88,7 +88,7 @@ def build(bld): excl=['*tests/*', 'third_party/*']) bld.program( source=cc_files, - cxxflags=['-std=c++11'], + cxxflags=['-std=c++11', '-Wall'], includes=['third_party/rapidjson/include', CLANG_INCLUDE_DIR], lib=['clang', 'rt', 'pthread'], libpath=[CLANG_LIB_DIR],