fix some warnings

This commit is contained in:
Jacob Dufault 2017-03-22 10:16:09 -07:00
parent 6a72712404
commit 539c779606
5 changed files with 23 additions and 22 deletions

View File

@ -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;
}

View File

@ -60,10 +60,11 @@ using VarId = Id<IndexedVarDef>;
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);
}

View File

@ -82,18 +82,20 @@ enum class RepeatResult { RunAgain, Break };
// Run |action| an arbitrary number of times.
void Repeat(std::function<RepeatResult()> 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<RepeatResult()> action) {
}
ResizableBuffer* CreateOrFindResizableBuffer(
std::unordered_map<int, std::unique_ptr<ResizableBuffer>>&
std::unordered_map<uint32_t, std::unique_ptr<ResizableBuffer>>&
resizable_buffers,
uint32_t id) {
auto it = resizable_buffers.find(id);
@ -119,7 +121,7 @@ ResizableBuffer* CreateOrFindResizableBuffer(
std::unique_ptr<Buffer> 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<std::unique_ptr<Buffer>> MessageQueue::DequeueAll() {
std::unordered_map<int, std::unique_ptr<ResizableBuffer>> resizable_buffers;
std::unordered_map<uint32_t, std::unique_ptr<ResizableBuffer>>
resizable_buffers;
std::vector<std::unique_ptr<Buffer>> result;

View File

@ -6,7 +6,7 @@
#include "buffer.h"
class ResizableBuffer;
struct ResizableBuffer;
struct Message {
Message(void* data, size_t size);

View File

@ -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],