xref: /src/contrib/llvm-project/clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp (revision fcaf7f8644a9988098ac6be2165bce3ea4786e91)
14b4fe385SDimitry Andric //===- TokenBufferTokenManager.cpp ----------------------------------------===//
24b4fe385SDimitry Andric //
34b4fe385SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44b4fe385SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
54b4fe385SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
64b4fe385SDimitry Andric //
74b4fe385SDimitry Andric //===----------------------------------------------------------------------===//
84b4fe385SDimitry Andric 
94b4fe385SDimitry Andric #include "clang/Tooling/Syntax/TokenBufferTokenManager.h"
104b4fe385SDimitry Andric 
114b4fe385SDimitry Andric namespace clang {
124b4fe385SDimitry Andric namespace syntax {
134b4fe385SDimitry Andric constexpr llvm::StringLiteral syntax::TokenBufferTokenManager::Kind;
144b4fe385SDimitry Andric 
154b4fe385SDimitry Andric std::pair<FileID, ArrayRef<syntax::Token>>
lexBuffer(std::unique_ptr<llvm::MemoryBuffer> Input)164b4fe385SDimitry Andric syntax::TokenBufferTokenManager::lexBuffer(
174b4fe385SDimitry Andric     std::unique_ptr<llvm::MemoryBuffer> Input) {
184b4fe385SDimitry Andric   auto FID = SM.createFileID(std::move(Input));
194b4fe385SDimitry Andric   auto It = ExtraTokens.try_emplace(FID, tokenize(FID, SM, LangOpts));
204b4fe385SDimitry Andric   assert(It.second && "duplicate FileID");
214b4fe385SDimitry Andric   return {FID, It.first->second};
224b4fe385SDimitry Andric }
234b4fe385SDimitry Andric 
244b4fe385SDimitry Andric } // namespace syntax
254b4fe385SDimitry Andric } // namespace clang
26