Bump version to 19.1.0 (final)
[llvm-project.git] / clang-tools-extra / clangd / FeatureModule.cpp
blob872cea14437894679c5cf9887df9e26a3661252b
1 //===--- FeatureModule.cpp - Plugging features into clangd ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "FeatureModule.h"
10 #include "support/Logger.h"
12 namespace clang {
13 namespace clangd {
15 void FeatureModule::initialize(const Facilities &F) {
16 assert(!Fac && "Initialized twice");
17 Fac.emplace(F);
20 FeatureModule::Facilities &FeatureModule::facilities() {
21 assert(Fac && "Not initialized yet");
22 return *Fac;
25 bool FeatureModuleSet::addImpl(void *Key, std::unique_ptr<FeatureModule> M,
26 const char *Source) {
27 if (!Map.try_emplace(Key, M.get()).second) {
28 // Source should (usually) include the name of the concrete module type.
29 elog("Tried to register duplicate feature modules via {0}", Source);
30 return false;
32 Modules.push_back(std::move(M));
33 return true;
36 } // namespace clangd
37 } // namespace clang