aaron.ballman added inline comments.

================
Comment at: clang-query/QueryParser.cpp:33
+  if (Line.empty())
+    return StringRef(Line.begin(), 0);
 
----------------
steveire wrote:
> steveire wrote:
> > aaron.ballman wrote:
> > > steveire wrote:
> > > > aaron.ballman wrote:
> > > > > Why not just return `Line`?
> > > > It is the pre-existing behavior to return a zero-length StringRef with 
> > > > a valid Begin pointer in this case. I think the reason is something to 
> > > > do with code completion. I can check later.
> > > I believe returning `Line` is identical -- you should wind up with the 
> > > same "begin" pointer for the returned string and a length of zero 
> > > (because `Line` must be empty by this point).
> > Actually, I can see it by reading the code - `P->CompletionPos <= 
> > Word.data()` in the `LexOrCompleteWord` ctor woudln't work anymore without 
> > this hack. (Working on removing the hack is out of scope of this change).
> Ok, I see your new comment now. I guess that will work. I don't know the 
> behavior of `ltrim` and whether it preserves that property.
`StringRef`s are immutable and non-owning, so `ltrim()` returns `Line.begin + 
someOffset` in essence. That should preserve the behavior you need here.


================
Comment at: clang-query/QueryParser.cpp:37
+    Line = {};
     return StringRef();
   }
----------------
steveire wrote:
> aaron.ballman wrote:
> > steveire wrote:
> > > aaron.ballman wrote:
> > > > Why not just return `Line` here as well?
> > > That's pre-existing. Seems more clear to leave it as is.
> > I don't have a strong preference, but I raised the point because it seems 
> > odd to explicitly clear a `StringRef` and then return a new, different, 
> > empty `StringRef` on the next line.
> Well, code changes, and `Line` may not always be empty here. As it is, this 
> communicates that we're returning an empty `StringRef` and always will (until 
> this line has a reason to change).
Okay, that's good enough for me, thanks!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D56415



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to