Add more detailed logging for failed unique file id

This commit is contained in:
Jacob Dufault 2017-06-13 20:08:31 -07:00
parent 64253ec174
commit 0e5312790e
5 changed files with 21 additions and 13 deletions

View File

@ -21,14 +21,15 @@ void FileConsumer::SharedState::Reset(const std::string& file) {
files.erase(it); files.erase(it);
} }
FileConsumer::FileConsumer(SharedState* shared_state) : shared_(shared_state) {} FileConsumer::FileConsumer(SharedState* shared_state, const std::string& parse_file)
: shared_(shared_state), parse_file_(parse_file) {}
IndexFile* FileConsumer::TryConsumeFile(CXFile file, bool* is_first_ownership) { IndexFile* FileConsumer::TryConsumeFile(CXFile file, bool* is_first_ownership) {
assert(is_first_ownership); assert(is_first_ownership);
CXFileUniqueID file_id; CXFileUniqueID file_id;
if (clang_getFileUniqueID(file, &file_id) != 0) { if (clang_getFileUniqueID(file, &file_id) != 0) {
std::cerr << "Could not get unique file id for " << FileName(file) << std::endl; std::cerr << "Could not get unique file id when parsing " << parse_file_ << std::endl;
return nullptr; return nullptr;
} }

View File

@ -33,7 +33,7 @@ struct FileConsumer {
void Reset(const std::string& file); void Reset(const std::string& file);
}; };
FileConsumer(SharedState* shared_state); FileConsumer(SharedState* shared_state, const std::string& parse_file);
// Returns true if this instance owns given |file|. This will also attempt to // Returns true if this instance owns given |file|. This will also attempt to
// take ownership over |file|. // take ownership over |file|.
@ -52,4 +52,5 @@ struct FileConsumer {
private: private:
std::unordered_map<CXFileUniqueID, std::unique_ptr<IndexFile>> local_; std::unordered_map<CXFileUniqueID, std::unique_ptr<IndexFile>> local_;
SharedState* shared_; SharedState* shared_;
std::string parse_file_;
}; };

View File

@ -1535,6 +1535,10 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
unsaved_files.push_back(unsaved); unsaved_files.push_back(unsaved);
} }
clang::TranslationUnit tu(index, file, args, unsaved_files, CXTranslationUnit_KeepGoing | CXTranslationUnit_DetailedPreprocessingRecord); clang::TranslationUnit tu(index, file, args, unsaved_files, CXTranslationUnit_KeepGoing | CXTranslationUnit_DetailedPreprocessingRecord);
if (tu.did_fail) {
std::cerr << "!! Failed creating translation unit for " << file << std::endl;
return {};
}
perf->index_parse = timer.ElapsedMicrosecondsAndReset(); perf->index_parse = timer.ElapsedMicrosecondsAndReset();
@ -1548,7 +1552,7 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
&indexEntityReference} &indexEntityReference}
}; };
FileConsumer file_consumer(file_consumer_shared); FileConsumer file_consumer(file_consumer_shared, file);
IndexParam param(&tu, &file_consumer); IndexParam param(&tu, &file_consumer);
CXFile cx_file = clang_getFile(tu.cx_tu, file.c_str()); CXFile cx_file = clang_getFile(tu.cx_tu, file.c_str());

View File

@ -2,6 +2,7 @@
#include "Utility.h" #include "Utility.h"
#include "../platform.h" #include "../platform.h"
#include "../utils.h"
#include <fstream> #include <fstream>
#include <sstream> #include <sstream>

View File

@ -1,15 +1,16 @@
#ifndef TRANSLATIONUNIT_H_ #pragma once
#define TRANSLATIONUNIT_H_
#include <clang-c/Index.h>
#include <string>
#include <vector>
#include <map>
#include <memory>
#include "Index.h" #include "Index.h"
#include "Cursor.h" #include "Cursor.h"
#include "../language_server_api.h"
#include <clang-c/Index.h>
#include <string>
#include <vector>
namespace clang { namespace clang {
class TranslationUnit { class TranslationUnit {
public: public:
TranslationUnit(Index* index, TranslationUnit(Index* index,
@ -27,5 +28,5 @@ class TranslationUnit {
CXTranslationUnit cx_tu; CXTranslationUnit cx_tu;
}; };
} // namespace clang } // namespace clang
#endif // TRANSLATIONUNIT_H_