[PATCH] D84009: [Syntax] expose API for expansions overlapping a spelled token range.

Aleksandr Platonov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 17 03:45:31 PDT 2020


ArcsinX added inline comments.


================
Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:252
     return {};
-  assert(Spelled.front().location().isFileID());
-
-  auto FID = sourceManager().getFileID(Spelled.front().location());
-  auto It = Files.find(FID);
-  assert(It != Files.end());
-
-  const MarkedFile &File = It->second;
+  const MarkedFile &File = fileForSpelled(Spelled);
   // `Spelled` must be a subrange of `File.SpelledTokens`.
----------------
Could we use `const auto &` here as in lines 419, 434 for consistency?


================
Comment at: clang/lib/Tooling/Syntax/Tokens.cpp:431
+std::vector<TokenBuffer::Expansion>
+TokenBuffer::expansionsAffecting(llvm::ArrayRef<syntax::Token> Spelled) const {
+  if (Spelled.empty())
----------------
Will it be useful to have similar API with FileID/MarkedFile parameter?
For example, we already have FileID in `SelectionTester::SelectionTester`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84009/new/

https://reviews.llvm.org/D84009





More information about the cfe-commits mailing list