aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Tooling/Syntax/TokenBufferTokenManager.cpp
blob: 3d63d4ab506ab6d893c4c98674fc742b42f77aaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//===- TokenBufferTokenManager.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 "clang/Tooling/Syntax/TokenBufferTokenManager.h"

namespace clang {
namespace syntax {
std::pair<FileID, ArrayRef<syntax::Token>>
syntax::TokenBufferTokenManager::lexBuffer(
    std::unique_ptr<llvm::MemoryBuffer> Input) {
  auto FID = SM.createFileID(std::move(Input));
  auto It = ExtraTokens.try_emplace(FID, tokenize(FID, SM, LangOpts));
  assert(It.second && "duplicate FileID");
  return {FID, It.first->second};
}

} // namespace syntax
} // namespace clang