mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	Add more detailed logging for failed unique file id
This commit is contained in:
		
							parent
							
								
									64253ec174
								
							
						
					
					
						commit
						0e5312790e
					
				@ -21,14 +21,15 @@ void FileConsumer::SharedState::Reset(const std::string& file) {
 | 
			
		||||
    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) {
 | 
			
		||||
  assert(is_first_ownership);
 | 
			
		||||
 | 
			
		||||
  CXFileUniqueID file_id;
 | 
			
		||||
  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;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,7 +33,7 @@ struct FileConsumer {
 | 
			
		||||
    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
 | 
			
		||||
  // take ownership over |file|.
 | 
			
		||||
@ -52,4 +52,5 @@ struct FileConsumer {
 | 
			
		||||
 private:
 | 
			
		||||
  std::unordered_map<CXFileUniqueID, std::unique_ptr<IndexFile>> local_;
 | 
			
		||||
  SharedState* shared_;
 | 
			
		||||
  std::string parse_file_;
 | 
			
		||||
};
 | 
			
		||||
@ -1535,6 +1535,10 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
 | 
			
		||||
    unsaved_files.push_back(unsaved);
 | 
			
		||||
  }
 | 
			
		||||
  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();
 | 
			
		||||
 | 
			
		||||
@ -1548,7 +1552,7 @@ std::vector<std::unique_ptr<IndexFile>> Parse(
 | 
			
		||||
       &indexEntityReference}
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  FileConsumer file_consumer(file_consumer_shared);
 | 
			
		||||
  FileConsumer file_consumer(file_consumer_shared, file);
 | 
			
		||||
  IndexParam param(&tu, &file_consumer);
 | 
			
		||||
 | 
			
		||||
  CXFile cx_file = clang_getFile(tu.cx_tu, file.c_str());
 | 
			
		||||
 | 
			
		||||
@ -2,6 +2,7 @@
 | 
			
		||||
 | 
			
		||||
#include "Utility.h"
 | 
			
		||||
#include "../platform.h"
 | 
			
		||||
#include "../utils.h"
 | 
			
		||||
 | 
			
		||||
#include <fstream>
 | 
			
		||||
#include <sstream>
 | 
			
		||||
 | 
			
		||||
@ -1,15 +1,16 @@
 | 
			
		||||
#ifndef TRANSLATIONUNIT_H_
 | 
			
		||||
#define TRANSLATIONUNIT_H_
 | 
			
		||||
#include <clang-c/Index.h>
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
#include <map>
 | 
			
		||||
#include <memory>
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "Index.h"
 | 
			
		||||
#include "Cursor.h"
 | 
			
		||||
#include "../language_server_api.h"
 | 
			
		||||
 | 
			
		||||
#include <clang-c/Index.h>
 | 
			
		||||
 | 
			
		||||
#include <string>
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
namespace clang {
 | 
			
		||||
 | 
			
		||||
class TranslationUnit {
 | 
			
		||||
 public:
 | 
			
		||||
  TranslationUnit(Index* index,
 | 
			
		||||
@ -27,5 +28,5 @@ class TranslationUnit {
 | 
			
		||||
 | 
			
		||||
  CXTranslationUnit cx_tu;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
}  // namespace clang
 | 
			
		||||
#endif  // TRANSLATIONUNIT_H_
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user