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

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 07:51:42 PST 2019


hokein added inline comments.


================
Comment at: clang-tools-extra/clangd/SourceCode.cpp:769
+        llvm::StringRef TokenName;
+        if (Tok.getKind() == tok::identifier)
+          TokenName = Tok.getIdentifierInfo()->getName();
----------------
ilya-biryukov wrote:
> 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`.
I just borrowed from `collectIdentifiers`. You are right, we only run a raw lexer, updated the code.


================
Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:690
+   void f() {
+     [[Foo]] foo;
+   }
----------------
ilya-biryukov wrote:
> Could you add a few more occurrences?
> Maybe also with the weird things like multi-line tokens:
> ```
> F\
> o\
> o
> ```
Done, note that multi-line identifier is not supported -- `getRawIdentifier` returns a literal name `F\o\o` which makes the check `Tok.getRawIdentifier() == Identifier` fail. I think it is fine to not support it.


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