[PATCH] D87831: [clang] Expose helper function to turn PP keywords spelling into PPKeywordKind

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 18 01:25:02 PDT 2020


kbobyrev added inline comments.


================
Comment at: clang/include/clang/Basic/TokenKinds.h:99
 
+PPKeywordKind getPPKeywordFromSpelling(const std::string &Name);
+
----------------
riccibruno wrote:
> A string is expensive here and unneeded. Why not a `StringRef`?
Yeah, this piece is unfortunate :( `llvm::StringRef` doesn't really work with the current code. It relies on checking `if` using `\0` at the end of given string which is not always the case for `StringRef` (and `StringRef` itself would not be a suitable data structure to access `Name[2]` given `Name.size() == 2` because of the bounds check.

This is a piece I didn't figure out and hence did not send the patch to the review yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87831



More information about the cfe-commits mailing list