view clang-tools-extra/clang-include-fixer/InMemorySymbolIndex.cpp @ 171:66f3bfe93da9

git version 2c4ca6832fa6b306ee6a7010bfb80a3f2596f824
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 11:07:02 +0900
parents 1d019706d866
children
line wrap: on
line source

//===-- InMemorySymbolIndex.cpp--------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "InMemorySymbolIndex.h"

using clang::find_all_symbols::SymbolAndSignals;

namespace clang {
namespace include_fixer {

InMemorySymbolIndex::InMemorySymbolIndex(
    const std::vector<SymbolAndSignals> &Symbols) {
  for (const auto &Symbol : Symbols)
    LookupTable[std::string(Symbol.Symbol.getName())].push_back(Symbol);
}

std::vector<SymbolAndSignals>
InMemorySymbolIndex::search(llvm::StringRef Identifier) {
  auto I = LookupTable.find(std::string(Identifier));
  if (I != LookupTable.end())
    return I->second;
  return {};
}

} // namespace include_fixer
} // namespace clang