diff --git a/CMakeLists.txt b/CMakeLists.txt index e3f623e..8510434 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 2.8.8) project(juci) -set(JUCI_VERSION "1.6.1") +set(JUCI_VERSION "1.6.1.1") set(CPACK_PACKAGE_NAME "jucipp") set(CPACK_PACKAGE_CONTACT "Ole Christian Eidheim ") diff --git a/src/config.cpp b/src/config.cpp index 281a8e2..ae9fa92 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -174,6 +174,7 @@ void Config::read(const boost::property_tree::ptree &cfg) { source.clang_usages_threads = static_cast(source_json.get("clang_usages_threads")); source.enable_clang_tidy = source_json.get("enable_clang_tidy"); source.clang_tidy_checks = source_json.get("clang_tidy_checks"); + source.enable_clang_detailed_preprocessing_record = source_json.get("enable_clang_detailed_preprocessing_record"); source.debug_place_cursor_at_stop = source_json.get("debug_place_cursor_at_stop"); auto pt_doc_search = cfg.get_child("documentation_searches"); for(auto &pt_doc_search_lang : pt_doc_search) { diff --git a/src/config.hpp b/src/config.hpp index af5dac5..5ca898e 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -100,6 +100,8 @@ public: bool enable_clang_tidy; std::string clang_tidy_checks; + bool enable_clang_detailed_preprocessing_record = false; + bool debug_place_cursor_at_stop; std::unordered_map documentation_searches; diff --git a/src/files.hpp b/src/files.hpp index 8b187f9..6e0686b 100644 --- a/src/files.hpp +++ b/src/files.hpp @@ -72,6 +72,8 @@ const std::string default_config_file = R"RAW({ "enable_clang_tidy": false, "clang_tidy_checks_comment": "In new C/C++ buffers, these checks are appended to the value of 'Checks' in the .clang-tidy file, if any", "clang_tidy_checks": "", + "enable_clang_detailed_preprocessing_record_comment": "Set to true to include all macro definitions and instantiations when parsing C/C++ buffers, at the cost of increased resource use. You should reopen buffers and delete build/.usages_clang after changing this option.", + "enable_clang_detailed_preprocessing_record": false, "debug_place_cursor_at_stop": false }, "terminal": { diff --git a/src/source_clang.cpp b/src/source_clang.cpp index 24ba741..755acd9 100644 --- a/src/source_clang.cpp +++ b/src/source_clang.cpp @@ -124,7 +124,9 @@ void Source::ClangViewParse::parse_initialize() { build->update_default(); auto arguments = CompileCommands::get_arguments(build->get_default_path(), file_path); clang_tokens.reset(); - clang_tu = std::make_unique(std::make_shared(0, Config::get().log.libclang), file_path.string(), arguments, &buffer_raw); + int flags = clangmm::TranslationUnit::DefaultFlags() & ~(CXTranslationUnit_DetailedPreprocessingRecord | CXTranslationUnit_Incomplete); + flags |= Config::get().source.enable_clang_detailed_preprocessing_record ? CXTranslationUnit_DetailedPreprocessingRecord : CXTranslationUnit_Incomplete; + clang_tu = std::make_unique(std::make_shared(0, Config::get().log.libclang), file_path.string(), arguments, &buffer_raw, flags); clang_tokens = clang_tu->get_tokens(); clang_tokens_offsets.clear(); clang_tokens_offsets.reserve(clang_tokens->size()); diff --git a/src/usages_clang.cpp b/src/usages_clang.cpp index 762034e..852a7c5 100644 --- a/src/usages_clang.cpp +++ b/src/usages_clang.cpp @@ -259,11 +259,10 @@ boost::optional> Usages::Clang::get_usages(co else ++it; } - int flags = CXTranslationUnit_Incomplete; + int flags = Config::get().source.enable_clang_detailed_preprocessing_record ? CXTranslationUnit_DetailedPreprocessingRecord : CXTranslationUnit_Incomplete; #if CINDEX_VERSION_MAJOR > 0 || (CINDEX_VERSION_MAJOR == 0 && CINDEX_VERSION_MINOR >= 35) flags |= CXTranslationUnit_KeepGoing; #endif - clangmm::TranslationUnit translation_unit(std::make_shared(0, 0), path.string(), arguments, &buffer, flags); {