diff options
author | Brad King <brad.king@kitware.com> | 2019-07-29 14:06:18 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-07-29 14:21:27 (GMT) |
commit | 833d9eae4e49ef7b9055c709fd8a6959588952c3 (patch) | |
tree | 0ae5c76579b141c403e85f1615c3270eb46d2d07 /Source | |
parent | c9c397a14ac59b25e43ce43264a420b2f9537547 (diff) | |
download | CMake-833d9eae4e49ef7b9055c709fd8a6959588952c3.zip CMake-833d9eae4e49ef7b9055c709fd8a6959588952c3.tar.gz CMake-833d9eae4e49ef7b9055c709fd8a6959588952c3.tar.bz2 |
fileapi: Refactor codemodel defines de-duplication
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmFileAPICodemodel.cxx | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 0c4f5c4..9ff8ffa 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -231,8 +231,6 @@ struct CompileData } }; - void SetDefines(std::set<BT<std::string>> const& defines); - std::string Language; std::string Sysroot; std::vector<BT<std::string>> Flags; @@ -240,14 +238,6 @@ struct CompileData std::vector<IncludeEntry> Includes; }; -void CompileData::SetDefines(std::set<BT<std::string>> const& defines) -{ - this->Defines.reserve(defines.size()); - for (BT<std::string> const& d : defines) { - this->Defines.push_back(d); - } -} - class Target { cmGeneratorTarget* GT; @@ -726,7 +716,10 @@ void Target::ProcessLanguage(std::string const& lang) } std::set<BT<std::string>> defines = lg->GetTargetDefines(this->GT, this->Config, lang); - cd.SetDefines(defines); + cd.Defines.reserve(defines.size()); + for (BT<std::string> const& d : defines) { + cd.Defines.emplace_back(d); + } std::vector<BT<std::string>> includePathList = lg->GetIncludeDirectories(this->GT, lang, this->Config); for (BT<std::string> const& i : includePathList) { @@ -814,11 +807,16 @@ CompileData Target::BuildCompileData(cmSourceFile* sf) genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS)); } - std::set<BT<std::string>> defines; - defines.insert(fileDefines.begin(), fileDefines.end()); - defines.insert(cd.Defines.begin(), cd.Defines.end()); + fd.Defines.reserve(cd.Defines.size() + fileDefines.size()); + fd.Defines = cd.Defines; + for (std::string const& d : fileDefines) { + fd.Defines.emplace_back(d, cmListFileBacktrace()); + } - fd.SetDefines(defines); + // De-duplicate defines. + std::stable_sort(fd.Defines.begin(), fd.Defines.end()); + auto end = std::unique(fd.Defines.begin(), fd.Defines.end()); + fd.Defines.erase(end, fd.Defines.end()); return fd; } |