================
@@ -387,8 +387,8 @@ const syntax::Token 
*TokenBuffer::spelledTokenAt(SourceLocation Loc) const {
   assert(Loc.isFileID());
   const auto *Tok = llvm::partition_point(
       spelledTokens(SourceMgr->getFileID(Loc)),
-      [&](const syntax::Token &Tok) { return Tok.location() < Loc; });
-  if (!Tok || Tok->location() != Loc)
+      [&](const syntax::Token &Tok) { return Tok.endLocation() <= Loc; });
+  if (!Tok || Tok->location() > Loc || Loc >= Tok->endLocation())
----------------
kadircet wrote:

i don't think `Loc >= Tok->endLocation()` can ever be true. `partition_point` 
will return either null or a `Tok` s.t. `Loc < Tok.endLocation()`.

nit: can you re-write the previous condition as `Loc < Tok->location()`, i 
think it's easier to visualize the relationship when it's left-to-right :D

https://github.com/llvm/llvm-project/pull/94528
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to