[PATCH] D69615: [clangd] Implement a function to lex the file to find candidate occurrences.

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 08:35:13 PST 2019


ilya-biryukov added inline comments.


================
Comment at: clang-tools-extra/clangd/SourceCode.cpp:769
+        llvm::StringRef TokenName;
+        if (Tok.getKind() == tok::identifier)
+          TokenName = Tok.getIdentifierInfo()->getName();
----------------
Why do we have both `raw_identifier` and `identifier`?
We should run lexer in the raw mode, in which case we should always get `raw_identifier`.


================
Comment at: clang-tools-extra/clangd/SourceCode.h:236
+/// Collects all ranges of the given identifier in the source code.
+std::vector<Range> collectIdentifierRanges(llvm::StringRef IdentifierName,
+                                           llvm::StringRef Content,
----------------
NIT: maybe use a shorter name for the paramter? `Identifier` conveys the same meaning.


================
Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:690
+   void f() {
+     [[Foo]] foo;
+   }
----------------
Could you add a few more occurrences?
Maybe also with the weird things like multi-line tokens:
```
F\
o\
o
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69615





More information about the cfe-commits mailing list