[PATCH] D99086: [clang][Syntax] Optimize expandedTokens for token ranges.
    Kadir Cetinkaya via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Mon Mar 22 11:08:49 PDT 2021
    
    
  
kadircet added inline comments.
================
Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:372
+  // useful while finding expanded tokens in a 'token range'.
+  llvm::DenseMap<SourceLocation, unsigned> ExpandedTokIndex;
   llvm::DenseMap<FileID, MarkedFile> Files;
----------------
this definitely makes sense, but most of the users of `TokenBuffers` are currently invoking `expandedTokens(Range)` only once, so i am not sure if this is a huge benefit on their-side, whereas they'll likely end up seeing some short-lived memory consumption (and an extra traversal of all the expanded tokens).
Any reasons for not moving this logic to the application? `expandedTokens()` endpoint will return all the tokens, no questions asked. Then the application can build whatever acceleration structure it wants. If you think there are in-tree use cases that can benefit from this caching, maybe even provide that as a separate helper?
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99086/new/
https://reviews.llvm.org/D99086
    
    
More information about the cfe-commits
mailing list