diff --git a/src/file_consumer.cc b/src/file_consumer.cc index 5e3effdc..5f548c8d 100644 --- a/src/file_consumer.cc +++ b/src/file_consumer.cc @@ -29,7 +29,7 @@ IndexFile* FileConsumer::TryConsumeFile(CXFile file, bool* is_first_ownership) { CXFileUniqueID file_id; if (clang_getFileUniqueID(file, &file_id) != 0) { - std::cerr << "Could not get unique file id when parsing " << parse_file_ << std::endl; + EmitError(file); return nullptr; } @@ -62,7 +62,7 @@ IndexFile* FileConsumer::ForceLocal(CXFile file) { // It's already been taken before, just create a local copy. CXFileUniqueID file_id; if (clang_getFileUniqueID(file, &file_id) != 0) { - std::cerr << "Could not get unique file id for " << FileName(file) << std::endl; + EmitError(file); return nullptr; } @@ -80,4 +80,10 @@ std::vector> FileConsumer::TakeLocalState() { result.push_back(std::move(entry.second)); } return result; +} + +void FileConsumer::EmitError(CXFile file) const { + std::string file_name = clang::ToString(clang_getFileName(file)); + std::string error_message = "Could not get unique file id for " + file_name + " when parsing " + parse_file_; + std::cerr << error_message << std::endl; } \ No newline at end of file diff --git a/src/file_consumer.h b/src/file_consumer.h index e0012f34..322e5e58 100644 --- a/src/file_consumer.h +++ b/src/file_consumer.h @@ -50,6 +50,8 @@ struct FileConsumer { std::vector> TakeLocalState(); private: + void EmitError(CXFile file) const; + std::unordered_map> local_; SharedState* shared_; std::string parse_file_;